File: AnnotationAdaptor.t

package info (click to toggle)
bioperl 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 40,768 kB
  • ctags: 12,005
  • sloc: perl: 174,299; xml: 13,923; sh: 1,941; lisp: 1,803; asm: 109; makefile: 53
file content (75 lines) | stat: -rw-r--r-- 2,261 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*-Perl-*- Test Harness script for Bioperl
# $Id: AnnotationAdaptor.t 15112 2008-12-08 18:12:38Z sendu $

use strict;

BEGIN { 
    use lib '.';
    use Bio::Root::Test;
    
    test_begin(-tests => 23);
	
	use_ok('Bio::SeqFeature::Generic');
	use_ok('Bio::SeqFeature::AnnotationAdaptor');
	use_ok('Bio::Annotation::DBLink');
	use_ok('Bio::Annotation::Comment');
	use_ok('Bio::Annotation::SimpleValue');
}


my $feat = Bio::SeqFeature::Generic->new();
$feat->add_tag_value("tag1", "value of tag1");
$feat->add_tag_value("tag1", "another value of tag1");
$feat->add_tag_value("tag2", "some value for a tag");

my $link1 = Bio::Annotation::DBLink->new(-database => 'TSC',
                                        -primary_id => 'TSC0000030',
                                        -tagname => "tag2"
                                       );
$feat->annotation->add_Annotation($link1);

my $anncoll = Bio::SeqFeature::AnnotationAdaptor->new(-feature => $feat);

is($anncoll->get_num_of_annotations(), 4);
is(scalar($anncoll->get_all_annotation_keys()), 2);

my @anns = $anncoll->get_Annotations("tag1");
my @vals = $feat->each_tag_value("tag1");

is (scalar(@anns), scalar(@vals));
for(my $i = 0; $i < @anns; $i++) {
  is ($anns[$i]->value(), $vals[$i]);
}

@anns = $anncoll->get_Annotations("tag2");
my @fanns = $feat->annotation->get_Annotations("tag2");
@vals = $feat->each_tag_value("tag2");

is (scalar(@fanns), 1);
is (scalar(@anns), 2);
is (scalar(@vals), 1);
is ($anns[0]->value(), $vals[0]);

is ($anns[1]->primary_id(), $fanns[0]->primary_id());

my $comment = Bio::Annotation::Comment->new( '-text' => 'sometext');
$anncoll->add_Annotation('comment', $comment);

@fanns = $feat->annotation->get_Annotations("comment");
is (scalar(@fanns), 1);
is ($fanns[0]->text(), "sometext");

my $tagval = Bio::Annotation::SimpleValue->new(-value => "boring value",
					       -tagname => "tag2");
$anncoll->add_Annotation($tagval);

@anns = $anncoll->get_Annotations("tag2");
@fanns = $feat->annotation->get_Annotations("tag2");
@vals = $feat->each_tag_value("tag2");

is (scalar(@fanns), 1);
is (scalar(@anns), 3);
is (scalar(@vals), 2);
is ($anns[0]->value(), $vals[0]);
is ($anns[1]->value(), $vals[1]);
is ($anns[2]->primary_id(), $fanns[0]->primary_id());