Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
some last minute clenaup
  • Loading branch information
Chris Fields committed Sep 4, 2012
1 parent 4df69ff commit 004a919
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 54 deletions.
16 changes: 4 additions & 12 deletions lib/Bio/Role/Range.pm
Expand Up @@ -27,7 +27,7 @@ our Bool method equals (Bio::Role::Range $range, :$test = 'ignore') {
(self.start == $range.start && self.end == $range.end))
}

our Bool method !teststranded (Bio::Role::Range $self: Bio::Role::Range $r, :$test = 'ignore') {
our Bool method !teststranded (Bio::Role::Range $self: Bio::Role::Range $r, RangeTest :$test) {
my ($s1, $s2) = (self.strand, $r.strand);
given $test {
when 'ignore' {
Expand All @@ -47,15 +47,7 @@ our Bool method !teststranded (Bio::Role::Range $self: Bio::Role::Range $r, :$te
return False;
}

# TODO:
# seeing an error when not using the named parameter version for test in
# .union() and .intersection:
#
# Method '!teststranded' not found for invocant of class 'Str'
#
# May be rakudobug, may be the signature (and me), needs checking

our Bio::Role::Range method intersection ( :$test = 'ignore', *@ranges) {
our Bio::Role::Range method intersection ( *@ranges, :$test = 'ignore') {
my $intersect;
while @ranges > 0 {
$intersect //= self;
Expand Down Expand Up @@ -84,7 +76,7 @@ our Bio::Role::Range method intersection ( :$test = 'ignore', *@ranges) {
return $intersect;
}

our Bio::Role::Range method union ( RangeTest :$test = 'ignore', *@ranges) {
our Bio::Role::Range method union (*@ranges, :$test = 'ignore') {
my $union_strand = self.strand; # Strand for the union range object.

# beware the hyperoperator!
Expand All @@ -102,7 +94,7 @@ our Bio::Role::Range method union ( RangeTest :$test = 'ignore', *@ranges) {
}

# this should have a return type of Array of Bio::Role::Range, but NYI
our method subtract (Bio::Role::Range $range, RangeTest :$test = 'ignore') {
our method subtract (Bio::Role::Range $range, :$test = 'ignore') {
if !(self!teststranded($range, :$test)) || !self.overlaps($range, :$test) {
return self
}
Expand Down
84 changes: 42 additions & 42 deletions t/Range.t
Expand Up @@ -8,48 +8,48 @@ use Test;

use Bio::Role::Range;

##=begin Range tests
##
##Test out simple ranges. Locations will expand on these...
##
## r0 |--------->
## r1 |---------|
## r2 <---------|
##
## r3 |-->
## r4 |--|
## r5 <--|
##
## r6 |-------->
## r7 |--------|
## r8 <--------|
##
## r9 |-------->
## r10 |--------|
## r11 <--------|
##
##Logic table for overlaps, contains, equals
##
##m = method, o = overlaps() c = contains() e = equals
##st = strand tests, i = ignore, w = weak, s = strong
##
## r0 |r1 |r2 |r3 |r4 |r5 |r6 |r7 |r8 |r9 |r10 |r11
## o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e
## iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws
##r0 111111111|110110110|100100100|111111000|110110000|100100000|111000000|110000000|100000000|000000000|000000000|000000000
##r1 xxxxxxxxx|110110110|110110110|110110000|110110000|110110000|110000000|110000000|110000000|000000000|000000000|000000000
##r2 xxxxxxxxx|xxxxxxxxx|111111111|100100000|110110000|111111000|100000000|110000000|111000000|000000000|000000000|000000000
##r3 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|110110110|100100100|111000000|110000000|100000000|000000000|000000000|000000000
##r4 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|110110110|110110110|110000000|110000000|110000000|000000000|000000000|000000000
##r5 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|100000000|110000000|111000000|000000000|000000000|000000000
##r6 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|110110110|100100100|111000000|110000000|100000000
##r7 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|110110110|110110110|110000000|110000000|110000000
##r8 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|100000000|110000000|111000000
##r9 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|110110110|100100100
##r10 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|110110110|110110110
##r11 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111
##
##=end Range tests
#=begin Range tests
#
#Test out simple ranges. Locations will expand on these...
#
# r0 |--------->
# r1 |---------|
# r2 <---------|
#
# r3 |-->
# r4 |--|
# r5 <--|
#
# r6 |-------->
# r7 |--------|
# r8 <--------|
#
# r9 |-------->
# r10 |--------|
# r11 <--------|
#
#Logic table for overlaps, contains, equals
#
#m = method, o = overlaps() c = contains() e = equals
#st = strand tests, i = ignore, w = weak, s = strong
#
# r0 |r1 |r2 |r3 |r4 |r5 |r6 |r7 |r8 |r9 |r10 |r11
# o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e |o c e
# iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws|iwsiwsiws
#r0 111111111|110110110|100100100|111111000|110110000|100100000|111000000|110000000|100000000|000000000|000000000|000000000
#r1 xxxxxxxxx|110110110|110110110|110110000|110110000|110110000|110000000|110000000|110000000|000000000|000000000|000000000
#r2 xxxxxxxxx|xxxxxxxxx|111111111|100100000|110110000|111111000|100000000|110000000|111000000|000000000|000000000|000000000
#r3 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|110110110|100100100|111000000|110000000|100000000|000000000|000000000|000000000
#r4 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|110110110|110110110|110000000|110000000|110000000|000000000|000000000|000000000
#r5 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|100000000|110000000|111000000|000000000|000000000|000000000
#r6 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|110110110|100100100|111000000|110000000|100000000
#r7 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|110110110|110110110|110000000|110000000|110000000
#r8 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|100000000|110000000|111000000
#r9 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111|110110110|100100100
#r10 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|110110110|110110110
#r11 xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|xxxxxxxxx|111111111
#
#=end Range tests

class MyRange does Bio::Role::Range {
our method Str {
Expand Down

0 comments on commit 004a919

Please sign in to comment.