Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
seqfeature/location both work with FTLocationFactory, test that
  • Loading branch information
Chris Fields committed Feb 23, 2012
1 parent 5e05b4a commit 93b16f9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Biome/Factory/FTLocationFactory.pm
Expand Up @@ -16,7 +16,7 @@ $LOCREG = qr{
}xmso;

# make global for now, allow for abstraction later
our $SIMPLE_CLASS = 'Biome::Location::Simple';
our $SIMPLE_CLASS = 'Biome::SeqFeature::Generic';

my %OPS = map { $_ => 1 } qw(join order bond complement);

Expand Down
2 changes: 1 addition & 1 deletion lib/Biome/Location/Simple.pm
Expand Up @@ -12,7 +12,7 @@ use namespace::autoclean;
# class can override

with 'Biome::Role::Location::Simple';
with 'Biome::Role::Location::Collection' => {base_name => 'Location'};
with 'Biome::Role::Location::Collection' => {base_name => 'Location', top => 0};
with 'Biome::Role::Location::Locatable';

sub BUILD {
Expand Down
2 changes: 2 additions & 0 deletions lib/Biome/Role/SeqFeature.pm
Expand Up @@ -52,6 +52,8 @@ has 'type' => (
predicate => 'has_type'
);

# TODO: add aliased methods for Location::Collection role

no Biome::Role;

1;
Expand Down
19 changes: 19 additions & 0 deletions lib/Biome/SeqFeature/Generic.pm
Expand Up @@ -10,6 +10,25 @@ with 'Biome::Role::Location::Collection' => {base_name => 'SeqFeature'};
with 'Biome::Role::Location::Locatable';
with 'Biome::Role::SeqFeature';

sub BUILD {
my ($self, $params) = @_;

if ($params->{location_string}) {
$self->throw("Can't use 'location_string' with other parameters")
if (scalar(keys %$params) > 1);
$self->from_string($params->{location_string});
}

if ($params->{start} && $params->{end} && ($params->{end} < $params->{start})) {
$self->warn('End is greater than start; flipping strands');
$self->end($params->{start});
$self->start($params->{end});
$self->strand($self->strand * -1);
}

$params->{location_type} && $self->location_type($params->{location_type});
}

__PACKAGE__->meta->make_immutable;

1;
Expand Down
2 changes: 1 addition & 1 deletion t/Factory/FTLocationFactory.t
Expand Up @@ -134,7 +134,7 @@ foreach my $locstr (keys %testcases) {
is($loc->to_string, $replace, "compare conversion of $locstr to $replace");
}

isa_ok($loc, 'Biome::Location::Simple');
does_ok($loc, 'Biome::Role::Location::Simple');
is($loc->min_start(), $rest[0], "min_start: $locstr");
is($loc->max_start(), $rest[1], "max_start: $locstr");
is($loc->start_pos_type(), $rest[2], "start_pos_type: $locstr");
Expand Down
4 changes: 2 additions & 2 deletions t/SeqFeature/Base.t
Expand Up @@ -2,9 +2,9 @@
# $Id: PrimarySeq.t 15112 2008-12-08 18:12:38Z sendu $

use strict;
use Biome::PrimarySeq;
my @sf_classes;


BEGIN {
@sf_classes = qw(
Biome::SeqFeature::Generic
Expand All @@ -13,7 +13,7 @@ BEGIN {
use Test::More;
use Test::Moose;
use Test::Exception;
use_ok('Biome::PrimarySeq');

for my $class (@sf_classes) {
use_ok($class);
}
Expand Down

0 comments on commit 93b16f9

Please sign in to comment.