This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Filter Blastn Results By Alignment Lenght

I want to filter the blastn result according to cutoff "alignment length more than 50bp , the gap max length less than 50bp in the alignment region and evalue less than 0.01.like this ,the cdna map to genome ,the intron length less than 50bp. some blastn result in the outfmt 6

gi|312461686|gb|HP608955.1|    gi|359614520|gb|JP881116.1|    94.86    564    25    3    613    1173    1764    1202    0.0     880
gi|312461686|gb|HP608955.1|    gi|359614520|gb|JP881116.1|    98.00    150    2    1    1447    1596    1208    1060    5e-72     259
gi|312461686|gb|HP608955.1|    gi|359614520|gb|JP881116.1|    95.17    145    7    0    1831    1975    1060    916    4e-63     230
gi|509468259|gb|GAJL01013922.1|    gi|391056808|gb|JV874923.1|    99.41    170    1    0    40    209    426    257    4e-88     309
gi|509468259|gb|GAJL01013922.1|    gi|391056808|gb|JV874923.1|    100.00    36    0    0    1    36    450    415    3e-15    67.6

the filter result

gi|509468259|gb|GAJL01013922.1|    gi|391056808|gb|JV874923.1|    99.41    170    1    0    40    209    426    257    4e-88     309
gi|509468259|gb|GAJL01013922.1|    gi|391056808|gb|JV874923.1|    100.00    36    0    0    1    36    450    415    3e-15    67.6
blastn

you need to specify what your columns are - also simplify the question is not clear what you want

A short python script will do the job.

Simple awk command will solve this too

1 answer

If this is blast tabular output, then the columns correspond to the following variables: query, subject, %id, alignment length, mismatches, gap openings, query start, query end, subject start, subject end, Evalue, bit score

You want to sort on alignment length greater than 50 (column 4) and gap opening less than 50 (column 6) and Evalue (column 11) less than 0.01, then using a simple awk command as suggested by Pgibas from your input file blast_results.txt:

awk '{if ($4>=50 && $6 <1 && $11<0.01)print $1 }' blast_results.txt

Log in to answer this question.