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)
Thank you! It works!
No problem. Please consider accepting the answer by clicking in "Accept" symbol :).