This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract country information of a fasta sequence on NCBI website using renterz

I want to extract the country location of a bunch of sequences in the NCBI using renterz. I have their accession numbers but I have the trouble of getting the country info. For example, I have this accession number MH939154 and I need to extract Romania using rentrez.

 source          1..10976
                 /organism="West Nile virus"
                 /mol_type="genomic RNA"
                 /strain="DD84c"
                 /host="Culex pipiens s.l."
                 /db_xref="taxon:11082"
                 /country="Romania"
                 /collection_date="2014"
                 /note="lineage 2"

I have tried the code below but it seems like it will only extract the countries related to publication. So I wonder if there is any way to get the country under the source.

id = "MH939154.1"
db = entrez_fetch(db= "pubmed", id = id, rettype = "xml")
xml <- read_xml(db)
recs <- xml_find_all(xml, "//Country")
r ncbi rentrez location

2 answers

i don't know r+xml , so using a XPATH expression:

$ wget -q -O - "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=MH939154&rettype=gb&retmode=xml"  | xmllint  --xpath '//GBQualifier[GBQualifier_name="country"]/GBQualifier_value/text()' - && echo

Romania

Great. I am able to integrate the command script and get the country info. Thanks!

This can also be obtained by using Entrez Direct:

$ esearch -db nuccore -query "MH939154" | esummary | xtract -pattern DocumentSummary -element SubName
DD84c|Culex pipiens s.l.|WNV|Romania|2014|lineage 2

4th field is Country. I will leave it for you to extract that.

Log in to answer this question.