Permalink
Browse files

New length() method neeed to consider strandedness

  • Loading branch information...
1 parent e766ed7 commit a75eeea8b442575cd280d695df8052f9c9e3791d @fangly fangly committed Nov 6, 2012
Showing with 5 additions and 2 deletions.
  1. +3 −1 Bio/DB/Fasta.pm
  2. +2 −1 t/LocalDB/Fasta.t
View
@@ -438,7 +438,9 @@ sub revcom {
sub length {
# Get length from sequence location, not the sequence string (too expensive)
my $self = shift;
- return $self->{stop} - $self->{start} + 1;
+ return $self->{start} < $self->{stop} ?
+ $self->{stop} - $self->{start} + 1 :
+ $self->{start} - $self->{stop} + 1 ;
}
sub description {
View
@@ -2,7 +2,7 @@ BEGIN {
use lib '.';
use Bio::Root::Test;
- test_begin( -tests => 91,
+ test_begin( -tests => 92,
-requires_modules => [qw(Bio::DB::Fasta Bio::SeqIO)]);
}
use strict;
@@ -72,6 +72,7 @@ my $test_files = [
isa_ok $rev, 'Bio::PrimarySeq::Fasta';
isa_ok $rev, 'Bio::PrimarySeqI';
is $rev->seq, 'accccgagaa';
+ is $rev->length, 10;
}

0 comments on commit a75eeea

Please sign in to comment.