Program for printing only the first hit from blast
#!/usr/bin/perl -w
#read from blastn output search file output simple
while (<>){
if(/Query=/){$a=0; $c=$_;}
if(/significant/){$b=0;print $c;$a=0;}
$b=$b+1;
if($b < 5){print $_;}
if(/BLAST/){$a=3;}
if(/>/){$a=$a+1;}
if($a == 1 ){print $_;}
if(/^BLAST/ ){print $_;}
}
Example:
>Query= 91395796 length 81 cvg_1.0_tip_1
Sequences producing significant alignments: (bits) Value
ref|XR_241314.2| PREDICTED: Homo sapiens membrane protein, palmi... 88 1e-21
>ref|XR_241314.2| PREDICTED: Homo sapiens membrane protein, palmitoylated 4 (MAGUK p55 subfamily member 4) (MPP4), transcript variant X7,
Score = 87.7 bits (44), Expect = 1e-21
Identities = 71/80 (88%)
Strand = Plus / Plus
Query: 2 ctcttgttgcccaggctggagtgtaatggtgagatctcagctcaccgcaacctctgcctc 61
||||||||||||||||||||||| ||||| ||||| ||||| ||||||||||||||
Sbjct: 1152 ctcttgttgcccaggctggagtgcaatggcactatctcgactcactgcaacctctgcctc 1211
Query: 62 ccgggttcaagcgattctcc 81
|||||||||| |||||||||
Sbjct: 1212 ccgggttcaaacgattctcc 1231