Hi,
I'm having some weird behaviour for esearch interpreting variables from the bash command line. I have a list of NCBI protein IDs, and I want to obtain the nucleotide database ID for the associated genome/contig as well as the genome length
This works:
esearch -db protein -query "GIR74039.1" | elink -target nuccore | efetch -format docsum
This works:
i="GIR74039.1"
esearch -db protein -query $i | elink -target nuccore | efetch -format docsum
This doesn't work:
INPUT contains only the protein sequence ID shown above
cat INPUT | while read i
do
echo $i
esearch -db protein -query ${i} | elink -target nuccore | efetch -format docsum > temp
done
Here's the error I'm getting
WARNING: FAILURE ( Mon 4 Mar 15:58:07 GMT 2024 )
-tool edirect -edirect 16.2 -edirect_os Linux -email XXX@XXX.ac.uk0 -usehistory y -db protein -term GIR74039.1
<ERROR>Empty term and query_key - nothing todo</ERROR>
SECOND ATTEMPT
WARNING: FAILURE ( Mon 4 Mar 15:58:09 GMT 2024 )
-tool edirect -edirect 16.2 -edirect_os Linux -email XXX@XXX.ac.uk0 -usehistory y -db protein -term GIR74039.1
<ERROR>Empty term and query_key - nothing todo</ERROR>
LAST ATTEMPT
ERROR: FAILURE ( Mon 4 Mar 15:58:11 GMT 2024 )
-tool edirect -edirect 16.2 -edirect_os Linux -email XXX@XXX.ac.uk0 -usehistory y -db protein -term GIR74039.1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE eSearchResult>
<eSearchResult>
<ERROR>Empty term and query_key - nothing todo</ERROR>
</eSearchResult>
QUERY FAILURE
ERROR: WebEnv value not found in elink input
ERROR: Missing -db argument
(I censored my email from the output)
I've tried all combinations I can think of single/double quotes and {} around the $i variable, none help
I think the record is still being found by esearch as it's mentioned in the error. This seems like an odd error from esearch
One ID that isn't working is shown in the question, they work individually
Many thanks, I wasn't aware of epost but this solved the issue
This now works: