This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Catching error "QueryKey value not found in link output" when fetching taxonomy from NCBI

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

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

0 answers

No answers yet.

Log in to answer this question.