small pod fix
[bioperl-live.git] / t / SeqFeatAnnotated.t
blobabd87815301b3c6e5c4a89123984d4d824c93629
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN { 
7     use lib 't/lib';
8     use BioperlTest;
9     
10     test_begin(-tests => 34, 
11                -requires_modules => [qw(URI::Escape Graph::Directed)],
12                -requires_networking => 1
13         );
14         
15         use_ok('Bio::SeqFeature::Generic');
16         use_ok('Bio::SeqFeature::Annotated');
19 my $sfa = Bio::SeqFeature::Annotated->new(-start => 1,
20                                           -end => 5,
21                                           -strand => "+",
22                                           -frame => 2,
23                                           -type => 'nucleotide_motif',
24                                           -phase => 2,
25                                           -score => 12,
26                                           -source => 'program_b',
27                                           -display_name => 'test.annot',
28                                           -seq_id => 'test.displayname' );
30 ok (defined $sfa);
31 my $loc = $sfa->location;
32 ok $loc->isa("Bio::Location::Simple");    
33 ok $sfa->display_name eq 'test.annot';
35 #test bsfa::from_feature
36 my $sfg = Bio::SeqFeature::Generic->new ( -start => 400,
37                                           -end => 440,
38                                           -strand => 1,
39                                           -primary => 'nucleotide_motif',
40                                           -source  => 'program_a',
41                                           -tag => {
42                                           silly => 20,
43                                           new => 1
44                                           }
45                                           );
46 my $sfa2;
47 $sfa2 = Bio::SeqFeature::Annotated->new(-feature => $sfg);
49 is $sfa2->type->name,'nucleotide_motif';
50 is $sfa2->primary_tag, 'nucleotide_motif';
51 is $sfa2->source->display_text,'program_a';
52 is $sfa2->source_tag,'program_a';
53 is $sfa2->strand,1;
54 is $sfa2->start,400;
55 is $sfa2->end,440;
56 is $sfa2->get_Annotations('silly')->value,20;
57 is $sfa2->get_Annotations('new')->value,1;
58 my $sfaa = Bio::SeqFeature::Annotated->new(-feature => $sfa);
59 is $sfaa->type->name,'nucleotide_motif';
60 is $sfaa->primary_tag, 'nucleotide_motif';
61 is $sfaa->source->display_text,'program_b';
62 is $sfaa->source_tag,'program_b';
63 is $sfaa->strand,1;
64 is $sfaa->start,1;
65 is $sfaa->end,5;
66 is $sfaa->score,12;
68 my $sfa3 = Bio::SeqFeature::Annotated->new( -start => 1,
69                                         -end => 5,
70                                         -strand => "+",
71                                         -frame => 2,
72                                         -phase => 2,
73                                         -score => 12,
74                                         -display_name => 'test.annot',
75                                         -seq_id => 'test.displayname' );
76 $sfa3->from_feature($sfg);
78 is $sfa3->type->name,'nucleotide_motif', 'type->name';
79 is $sfa3->primary_tag, 'nucleotide_motif', 'primary_tag';
80 is $sfa3->source->display_text,'program_a';
81 is $sfa3->source_tag,'program_a';
82 is $sfa3->strand,1;
83 is $sfa3->start,400;
84 is $sfa3->end,440;
85 is $sfa3->get_Annotations('silly')->value,20;
86 is $sfa3->get_Annotations('new')->value,1;
88 # Note there is an API conflict with SeqFeature::Generic, where score is a
89 # simple scalar, and here it is a Bio::Annotation::SimpleValue
90 # By popular vote there is no operator overloading, so this needs to be
91 # resolved
92 is $sfa3->score(), 12; 
93 $sfa3->score(11);
94 is $sfa3->score(), 11; 
95 $sfa3->score(0);
96 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)