2
2
## Bioperl Test Harness Script for Modules
3
## $Id: Location.t,v 1.21 2002/02/03 21:00:19 jason Exp $
3
## $Id: Location.t,v 1.26 2002/08/12 04:25:35 lapp Exp $
5
5
# Before `make install' is performed this script should be runnable with
6
6
# `make test'. After `make install' it should work as `perl test.t'
10
10
# to handle systems with no installed Test module
11
11
# we include the t dir (where a copy of Test.pm is located)
31
31
my $simple = new Bio::Location::Simple('-start' => 10, '-end' => 20,
32
'-strand' => 1, -seq_id => 'my1');
33
33
ok $simple->isa('Bio::LocationI') && $simple->isa('Bio::RangeI');
35
35
ok $simple->start, 10;
36
36
ok $simple->end, 20;
37
ok $simple->seq_id, 'my1';
39
my ($loc) = $simple->each_Location();
41
ok ("$loc", "$simple");
38
43
my $generic = new Bio::SeqFeature::Generic('-start' => 5, '-end' => 30,
65
70
ok($generic->contains($simple));
67
72
# fuzzy location tests
68
my $fuzzy = new Bio::Location::Fuzzy('-start' =>'<10', '-end' => 20,
73
my $fuzzy = new Bio::Location::Fuzzy('-start' =>'<10', '-end' => 20,
74
-strand=>1, -seq_id=>'my2');
71
76
ok($fuzzy->strand, 1);
72
77
ok($fuzzy->start, 10);
73
78
ok($fuzzy->end,20);
78
83
ok($fuzzy->location_type, 'EXACT');
79
84
ok($fuzzy->start_pos_type, 'BEFORE');
80
85
ok($fuzzy->end_pos_type, 'EXACT');
86
ok $fuzzy->seq_id, 'my2';
87
ok $fuzzy->seq_id('my3'), 'my3';
89
($loc) = $fuzzy->each_Location();
91
ok ("$loc", "$fuzzy");
82
93
# split location tests
83
94
my $splitlocation = new Bio::Location::Split;
112
124
ok(! defined $f->min_start);
113
125
ok($f->max_start, 50);
127
ok (scalar($splitlocation->each_Location()), 4);
115
129
$splitlocation->add_sub_Location($f);
117
131
ok($splitlocation->max_end, 90);
127
141
ok($simple->to_FTstring(), '10..20');
128
142
$simple->strand(-1);
129
143
ok($simple->to_FTstring(), 'complement(10..20)');
130
ok( $splitlocation->to_FTstring(), 'join(13..30,30..90,18..22,19..20,<50..61)');
144
ok( $splitlocation->to_FTstring(),
145
'join(13..30,30..90,18..22,19..20,<50..61)');
131
146
# test for bug #1074
132
147
$f = new Bio::Location::Simple(-start => 5,
135
150
$splitlocation->add_sub_Location($f);
136
ok( $splitlocation->to_FTstring(), 'join(13..30,30..90,18..22,19..20,<50..61,complement(5..12))');
151
ok( $splitlocation->to_FTstring(),
152
'join(13..30,30..90,18..22,19..20,<50..61,complement(5..12))');
137
153
$splitlocation->strand(-1);
138
ok( $splitlocation->to_FTstring(), 'join(13..30,30..90,18..22,19..20,<50..61,complement(5..12))');
154
ok( $splitlocation->to_FTstring(),
155
'join(complement(13..30),complement(30..90),complement(18..22),complement(19..20),complement(<50..61),complement(5..12))');
140
157
$f = new Bio::Location::Fuzzy(-start => '45.60',
141
158
-end => '75^80');
143
ok($f->to_FTstring(), '45.60..75^80');
160
ok($f->to_FTstring(), '(45.60)..(75^80)');
144
161
$f->start('20>');
145
ok($f->to_FTstring(), '>20..75^80');
162
ok($f->to_FTstring(), '>20..(75^80)');
147
164
# test that even when end < start that length is always positive
152
169
ok($f->length, 81);
153
170
ok($f->strand,-1);
172
# test that can call seq_id() on a split location;
173
$splitlocation = new Bio::Location::Split(-seq_id => 'mysplit1');
174
ok $splitlocation->seq_id,'mysplit1';
175
ok $splitlocation->seq_id('mysplit2'),'mysplit2';
178
# Test Bio::Location::Exact
180
ok my $exact = new Bio::Location::Simple('-start' => 10, '-end' => 20,
181
'-strand' => 1, -seq_id => 'my1');
182
ok $exact->isa('Bio::LocationI') && $exact->isa('Bio::RangeI');
184
ok $exact->start, 10;
186
ok $exact->seq_id, 'my1';
187
ok $exact->length, 11;
188
ok $exact->location_type, 'EXACT';
190
ok $exact = new Bio::Location::Simple('-start' => 10, '-end' => 11,
191
-location_type => 'IN-BETWEEN',
192
'-strand' => 1, -seq_id => 'my2');
194
ok $exact->start, 10;
196
ok $exact->seq_id, 'my2';
197
ok $exact->length, 0;
198
ok $exact->location_type, 'IN-BETWEEN';
201
$exact = new Bio::Location::Simple('-start' => 10, '-end' => 12,
202
-location_type => 'IN-BETWEEN');
206
# testing error when assigning 10^11 simple location into fuzzy
208
ok $fuzzy = new Bio::Location::Fuzzy('-start' =>'10', '-end' => 11,
209
-location_type => '^',
210
-strand=>1, -seq_id=>'my2');
214
$fuzzy = new Bio::Location::Fuzzy(-location_type => '^',
215
-strand=>1, -seq_id=>'my2');
223
$fuzzy = new Bio::Location::Fuzzy(-location_type => '^',
224
-strand=>1, -seq_id=>'my2');