Convert Accession Numbers in blast HIT output to Full Taxonomy
1
0
Entering edit mode
11 months ago

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 • 605 views
ADD COMMENT
2
Entering edit mode
11 months ago
iraun 6.2k

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

ADD COMMENT
0
Entering edit mode

Thank you! It works!

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2857 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6