1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 23);
12 use_ok('Bio::SeqFeature::Generic');
13 use_ok('Bio::SeqFeature::AnnotationAdaptor');
14 use_ok('Bio::Annotation::DBLink');
15 use_ok('Bio::Annotation::Comment');
16 use_ok('Bio::Annotation::SimpleValue');
20 my $feat = Bio::SeqFeature::Generic->new();
21 $feat->add_tag_value("tag1", "value of tag1");
22 $feat->add_tag_value("tag1", "another value of tag1");
23 $feat->add_tag_value("tag2", "some value for a tag");
25 my $link1 = Bio::Annotation::DBLink->new(-database => 'TSC',
26 -primary_id => 'TSC0000030',
29 $feat->annotation->add_Annotation($link1);
31 my $anncoll = Bio::SeqFeature::AnnotationAdaptor->new(-feature => $feat);
33 is($anncoll->get_num_of_annotations(), 4);
34 is(scalar($anncoll->get_all_annotation_keys()), 2);
36 my @anns = $anncoll->get_Annotations("tag1");
37 my @vals = $feat->each_tag_value("tag1");
39 is (scalar(@anns), scalar(@vals));
40 for(my $i = 0; $i < @anns; $i++) {
41 is ($anns[$i]->value(), $vals[$i]);
44 @anns = $anncoll->get_Annotations("tag2");
45 my @fanns = $feat->annotation->get_Annotations("tag2");
46 @vals = $feat->each_tag_value("tag2");
48 is (scalar(@fanns), 1);
49 is (scalar(@anns), 2);
50 is (scalar(@vals), 1);
51 is ($anns[0]->value(), $vals[0]);
53 is ($anns[1]->primary_id(), $fanns[0]->primary_id());
55 my $comment = Bio::Annotation::Comment->new( '-text' => 'sometext');
56 $anncoll->add_Annotation('comment', $comment);
58 @fanns = $feat->annotation->get_Annotations("comment");
59 is (scalar(@fanns), 1);
60 is ($fanns[0]->text(), "sometext");
62 my $tagval = Bio::Annotation::SimpleValue->new(-value => "boring value",
64 $anncoll->add_Annotation($tagval);
66 @anns = $anncoll->get_Annotations("tag2");
67 @fanns = $feat->annotation->get_Annotations("tag2");
68 @vals = $feat->each_tag_value("tag2");
70 is (scalar(@fanns), 1);
71 is (scalar(@anns), 3);
72 is (scalar(@vals), 2);
73 is ($anns[0]->value(), $vals[0]);
74 is ($anns[1]->value(), $vals[1]);
75 is ($anns[2]->primary_id(), $fanns[0]->primary_id());