def test_create_from_rsat_feature_names_with_transform(self): """test the creation from RSAT feature names using a key transformer""" thes = thesaurus.create_from_rsat_feature_names( MockRsatFeatureNameFile(), [lambda x: [x, x.rstrip('m')]]) self.assertEquals('NAME1', thes['PRIME1']) self.assertEquals('NAME1', thes['ALT1']) self.assertEquals('NAME2', thes['PRIME2']) self.assertEquals('NAME2', thes['VNG2664G'])
def test_create_from_rsat_feature_names_no_transform(self): """test the creation from RSAT feature names file""" thes = thesaurus.create_from_rsat_feature_names( MockRsatFeatureNameFile()) self.assertEquals('NAME1', thes['PRIME1']) self.assertEquals('NAME1', thes['ALT1']) self.assertEquals('NAME2', thes['PRIME2']) self.assertEquals('NAME2', thes['VNG2664Gm'])
def thesaurus(self): """reads the thesaurus from a feature_names file. The thesaurus is also cached, because it is used many times """ if not self.__synonyms: feature_names_dfile = util.dfile_from_text(self.__rsat_info.get_feature_names(), comment="--") self.__synonyms = thesaurus.create_from_rsat_feature_names( feature_names_dfile, [thesaurus.strip_vng_modification] ) return self.__synonyms
def thesaurus(self): """reads the thesaurus from a feature_names file. The thesaurus is also cached, because it is used many times """ if not self.__synonyms: feature_names_dfile = util.dfile_from_text( self.__rsat_info.get_feature_names(), comment='--') self.__synonyms = thesaurus.create_from_rsat_feature_names( feature_names_dfile, [thesaurus.strip_vng_modification]) return self.__synonyms
def __make_organism(self): """makes a mock organism with almost real data""" features = {} dfile = util.read_dfile('testdata/Halobacterium_sp_features', comment='--') for line in dfile.lines: features[line[0]] = st.Feature( line[0], line[1], line[2], st.Location(line[3], int(line[4]), int(line[5]), line[6] == 'R')) tfile = util.read_dfile('testdata/Halobacterium_sp_feature_names', comment='--') synonyms = th.create_from_rsat_feature_names(tfile) return MockOrganismWithSynonyms('64091', features, synonyms)
def __make_organism(self): """makes a mock organism with almost real data""" features = {} dfile = util.read_dfile('testdata/Halobacterium_sp_features', comment='--') for line in dfile.lines: features[line[0]] = st.Feature(line[0], line[1], line[2], st.Location(line[3], int(line[4]), int(line[5]), line[6] == 'R')) tfile = util.read_dfile( 'testdata/Halobacterium_sp_feature_names', comment='--') synonyms = th.create_from_rsat_feature_names(tfile) return MockOrganismWithSynonyms('64091', features, synonyms)