Skip to content

Commit

Permalink
For SeqFeatureI compliance, Bio::SeqFeature::Generic primary_tag(), s…
Browse files Browse the repository at this point in the history
…ource_tag() and display_name() methods must return a string, not undef
  • Loading branch information
fangly committed Mar 5, 2012
1 parent 58ed779 commit c127d8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Bio/SeqFeature/Generic.pm
Expand Up @@ -444,7 +444,7 @@ sub frame {
sub primary_tag {
my $self = shift;
return $self->{'_primary_tag'} = shift if @_;
return $self->{'_primary_tag'};
return $self->{'_primary_tag'} || '';
}


Expand All @@ -463,7 +463,7 @@ sub primary_tag {
sub source_tag {
my $self = shift;
return $self->{'_source_tag'} = shift if @_;
return $self->{'_source_tag'};
return $self->{'_source_tag'} || '';
}


Expand Down Expand Up @@ -693,7 +693,7 @@ sub seq_id {
sub display_name{
my $self = shift;
return $self->{'display_name'} = shift if @_;
return $self->{'display_name'};
return $self->{'display_name'} || '';
}


Expand Down
16 changes: 13 additions & 3 deletions t/SeqFeature/SeqFeature.t
Expand Up @@ -7,7 +7,7 @@ BEGIN {
use lib '.';
use Bio::Root::Test;

test_begin(-tests => 249);
test_begin(-tests => 256);

use_ok('Bio::Seq');
use_ok('Bio::SeqIO');
Expand All @@ -27,11 +27,20 @@ my ($feat,$str,$feat2,$pair,$comp_obj1,$comp_obj2,@sft);

my $DEBUG = test_debug();

$feat = Bio::SeqFeature::Generic->new( -start => 40,
ok $feat = Bio::SeqFeature::Generic->new( -start => 40,
-end => 80,
-strand => 1,
);
is $feat->primary_tag, '';
is $feat->source_tag, '';
is $feat->display_name, '';

ok $feat = Bio::SeqFeature::Generic->new( -start => 40,
-end => 80,
-strand => 1,
-primary => 'exon',
-source => 'internal',
-display_name => 'my exon feature',
-tag => {
silly => 20,
new => 1
Expand All @@ -42,11 +51,12 @@ is $feat->start, 40, 'start of feature location';
is $feat->end, 80, 'end of feature location';
is $feat->primary_tag, 'exon', 'primary tag';
is $feat->source_tag, 'internal', 'source tag';
is $feat->display_name, 'my exon feature', 'display name';
is $feat->phase, undef, 'undef phase by default';
is $feat->phase(1), 1, 'phase accessor returns';
is $feat->phase, 1, 'phase is persistent';

$str = $feat->gff_string() || ""; # placate -w
ok $feat->gff_string();

$pair = Bio::SeqFeature::FeaturePair->new();
ok defined $pair;
Expand Down

0 comments on commit c127d8d

Please sign in to comment.