def runProgram(Species,Array_type,mir_source,stringency,Force): global species; global array_type; global force process_microRNA_predictions = 'yes' species = Species; array_type = Array_type; force = Force import_dir = '/AltDatabase/'+species+'/'+array_type filedir = import_dir[1:]+'/' dir_list = read_directory(import_dir) #send a sub_directory to a function to identify all files in a directory probeset_seq_file='' for input_file in dir_list: #loop through each file in the directory to results if 'critical-exon-seq_updated' in input_file: probeset_seq_file = filedir+input_file elif 'critical-exon-seq' in input_file: probeset_seq_file2 = filedir+input_file if len(probeset_seq_file)==0: probeset_seq_file=probeset_seq_file2 data_type = 'critical-exons' try: splice_event_db = getParametersAndExecute(probeset_seq_file,array_type,species,data_type) except UnboundLocalError: probeset_seq_file = 'AltDatabase/'+species+'/'+array_type+'/'+array_type+'_critical-exon-seq_updated.txt' update.downloadCurrentVersion(probeset_seq_file,array_type,'txt') splice_event_db = getParametersAndExecute(probeset_seq_file,array_type,species,data_type) if process_microRNA_predictions == 'yes': print 'stringency:',stringency try: ensembl_mirna_db = ExonSeqModule.importmiRNATargetPredictionsAdvanced(species) ExonSeqModule.alignmiRNAData(array_type,mir_source,species,stringency,ensembl_mirna_db,splice_event_db) except Exception: pass
def runExtractUniProt(species,species_full,uniprot_filename_url,trembl_filename_url,force): global uniprot_ensembl_db;uniprot_ensembl_db={} global uniprot_db;uniprot_db={}; global species_name; global uniprot_fildir global secondary_to_primary_db; secondary_to_primary_db={} import update; reload(update) species_name = species_full import UI; species_names = UI.getSpeciesInfo() species_full = species_names[species] species_full = string.replace(species_full,' ','_') uniprot_file = string.split(uniprot_filename_url,'/')[-1]; uniprot_file = string.replace(uniprot_file,'.gz','') trembl_file = string.split(trembl_filename_url,'/')[-1]; trembl_file = string.replace(trembl_file,'.gz','') uniprot_fildir = 'AltDatabase/uniprot/'+species+'/' uniprot_download_fildir = 'AltDatabase/uniprot/' uniprot_ens_file = species+'_Ensembl-UniProt.txt'; uniprot_ens_location = uniprot_fildir+uniprot_ens_file uniprot_location = uniprot_download_fildir+uniprot_file trembl_location = uniprot_download_fildir+trembl_file add_trembl_annotations = 'no' ### Currently we don't need these annotations try: importEnsemblUniprot(uniprot_ens_location) except IOError: try: ### Download the data from the AltAnalyze website (if there) update.downloadCurrentVersion(uniprot_ens_location,species,'txt') importEnsemblUniprot(uniprot_ens_location) except Exception: null=[] try: uniprot_ens_location_built = string.replace(uniprot_ens_location,'UniProt','Uniprot-SWISSPROT') uniprot_ens_location_built = string.replace(uniprot_ens_location_built,'uniprot','Uniprot-SWISSPROT') importEnsemblUniprot(uniprot_ens_location_built) except Exception: null=[] ### Import UniProt annotations counts = update.verifyFile(uniprot_location,'counts') if force == 'no' or counts > 8: import_uniprot_db(uniprot_location) else: ### Directly download the data from UniProt gz_filepath, status = update.download(uniprot_filename_url,uniprot_download_fildir,'') if status == 'not-removed': try: os.remove(gz_filepath) ### Not sure why this works now and not before except OSError: status = status import_uniprot_db(uniprot_location) if add_trembl_annotations == 'yes': ### Import TreMBL annotations try: if force == 'yes': uniprot_location += '!!!!!' ### Force an IOError import_uniprot_db(trembl_location) except IOError: ### Directly download the data from UniProt update.download(trembl_filename_url,uniprot_download_fildir,'') import_uniprot_db(trembl_location) export() exportEnsemblUniprot(uniprot_ens_location)
def checkProbesetSequenceFile(species): """ Check to see if the probeset sequence file is present and otherwise download AltAnalyze hosted version""" probeset_seq_file = getProbesetSequenceFile(species) if probeset_seq_file == None: dir = '/AltDatabase/'+species+'/'+array_type filename = update.getFileLocations(species,'exon_seq') filename = dir[1:]+'/'+ filename update.downloadCurrentVersion(filename,'exon','.fa') probeset_seq_file = getProbesetSequenceFile(species) return probeset_seq_file
def runProgram(Species, Array_type, mir_source, stringency, Force): global species global array_type global force process_microRNA_predictions = 'yes' species = Species array_type = Array_type force = Force import_dir = '/AltDatabase/' + species + '/' + array_type filedir = import_dir[1:] + '/' dir_list = read_directory( import_dir ) #send a sub_directory to a function to identify all files in a directory probeset_seq_file = '' for input_file in dir_list: #loop through each file in the directory to results if 'critical-exon-seq_updated' in input_file: probeset_seq_file = filedir + input_file elif 'critical-exon-seq' in input_file: probeset_seq_file2 = filedir + input_file if len(probeset_seq_file) == 0: probeset_seq_file = probeset_seq_file2 data_type = 'critical-exons' try: splice_event_db = getParametersAndExecute(probeset_seq_file, array_type, species, data_type) except UnboundLocalError: probeset_seq_file = 'AltDatabase/' + species + '/' + array_type + '/' + array_type + '_critical-exon-seq_updated.txt' update.downloadCurrentVersion(probeset_seq_file, array_type, 'txt') splice_event_db = getParametersAndExecute(probeset_seq_file, array_type, species, data_type) if process_microRNA_predictions == 'yes': print 'stringency:', stringency try: ensembl_mirna_db = ExonSeqModule.importmiRNATargetPredictionsAdvanced( species) ExonSeqModule.alignmiRNAData(array_type, mir_source, species, stringency, ensembl_mirna_db, splice_event_db) except Exception: pass
def verifyFile(filename,species_name): fn=filepath(filename); counts=0 try: for line in open(fn,'rU').xreadlines(): counts+=1 if counts>10: break except Exception: counts=0 if species_name == 'counts': ### Used if the file cannot be downloaded from http://www.altanalyze.org return counts elif counts == 0: if species_name in filename: server_folder = species_name ### Folder equals species unless it is a universal file elif 'Mm' in filename: server_folder = 'Mm' ### For PicTar else: server_folder = 'all' print 'Downloading:',server_folder,filename update.downloadCurrentVersion(filename,server_folder,'txt') else: return counts
def verifyFile(filename, species_name): fn = filepath(filename) counts = 0 try: for line in open(fn, 'rU').xreadlines(): counts += 1 if counts > 10: break except Exception: counts = 0 if species_name == 'counts': ### Used if the file cannot be downloaded from http://www.altanalyze.org return counts elif counts == 0: if species_name in filename: server_folder = species_name ### Folder equals species unless it is a universal file elif 'Mm' in filename: server_folder = 'Mm' ### For PicTar else: server_folder = 'all' print 'Downloading:', server_folder, filename update.downloadCurrentVersion(filename, server_folder, 'txt') else: return counts