Skip to content

Commit

Permalink
get some basic location stuff added
Browse files Browse the repository at this point in the history
  • Loading branch information
cjfields committed Sep 10, 2014
1 parent 2223822 commit 4096f58
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
30 changes: 15 additions & 15 deletions lib/Bio/Role/Location.pm6
Expand Up @@ -9,21 +9,21 @@ has Int $.end-offset is rw = 0;
has $.seqid is rw;

# use enum here
has $.type is rw;

method max-start { ... }
method min-start { ... }
method max-end { ... }
method min-end { ... }

# use enum here
method start-pos-type { ... }
method end-pos-type { ... }

# return Bool
method is-valid { ... }
method is-remote { ... }
method is-fuzzy { ... }
has $.type is rw = 'EXACT';

method max-start { self.start + $!start-offset }
method min-start { self.start }
method max-end { self.end + $!end-offset }
method min-end { self.end }

# use enum here?
#method start-pos-type { ... }
#method end-pos-type { ... }
#
## return Bool
method is-valid returns Bool { ?( self.start.defined && self.end.defined ) }
method is-remote returns Bool { ?($!seqid.defined) }
#method is-fuzzy { ... }

# stringification?
#multi method WHICH { ... }
18 changes: 17 additions & 1 deletion t/Location/Simple.t
Expand Up @@ -6,6 +6,22 @@ use Test;

use Bio::Location::Simple;

ok(1);
my $loc = Bio::Location::Simple.new(:start(1), :end(100), :strand(-1));

ok( Bio::Location::Simple ~~ Bio::Role::Location, 'does Location' );
ok( Bio::Location::Simple ~~ Bio::Role::Range, 'does Range' );

is($loc.start, 1, 'start');
is($loc.end, 100, 'end');
is($loc.length(), 100, 'length');
is($loc.strand, -1, 'strand');
is($loc.min-start, 1, 'min-start');
is($loc.max-start, 1, 'max-start');
is($loc.type, 'EXACT', 'type');

is($loc.min-end, 100, 'min-end');
is($loc.max-end, 100, 'max-end');
ok($loc.is-valid, 'is-valid');
ok(!$loc.is-remote, 'is-fuzzy');

done();

0 comments on commit 4096f58

Please sign in to comment.