Thank you so much for the help
esearch -db nucleotide -query "MW605321:MW605421[accn]" | efetch -format docsum | xtract -pattern DocumentSummary -element Caption TaxId Organism
I have to get the family information of viruses from their species information. I have more than 200 virus species data with me. I have tried a lot of things to get the family information of multiple viruses using NCBI utilities.
So can any one please help me hoe to get the family information of viruses from species information.
esearch -db nucleotide -query "MW605321:MW605421[accn]" | efetch -format docsum | xtract -pattern DocumentSummary -element Caption TaxId Organism
how to modify this command .
1 answer
Such a query in E-Utils is not trivial and cannot be done properly in a single command. Also note that the results you are getting from your query hint at environmental samples from animals, not viruses. So I am not sure what you are exactly looking for here. If you are looking for viruses in these samples you may need a different analysis.
Anyway, the following query resolves a taxid to the family level using e-fetch:
efetch -db taxonomy -id 333810,2811796,2811795,2811794,2811793,2811792,696705 -format xml | \
xtract -pattern LineageEx -block Taxon -if Rank -equals family -element "ScientificName"
Chironomidae
Naididae
Tephritidae
Chironomidae
Sepsidae
Culicidae
To add a fourth column to your output file requires a little scripting, like so:
esearch -db nucleotide -query "MW605321:MW605421[accn]" | efetch -format docsum | xtract -pattern DocumentSummary \
-element Caption TaxId Organism > file1.txt
efetch -db taxonomy -id $(cut -f2 file1.txt | tr "\n" ",") -format xml |
xtract -pattern LineageEx -block Taxon -if Rank -equals family -element "ScientificName" > file2.txt
paste file1.txt file2.txt
MW605421 333810 Chironomidae environmental sample Chironomidae
MW605420 333810 Chironomidae environmental sample Chironomidae
MW605419 333810 Chironomidae environmental sample Chironomidae
MW605418 333810 Chironomidae environmental sample Chironomidae
MW605417 333810 Chironomidae environmental sample Chironomidae
MW605416 333810 Chironomidae environmental sample Chironomidae
....
Log in to answer this question.