1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 110);
11 use_ok('Bio::Map::CytoMap');
12 use_ok('Bio::Map::CytoPosition');
13 use_ok('Bio::Map::CytoMarker');
17 # Let's test first the map class : Bio::Map::CytoMap
20 ok my $map = Bio::Map::CytoMap->new(-name => 'my');
21 is $map->type, 'cyto';
25 is $map->species('human'), 'human';
26 is $map->species, 'human';
27 is $map->unique_id, '1';
31 # Secondly, we make sure the location calculations in
32 # Bio::Map::CytoPosition make sense
37 is Bio::Map::CytoPosition::_pad($string, 5, 'z'), 'bzzzz';
39 ok $a = Bio::Map::CytoPosition->new();
40 isa_ok $a, 'Bio::Map::CytoPosition';
41 is $a->cytorange, undef;
46 is $a->value('C'), 'C';
47 is $a->cytorange, undef ;
52 is $a->value('X'), 'X';
54 isa_ok $r, 'Bio::Range';
55 is $r->start, 100000000;
56 is $r->end, 100200000;
59 is $a->cytorange->start, 1000000;
60 is $a->cytorange->end, 1100000;
63 is $a->cytorange->start, 2200000;
64 is $a->cytorange->end, 2200000;
67 is $a->cytorange->start, 2100000;
68 is $a->cytorange->end, 2100000;
77 is $a->cytorange->start, 2122000;
78 is $a->cytorange->end, 2122999;
81 is $a->cytorange->start, 2077001;
82 is $a->cytorange->end, 2078000;
85 is $a->cytorange->start, 2078001;
86 is $a->cytorange->end, 2079000;
88 $a->value('10p22.1-cen');
89 is $a->cytorange->start, 10022199;
90 is $a->cytorange->end, 10100000;
93 $a->value('10q22.1-cen');
98 $a->value('10q22.1-ter');
99 is $a->cytorange->start, 10122100;
100 is $a->cytorange->end, 10200000;
104 $a->value('10q22.1-p');
105 $a->cytorange->start;
109 $a->value('10qcen-qter');
110 is $a->cytorange->start, 10100000;
111 is $a->cytorange->end, 10200000;
113 $a->value('10pcen-qter');
114 is $a->cytorange->start, 10100000;
115 is $a->cytorange->end, 10200000;
117 $a->value('10q22.1-q23');
118 is $a->cytorange->start, 10122100;
119 is $a->cytorange->end, 10123999;
120 cmp_ok ($a->cytorange->start, '<', $a->cytorange->end );
122 $a->value('10p22.1-p23');
123 is $a->cytorange->start, 10076001;
124 is $a->cytorange->end, 10077900;
125 cmp_ok ($a->cytorange->start, '<', $a->cytorange->end );
127 $a->value('10cen-p23');
128 is $a->cytorange->start, 10076001;
129 is $a->cytorange->end, 10100000;
130 cmp_ok ($a->cytorange->start, '<', $a->cytorange->end );
132 $a->value('10q22.1-p23');
133 is $a->cytorange->start, 10076001;
134 is $a->cytorange->end, 10122199;
135 cmp_ok ($a->cytorange->start, '<', $a->cytorange->end );
137 $a->value('10p22.1-q23');
138 is $a->cytorange->start, 10077801;
139 is $a->cytorange->end, 10123999;
140 cmp_ok ($a->cytorange->start, '<', $a->cytorange->end );
142 $a->value('10q22.1-p22');
143 is $a->cytorange->start, 10077001 ;
144 is $a->cytorange->end, 10122199 ;
146 $b = Bio::Map::CytoPosition->new();
147 $b->value('10p22-p22.1');
148 is $b->cytorange->start, 10077801 ;
149 is $b->cytorange->end, 10078000;
150 ok $a->cytorange->overlaps($b->cytorange);
152 $a->value('10p22.1-q23');
153 is $a->cytorange->start, 10077801;
154 is $a->cytorange->end, 10123999;
155 cmp_ok ($a->cytorange->start, '<', $a->cytorange->end );
157 $a->value('17p13-pter');
158 is $a->cytorange->start, 17000000;
159 is $a->cytorange->end, 17087000;
160 cmp_ok ($a->cytorange->start, '<', $a->cytorange->end );
162 $a->value('17cen-pter');
163 is $a->cytorange->start, 17000000;
164 is $a->cytorange->end, 17100000;
165 cmp_ok ($a->cytorange->start, '<', $a->cytorange->end );
168 #-----------------------------------------
173 my $a = Bio::Map::CytoPosition->new();
176 is $a->range2value($r), $s;
191 test '11p13.13-qter';
192 test '12p13.13-qter';
194 test '14p13.13-pter';
197 #test '17cen-pter'; eq 17p
198 #test '18cen-qter'; eq 18q
201 # by now we should be convinced that band conversion to a range works
202 # so lets try to use it for comparing markers.
204 ok my $marker1 = Bio::Map::CytoMarker->new();
205 is $marker1->name('gene1'), 'gene1' ;
206 ok $marker1->position($map, '10p33.13-q15');
208 ok my $marker2 = Bio::Map::CytoMarker->new(-name => 'gene2' );
209 ok $marker2->position($map, '10p10-15');
210 is $marker1->get_chr, 10;
212 ok my $marker3 = Bio::Map::CytoMarker->new(-name => '3' );
213 ok $marker3->position($map, '10p1');
215 ok my $marker4 = Bio::Map::CytoMarker->new(-name => '4' );
216 ok $marker4->position($map, '10q2');
219 # Lastly, let's test the comparison methods
222 ok $marker1->equals($marker1);
223 ok ! $marker1->equals($marker2);
225 ok $marker3->less_than($marker4);
226 ok ! $marker3->greater_than($marker4);
227 ok ! $marker4->less_than($marker3);
228 ok $marker4->greater_than($marker3);
230 ok ! $marker4->overlaps($marker3);
231 ok $marker1->overlaps($marker3);
233 ok ! $marker4->contains($marker3);
234 ok $marker1->contains($marker3);
237 # Test throw() in some private functions
240 eval { Bio::Map::CytoPosition::_pad('string', -1, 'x'); };
241 like($@, qr/positive integer/);
242 eval { Bio::Map::CytoPosition::_pad('string', +1, 'toolong'); };
243 like($@, qr/single character/);