2 ## Bioperl Test Harness Script for Modules
5 # Before `make install' is performed this script should be runnable with
6 # `make test'. After `make install' it should work as `perl test.t'
10 # to handle systems with no installed Test module
11 # we include the t dir (where a copy of Test.pm is located)
13 eval { require Test; };
21 use Bio::Phenotype::Phenotype;
23 use Bio::Annotation::Reference;
24 use Bio::Map::CytoPosition;
25 use Bio::Phenotype::Correlate;
26 use Bio::Phenotype::Measure;
27 use Bio::Annotation::DBLink;
30 my $obj = Bio::Phenotype::Phenotype->new();
32 ok( $obj->isa( "Bio::Phenotype::PhenotypeI" ) );
33 ok( $obj->isa( "Bio::Phenotype::Phenotype" ) );
35 ok( $obj->name( "r1" ) );
36 ok( $obj->name(), "r1" );
38 ok( $obj->description( "This is ..." ) );
39 ok( $obj->description(), "This is ..." );
41 my $mouse = Bio::Species->new();
42 $mouse->classification( qw( musculus Mus ) );
43 ok( $obj->species( $mouse ) );
44 ok( $obj->species()->binomial(), "Mus musculus" );
46 ok( $obj->comment( "putative" ) );
47 ok( $obj->comment(), "putative" );
51 ok( $obj->each_gene_symbol(), 0 );
53 ok( $obj->add_gene_symbols( ( "A", "B" ) ) );
54 ok( $obj->each_gene_symbol(), 2 );
55 my @gs = $obj->each_gene_symbol();
58 ok( $obj->each_gene_symbol(), 2 );
60 my @gs2 = $obj->remove_gene_symbols();
64 ok( $obj->each_gene_symbol(), 0 );
65 ok( $obj->remove_gene_symbols(), 0 );
69 my $v1 = Bio::Variation::VariantI->new();
70 my $v2 = Bio::Variation::VariantI->new();
74 ok( $obj->each_Variant(), 0 );
76 ok( $obj->add_Variants( ( $v1, $v2 ) ) );
77 ok( $obj->each_Variant(), 2 );
78 my @vs = $obj->each_Variant();
81 ok( $vs[ 0 ]->length(), "123" );
82 ok( $obj->each_Variant(), 2 );
84 my @vs2 = $obj->remove_Variants();
88 ok( $obj->each_Variant(), 0 );
89 ok( $obj->remove_Variants(), 0 );
94 my $r1 = Bio::Annotation::Reference->new();
95 my $r2 = Bio::Annotation::Reference->new();
97 $r1->title( "title" );
99 ok( $obj->each_Reference(), 0 );
101 ok( $obj->add_References( ( $r1, $r2 ) ) );
102 ok( $obj->each_Reference(), 2 );
103 my @rs = $obj->each_Reference();
106 ok( $rs[ 0 ]->title(), "title" );
107 ok( $obj->each_Reference(), 2 );
109 my @rs2 = $obj->remove_References();
110 ok( $rs2[ 0 ], $r1 );
111 ok( $rs2[ 1 ], $r2 );
113 ok( $obj->each_Reference(), 0 );
114 ok( $obj->remove_References(), 0 );
119 my $c1 = Bio::Map::CytoPosition->new();
120 my $c2 = Bio::Map::CytoPosition->new();
124 ok( $obj->each_CytoPosition(), 0 );
126 ok( $obj->add_CytoPositions( ( $c1, $c2 ) ) );
127 ok( $obj->each_CytoPosition(), 2 );
128 my @cs = $obj->each_CytoPosition();
131 ok( $cs[ 0 ]->chr(), "12" );
132 ok( $obj->each_CytoPosition(), 2 );
134 my @cs2 = $obj->remove_CytoPositions();
135 ok( $cs2[ 0 ], $c1 );
136 ok( $cs2[ 1 ], $c2 );
138 ok( $obj->each_CytoPosition(), 0 );
139 ok( $obj->remove_CytoPositions(), 0 );
144 my $co1 = Bio::Phenotype::Correlate->new();
145 my $co2 = Bio::Phenotype::Correlate->new();
147 ok( $co1->name( "name" ) );
149 ok( $obj->each_Correlate(), 0 );
151 ok( $obj->add_Correlates( ( $co1, $co2 ) ) );
152 ok( $obj->each_Correlate(), 2 );
153 my @cos = $obj->each_Correlate();
154 ok( $cos[ 0 ], $co1 );
155 ok( $cos[ 1 ], $co2 );
156 ok( $cos[ 0 ]->name, "name" );
157 ok( $obj->each_Correlate(), 2 );
159 my @cos2 = $obj->remove_Correlates();
160 ok( $cos2[ 0 ], $co1 );
161 ok( $cos2[ 1 ], $co2 );
163 ok( $obj->each_Correlate(), 0 );
164 ok( $obj->remove_Correlates(), 0 );
169 my $m1 = Bio::Phenotype::Measure->new();
170 my $m2 = Bio::Phenotype::Measure->new();
172 ok( $m1->description( "desc" ) );
174 ok( $obj->each_Measure(), 0 );
176 ok( $obj->add_Measures( ( $m1, $m2 ) ) );
177 ok( $obj->each_Measure(), 2 );
178 my @ms = $obj->each_Measure();
181 ok( $ms[ 0 ]->description, "desc" );
182 ok( $obj->each_Measure(), 2 );
184 my @ms2 = $obj->remove_Measures();
185 ok( $ms2[ 0 ], $m1 );
186 ok( $ms2[ 1 ], $m2 );
188 ok( $obj->each_Measure(), 0 );
189 ok( $obj->remove_Measures(), 0 );
193 ok( $obj->each_keyword(), 0 );
195 ok( $obj->add_keywords( ( "A", "B" ) ) );
196 ok( $obj->each_keyword(), 2 );
197 my @ks = $obj->each_keyword();
200 ok( $obj->each_keyword(), 2 );
202 my @ks2 = $obj->remove_keywords();
203 ok( $ks2[ 0 ], "A" );
204 ok( $ks2[ 1 ], "B" );
206 ok( $obj->each_keyword(), 0 );
207 ok( $obj->remove_keywords(), 0 );
211 my $l1 = Bio::Annotation::DBLink->new();
212 my $l2 = Bio::Annotation::DBLink->new();
214 ok( $l1->comment( "comment" ) );
216 ok( $obj->each_DBLink(), 0 );
218 ok( $obj->add_DBLinks( ( $l1, $l2 ) ) );
219 ok( $obj->each_DBLink(), 2 );
220 my @ls = $obj->each_DBLink();
223 ok( $ls[ 0 ]->comment(), "comment" );
224 ok( $obj->each_DBLink(), 2 );
226 my @ls2 = $obj->remove_DBLinks();
227 ok( $ls2[ 0 ], $l1 );
228 ok( $ls2[ 1 ], $l2 );
230 ok( $obj->each_DBLink(), 0 );
231 ok( $obj->remove_DBLinks(), 0 );
235 ok( $obj->each_Genotype(), 0 );
237 ok( $obj->add_Genotypes( ( "A", "B" ) ) );
238 ok( $obj->each_Genotype(), 2 );
239 my @gts = $obj->each_Genotype();
240 ok( $gts[ 0 ], "A" );
241 ok( $gts[ 1 ], "B" );
242 ok( $obj->each_Genotype(), 2 );
244 my @gts2 = $obj->remove_Genotypes();
245 ok( $gts2[ 0 ], "A" );
246 ok( $gts2[ 1 ], "B" );
248 ok( $obj->each_Genotype(), 0 );
249 ok( $obj->remove_Genotypes(), 0 );