This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is there a way to obtain taxonomy IDs of organisms with associated protein sequences?

I want to get a list of taxonomy IDs from a taxonomic group. If I enter the taxon ID (ex. txid4751[Organism]) in taxonomy database in NCBI, there are a lot of entries, some of them don't have associated protein sequences. I would only need the IDs of those organisms with protein sequences. A much as possible, searching for that taxon in the protein database, and downloading the data, then extracting the taxon IDs, is not an option. Is there an easier way to do this? Any help would be greatly appreciated.

blast ncbi

1 answer

Don't know if I understand the question right, don't know if you want to get taxonids or protein sequences or both.

To get all the taxonid's of a certain group you can look at this file:

taxidlineage.dmp (ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/new_taxdump/) With something like the following command you can extract the taxonid's, for example all bacterial.

grep -w [taxonid of group] taxidlineage.dmp | awk '{print $1}' > taxonids_group
#get bacterial ids
grep -w 2 taxidlineage.dmp | awk '{print $1}' > taxonids_group

To get the protein sequences you can download the nr database, that update script comes with the blast program in the bin folder:

update_blastdb.pl nr --passive

To get the protein sequences you can do (not sure if this is the right full command):

blastdbcmd -db nr -entry_batch taxonids_group

EDIT:

Reading your question again, this is an option to get only taxonids which have proteins sequences. First download the nr database:

update_blastdb.pl nr --passive

Extract all taxonids:

blastdbcmd -db nr -entry all -outfmt '%T' > nr_taxonids

Get all taxonids of your interest:

wget ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/new_taxdump/new_taxdump.zip
unzip new_taxdump.zip 
grep -w [taxonid of group] taxidlineage.dmp | awk '{print $1}' > taxonids_group
#get bacterial ids
grep -w 2 taxidlineage.dmp | awk '{print $1}' > taxonids_group

Last step is to find a way to compare taxonids_group and nr_taxonids. I would do it with python but for sure you can find a command on this forum to better do it.

Did this answer helped? or you need more info?

Log in to answer this question.