Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial import of Location/Simple.t from Bioperl5

  • Loading branch information...
commit 9718c38ad50ed044279cdb3cf8d00bc0e92d97e4 1 parent 45278b6
Philip Mabon authored

Showing 1 changed file with 226 additions and 0 deletions. Show diff stats Hide diff stats

  1. 226  t/Location/Simple.t
226  t/Location/Simple.t
... ...
@@ -0,0 +1,226 @@
  1
+use v6;
  2
+
  3
+ BEGIN {
  4
+	 @*INC.push('./lib');
  5
+ }
  6
+
  7
+ my $simple = Bio::Location::Simple.new(
  8
+     start  => 10,
  9
+     end    => 20,
  10
+     strand => 1,
  11
+     seq_id => 'my1',
  12
+     is_remote => 1);
  13
+# isa_ok($simple, 'Biome::Location::Simple');
  14
+# does_ok($simple, 'Biome::Role::Location::Simple',  'does Location');
  15
+# does_ok($simple, 'Biome::Role::Location::Does_Range',  'has basic Range interface');
  16
+# does_ok($simple, 'Biome::Role::Location::Does_Location',  'has more defined Location interface');
  17
+
  18
+# is($simple->start, 10, 'has a start location');
  19
+# is($simple->end, 20,  'has an end location');
  20
+# is($simple->seq_id, 'my1',  'has an identifier');
  21
+# is($simple->start_pos_type, 'EXACT', 'pos_type is EXACT for start');
  22
+# is($simple->end_pos_type, 'EXACT', 'pos_type is EXACT for end');
  23
+# ok($simple->valid_Location);
  24
+# is($simple->location_type, 'EXACT',  'has a default location type');
  25
+# ok(!$simple->is_fuzzy);
  26
+
  27
+# is ($simple->to_string, 'my1:10..20', 'full FT string');
  28
+
  29
+# # test that even when end < start that length is always positive
  30
+# my $f = Biome::Location::Simple->new(
  31
+#         -strict  => -1,
  32
+#         -start   => 100, 
  33
+#         -end     => 20, 
  34
+#         -strand  => 1);
  35
+
  36
+# is($f->length, 81, 'Positive length');
  37
+# is($f->strand,-1,  'Negative strand' );
  38
+
  39
+# is ($f->to_string, 'complement(20..100)','full FT string');
  40
+
  41
+# my $exact = Biome::Location::Simple->new(
  42
+#                     -start         => 10,
  43
+#                     -end           => 11,
  44
+#                     -location_type  => 'IN-BETWEEN',
  45
+#                     -strand        => 1, 
  46
+#                     -seq_id        => 'my2');
  47
+
  48
+# is($exact->start, 10, 'Biome::Location::Simple IN-BETWEEN');
  49
+# is($exact->end, 11);
  50
+# is($exact->seq_id, 'my2');
  51
+# is($exact->length, 0);
  52
+# is($exact->location_type, 'IN-BETWEEN');
  53
+# ok(!$exact->is_fuzzy);
  54
+
  55
+# is ($exact->to_string, '10^11','full FT string');
  56
+
  57
+# # check coercions with location_type and strand
  58
+# $exact = Biome::Location::Simple->new(
  59
+#                     -start         => 10, 
  60
+#                     -end           => 11,
  61
+#                     -location_type  => '^',
  62
+#                     -strand        => '+');
  63
+
  64
+# is($exact->start, 10, 'Bio::Location::Simple IN-BETWEEN');
  65
+# is($exact->end, 11);
  66
+# is($exact->strand, 1, 'strand coerced');
  67
+# is($exact->seq_id, undef);
  68
+# is($exact->length, 0);
  69
+# is($exact->location_type, 'IN-BETWEEN');
  70
+# is($exact->start_pos_type, 'EXACT');
  71
+# is($exact->end_pos_type, 'EXACT');
  72
+
  73
+# is($exact->to_string, '10^11', 'full FT string');
  74
+
  75
+# $exact = Biome::Location::Simple->new(
  76
+#                     -start          => 10, 
  77
+#                     -end            => 20,
  78
+#                     -start_pos_type => '<',
  79
+#                     -end_pos_type   => '>', # this should default to 'EXACT'
  80
+#                     -strand         => '+');
  81
+
  82
+# is($exact->start, 10);
  83
+# is($exact->end, 20);
  84
+# is($exact->strand, 1, 'strand coerced');
  85
+# is($exact->seq_id, undef);
  86
+# is($exact->length, 11);
  87
+
  88
+# # this doesn't seem correct, shouldn't it be 'FUZZY' or 'UNCERTAIN'?
  89
+# is($exact->location_type, 'EXACT');
  90
+
  91
+# is($exact->start_pos_type, 'BEFORE');
  92
+# is($exact->end_pos_type, 'AFTER');
  93
+# ok($exact->is_fuzzy);
  94
+
  95
+# is($exact->to_string, '<10..>20', 'full FT string');
  96
+
  97
+# # check coercions with start/end_pos_type, and length determination
  98
+# $exact = Biome::Location::Simple->new(
  99
+#                     -start          => 10, 
  100
+#                     -end            => 20,
  101
+#                     -start_pos_type => '<',
  102
+#                     -strand         => '+');
  103
+
  104
+# is($exact->start, 10);
  105
+# is($exact->end, 20);
  106
+# is($exact->strand, 1, 'strand coerced');
  107
+# is($exact->seq_id, undef);
  108
+# is($exact->length, 11);
  109
+# is($exact->location_type, 'EXACT');
  110
+# is($exact->start_pos_type, 'BEFORE');
  111
+# is($exact->end_pos_type, 'EXACT');
  112
+
  113
+# is($exact->to_string, '<10..20', 'full FT string');
  114
+
  115
+# # check exception handling
  116
+# throws_ok { $exact = $exact = Biome::Location::Simple->new(
  117
+#                     -start          => 10, 
  118
+#                     -end            => 12,
  119
+#                     -start_pos_type => '>',
  120
+#                     -strand         => '+') }
  121
+#     qr/Start position can't have type AFTER/,
  122
+#     'Check start_pos_type constraint';
  123
+
  124
+# throws_ok { $exact = $exact = Biome::Location::Simple->new(
  125
+#                     -start          => 10, 
  126
+#                     -end            => 12,
  127
+#                     -end_pos_type   => '<',
  128
+#                     -strand         => '+') }
  129
+#     qr/End position can't have type BEFORE/,
  130
+#     'Check end_pos_type constraint';
  131
+  
  132
+  
  133
+# throws_ok {$exact = Biome::Location::Simple->new(-start         => 10, 
  134
+#                                    -end           => 12,
  135
+#                                    -location_type => 'IN-BETWEEN')}
  136
+#     qr/length of location with IN-BETWEEN/,
  137
+#     'IN-BETWEEN must have length of 1';  
  138
+
  139
+# # fuzzy location tests
  140
+# my $fuzzy = Biome::Location::Simple->new(
  141
+#                                      -start    => 10,
  142
+#                                      -start_pos_type => '<',
  143
+#                                      -end      => 20,
  144
+#                                      -strand   => 1, 
  145
+#                                      -seq_id   =>'my2');
  146
+
  147
+# is($fuzzy->strand, 1, 'Biome::Location::Simple tests');
  148
+# is($fuzzy->start, 10);
  149
+# is($fuzzy->end,20);
  150
+# ok(!defined $fuzzy->min_start);
  151
+# is($fuzzy->max_start, 10);
  152
+# is($fuzzy->min_end, 20);
  153
+# is($fuzzy->max_end, 20);
  154
+# is($fuzzy->location_type, 'EXACT');
  155
+# is($fuzzy->start_pos_type, 'BEFORE');
  156
+# is($fuzzy->end_pos_type, 'EXACT');
  157
+# is($fuzzy->seq_id, 'my2');
  158
+# is($fuzzy->seq_id('my3'), 'my3');
  159
+
  160
+# $f = Biome::Location::Simple->new(
  161
+#                                -strict  => -1,
  162
+#                                -start   => 100, 
  163
+#                                -end     => 20, 
  164
+#                                -strand  => 1);
  165
+
  166
+# is($f->length, 81, 'Positive length');
  167
+# is($f->strand,-1);
  168
+
  169
+# # Test Biome::Location::Simple
  170
+
  171
+# ok($exact = Biome::Location::Simple->new(-start    => 10, 
  172
+#                                          -end      => 20,
  173
+#                                          -strand   => 1, 
  174
+#                                          -seq_id   => 'my1'));
  175
+# does_ok($exact, 'Biome::Role::Location::Does_Range');
  176
+
  177
+# is( $exact->start, 10, 'Biome::Location::Simple EXACT');
  178
+# is( $exact->end, 20);
  179
+# is( $exact->seq_id, 'my1');
  180
+# is( $exact->length, 11);
  181
+# is( $exact->location_type, 'EXACT');
  182
+
  183
+# ok ($exact = Biome::Location::Simple->new(-start         => 10, 
  184
+#                                       -end           => 11,
  185
+#                                       -location_type => 'IN-BETWEEN',
  186
+#                                       -strand        => 1, 
  187
+#                                       -seq_id        => 'my2'));
  188
+
  189
+# is($exact->start, 10, 'Biome::Location::Simple BETWEEN');
  190
+# is($exact->end, 11);
  191
+# is($exact->seq_id, 'my2');
  192
+# is($exact->length, 0);
  193
+# is($exact->location_type, 'IN-BETWEEN');
  194
+
  195
+# # 'fuzzy' locations are combined with simple ones in Biome
  196
+
  197
+# my $error = qr/length of location with IN-BETWEEN position type cannot be larger than 1/;
  198
+
  199
+# # testing error when assigning 10^12 simple location into fuzzy
  200
+# throws_ok {
  201
+#     $fuzzy = Biome::Location::Simple->new(
  202
+#                                         -start         => 10, 
  203
+#                                         -end           => 12,
  204
+#                                         -location_type  => '^',
  205
+#                                         -strand        => 1, 
  206
+#                                         -seq_id        => 'my2');
  207
+# } $error, 'Exception:IN-BETWEEN locations should be contiguous';
  208
+
  209
+# $fuzzy = Biome::Location::Simple->new(-location_type => '^',
  210
+#                                   -strand        => 1, 
  211
+#                                   -seq_id        => 'my2');
  212
+
  213
+# $fuzzy->start(10);
  214
+# throws_ok { $fuzzy->end(12) } $error, 'Exception:IN-BETWEEN locations should be contiguous';
  215
+
  216
+# $fuzzy = Biome::Location::Simple->new(-location_type => '^',
  217
+#                                   -strand        => 1, 
  218
+#                                   -seq_id        =>'my2');
  219
+
  220
+# $fuzzy->end(12);
  221
+# throws_ok { $fuzzy->start(10); } $error, 'Exception:IN-BETWEEN locations should be contiguous';
  222
+
  223
+# done_testing;
  224
+
  225
+# __END__
  226
+

0 notes on commit 9718c38

Please sign in to comment.
Something went wrong with that request. Please try again.