Last active
November 23, 2016 01:42
-
-
Save jmberros/d0422c337f998ce972e6d0698a89e466 to your computer and use it in GitHub Desktop.
Get Taxa scientific name and lineage from Entrez
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Bio import Entrez | |
taxids_filename = '/tmp/taxids.list' # Replace with the path to your Tax IDs file! | |
with open(taxids_filename) as f: | |
tax_ids = f.read().split('\n') | |
Entrez.email = '[email protected]' # Put your email here | |
handle = Entrez.efetch('taxonomy', id=tax_ids, rettype='xml') | |
response = Entrez.read(handle) | |
for entry in response: | |
sci_name = entry.get('ScientificName') | |
lineage_taxa = entry.get('Lineage').split(';') | |
print(sci_name, ' > '.join(lineage_taxa), sep=',') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment