Skip to content

Commit

Permalink
Cleaned up class variable names, fixed type checks and function to ge…
Browse files Browse the repository at this point in the history
…t formatted trim point file. Re #45
  • Loading branch information
suryasaha committed May 13, 2015
1 parent c9200f4 commit 12e8a2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
19 changes: 8 additions & 11 deletions lib/Bio/GenomeUpdate/TP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ Gets the taxonomy identifier for the SP file.
=cut

has 'tp_taxid' => (
has 'taxid' => (
isa => 'Str',
is => 'rw',
default => '4081',
required => 1,
clearer => 'clear_tp_taxid'
clearer => 'clear_taxid'
);

=item C<set_assembly_group ( $organism_string )>
Expand Down Expand Up @@ -80,7 +80,7 @@ Gets the TPF type.
subtype 'TPTPFType', as 'Str', where { $_ eq "chromosome" || $_ eq "contig" },
message { "The string, $_, was not a valid TPF type. See http://www.ncbi.nlm.nih.gov/projects/genome/assembly/grc/overlap/ specification link" };

has 'tp_tpf_type' => ( isa => 'TPTPFType', is => 'rw', default => 'chromosome', required => 1, clearer => 'clear_chromosome' );
has 'tpf_type' => ( isa => 'TPTPFType', is => 'rw', default => 'chromosome', required => 1, clearer => 'clear_tpf_type' );

subtype 'TPLine',
as 'Bio::GenomeUpdate::TP::TPLine',
Expand Down Expand Up @@ -145,17 +145,14 @@ sub get_formatted_tp {
%lines = %{ $self->get_tp_lines() };
my @sorted_line_numbers = sort { $a <=> $b } keys %lines;
foreach my $line_key (@sorted_line_numbers) {
$out_str .= $self->get_tp_taxid() . "\t";
$out_str .= $self->get_taxid() . "\t";
$out_str .= $self->get_assembly_group() . "\t";
$out_str .= $self->get_assembly_unit() . "\t";
$out_str .= $lines{$line_key}->get_chromosome() . "\t";
$out_str .= $self->get_tp_tpf_type() . "\t";
$out_str .= $lines{$line_key}->get_accession_prefix() . "\t";
$out_str .= $lines{$line_key}->get_accession_suffix() . "\t";
$out_str .= $lines{$line_key}->get_accession_prefix_orientation() . "\t";
$out_str .= $lines{$line_key}->get_accession_suffix_orientation() . "\t";
$out_str .= $lines{$line_key}->get_accession_prefix_last_base() . "\t";
$out_str .= $lines{$line_key}->get_accession_suffix_first_base() . "\t";
$out_str .= $self->get_tpf_type() . "\t";
$out_str .= $lines{$line_key}->get_accession() . "\t";
$out_str .= $lines{$line_key}->get_accession_prefix_first_or_last_base() . "\t";
$out_str .= $lines{$line_key}->get_trim_from_end() . "\t";
$out_str .= $lines{$line_key}->get_comment() . "\n";
}
}
Expand Down
12 changes: 8 additions & 4 deletions lib/Bio/GenomeUpdate/TP/TPLine.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
TP - Trim 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 'TPChromosome',
as 'Str',
where { ( $_ >= 1 && $_ <=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 => 'TPChromosome', is => 'rw', required => 1, clearer => 'clear_chromosome' );

Expand All @@ -50,9 +48,15 @@ subtype 'PositiveInt',
message { "The string, $_, was not a positive coordinate" };
has 'accession_prefix_first_or_last_base' => ( isa => 'PositiveInt', is => 'rw', required => 1, clearer => 'clear_accession_prefix_first_or_last_base' );

subtype 'TPTrimDirection',
as 'Str',
where { ( $_ eq 'L' ) || ( $_ eq "H" )},
message { "The string, $_, was not a valid trim direction. Valid values values are L and H where L: trim bases with values lt accession_prefix_first_or_last_base; H: trim bases with values gt accession_prefix_first_or_last_base." };
has 'trim_from_end' => ( isa => 'TPTrimDirection', is => 'rw', required => 1, clearer => 'clear_trim_from_end' );

subtype 'TPComment',
as 'Str',
where { (scalar $_) >= 25 },#does not work!!
where { (length $_) >= 25 },
message { "The string, $_, was shorter than the minimum length of 25 characters." };
has 'comment' => ( isa => 'TPComment', is => 'rw', required => 1, clearer => 'clear_comment' );

Expand Down

0 comments on commit 12e8a2c

Please sign in to comment.