Skip to content

Commit

Permalink
commenting out all passing tests and focusing on the crapped out ones…
Browse files Browse the repository at this point in the history
…, whittled down to 26 failing
  • Loading branch information
Chris Fields committed Sep 4, 2012
1 parent 2a2dcda commit 8b70f83
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 129 deletions.
4 changes: 2 additions & 2 deletions lib/Bio/Role/Range.pm
Expand Up @@ -12,8 +12,8 @@ our Int method length {
return self.end - self.start + 1;
}

our Bool method overlaps (Bio::Role::Range $range, :$test) {
(self!teststranded($range, :$test) && !((self.start() > $range.end() || self.end() < $range.start())))
our Bool method overlaps (Bio::Role::Range $range, :$test = 'ignore') {
(self!teststranded($range, test => $test) && !((self.start() > $range.end() || self.end() < $range.start())))
?? True !! False;
}

Expand Down
257 changes: 130 additions & 127 deletions t/Range.t
Expand Up @@ -88,107 +88,110 @@ is(@ranges[11].length, 50);
# test overlaps, contains, equals, cover all variations

my %map = (
r0 => '111111111111111000111000000110110110110110000110000000100100100100100000100000000000000000000000000000000000',
r1 => '111111000111111000110110000110110000110110000100100000100100000100100000000000000000000000000000000',
r2 => '111111111110000000110110000110110110100000000100100000100100100000000000000000000000000000',
r3 => '111111111111111000111000000100100100100100000100000000000000000000000000000000000',
r4 => '111111000111111000100100000100100000100100000000000000000000000000000000',
r5 => '111111111100000000100100000100100100000000000000000000000000000',
r6 => '111111111111111000111000000100100100100100000100000000',
r7 => '111111000111111000100100000100100000100100000',
r8 => '111111111100000000100100000100100100',
r9 => '111111111111111000111000000',
r10 => '111111000111111000',
r11 => '111111111',
r0 => '111111111110110110100100100111111000110110000100100000111000000110000000100000000000000000000000000000000000',
#r1 => '111111000111111000110110000110110000110110000100100000100100000100100000000000000000000000000000000',
#r2 => '111111111110000000110110000110110110100000000100100000100100100000000000000000000000000000',
#r3 => '111111111111111000111000000100100100100100000100000000000000000000000000000000000',
#r4 => '111111000111111000100100000100100000100100000000000000000000000000000000',
#r5 => '111111111100000000100100000100100100000000000000000000000000000',
#r6 => '111111111111111000111000000100100100100100000100000000',
#r7 => '111111000111111000100100000100100000100100000',
#r8 => '111111111100000000100100000100100100',
#r9 => '111111111111111000111000000',
#r10 => '111111000111111000',
#r11 => '111111111',
);

for 0..@ranges.end -> $i {
my $test_data = %map{'r' ~ $i};
my @tests = $test_data.comb(/\d/);
next unless %map.exists("r$i");
my @tests = %map{"r$i"}.comb(/\d/);
for $i..@ranges.end -> $j {
my $r1 = @ranges[$i];
my $r2 = @ranges[$j];
for <ignore weak strong> -> $test {
is($r1.overlaps($r2, :test<$test>), ?@tests.shift, ~$r1 ~ ' overlaps ' ~ $r2 ~ ": $test");
is($r1.contains($r2, :test<$test>), ?@tests.shift, ~$r1 ~ ' contains ' ~ $r2 ~ ": $test");
is($r1.equals($r2, :test<$test>), ?@tests.shift, ~$r1 ~ ' equals ' ~ $r2 ~ ": $test");
my $current = ?@tests.shift;
is($r1.overlaps($r2, test => $test ), ?$current, ~$r1 ~ ' overlaps ' ~ $r2 ~ ", $test: "~ $current);
$current = ?@tests.shift;
is($r1.contains($r2, :test<$test>), ?$current, ~$r1 ~ ' contains ' ~ $r2 ~ ", $test: " ~ $current);
$current = ?@tests.shift;
is($r1.equals($r2, :test<$test>), ?$current, ~$r1 ~ ' equals ' ~ $r2 ~ ", $test: " ~ $current);
}
}
}

##=begin Geometric tests
##
##With these ranges:
##
## r0 |--------->
## r1 |---------|
## r2 <---------|
##
## r3 |-->
## r4 |--|
## r5 <--|
##
## r6 |-------->
## r7 |--------|
## r8 <--------|
##
## r9 |-------->
## r10 |--------|
## r11 <--------|
##
## intersection of r0, r3, r6 => [75,75,1] for all st
## intersection of r6, r9 => [101, 125, 1] for all st
## intersection of r6, r10 => [101, 125, 0] for ignore, weak, undef for strong
## intersection of r6, r11 => [101, 125, 0] for ignore, undef for weak & strong
## intersection of r0, r6, r9 => undef for all
##
## union of r0, r3, r6 => [1,125,1] for all st
## union of r6, r9 => [75, 150, 1] for all st
## union of r6, r10 => [75, 150, 0] for all st
## union of r6, r11 => [75, 150, 0] for all st
## union of r0, r6, r9 => [1,150,1] for all st
##
##=end Geometric tests

my %geo_tests =
('0,3,6' => { # intersection union
'strong' => ['(75, 75) strand=1', '(1, 125) strand=1'],
'weak' => ['(75, 75) strand=1', '(1, 125) strand=1'],
'ignore' => ['(75, 75) strand=1', '(1, 125) strand=1'],
},
'6,9' => {
'strong' => ['(101, 125) strand=1', '(75, 150) strand=1'],
'weak' => ['(101, 125) strand=1', '(75, 150) strand=1'],
'ignore' => ['(101, 125) strand=1', '(75, 150) strand=1'],
},
'6,10' => {
'strong' => ['', '(75, 150) strand=0'],
'weak' => ['(101, 125) strand=0', '(75, 150) strand=0'],
'ignore' => ['(101, 125) strand=0', '(75, 150) strand=0'],
},
'6,11' => {
'strong' => ['', '(75, 150) strand=0'],
'weak' => ['', '(75, 150) strand=0'],
'ignore' => ['(101, 125) strand=0', '(75, 150) strand=0'],
},
'0,6,9' => {
'strong' => ['', '(1, 150) strand=1'],
'weak' => ['', '(1, 150) strand=1'],
'ignore' => ['', '(1, 150) strand=1'],
},
);

for %geo_tests.keys.sort -> $set {
my @rest = @ranges[$set.split(',')];
my $primary = @rest.shift;
for <ignore weak strong> -> $test {
my $int = $primary.intersection(@rest, :$test);
my $union = $primary.union(@rest, :$test);
is(($int.defined ?? $int.Str !! ''), %geo_tests{$set}{$test}[0], "intersection of $set, $test");
is(($union.defined ?? $union.Str !! ''), %geo_tests{$set}{$test}[1], "union of $set, $test");
}
}
#=begin Geometric tests
#
#With these ranges:
#
# r0 |--------->
# r1 |---------|
# r2 <---------|
#
# r3 |-->
# r4 |--|
# r5 <--|
#
# r6 |-------->
# r7 |--------|
# r8 <--------|
#
# r9 |-------->
# r10 |--------|
# r11 <--------|
#
# intersection of r0, r3, r6 => [75,75,1] for all st
# intersection of r6, r9 => [101, 125, 1] for all st
# intersection of r6, r10 => [101, 125, 0] for ignore, weak, undef for strong
# intersection of r6, r11 => [101, 125, 0] for ignore, undef for weak & strong
# intersection of r0, r6, r9 => undef for all
#
# union of r0, r3, r6 => [1,125,1] for all st
# union of r6, r9 => [75, 150, 1] for all st
# union of r6, r10 => [75, 150, 0] for all st
# union of r6, r11 => [75, 150, 0] for all st
# union of r0, r6, r9 => [1,150,1] for all st
#
#=end Geometric tests

#my %geo_tests =
#('0,3,6' => { # intersection union
# 'strong' => ['(75, 75) strand=1', '(1, 125) strand=1'],
# 'weak' => ['(75, 75) strand=1', '(1, 125) strand=1'],
# 'ignore' => ['(75, 75) strand=1', '(1, 125) strand=1'],
# },
# '6,9' => {
# 'strong' => ['(101, 125) strand=1', '(75, 150) strand=1'],
# 'weak' => ['(101, 125) strand=1', '(75, 150) strand=1'],
# 'ignore' => ['(101, 125) strand=1', '(75, 150) strand=1'],
# },
# '6,10' => {
# 'strong' => ['', '(75, 150) strand=0'],
# 'weak' => ['(101, 125) strand=0', '(75, 150) strand=0'],
# 'ignore' => ['(101, 125) strand=0', '(75, 150) strand=0'],
# },
# '6,11' => {
# 'strong' => ['', '(75, 150) strand=0'],
# 'weak' => ['', '(75, 150) strand=0'],
# 'ignore' => ['(101, 125) strand=0', '(75, 150) strand=0'],
# },
# '0,6,9' => {
# 'strong' => ['', '(1, 150) strand=1'],
# 'weak' => ['', '(1, 150) strand=1'],
# 'ignore' => ['', '(1, 150) strand=1'],
# },
#);
#
#for %geo_tests.keys.sort -> $set {
# my @rest = @ranges[$set.split(',')];
# my $primary = @rest.shift;
# for <ignore weak strong> -> $test {
# my $int = $primary.intersection(@rest, :$test);
# my $union = $primary.union(@rest, :$test);
# is(($int.defined ?? $int.Str !! ''), %geo_tests{$set}{$test}[0], "intersection of $set, $test");
# is(($union.defined ?? $union.Str !! ''), %geo_tests{$set}{$test}[1], "union of $set, $test");
# }
#}
#
##=begin Subtraction
##
## r0 |--------->
Expand Down Expand Up @@ -217,43 +220,43 @@ for %geo_tests.keys.sort -> $set {
## subtraction of r0 from r9 => original (or clone?) r9 Range [101,150,1]
##
##=end Subtraction

my %subtract_tests = ( # rx->subtract(ry) ry->subtract(rx)
'0,3' => {
'strong' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
'weak' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
'ignore' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
},
'0,4' => {
'strong' => ['(1, 100) strand=1', '(25, 75) strand=0'],
'weak' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
'ignore' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
},
'0,6' => {
'strong' => ['(1, 74) strand=1', '(101, 125) strand=1'],
'weak' => ['(1, 74) strand=1', '(101, 125) strand=1'],
'ignore' => ['(1, 74) strand=1', '(101, 125) strand=1'],
},
'6,9' => {
'strong' => ['(75, 100) strand=1', '(126, 150) strand=1'],
'weak' => ['(75, 100) strand=1', '(126, 150) strand=1'],
'ignore' => ['(75, 100) strand=1', '(126, 150) strand=1'],
},
'0,9' => {
'strong' => ['(1, 100) strand=1', '(101, 150) strand=1'],
'weak' => ['(1, 100) strand=1', '(101, 150) strand=1'],
'ignore' => ['(1, 100) strand=1', '(101, 150) strand=1'],
},
);

for %subtract_tests.keys.sort -> $set {
my ($r1, $r2) = @ranges[split(',',$set)];
for <ignore weak strong> -> $st {
my @sub1 = $r1.subtract($r2, test => $st);
my @sub2 = $r2.subtract($r1, test => $st);
is(join(',', @sub1».Str), %subtract_tests{$set}{$st}[0], "subtract" );
is(join(',', @sub2».Str), %subtract_tests{$set}{$st}[1], "subtract");
}
}
#
#my %subtract_tests = ( # rx->subtract(ry) ry->subtract(rx)
# '0,3' => {
# 'strong' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
# 'weak' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
# 'ignore' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
# },
# '0,4' => {
# 'strong' => ['(1, 100) strand=1', '(25, 75) strand=0'],
# 'weak' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
# 'ignore' => ['(1, 24) strand=1,(76, 100) strand=1','(0, 0) strand=0'],
# },
# '0,6' => {
# 'strong' => ['(1, 74) strand=1', '(101, 125) strand=1'],
# 'weak' => ['(1, 74) strand=1', '(101, 125) strand=1'],
# 'ignore' => ['(1, 74) strand=1', '(101, 125) strand=1'],
# },
# '6,9' => {
# 'strong' => ['(75, 100) strand=1', '(126, 150) strand=1'],
# 'weak' => ['(75, 100) strand=1', '(126, 150) strand=1'],
# 'ignore' => ['(75, 100) strand=1', '(126, 150) strand=1'],
# },
# '0,9' => {
# 'strong' => ['(1, 100) strand=1', '(101, 150) strand=1'],
# 'weak' => ['(1, 100) strand=1', '(101, 150) strand=1'],
# 'ignore' => ['(1, 100) strand=1', '(101, 150) strand=1'],
# },
#);
#
#for %subtract_tests.keys.sort -> $set {
# my ($r1, $r2) = @ranges[split(',',$set)];
# for <ignore weak strong> -> $st {
# my @sub1 = $r1.subtract($r2, test => $st);
# my @sub2 = $r2.subtract($r1, test => $st);
# is(join(',', @sub1».Str), %subtract_tests{$set}{$st}[0], "subtract" );
# is(join(',', @sub2».Str), %subtract_tests{$set}{$st}[1], "subtract");
# }
#}

done();

0 comments on commit 8b70f83

Please sign in to comment.