Permalink
Browse files

Let PrimarySeqI handle revcom() and trunc()

Bio::PrimarySeq::Fasta is a Bio::PrimarySeqI-implementing class. Since Bio::PrimarySeqI already implements revcom() and trunc(), it's best if Bio::PrimarySeq::Fasta does not override these methods.
  • Loading branch information...
1 parent 32aaa54 commit 66583c8ac155db315f05b11d9b7e5f26c849d026 @fangly fangly committed Nov 6, 2012
Showing with 10 additions and 19 deletions.
  1. +10 −19 Bio/DB/Fasta.pm
View
29 Bio/DB/Fasta.pm
@@ -379,22 +379,16 @@ sub seq {
}
sub subseq {
- my $self = shift;
- return $self->trunc(@_)->seq();
-}
-
-sub trunc {
my ($self, $start, $stop) = @_;
$self->throw("Stop cannot be smaller than start") if $stop < $start;
- return $self->{start} <= $self->{stop} ?
- $self->new( $self->{db},
- $self->{id},
- $self->{start}+$start-1,
- $self->{start}+$stop-1, ) :
- $self->new( $self->{db},
- $self->{id},
- $self->{start}-($start-1),
- $self->{start}-($stop-1) );
+ if ($self->{start} <= $self->{stop}) {
+ $start = $self->{start}+$start-1;
+ $stop = $self->{start}+$stop-1;
+ } else {
+ $start = $self->{start}-($start-1);
+ $stop = $self->{start}-($stop-1);
+ }
+ return $self->{db}->seq($self->{id}, $start, $stop);
}
sub is_circular {
@@ -413,6 +407,8 @@ sub accession_number {
}
sub primary_id {
+ # Following Bio::PrimarySeqI, since this sequence has no accession number,
+ # its primary_id should be a stringified memory location.
my $self = shift;
return overload::StrVal($self);
}
@@ -426,11 +422,6 @@ sub alphabet {
return $self->{db}->alphabet($self->{id});
}
-sub revcom {
- my $self = shift;
- return $self->new(@{$self}{'db', 'id', 'stop', 'start'});
-}
-
sub length {
my $self = shift;
return CORE::length($self->seq);

0 comments on commit 66583c8

Please sign in to comment.