Catching error "QueryKey value not found in link output" when fetching taxonomy from NCBI
0
1
Entering edit mode
4.2 years ago
Frieda ▴ 60

Dear reader!

I intend to retrieve the taxonomy for some accession numbers in NCBI using the following command:

Using the following example: https://www.ncbi.nlm.nih.gov/protein/XP_018619665.1

I run this command:

esearch -db protein -query "XP_018619665.1" | elink -target taxonomy | efetch -format native -mode xml | grep ScientificName | awk -F ">|<" 'BEGIN{ORS=", ";}{print $3;}'

The above example returns:

"QueryKey value not found in fetch input"

I believe the reason is that the sequence has been updated.

I am now wondering how I can handle this kind of error within the terminal or within R? This command is used within R in part of my code.

NCBI r efetch bash error_handling • 1.2k views
ADD COMMENT
2
Entering edit mode
$ wget -O - -q "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=protein&id=XP_018619665.1&retmode=xml" | xmllint --xpath '//GBQualifier_value[starts-with(.,"taxon:")]/text()'  -
taxon:113540
ADD REPLY
2
Entering edit mode

If you drop the version number your command should work fine:

$ esearch -db protein -query "XP_018619665" | elink -target taxonomy | efetch -format native -mode xml | grep ScientificName | awk -F ">|<" 'BEGIN{ORS=", ";}{print $3;}'
Scleropages formosus, cellular organisms, Eukaryota, Opisthokonta, Metazoa, Eumetazoa, Bilateria, Deuterostomia, Chordata, Craniata, Vertebrata, Gnathostomata, Teleostomi, Euteleostomi, Actinopterygii, Actinopteri, Neopterygii, Teleostei, Osteoglossocephalai, Osteoglossocephala, Osteoglossomorpha, Osteoglossiformes, Osteoglossidae, Scleropages,

You could also do something like:

$ esearch -db protein -query "XP_018619665" | elink -target taxonomy | efetch -format xml | xtract -pattern Taxon -block "*/Taxon" -unless Rank -equals "no rank" -tab "\n" -element Rank,ScientificName
superkingdom    Eukaryota
kingdom Metazoa
phylum  Chordata
subphylum       Craniata
superclass      Actinopterygii
class   Actinopteri
subclass        Neopterygii
infraclass      Teleostei
order   Osteoglossiformes
family  Osteoglossidae
genus   Scleropages
ADD REPLY
0
Entering edit mode

Hello Fardokht!

It appears that your post has been cross-posted to another site: https://stackoverflow.com/questions/60260711

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLY

Login before adding your answer.

Traffic: 2219 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6