Thank you for your help, but I need a solution specifically in the R environment - rentrez package
I would like to get taxonomy information (species, family, class, and so on) based on SRA id using rentrez package. I was trying to build a query but was not sure if approaching it correctly.
The taxonomy information are directly included in sra database, as: entrez_db_searchable("sra") --> [ORGN] - Scientific and common names of organism, and all higher levels of taxonomy.
So if I understand correctly, I don't need to link any other database (e.g taxonomy) to get all I need. When I tried:
test <- entrez_search(db="sra", term="ERR5883998[ACCN]", rettype="xml", parsed=TRUE)
test
Entrez search result with 1 hits (object contains 1 IDs and no web_history object)
Search term (as translated): ERR5883998[ACCN]
But when I want to extract XML to extract taxonomy, I got error:
info <- XML::xmlToList(test)
Error in UseMethod("xmlSApply") :
no applicable method for 'xmlSApply' applied to an object of class "c('esearch', 'list')"
2 answers
I found a way how to use the rentrez package to obtain the ScienticName based on SRAid (here more info: manual). Maybe someone else will also find it useful.
test <- entrez_search(db="sra", term=sraid)
tax_rec <- entrez_fetch(db="sra", id=test$ids, rettype="xml", parsed=TRUE)
tax_list <- XML::xmlToList(tax_rec)
info <- tax_list$EXPERIMENT_PACKAGE$RUN_SET$RUN$Pool$Member$.attrs
organism <- as.vector(info["organism"])
Using EntrezDirect:
$ esearch -db sra -query ERR5883998 | efetch -format runinfo | awk -F "," '{print $28,$29}'
TaxID ScientificName
39272 Allacma fusca
OR
$ efetch -db sra -id ERR5883998 -format runinfo | awk -F "," '{print $28,$29}'
TaxID ScientificName
39272 Allacma fusca
Log in to answer this question.