2 ## Bioperl Test Harness Script for Modules
10 $DEBUG = $ENV{'BIOPERLDEBUG'};
11 # to handle systems with no installed Test module
12 # we include the t dir (where a copy of Test.pm is located)
14 eval { require Test; };
26 # Let's test first the map class : Bio::Map::SimpleMap
29 use Bio::Map::SimpleMap;
32 ok my $map = new Bio::Map::SimpleMap(-name => 'my');
33 ok $map->type('cyto');
34 ok $map->type, 'cyto';
36 ok $map->length, 0, "Length is ". $map->length;
38 ok $map->species('human'), 'human';
39 ok $map->species, 'human';
40 ok $map->unique_id, '1';
44 # Secondly, create Markers for the Map
51 # Four ways of adding a position:
53 # 1. position gets a map object and a value as arguments
55 ok my $marker1 = new Bio::Map::Marker();
56 ok $marker1->name('gene1'), 'Unnamed marker' ;
57 ok $marker1->name(), 'gene1';
59 ok $marker1->position($map, 100);
60 ok $marker1->position->value, 100;
61 ok $marker1->map, $map;
65 # Now that we have a Marker, let's
66 # make sure the basic Position class works
69 use Bio::Map::Position;
71 ok my $pos = new Bio::Map::Position();
74 ok $pos->marker($marker1);
75 ok $pos->marker(), $marker1;
77 ok $pos->value('999');
78 ok $pos->value(), '999';
79 ok $pos->numeric, 999;
81 # ... and then continue testing the Marker
83 # 2. position is set in the constructor
84 ok my $marker2 = new Bio::Map::Marker(-name => 'gene2',
85 -position => [$map, 200]
87 ok ( $marker2->map, $map);
88 ok ($marker2->position->value, 200);
90 # 3. marker is first added into map,
91 # then marker knows the the position belongs to
92 ok my $marker3 = new Bio::Map::Marker(-name => 'gene3');
93 ok $map->add_element($marker3);
94 ok $marker3->map, $map;
95 ok $marker3->position(300);
96 ok $marker3->position->value, 300;
97 ok my $position = $marker3->position($map);
99 # 4. A Position is explicitely created
100 ok my $cpos = new Bio::Map::Position(-map => $map,
102 ok $marker3->position($cpos);
103 my $cpos2 = $marker3->position($cpos);
105 ok $marker3->position->value, 500;
109 # Next, what do markers know about Maps?
112 ok (scalar ($marker3->known_maps), 1);
113 ok $marker3->in_map(1);
114 ok ! $marker3->in_map(2);
119 # Lastly, let's test the comparison methods
122 ok $marker1->equals($marker1);
123 ok ! $marker1->equals($marker3);
124 ok $marker1->less_than($marker3);
125 ok ! $marker1->greater_than($marker3);
126 ok ! $marker3->less_than($marker1);
127 ok $marker3->greater_than($marker1);