def test_get_from_taxonomy_db(self): """EUtils access from taxonomy database should work""" #note: this is more fragile than the nucleotide databases g = EUtils(db='taxonomy', rettype='xml', retmode='xml') ids = '9606[taxid] OR 28901[taxid]' fh = StringIO() fh.write(g[ids].read()) fh.seek(0) data = parse_taxonomy_using_elementtree_xml_parse(fh) result = sorted([item['ScientificName'] for item in data]) self.assertEqual(result, ['H**o sapiens', 'Salmonella enterica'])
def test_parse_taxonomy_using_elementtree_xml_parse(self): """parse_taxonomy_using_elementtree_xml_parse should return taxonomy associated information""" g = EUtils(db='taxonomy', rettype='xml', retmode='xml') ids = '28901[taxid]' fh = StringIO() fh.write(g[ids].read()) fh.seek(0) data = parse_taxonomy_using_elementtree_xml_parse(fh)[0] obs = (data['Lineage'],data['TaxId'],data['ScientificName'],\ data['Rank']) exp = ('cellular organisms; Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Salmonella',\ '28901','Salmonella enterica','species') self.assertEqual(obs,exp)
def test_parse_taxonomy_using_elementtree_xml_parse(self): """parse_taxonomy_using_elementtree_xml_parse should return taxonomy associated information""" g = EUtils(db='taxonomy', rettype='xml', retmode='xml') ids = '28901[taxid]' fh = StringIO() fh.write(g[ids].read()) fh.seek(0) data = parse_taxonomy_using_elementtree_xml_parse(fh)[0] obs = (data['Lineage'],data['TaxId'],data['ScientificName'],\ data['Rank']) exp = ('cellular organisms; Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Salmonella',\ '28901','Salmonella enterica','species') self.assertEqual(obs, exp)