This is a test version of Biostars. For the public version, visit https://www.biostars.org.
TaxID to taxonomy (Entrez Direct: E-utilities on the Unix Command Line)

Entrez Direct: E-utilities on the Unix Command Line

I would like to execute the following command but with a list where i have thousands tax ids (id). How to execute that?

efetch -db taxonomy -id 9606,7227,10090 -format xml | xtract -pattern Taxon \ -element TaxId ScientificName GenbankCommonName Division

entrez

you either download the complete taxonomy table locally and query that one (with eg grep ) or you put the the efetch command in a for loop and loop over all your taxIDs.

thanks, how to do that, any suggestion? is at like that?

for i in tax_ids.txt;    do  efetch -db taxonomy -id $i -format xml | xtract -pattern Taxon \ -element TaxId ScientificName GenbankCommonName Division

1 answer

One way

$ more ids
9606
7227
10090

$ for i in `cat ids`; do  efetch -db taxonomy -id ${i} -format xml | xtract -pattern Taxon -element TaxId,ScientificName,GenbankCommonName,Division;done 
9606    Homo sapiens    human   Primates
7227    Drosophila melanogaster fruit fly   Invertebrates
10090   Mus musculus    house mouse Rodents

Log in to answer this question.