This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Issue with NCBI esearch

Hi all,

I'm trying to retrieve some taxonomy information using esearch from NCBI, I have a list of tax IDs (one per line) in a file called ids.txt

I'm running this code and it keeps failing, I've checked all previous resolved posts about this issue and I followed the same syntax. Any ideas what's going on here?

my code:

cat ids.txt | while read line;
do
echo $line;
esearch -db taxonomy -query “$line[taxID]"
done

and the error message:

> sed: RE error: illegal byte sequence 
> ERROR: Missing -query argument

I tried removing the "taxID" part from the query to see if that was the problem, but then I get another error:

cat ids.txt | while read line;
> do
> echo $line;
> esearch -db taxonomy -query $line
> done
 WARNING:  FAILURE ( Fri  7 May 2021 15:46:57 EDT )
nquire -url https://eutils.ncbi.nlm.nih.gov/entrez/eutils/ esearch.fcgi -retmax 0 -usehistory y -db taxonomy -term $'743375\r' -tool edirect -edirect 15.0 -edirect_os Darwin -email 
<ERROR>Empty term and query_key - nothing todo</ERROR>
ncbi esearch edirect

1 answer

This looks like a line ending (see https://en.wikipedia.org/wiki/Newline) issue. Please run mac2unix on your ids.txt file before you run the command. That should change the line endings to unix style. For the first command, try "${line}[TaxID]"

This fixed the issue, thank you very much!

Log in to answer this question.