View Single Post
Old 09-09-2012, 03:55 AM   #4
Location: japan

Join Date: Sep 2012
Posts: 24

Originally Posted by dariober View Post
Hi- I'm not sure how/if it can be done by Blast. However you can extract the top hit from the blast ouput (blastout.txt) with the code below:

sort -k1,1 -k12,12nr -k11,11n  blastout.txt | sort -u -k1,1 --merge
The first sort orders the blast output by query name then by the 12th column in descending order (bit score - I think), then by 11th column ascending (evalue I think).
The second sort picks the first line from each query. Obviously you can skip the first sort if the output is already sorted in the 'correct' order.

Hope it helps (make sure it does what you want)...

Dear Dario,
Thank you very much for answering this question, and you helped me a lot to resolve the problems of python several days ago.

In order to extract the best hit in results.txt, I have tried an alternative way in using macro tool of excel. The script for this purpose was written like
Sub tophitonly()
Dim i%
For i = [a65536].End(3).Row To 1 Step -1
If Application.CountIf(Range("a:a"), Cells(i, 1)) > 1 Then
Cells(i, 1).EntireRow.Delete
End If
Next i
End Sub
Anyway, thank you very much. And I would like to try your method in the following days.
Tsuyoshi is offline   Reply With Quote