From 12e8a2c705f610cea939036cd14178daa7ec8f01 Mon Sep 17 00:00:00 2001 From: Surya Saha Date: Wed, 13 May 2015 14:29:59 -0400 Subject: [PATCH] Cleaned up class variable names, fixed type checks and function to get formatted trim point file. Re #45 --- lib/Bio/GenomeUpdate/TP.pm | 19 ++++++++----------- lib/Bio/GenomeUpdate/TP/TPLine.pm | 12 ++++++++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/Bio/GenomeUpdate/TP.pm b/lib/Bio/GenomeUpdate/TP.pm index afed7ba..9a89d64 100644 --- a/lib/Bio/GenomeUpdate/TP.pm +++ b/lib/Bio/GenomeUpdate/TP.pm @@ -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 @@ -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', @@ -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"; } } diff --git a/lib/Bio/GenomeUpdate/TP/TPLine.pm b/lib/Bio/GenomeUpdate/TP/TPLine.pm index 61f7781..4dad481 100644 --- a/lib/Bio/GenomeUpdate/TP/TPLine.pm +++ b/lib/Bio/GenomeUpdate/TP/TPLine.pm @@ -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 @@ -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' ); @@ -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' );