This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Counting the number of species from NCBI Taxonomy browser

Hi, I need to count the number of species for each genus search from NCBI Taxonomy Browser result. Is there any way to do this using coding ? Manual counting is highly tedious work. Thanks

taxonomy ncbi

1 answer

Try using taxonkit, but it needs some time.

There are 96645 TaxIds at genus rank.

$ time taxonkit list --ids 1 \
    | taxonkit filter --equal-to genus
    | wc -l
96645

Counting for 100 genuses costs:

time taxonkit list --ids 1 \
    | taxonkit filter --equal-to genus \
    | head -n 100 \
    | rush 'echo -ne "{}\t$(echo {} \
                                | taxonkit list --ids {} \
                                | taxonkit filter --equal-to species \
                                | wc -l \
                            )\n" ' \
    | csvtk sort -H -t -k 2:nr \
    | head -n 5

190729  178
558016  157
558017  55
687331  40
1307798 32

real    1m11.472s
user    16m28.239s
sys     0m55.687s

It works but is not efficient for this work.

Log in to answer this question.