-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblast2blastm8.pl
29 lines (26 loc) · 964 Bytes
/
blast2blastm8.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/local/bin/perl -w
use strict;
use Bio::SearchIO;
my $in = new Bio::SearchIO(-format => 'blast', -file => $ARGV[0]);
while (my $result = $in->next_result ) {
while (my $hit = $result->next_hit ) {
while (my $hsp = $hit->next_hsp ) {
my $pcid = $hsp->percent_identity;
my $len = $hsp->length('total');
my $mismatches = $len - $hsp->num_identical -
$hsp->gaps('total');
#Find runs of '-' in query, hit strings
my @gap_list = (($hsp->query_string . $hsp->hit_string) =~
/-+/g);
my $ngaps = @gap_list;
my @fields = (
$result->query_name, $hit->name, sprintf("%.2f",$pcid),
$len, $mismatches, $ngaps,
$hsp->start('query'), $hsp->end('query'),
$hsp->start('hit'), $hsp->end('hit'),
$hsp->evalue, $hsp->bits
);
print join("\t", @fields), "\n";
}
}
}