Question: Catching error "QueryKey value not found in link output" when fetching taxonomy from NCBI
1
gravatar for Freddy
8 months ago by
Freddy20
Freddy20 wrote:

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.

error_handling bash efetch R ncbi • 249 views
ADD COMMENTlink modified 8 months ago by Asaf8.4k • written 8 months ago by Freddy20
2
$ 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 REPLYlink written 8 months ago by Pierre Lindenbaum131k
2

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 REPLYlink modified 8 months ago • written 8 months ago by genomax91k

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 REPLYlink written 8 months ago by Pierre Lindenbaum131k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1009 users visited in the last hour