This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to fill taxonomy informations from NCBI?

Hi, there!

I've seen questions related to that but none addressing in with lay explanations which is very much indeed my case. I have about 500 species list to fill with Kingdom, Phylum, Class, Order, Family

I saw that i should follow something such as "specie OR specie OR..." in NCBI taxonomy > Display setting > common tree > Save as

When i save this it just gives me a messy information in all one column

I looked for simple tutorials, scripts but didnt find any

Would love and deeply appreciate some help for a lay person!

taxonomy ncbi

2 answers

Step 1

Use NCBI Taxonomy browser to convert species name to corresponding Taxonomy ID.

Step 2

Use TaxonKit to convert related lineage detail (Phylum, class, order,....species) of those TaxId

taxonkit lineage id.txt | tee lineage.txt

Step 3

Use csvtk to formating these lineage.

cat lineage.txt \
    | taxonkit reformat \
    | csvtk -H -t cut -f 1,3 \
    | csvtk -H -t sep -f 2 -s ';' -R \
    | csvtk add-header -t -n taxid,kindom,phylum,class,order,family,genus,species \
    | csvtk pretty -t > out_id.txt

Thank you

taxonkit reformat supports input of TaxIds (since v0.8.0) and recognizes "\t" in output format. Therefore, it can be simplified as:

taxonkit name2taxid names.txt \
    | taxonkit reformat -I 2 -f "{k}\t{p}\t{c}\t{o}\t{f}\t{g}\t{s}" -o result.txt

Add header and save to XLSX format if you like:

taxonkit name2taxid names.txt \
    | taxonkit reformat -I 2 -f "{k}\t{p}\t{c}\t{o}\t{f}\t{g}\t{s}" \
    | csvtk add-header -t -n "name,taxid,kindom,phylum,class,order,family,genus,species" \
    | csvtk csv2xlsx -t -o result.xlsx

See answers here:

Convert list of Accession Numbers to Full Taxonomy
converting taxID to taxonomy

If this does not help solve your problem provide examples of species names.

Log in to answer this question.