def load_exon_configuration (ref_protein_id, ref_species_dict, exon_type): ''' Load exons of a particular type for all available species @param ref_protein_id: referent protein id @param exon_type: exon_type: ensembl, genewise, blatn, tblastn, sw_gene, sw_exon ''' dc = DescriptionParser() exon_container = ExonContainer.Instance() ens_exon_container = EnsemblExonContainer.Instance() logger = Logger.Instance() containers_logger = logger.get_logger('containers') if exon_type == "ensembl" or exon_type == "genewise": if not check_status_file_no_alignment(ref_protein_id): containers_logger.info ("{0},exon_type:{1},check status file -> failed".format(ref_protein_id, exon_type)) return False else: if not check_status_file(ref_protein_id): containers_logger.info ("{0},exon_type:{1},check status file -> failed".format(ref_protein_id, exon_type)) return False if not ref_species_dict: ref_species_dict = FileUtilities.get_reference_species_dictionary() (known_species, abinitio_species) = dc.get_separated_species(ref_protein_id) for species in known_species: ref_species = ref_species_dict[species] if exon_type != "genewise": if exon_type == "ensembl": exons = EnsemblExons ((ref_protein_id, species), ref_species) try: exon_dict = exons.load_exons() except Exception, e: containers_logger.error("{0},{1},{2},error loading exons".format(ref_protein_id, species, exon_type)) continue else: exons = Exons((ref_protein_id, species), ref_species, exon_type) try: exon_dict = exons.load_exons() except Exception, e: containers_logger.error("{0},{1},{2},error loading exons".format(ref_protein_id, species, exon_type)) continue if not exon_dict: continue if (exon_type != "ensembl"): exons.set_exon_ordinals() data_map_key = [ref_protein_id, species] exon_container.add(exon_type, data_map_key, exons)
def get_species_list(protein_id, path): ''' @param path: returns the list of species in the .status file, if the file doesn't exist, it returns the list parsed from protein description file. ''' desc_parser = DescriptionParser() species_list = [] if (os.path.isfile("{0}/.status".format(path))): for species in open('{0}/.status'.format(path), 'r').readlines(): species_list.append(species.strip()) else: species_list = desc_parser.get_species(protein_id) return species_list