Skip to content

Commit

Permalink
SeqFeature::Annotated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fangly committed Mar 5, 2012
1 parent 8f07a6d commit c334576
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 44 deletions.
1 change: 1 addition & 0 deletions Bio/SeqFeature/Annotated.pm
Expand Up @@ -312,6 +312,7 @@ sub from_feature {
$self->add_Annotation($key,$val)
}
}
return 1;
}
#given a key and its values, make the values into
#Bio::Annotation::\w+ objects
Expand Down
97 changes: 53 additions & 44 deletions t/SeqFeature/SeqFeatAnnotated.t → t/SeqFeature/Annotated.t
Expand Up @@ -7,44 +7,50 @@ BEGIN {
use lib '.';
use Bio::Root::Test;

test_begin(-tests => 34,
-requires_modules => [qw(URI::Escape Graph::Directed)],
-requires_networking => 1
);

use_ok('Bio::SeqFeature::Generic');
use_ok('Bio::SeqFeature::Annotated');
test_begin(
-tests => 40,
-requires_modules => [qw(URI::Escape Graph::Directed)],
-requires_networking => 1
);

use_ok('Bio::SeqFeature::Generic');
use_ok('Bio::SeqFeature::Annotated');
}

my $sfa = Bio::SeqFeature::Annotated->new(-start => 1,
-end => 5,
-strand => "+",
-frame => 2,
-type => 'nucleotide_motif',
-phase => 2,
-score => 12,
-source => 'program_b',
-display_name => 'test.annot',
-seq_id => 'test.displayname' );
my ($sfa, $sfa2, $sfa3, $loc, $sfg, $sfaa);


ok (defined $sfa);
my $loc = $sfa->location;
ok $loc->isa("Bio::Location::Simple");
ok $sfa = Bio::SeqFeature::Annotated->new(
-start => 1,
-end => 5,
-strand => '+',
-frame => 2,
-type => 'nucleotide_motif',
-phase => 2,
-score => 12,
-source => 'program_b',
-display_name => 'test.annot',
-seq_id => 'test.displayname',
);
ok $loc = $sfa->location;
ok $loc->isa('Bio::Location::Simple');
ok $sfa->display_name eq 'test.annot';

#test bsfa::from_feature
my $sfg = Bio::SeqFeature::Generic->new ( -start => 400,
-end => 440,
-strand => 1,
-primary => 'nucleotide_motif',
-source => 'program_a',
-tag => {
silly => 20,
new => 1
}
);
my $sfa2;
$sfa2 = Bio::SeqFeature::Annotated->new(-feature => $sfg);

# Test bsfa::from_feature
$sfg = Bio::SeqFeature::Generic->new (
-start => 400,
-end => 440,
-strand => 1,
-primary => 'nucleotide_motif',
-source => 'program_a',
-tag => {
silly => 20,
new => 1
}
);

ok $sfa2 = Bio::SeqFeature::Annotated->new(-feature => $sfg);

is $sfa2->type->name,'nucleotide_motif';
is $sfa2->primary_tag, 'nucleotide_motif';
Expand All @@ -55,7 +61,8 @@ is $sfa2->start,400;
is $sfa2->end,440;
is $sfa2->get_Annotations('silly')->value,20;
is $sfa2->get_Annotations('new')->value,1;
my $sfaa = Bio::SeqFeature::Annotated->new(-feature => $sfa);

ok $sfaa = Bio::SeqFeature::Annotated->new(-feature => $sfa);
is $sfaa->type->name,'nucleotide_motif';
is $sfaa->primary_tag, 'nucleotide_motif';
is $sfaa->source->display_text,'program_b';
Expand All @@ -65,16 +72,18 @@ is $sfaa->start,1;
is $sfaa->end,5;
is $sfaa->score,12;

my $sfa3 = Bio::SeqFeature::Annotated->new( -start => 1,
-end => 5,
-strand => "+",
-frame => 2,
-phase => 2,
-score => 12,
-display_name => 'test.annot',
-seq_id => 'test.displayname' );
$sfa3->from_feature($sfg);
ok $sfa3 = Bio::SeqFeature::Annotated->new(
-start => 1,
-end => 5,
-strand => '+',
-frame => 2,
-phase => 2,
-score => 12,
-display_name => 'test.annot',
-seq_id => 'test.displayname',
);

ok $sfa3->from_feature($sfg);
is $sfa3->type->name,'nucleotide_motif', 'type->name';
is $sfa3->primary_tag, 'nucleotide_motif', 'primary_tag';
is $sfa3->source->display_text,'program_a';
Expand All @@ -90,7 +99,7 @@ is $sfa3->get_Annotations('new')->value,1;
# By popular vote there is no operator overloading, so this needs to be
# resolved
is $sfa3->score(), 12;
$sfa3->score(11);
ok $sfa3->score(11);
is $sfa3->score(), 11;
$sfa3->score(0);
is $sfa3->score(), 0; # test that setting to 0 no longer is overriddent to set score to '.' (fixed in Bio::SeqFeature::Annotated version 1.3.7)
Expand Down

0 comments on commit c334576

Please sign in to comment.