Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bio::DB::length improvement

Get length from database, not from seq. This should be much more efficient since the database has a record of the length and since this avoid bringing a possibly very large sequence in memory.
  • Loading branch information...
commit 366308d24393d94db59184801cd537ffb3aefd98 1 parent cc59da8
@fangly fangly authored
Showing with 6 additions and 4 deletions.
  1. +4 −3 Bio/DB/Fasta.pm
  2. +2 −1  t/LocalDB/Fasta.t
View
7 Bio/DB/Fasta.pm
@@ -307,7 +307,7 @@ sub subseq {
Title : length
Usage : my $length = $qualdb->length($id);
- Function: Get the number of residies in the indicated sequence.
+ Function: Get the number of residues in the indicated sequence.
Returns : Number
Args : ID of entry
@@ -423,14 +423,15 @@ sub alphabet {
}
sub length {
+ # For efficiency, get length from the database, not from the sequence string
my $self = shift;
- return CORE::length($self->seq);
+ return $self->{db}->length($self->{id});
}
sub description {
my $self = shift;
my $header = $self->{'db'}->header($self->{id});
- # remove the id from the header
+ # remove the ID from the header
return (split(/\s+/, $header, 2))[1];
}
*desc = \&description;
View
3  t/LocalDB/Fasta.t
@@ -2,7 +2,7 @@ BEGIN {
use lib '.';
use Bio::Root::Test;
- test_begin( -tests => 84,
+ test_begin( -tests => 85,
-requires_modules => [qw(Bio::DB::Fasta Bio::SeqIO)]);
}
use strict;
@@ -50,6 +50,7 @@ my $test_files = [
ok $primary_seq = $db->get_Seq_by_acc('AW057119');
ok $primary_seq = $db->get_Seq_by_version('AW057119');
ok $primary_seq = $db->get_Seq_by_primary_id('AW057119');
+ isa_ok $primary_seq, 'Bio::PrimarySeq::Fasta';
isa_ok $primary_seq, 'Bio::PrimarySeqI';
# Bio::PrimarySeqI methods
Please sign in to comment.
Something went wrong with that request. Please try again.