File Coverage

blib/lib/Bio/PrimerDesigner/Result.pm
Criterion Covered Total %
statement 28 30 93.3
branch 3 4 75.0
condition 1 2 50.0
subroutine 7 8 87.5
pod 2 2 100.0
total 41 46 89.1


line stmt bran cond sub pod time code
1             package Bio::PrimerDesigner::Result;
2              
3             # $Id: Result.pm 14 2008-11-07 02:40:49Z kyclark $
4              
5             =head1 NAME
6              
7             Bio::PrimerDesigner::Result - a class for handling primer
8             design or validation results
9              
10             =head1 SYNOPSIS
11              
12             use Bio::PrimerDesigner;
13            
14             #
15             # primer3
16             #
17             my $primer3_obj = Bio::PrimerDesigner->new( program => 'primer3 );
18             my $result = $primer3_obj->design( %hash_of_options );
19             my $left_primer = $result->left;
20             my @left_primers = $result->left(1..$num_primers);
21            
22             #
23             # e-PCR -- first make a hash of options from primer3 results
24             # then run e-PCR
25             #
26             my $epcr_obj = Bio::PrimerDesigner->new( program => 'primer3 );
27             my $epcr_result = $epcr_obj->design( %hash_of_options );
28             my $num_products = $epcr_result->products;
29            
30             #
31             # one product
32             #
33             my $first_prod_size = $epcr_result->size;
34             my $first_prod_start = $epcr_result->start;
35             my $first_prod_stop = $epcr_result->start;
36            
37             #
38             # more than one product
39             #
40             my @pcr_product_sizes = ();
41             for (1..$num_products) {
42             push @pcr_product_sizes, $epcr_result->size;
43             }
44              
45             =head1 DESCRIPTION
46              
47             Bio::PrimerDesigner::Result will autogenerate result access methods
48             for for Native Boulder IO keys and Bio::PrimerDesigner keys for
49             primer3, e-PCR, isPcr and ipcress.
50              
51             =head1 METHODS
52              
53             =cut
54              
55 6     6   37 use strict;
  6         13  
  6         226  
56 6     6   30 use warnings;
  6         13  
  6         202  
57 6     6   31 use Readonly;
  6         12  
  6         623  
58              
59             Readonly our
60             $VERSION => sprintf "%s", q$Revision: 24 $ =~ /(\d+)/;
61              
62 6     6   39 use base 'Class::Base';
  6         12  
  6         1645  
63              
64             Readonly my @AUTO_FIELDS => qw(
65             ***PRIMER3_KEYS***
66             PRIMER_LEFT_EXPLAIN PRIMER_RIGHT_EXPLAIN PRIMER_PAIR_EXPLAIN
67             PRIMER_INTERNAL_OLIGO_EXPLAIN left_explain right_explain
68             hyb_oligo_explain hyb_oligo lselfend PRIMER_LEFT rendstab
69             PRIMER_LEFT_SEQUENCE prod SEQUENCE TARGET PRIMER_RIGHT_END_STABILITY
70             right lselfany PRIMER_RIGHT_GC_PERCENT left PRIMER_PRODUCT_SIZE_RANGE
71             PRIMER_PAIR_COMPL_END raw_output lendstab PRIMER_INTERNAL_OLIGO_TM
72             hyb_tm PRIMER_RIGHT_SEQUENCE PRIMER_PRODUCT_SIZE PRIMER_PAIR_COMPL_ANY
73             leftgc PRIMER_LEFT_SELF_END rightgc rqual qual PRIMER_PAIR_PENALTY
74             PRIMER_LEFT_SELF_ANY PRIMER_SEQUENCE_ID PRIMER_LEFT_TM PRIMER_RIGHT_TM
75             tmright PRIMER_RIGHT startright tmleft pairendcomp PRIMER_RIGHT_SELF_END
76             PRIMER_LEFT_GC_PERCENT rselfend PRIMER_LEFT_PENALTY PRIMER_RIGHT_PENALTY
77             EXCLUDED_REGION PRIMER_LEFT_END_STABILITY PRIMER_NUM_RETURN
78             PRIMER_RIGHT_SELF_ANY rselfany pairanycomp lqual startleft
79             ***other keys***
80             products size start stop end amplicon strand
81             );
82              
83             # -------------------------------------------------------------------
84             sub init {
85 1     1 1 18 my ( $self, $config ) = @_;
86              
87 1         8 $self->params( $config, 'data' );
88              
89 1         320 for my $sub_name ( @AUTO_FIELDS ) {
90 67 100       335 next if $sub_name =~ /^\*/;
91              
92 6     6   35 no strict 'refs';
  6         11  
  6         1260  
93 65         310 *{ $sub_name } = sub {
94 1     1   2 my $self = shift;
95 1         2 my @nums = @_;
96 1   50     7 $nums[0] ||= 1;
97 1         2 my @result = map { $self->{$_}->{$sub_name} } @nums;
  1         5  
98 1 50       8 return @result > 1 ? @result : $result[0];
99             }
100 65         644 }
101              
102 1         6 return $self;
103             }
104              
105             # -------------------------------------------------------------------
106             sub keys {
107              
108             =pod
109              
110             =head2 keys
111              
112             This handles result method calls made via the
113             Bio::PrimerDesigner::Result object. Returns either a scalar or list
114             depending on the on the arguments:
115              
116             ------------------+------------------------
117             Args passed | Returns
118             ------------------+------------------------
119             none scalar value for set 1
120             numeric n scalar value for set n
121             numeric list 1..n list with n elements
122              
123             The aliased output methods (below) return a string when called in a
124             scalar context and a list when called in a list context. The native
125             primer3 (Boulder IO) keys can also be used. There are also e-PCR,
126             isPcr and ipcress specific methods
127              
128             B
129              
130             =over 4
131              
132             =item * left -- left primer sequence
133              
134             =item * right -- right primer sequence
135              
136             =item * hyb_oligo -- internal oligo sequence
137              
138             =item * startleft -- left primer 5' sequence coordinate
139              
140             =item * startright -- right primer 5' sequence coordinate
141              
142             =item * tmleft -- left primer tm
143              
144             =item * tmright -- right primer tm
145              
146             =item * qual -- primer pair penalty (Q value)
147              
148             =item * lqual -- left primer penalty
149              
150             =item * rqual -- right primer penalty
151              
152             =item * leftgc -- left primer % gc
153              
154             =item * rightgc -- right primer % gc
155              
156             =item * lselfany -- left primer self-complementarity (any)
157              
158             =item * lselfend -- left primer self-complementarity (end)
159              
160             =item * rselfany -- right primer self-complementarity (any)
161              
162             =item * rselfend -- right primer self-complementarity (end)
163              
164             =item * pairanycomp -- primer pair complementarity (any)
165              
166             =item * pairendcomp -- primer pair complementarity (end)
167              
168             =item * lendstab -- left primer end stability
169              
170             =item * rendstab -- right primer end stability
171              
172             =item * amplicon -- amplified PCR product
173              
174             =back
175              
176             B
177              
178             =over 4
179              
180             =item * products -- number of PCR products
181              
182             =item * size -- product size
183              
184             =item * start -- product start coordinate
185              
186             =item * stop -- product stop coordinate
187              
188             =item * end -- synonymous with stop
189              
190             =item * strand -- strand of product relative to the ref. sequence (isPCR, ipcress)
191              
192             =item * amplicon -- returns the PCR product (isPCR only)
193              
194             =back
195              
196             =cut
197              
198 0     0 1   my $self = shift;
199 0           return $self->error('method not implemented');
200             }
201              
202             1;
203              
204             # -------------------------------------------------------------------
205              
206             =pod
207              
208             =head1 AUTHOR
209              
210             Copyright (c) 2003-2009 Sheldon McKay Emckays@cshl.eduE,
211             Ken Youens-Clark Ekclark@cpan.orgE.
212              
213             =head1 LICENSE
214              
215             This program is free software; you can redistribute it and/or modify
216             it under the terms of the GNU General Public License as published by
217             the Free Software Foundation; version 3 or any later version.
218              
219             This program is distributed in the hope that it will be useful, but
220             WITHOUT ANY WARRANTY; without even the implied warranty of
221             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
222             General Public License for more details.
223              
224             You should have received a copy of the GNU General Public License
225             along with this program; if not, write to the Free Software
226             Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
227             USA.
228              
229             =head1 SEE ALSO
230              
231             Bio::PrimerDesigner.
232              
233             =cut