I am a new guy and want to add taxID to the fasta file (1.fa) which begins with GI for each line. So firstly I try to get the taxID by efetch through the following code.
cat 1.fa | while read line
do
GI=`grep ">" | cut -d '>' -f 2 | cut -d ' ' -f 1`
wget curl "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=${GI}&rettype=fasta&retmode=xml"
done
But it did not work by saying:
--2017-06-01 16:10:48-- http://curl/ Resolving curl (curl)... failed: Name or service not known. wget: unable to resolve host address ‘curl’ URL transformed to HTTPS due to an HSTS policy --2017-06-01 16:10:48-- https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=X51700.1%0AX68321.1%0AX55027.1%0AZ12029.1%0AX52700.1&rettype=fasta&retmode=xml Resolving eutils.ncbi.nlm.nih.gov eutils.ncbi.nlm.nih.gov)... 130.14.29.110, 2607:f220:41e:4290::110 Connecting to eutils.ncbi.nlm.nih.gov eutils.ncbi.nlm.nih.gov)|130.14.29.110|:443... connected. HTTP request sent, awaiting response... 400 Bad Request 2017-06-01 16:10:49 ERROR 400: Bad Request.
However it works well when replacing the ${GI} to the real GI numbers, like
wget curl "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=X51700.1&rettype=fasta&retmode=xml"
And could produce the correct GI no. by
cat 1.fa | while read line
do
GI=`grep ">" | cut -d '>' -f 2 | cut -d ' ' -f 1`
echo "$GI"
done
Could anyone tell me where is the mistake? Thank you guys!
Thanks! I have got the clean GI. And also I tried to curl the https, but it did not work even when I typed the GI manually:
As I said above you need to use
https
. Try:curl "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=X52700.1&rettype=fasta&retmode=xml"
It works now. Thanks a lot!!