Skip to content
Browse files

Fixed Bug 3343 by correctly calculating the total gaps

  • Loading branch information...
1 parent 4e947ea commit 355335ea2d7353d69267f7b369e74b2431a7d8be @pcantalupo pcantalupo committed Oct 31, 2012
Showing with 13 additions and 2 deletions.
  1. +10 −0 Bio/SearchIO/blasttable.pm
  2. +3 −2 t/SearchIO/blasttable.t
View
10 Bio/SearchIO/blasttable.pm
@@ -219,6 +219,16 @@ sub next_result{
$gapsm=$qgaps+$sgaps;
}
+ if (@fields == 12 || @fields == 13) {
+ # need to determine total gaps in the alignment for NCBI output
+ # since NCBI reports number of gapopens and NOT total gaps
+ my $qlen = abs($qstart - $qend) + 1;
+ my $querygaps = $hsp_len - $qlen;
+ my $hlen = abs($hstart - $hend) + 1;
+ my $hitgaps = $hsp_len - $hlen;
+ $gapsm = $querygaps + $hitgaps;
+ }
+
# Remember Jim's code is 0 based
if( defined $lastquery &&
$lastquery ne $qname ) {
View
5 t/SearchIO/blasttable.t
@@ -7,7 +7,7 @@ BEGIN {
use lib '.';
use Bio::Root::Test;
- test_begin(-tests => 165);
+ test_begin(-tests => 166);
use_ok('Bio::SearchIO');
use_ok('Bio::Search::SearchUtils');
@@ -72,7 +72,8 @@ while(my $res = $searchio->next_result) {
is($hsp->start('query'), 5);
is($hsp->end('query'), 812);
is($hsp->length, 821);
- is($hsp->gaps, 14);
+ is($hsp->percent_identity, 30.0852618757613, 'fixed bug 3343 (percent identity)');
+ is($hsp->gaps, 44, 'side effect of fixing bug 3343 (number of gaps)');
my $hit_sf = $hsp->hit;
my $query_sf = $hsp->query;
isa_ok($hit_sf, 'Bio::SeqFeatureI');

0 comments on commit 355335e

Please sign in to comment.
Something went wrong with that request. Please try again.