This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Best Blast Hit Without Pain

Hi,

This might be naive but here I go. I have a set of target sequences and a query sequence. I want to find the best BLAST hit (lets say using the bit score). The straightforward way to do this is to run BLAST against the targets and then parse the output file (looking at every hit one at a time) and then finding the best hit.

My question is, is there any other way to do this? For example, already getting sorted output (according to bit score) and then retrieve the first hit?

EDIT (added information):

To make it clear, I want to search 1 (or more) sequences with a custom database using local NCBI BLAST (nucleotide vs nucleotide). I donot want to use e-value as criterion as the length of alignment is important. Thats why I would like to use bit score. As per Pierre's link what I need is -v. Thanks again for comments.

Any suggestions are welcome.

best regards

ncbi blast

The only way to know which is the best alignment is to look at the alignments. If you bypass this step, you will get a lot of false positive results.

2 answers

I think one trick is to use tabular output format (-m 8) and then sort manually according to the field you are interested in.

You will have to tell sort which field to use (bit-score should be field 12, I think) and to sort numerically, supporting scientific notation (-g):

An example:

$ blastall -p blastn -i seq.fa -d db.fa -m 8 | sort -g -k 12

To get the best hit just append a tail -n1

Andreas

PS: Be warned: I only did a quick test!

The Hits are already sorted on the e-value, why would you want to use another field ? To extract the first hit, this this previous question: Standalone Blast Options

I think he means that he uses blast between a pair of sequences, and not with 1 sequence against a custom database. I'm pretty sure blast allows this later, but it's been ages since I last ran it and I don't remember how to do so.

Hi Pierre and Jorge,

Thanks for your comments.

To make it clear, I want to search 1 (or more) sequences with a custom database using local NCBI BLAST (nucleotide vs nucleotide).

I donot want to use e-value as criterion as the length of alignment is important. Thats why I would like to use bit score.

As per Pierre's link what I need is -v.

Thanks again for comments. Anymore comments are very welcome.

best

As Andreas wrote, I select hits in similar way, using e-value and % identity by sorting blast file (output format -m 8) and then I sort with unique option on the first (query) column.

Log in to answer this question.