File: Map.t

package info (click to toggle)
bioperl 1.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,784 kB
  • ctags: 4,962
  • sloc: perl: 70,732; xml: 3,279; lisp: 107; makefile: 53
file content (128 lines) | stat: -rw-r--r-- 2,748 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# -*-Perl-*-
## Bioperl Test Harness Script for Modules
## $Id: Map.t,v 1.2 2002/02/11 19:04:21 jason Exp $
#

use strict;

BEGIN {
    use vars qw($DEBUG);
    $DEBUG = $ENV{'BIOPERLDEBUG'};
    # to handle systems with no installed Test module
    # we include the t dir (where a copy of Test.pm is located)
    # as a fallback
    eval { require Test; };
    if( $@ ) {
        use lib 't';
    }
    use Test;
    plan tests => 48;
}

END {
}

#
# Let's test first the map class : Bio::Map::SimpleMap
#
use Data::Dumper;
use Bio::Map::SimpleMap;
ok 1;

ok my $map = new Bio::Map::SimpleMap(-name  => 'my');
ok $map->type('cyto'); 
ok $map->type, 'cyto'; 
ok $map->units, ''; 
ok $map->length, 0, "Length is ". $map->length;
ok $map->name, 'my';
ok $map->species('human'), 'human';
ok $map->species, 'human';
ok $map->unique_id, '1';


#
# Secondly, create Markers for the Map
#

use Bio::Map::Marker;
ok 1;

#
# Four ways of adding a position:
#
# 1. position gets a map object and a value as arguments

ok my $marker1 = new Bio::Map::Marker();
ok $marker1->name('gene1'), 'Unnamed marker' ;
ok $marker1->name(), 'gene1';

ok $marker1->position($map, 100);
ok $marker1->position->value, 100;
ok $marker1->map, $map;


#
# Now that we have a Marker, let's 
#    make sure the basic Position class works
#

use Bio::Map::Position;
ok 1;
ok my $pos = new Bio::Map::Position();
ok $pos->map($map);
ok $pos->map(), $map;
ok $pos->marker($marker1);
ok $pos->marker(), $marker1;

ok $pos->value('999');
ok $pos->value(), '999';
ok $pos->numeric, 999;

# ... and then continue testing the Marker

# 2. position is set in the constructor
ok my $marker2 = new Bio::Map::Marker(-name => 'gene2',
				      -position => [$map, 200]
				      );
ok ( $marker2->map, $map);
ok ($marker2->position->value, 200);

# 3. marker is first added into map, 
#    then marker knows the the position belongs to
ok my $marker3 = new Bio::Map::Marker(-name => 'gene3');
ok $map->add_element($marker3);
ok $marker3->map, $map;
ok $marker3->position(300);
ok $marker3->position->value, 300;
ok my $position = $marker3->position($map);

# 4. A Position is explicitely created
ok my $cpos = new Bio::Map::Position(-map => $map,
				     -value => 500);
ok $marker3->position($cpos);
my $cpos2 = $marker3->position($cpos);
ok $cpos2 eq $cpos;
ok $marker3->position->value, 500;


#
# Next, what do markers know about Maps?
#

ok $marker3->known_maps, qw ( 1 ); 
ok $marker3->in_map(1);
ok ! $marker3->in_map(2);



#
# Lastly, let's test the comparison methods
#

ok $marker1->equals($marker1);
ok ! $marker1->equals($marker3);
ok $marker1->less_than($marker3);
ok ! $marker1->greater_than($marker3);
ok ! $marker3->less_than($marker1);
ok $marker3->greater_than($marker1);