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