This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How can I use formatted output file in the following code?

I'm a beginner in blast. I want to find the best BLAST hit. I add -outfmt 6 in my code like blastn -query $input -out out.txt -db db1 -outfmt 6. I can get out.txt, which is formatted in my directory. However, in the same script, when I try to loop the out.txt to find the best BLAST hit, I can only use out.txt that is not formatted. How can I use formatted output file in the following code?

blast

You only need to find the top hit from each search? Why not consider using a separate output file for each query so you won't overwrite the output file (e.g. -out $input\_out.txt. Otherwise it is not clear exactly what you are asking.

1 answer

You need to define what "best blast hit" means for your use case.

Then look at the blast help to see all types of columns that you can output and select that one that captures what you call "best".

Then use the -outfmt 6 and add to the output your selected column of interest. Sort by it and you have what you wanted.

Log in to answer this question.