1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 23);
11 use_ok('Bio::SeqFeature::Generic');
12 use_ok('Bio::SeqFeature::AnnotationAdaptor');
13 use_ok('Bio::Annotation::DBLink');
14 use_ok('Bio::Annotation::Comment');
15 use_ok('Bio::Annotation::SimpleValue');
19 my $feat = Bio::SeqFeature::Generic->new();
20 $feat->add_tag_value("tag1", "value of tag1");
21 $feat->add_tag_value("tag1", "another value of tag1");
22 $feat->add_tag_value("tag2", "some value for a tag");
24 my $link1 = Bio::Annotation::DBLink->new(-database => 'TSC',
25 -primary_id => 'TSC0000030',
28 $feat->annotation->add_Annotation($link1);
30 my $anncoll = Bio::SeqFeature::AnnotationAdaptor->new(-feature => $feat);
32 is($anncoll->get_num_of_annotations(), 4);
33 is(scalar($anncoll->get_all_annotation_keys()), 2);
35 my @anns = $anncoll->get_Annotations("tag1");
36 my @vals = $feat->get_tag_values("tag1");
38 is (scalar(@anns), scalar(@vals));
39 for(my $i = 0; $i < @anns; $i++) {
40 is ($anns[$i]->value(), $vals[$i]);
43 @anns = $anncoll->get_Annotations("tag2");
44 my @fanns = $feat->annotation->get_Annotations("tag2");
45 @vals = $feat->get_tag_values("tag2");
47 is (scalar(@fanns), 1);
48 is (scalar(@anns), 2);
49 is (scalar(@vals), 1);
50 is ($anns[0]->value(), $vals[0]);
52 is ($anns[1]->primary_id(), $fanns[0]->primary_id());
54 my $comment = Bio::Annotation::Comment->new( '-text' => 'sometext');
55 $anncoll->add_Annotation('comment', $comment);
57 @fanns = $feat->annotation->get_Annotations("comment");
58 is (scalar(@fanns), 1);
59 is ($fanns[0]->text(), "sometext");
61 my $tagval = Bio::Annotation::SimpleValue->new(-value => "boring value",
63 $anncoll->add_Annotation($tagval);
65 @anns = $anncoll->get_Annotations("tag2");
66 @fanns = $feat->annotation->get_Annotations("tag2");
67 @vals = $feat->get_tag_values("tag2");
69 is (scalar(@fanns), 1);
70 is (scalar(@anns), 3);
71 is (scalar(@vals), 2);
72 is ($anns[0]->value(), $vals[0]);
73 is ($anns[1]->value(), $vals[1]);
74 is ($anns[2]->primary_id(), $fanns[0]->primary_id());