This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Convert Accession Numbers in blast HIT output to Full Taxonomy

I have the Hit table output from a BlastWeb search which presents itself basically like this:

M_A00619 | XM_034926345.1 | 100.000

M_A00619 | OV754683.1 | 95.588

M_A00619 | OV754677.1 | 95.588

M_A00619 | OV737695.1 | 95.588

I want to convert the accession in the second column to full taxonomies. i.e.

XM_034926345.1 --> Acipenser ruthenus cellular organisms Eukaryota Opisthokonta Metazoa Eumetazoa Bilateria Deuterostomia Chordata Craniata Vertebrata Gnathostomata Teleostomi Euteleostomi Actinopterygii Actinopteri Chondrostei Acipenseriformes Acipenseroidei Acipenseridae Acipenserinae Acipenserini Acipenser

Or something similar to that.

I'm trying to use this simple while read loop:

input="Blast.hit.table.txt"
while read -r line
do 
    id=$(echo $line |sed 's/|/      /g' | cut -f2)
    tax=$( esearch -db nucleotide -query "$id" | elink -target taxonomy | efetch -format native -mode xml | grep ScientificName | awk -F ">|<" 'BEGIN{ORS=", ";}{print $3;}' )
done < $input

But for some reason the loop doesnt work and stops after the first line. (for the first line it works)

esearch blast accession taxid

1 answer

Try adding < /dev/null after esearch function:

tax=$(esearch -db nucleotide -query "$id" < /dev/null | elink -target taxonomy | efetch -format native -mode xml | grep ScientificName | awk -F ">|<" 'BEGIN{ORS=", ";}{print $3;}')

The issue is explained here

No problem. Please consider accepting the answer by clicking in "Accept" symbol :).

Log in to answer this question.