Skip to content

Commit

Permalink
removed comment and added type check for SP object. Re #26
Browse files Browse the repository at this point in the history
  • Loading branch information
suryasaha committed May 13, 2015
1 parent f189681 commit c9200f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/Bio/GenomeUpdate/SP/SPLine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use Moose;
use MooseX::FollowPBP;
use Moose::Util::TypeConstraints;

use Data::Dumper;#for debugging

=head1 NAME
SP - Switch point lines for NCBI GRC pipeline with instructions used to generate a Accessioned Golden Path (AGP) file
Expand Down Expand Up @@ -38,7 +36,7 @@ Gets the chromosome.

subtype 'SPChromosome', #only works for genomes with 12 chrs or less.
as 'Str',
where { $_ eq '1' || $_ eq '2' || $_ eq '3' || $_ eq '4' || $_ eq '5' || $_ eq '6' || $_ eq '7' || $_ eq '8' || $_ eq '9' || $_ eq '10' || $_ eq '11' || $_ eq '12' || $_ eq "Un" },#does NOT work. need to do -> if int check 1-12, if str check Un
where { $_ eq '1' || $_ eq '2' || $_ eq '3' || $_ eq '4' || $_ eq '5' || $_ eq '6' || $_ eq '7' || $_ eq '8' || $_ eq '9' || $_ eq '10' || $_ eq '11' || $_ eq '12' || $_ eq "Un" },
message { "The string, $_, was not a valid chromosome number. Valid values for Solanum lycopersicum are 1-12 and Un." };
has 'chromosome' => ( isa => 'SPChromosome', is => 'rw', required => 1, clearer => 'clear_chromosome' );

Expand Down
11 changes: 8 additions & 3 deletions t/GenomeUpdate/sp.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use strict;
use warnings;
use autodie;

use Test::More tests => 1;
use Test::More;
use Test::Exception;

BEGIN {use_ok( 'Bio::GenomeUpdate::SP' ); }
Expand Down Expand Up @@ -64,7 +64,7 @@ is($sp_line1->get_accession_prefix_last_base(), 100, 'Got correct accession_pref
is($sp_line1->get_accession_suffix_first_base(), 200, 'Got correct accession_suffix_first_base from $sp_line1');
is($sp_line1->get_comment(), 'test line 1 comment some nonsense here and here too', 'Got correct comment from $sp_line1');

#test for type checks
#test for type checks for SP line
throws_ok{$sp_line1->set_chromosome(13)} qr/not a valid chromosome number/, "invalid chr exception caught";
throws_ok{$sp_line1->set_accession_prefix_orientation('3')} qr/not a valid orientation type/, "invalid orientation exception caught";
throws_ok{$sp_line1->set_accession_prefix_last_base(-1)} qr/not a positive coordinate/, "negative coordinate exception caught";
Expand All @@ -81,9 +81,11 @@ ok(my $sp = Bio::GenomeUpdate::SP->new(
ok ($sp->add_line_to_end($sp_line1), 'added $sp_line1');
ok ($sp->add_line_to_end($sp_line2), 'added $sp_line2');

#test for type checks for SP object
throws_ok{$sp->set_tpf_type('blah blah')} qr/not a valid TPF type/, "invalid TPF type exception caught";

#print out SP object and compare to string
ok(my $sp_file_string = $sp->get_formatted_sp(), 'got switch point file content' );
print $sp_file_string;
my $expected_sp_file_string = q(001 TGP Primary Un chromosome accession1 accession2 + - 100 200 test line 1 comment some nonsense here and here too
001 TGP Primary 1 chromosome accession3 accession4 - - 300 100 test line 2 comment some nonsense here and here too
);
Expand All @@ -101,3 +103,6 @@ $expected_sp_file_string = q(001 TGP Primary Un chromosome accession1 accession2
001 TGP Primary Un chromosome accession1 accession2 + - 110 210 test line 1 comment some nonsense here and here too
); #$sp_line1 also changes as its a hashref
ok( $sp_file_string eq $expected_sp_file_string, 'modified switch point file content looks good' );

#no more tests
done_testing();

0 comments on commit c9200f4

Please sign in to comment.