File Coverage

blib/lib/Bio/Tools/Run/Primer3.pm
Criterion Covered Total %
statement 50 177 28.2
branch 12 96 12.5
condition 0 8 0.0
subroutine 11 17 64.7
pod 7 7 100.0
total 80 305 26.2


line stmt bran cond sub pod time code
1             #
2             # This is the original copyright statement. I have relied on Chad's module
3             # extensively for this module.
4             #
5             # Copyright (c) 1997-2001 bioperl, Chad Matsalla. All Rights Reserved.
6             # This module is free software; you can redistribute it and/or
7             # modify it under the same terms as Perl itself.
8             #
9             # Copyright Chad Matsalla
10             #
11             # You may distribute this module under the same terms as perl itself
12             # POD documentation - main docs before the code
13             #
14             # But I have modified lots of it, so I guess I should add:
15             #
16             # Copyright (c) 2003 bioperl, Rob Edwards. All Rights Reserved.
17             # This module is free software; you can redistribute it and/or
18             # modify it under the same terms as Perl itself.
19             #
20             # Copyright Rob Edwards
21             #
22             # You may distribute this module under the same terms as perl itself
23             # POD documentation - main docs before the code
24              
25             =head1 NAME
26              
27             Bio::Tools::Run::Primer3 - Create input for and work with the output
28             from the program primer3
29              
30             =head1 SYNOPSIS
31              
32             Bio::Tools::Primer3 creates the input files needed to design primers
33             using primer3 and provides mechanisms to access data in the primer3
34             output files.
35              
36             This module provides a bioperl interface to the program primer3. See
37             http://frodo.wi.mit.edu/primer3/primer3_code.html for
38             details and to download the software. This module only works for
39             primer3 release 1 but is not guaranteed to work with earlier versions.
40              
41             # design some primers.
42             # the output will be put into temp.out
43             use Bio::Tools::Run::Primer3;
44             use Bio::SeqIO;
45              
46             my $seqio = Bio::SeqIO->new(-file=>'data/dna1.fa');
47             my $seq = $seqio->next_seq;
48             my $primer3 = Bio::Tools::Run::Primer3->new(-seq => $seq,
49             -outfile => "temp.out",
50             -path => "/usr/bin/primer3_core");
51              
52             # or after the fact you can change the program_name
53             $primer3->program_name('my_suprefast_primer3');
54              
55             unless ($primer3->executable) {
56             print STDERR "primer3 can not be found. Is it installed?\n";
57             exit(-1)
58             }
59              
60             # what are the arguments, and what do they mean?
61             my $args = $primer3->arguments;
62              
63             print "ARGUMENT\tMEANING\n";
64             foreach my $key (keys %{$args}) {print "$key\t", $$args{$key}, "\n"}
65              
66             # set the maximum and minimum Tm of the primer
67             $primer3->add_targets('PRIMER_MIN_TM'=>56, 'PRIMER_MAX_TM'=>90);
68              
69             # design the primers. This runs primer3 and returns a
70             # Bio::Tools::Run::Primer3 object with the results
71             $results = $primer3->run;
72              
73             # see the Bio::Tools::Run::Primer3 pod for
74             # things that you can get from this. For example:
75              
76             print "There were ", $results->number_of_results, " primers\n";
77              
78             Bio::Tools::Run::Primer3 creates the input files needed to design primers
79             using primer3 and provides mechanisms to access data in the primer3
80             output files.
81              
82             This module provides a bioperl interface to the program primer3. See
83             http://www-genome.wi.mit.edu/genome_software/other/primer3.html for
84             details and to download the software.
85              
86             This module is based on one written by Chad Matsalla
87             (bioinformatics1@dieselwurks.com). I have ripped some of his code, and
88             added a lot of my own. I hope he is not mad at me!
89              
90             =head1 FEEDBACK
91              
92             =head2 Mailing Lists
93              
94             User feedback is an integral part of the evolution of this and other
95             Bioperl modules. Send your comments and suggestions preferably to one
96             of the Bioperl mailing lists. Your participation is much appreciated.
97              
98             bioperl-l@bioperl.org - General discussion
99             http://www.bioperl.org/MailList.html - About the mailing lists
100              
101             =head2 Support
102              
103             Please direct usage questions or support issues to the mailing list:
104              
105             I
106              
107             rather than to the module maintainer directly. Many experienced and
108             reponsive experts will be able look at the problem and quickly
109             address it. Please include a thorough description of the problem
110             with code and data examples if at all possible.
111              
112             =head2 Reporting Bugs
113              
114             Report bugs to the Bioperl bug tracking system to help us keep track
115             the bugs and their resolution. Bug reports can be submitted via the
116             web:
117              
118             http://redmine.open-bio.org/projects/bioperl/
119              
120             =head1 AUTHOR
121              
122             Rob Edwards
123              
124             redwards@utmem.edu
125              
126             Based heavily on work of Chad Matsalla
127              
128             bioinformatics1@dieselwurks.com
129              
130             =head1 CONTRIBUTORS
131              
132             Shawn Hoon shawnh-at-stanford.edu
133             Jason Stajich jason-at-bioperl.org
134             Brian Osborne osborne1-at-optonline.net
135              
136             =head1 SEE ALSO
137              
138             L
139              
140             =head1 APPENDIX
141              
142             The rest of the documentation details each of the object methods.
143             Internal methods are usually preceded with a _
144              
145             =cut
146              
147             # Let the code begin...
148              
149              
150             package Bio::Tools::Run::Primer3;
151              
152 1     1   104942 use vars qw(@ISA);
  1         1  
  1         35  
153 1     1   3 use strict;
  1         1  
  1         14  
154 1     1   399 use Bio::Root::Root;
  1         14911  
  1         25  
155 1     1   426 use Bio::Tools::Primer3;
  1         58583  
  1         23  
156 1     1   388 use Bio::Tools::Run::WrapperBase;
  1         1  
  1         33  
157 1     1   5 use File::Spec;
  1         1  
  1         17  
158              
159 1     1   2 use vars qw($AUTOLOAD @ISA @PRIMER3_PARAMS $PROGRAMNAME %OK_FIELD);
  1         2  
  1         141  
160              
161             @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
162              
163              
164             BEGIN {
165 1     1   1 $PROGRAMNAME = 'primer3';
166 1         12 @PRIMER3_PARAMS=qw( PROGRAM EXCLUDED_REGION INCLUDED_REGION
167             PRIMER_COMMENT PRIMER_DNA_CONC PRIMER_EXPLAIN_FLAG PRIMER_FILE_FLAG
168             PRIMER_FIRST_BASE_INDEX PRIMER_GC_CLAMP
169             PRIMER_INTERNAL_OLIGO_DNA_CONC PRIMER_INTERNAL_OLIGO_EXCLUDED_REGION
170             PRIMER_INTERNAL_OLIGO_INPUT PRIMER_INTERNAL_OLIGO_MAX_GC
171             PRIMER_INTERNAL_OLIGO_MAX_MISHYB PRIMER_INTERNAL_OLIGO_MAX_POLY_X
172             PRIMER_INTERNAL_OLIGO_MAX_SIZE PRIMER_INTERNAL_OLIGO_MAX_TM
173             PRIMER_INTERNAL_OLIGO_MIN_GC PRIMER_INTERNAL_OLIGO_MIN_QUALITY
174             PRIMER_INTERNAL_OLIGO_MIN_SIZE PRIMER_INTERNAL_OLIGO_MIN_TM
175             PRIMER_INTERNAL_OLIGO_MISHYB_LIBRARY
176             PRIMER_INTERNAL_OLIGO_OPT_GC_PERCENT PRIMER_INTERNAL_OLIGO_OPT_SIZE
177             PRIMER_INTERNAL_OLIGO_OPT_TM PRIMER_INTERNAL_OLIGO_SALT_CONC
178             PRIMER_INTERNAL_OLIGO_SELF_ANY PRIMER_INTERNAL_OLIGO_SELF_END
179             PRIMER_IO_WT_COMPL_ANY PRIMER_IO_WT_COMPL_END PRIMER_IO_WT_END_QUAL
180             PRIMER_IO_WT_GC_PERCENT_GT PRIMER_IO_WT_GC_PERCENT_LT
181             PRIMER_IO_WT_NUM_NS PRIMER_IO_WT_REP_SIM PRIMER_IO_WT_SEQ_QUAL
182             PRIMER_IO_WT_SIZE_GT PRIMER_IO_WT_SIZE_LT PRIMER_IO_WT_TM_GT
183             PRIMER_IO_WT_TM_LT PRIMER_LEFT_INPUT PRIMER_LIBERAL_BASE
184             PRIMER_MAX_DIFF_TM PRIMER_MAX_END_STABILITY PRIMER_MAX_GC
185             PRIMER_MAX_MISPRIMING PRIMER_MAX_POLY_X PRIMER_MAX_SIZE PRIMER_MAX_TM
186             PRIMER_MIN_END_QUALITY PRIMER_MIN_GC PRIMER_MIN_QUALITY
187             PRIMER_MIN_SIZE PRIMER_MIN_TM PRIMER_MISPRIMING_LIBRARY
188             PRIMER_NUM_NS_ACCEPTED PRIMER_NUM_RETURN PRIMER_OPT_GC_PERCENT
189             PRIMER_OPT_SIZE PRIMER_OPT_TM PRIMER_PAIR_MAX_MISPRIMING
190             PRIMER_PAIR_WT_COMPL_ANY PRIMER_PAIR_WT_COMPL_END
191             PRIMER_PAIR_WT_DIFF_TM PRIMER_PAIR_WT_IO_PENALTY
192             PRIMER_PAIR_WT_PRODUCT_SIZE_GT PRIMER_PAIR_WT_PRODUCT_SIZE_LT
193             PRIMER_PAIR_WT_PRODUCT_TM_GT PRIMER_PAIR_WT_PRODUCT_TM_LT
194             PRIMER_PAIR_WT_PR_PENALTY PRIMER_PAIR_WT_REP_SIM PRIMER_PICK_ANYWAY
195             PRIMER_PICK_INTERNAL_OLIGO PRIMER_PRODUCT_MAX_TM
196             PRIMER_PRODUCT_MIN_TM PRIMER_PRODUCT_OPT_SIZE PRIMER_PRODUCT_OPT_TM
197             PRIMER_PRODUCT_SIZE_RANGE PRIMER_QUALITY_RANGE_MAX
198             PRIMER_QUALITY_RANGE_MIN PRIMER_RIGHT_INPUT PRIMER_SALT_CONC
199             PRIMER_SELF_ANY PRIMER_SELF_END PRIMER_SEQUENCE_ID
200             PRIMER_SEQUENCE_QUALITY PRIMER_START_CODON_POSITION PRIMER_TASK
201             PRIMER_WT_COMPL_ANY PRIMER_WT_COMPL_END PRIMER_WT_END_QUAL
202             PRIMER_WT_END_STABILITY PRIMER_WT_GC_PERCENT_GT
203             PRIMER_WT_GC_PERCENT_LT PRIMER_WT_NUM_NS PRIMER_WT_POS_PENALTY
204             PRIMER_WT_REP_SIM PRIMER_WT_SEQ_QUAL PRIMER_WT_SIZE_GT
205             PRIMER_WT_SIZE_LT PRIMER_WT_TM_GT PRIMER_WT_TM_LT SEQUENCE TARGET
206             PRIMER_DEFAULT_PRODUCT
207             PRIMER_DEFAULT_SIZE
208             PRIMER_INSIDE_PENALTY
209             PRIMER_INTERNAL_OLIGO_MAX_TEMPLATE_MISHYB
210             PRIMER_OUTSIDE_PENALTY
211             PRIMER_LIB_AMBIGUITY_CODES_CONSENSUS
212             PRIMER_MAX_TEMPLATE_MISPRIMING
213             PRIMER_PAIR_MAX_TEMPLATE_MISPRIMING
214             PRIMER_PAIR_WT_TEMPLATE_MISPRIMING
215             PRIMER_WT_TEMPLATE_MISPRIMING
216             );
217              
218 1         2 foreach my $attr (@PRIMER3_PARAMS) {$OK_FIELD{$attr}++}
  114         1676  
219             }
220              
221             sub AUTOLOAD {
222 0     0   0 my $self = shift;
223 0         0 my $attr = $AUTOLOAD;
224 0         0 $attr =~ s/.*:://;
225 0         0 $attr = uc $attr;
226 0 0       0 $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
227 0 0       0 $self->{$attr} = shift if @_;
228 0         0 return $self->{$attr};
229             }
230              
231              
232             =head2 new()
233              
234             Title : new()
235             Usage : my $primer3 = Bio::Tools::Run::Primer3->new(-file=>$file) to read
236             a primer3 output file.
237             my $primer3 = Bio::Tools::Run::Primer3->new(-seq=>sequence object)
238             design primers against sequence
239             Function: Start primer3 working and adds a sequence. At the moment it
240             will not clear out the old sequence, but I suppose it should.
241             Returns : Does not return anything. If called with a filename will allow
242             you to retrieve the results
243             Args : -seq (optional) Bio::Seq object of sequence. This is required
244             to run primer3 but can be added later with add_targets()
245             -outfile file name to output results to (can also be added
246             with $primer3->outfile_name
247             -path path to primer3 executable, including program name, e.g.
248             "/usr/bin/primer3_core". This can also be set with program_name
249             and program_dir
250             -verbose (optional) set verbose output
251             Notes :
252              
253             =cut
254              
255              
256             sub new {
257 1     1 1 2892 my($class,%args) = @_;
258 1         8 my $self = $class->SUPER::new(%args);
259 1         22 $self->io->_initialize_io();
260              
261 1 50       21 $self->program_name($args{-program}) if defined $args{'-program'};
262              
263 1 50       4 if ($args{'-verbose'}) {$self->{'verbose'}=1}
  0         0  
264 1 50       2 if ($args{'-seq'}) {
265 1         2 $self->{'seqobject'}=$args{'-seq'};
266 1         1 my @input;
267             push (@input, ("PRIMER_SEQUENCE_ID=".$self->{'seqobject'}->id),
268 1         4 ("SEQUENCE=".$self->{'seqobject'}->seq));
269 1         25 $self->{'primer3_input'}=\@input;
270             }
271 1 50       3 if ($args{'-outfile'}) {$self->{_outfilename}=$args{'-outfile'}}
  0         0  
272 1 50       2 if ($args{'-path'}) {
273            
274 0         0 my (undef,$path,$prog) = File::Spec->splitpath($args{'-path'});
275            
276             # For Windows system, $path better (Letter disk not truncated)
277 0 0       0 if ( $^O =~ m{mswin}i ) {
278 0         0 require File::Basename;
279 0         0 $path = File::Basename::dirname( $args{'-path'} );
280 0         0 $prog = File::Basename::basename( $args{'-path'} );
281             }
282            
283 0         0 $self->program_dir($path);
284 0         0 $self->program_name($prog);
285             }
286 1         4 return $self;
287             }
288              
289             =head2 program_name
290              
291             Title : program_name
292             Usage : $primer3->program_name()
293             Function: holds the program name
294             Returns: string
295             Args : None
296              
297             =cut
298              
299             sub program_name {
300 6     6 1 6 my $self = shift;
301 6 50       8 return $self->{'program_name'} = shift @_ if @_;
302 6 50       11 return $self->{'program_name'} if $self->{'program_name'};
303 6         9 for (qw(primer3 primer3_core)) {
304 12 50       674 if ($self->io->exists_exe($_)) {
305 0         0 $PROGRAMNAME = $_;
306 0         0 last;
307             }
308             }
309             # don't set permanently, use global
310 6         541 return $PROGRAMNAME;
311             }
312              
313             =head2 program_dir
314              
315             Title : program_dir
316             Usage : $primer3->program_dir($dir)
317             Function: returns the program directory, which may also be obtained from ENV variable.
318             Returns : string
319             Args :
320              
321             =cut
322              
323             sub program_dir {
324 5     5 1 5 my ($self, $dir) = @_;
325 5 50       8 if ($dir) {
326 0         0 $self->{'program_dir'}=$dir;
327             }
328            
329             # we need to stop here if we know what the answer is, otherwise we can
330             # never set it and then call it later
331 5 100       15 return $self->{'program_dir'} if $self->{'program_dir'};
332            
333 1 50       3 if ($ENV{PRIMER3}) {
334 0         0 $self->{'program_dir'} = Bio::Root::IO->catfile($ENV{PRIMER3});
335             } else {
336 1         3 $self->{'program_dir'} = Bio::Root::IO->catfile('usr','local','bin');
337             }
338            
339 1         16 return $self->{'program_dir'}
340             }
341              
342              
343             =head2 add_targets()
344              
345             Title : add_targets()
346             Usage : $primer3->add_targets(key=>value)
347             Function: Add any legal value to the input command line.
348             Returns : Returns the number of arguments added.
349             Args : Use $primer3->arguments to find a list of all the values
350             that are allowed, or see the primer3 docs.
351             Notes : This will only do limited error checking at the moment,
352             but it should work.
353              
354             =cut
355              
356              
357             sub add_targets {
358 0     0 1   my ($self, %args)=@_;
359 0           my $added_args; # a count of what we have added.
360 0           my $inputarray = $self->{'primer3_input'};
361 0           foreach my $key (keys %args) {
362             # we will allow them to add a sequence before checking for arguments
363 0 0 0       if ((uc($key) eq "-SEQ") || (uc($key) eq "-SEQUENCE")) {
364             # adding a new sequence. We need to separate them with an =
365 0           $self->{'seqobject'}=$args{$key};
366 0 0         if (defined $$inputarray[0]) {push (@$inputarray, "=")}
  0            
367             push (@$inputarray, ("PRIMER_SEQUENCE_ID=".
368 0           $self->{'seqobject'}->id),("SEQUENCE=".$self->{'seqobject'}->seq));
369 0           next;
370             }
371              
372 0 0         unless ($self->{'no_param_checks'}) {
373 0 0         unless ($OK_FIELD{$key}) {
374 0           $self->warn("Parameter $key is not a valid Primer3 parameter");
375 0           next}
376             }
377              
378 0 0         if (uc($key) eq "INCLUDED_REGION") {
    0          
    0          
    0          
379             # this must be a comma separated start, length.
380 0           my $sequencelength;
381             # we don't have a length, hence we need to add the length of the
382             # sequence less the start.
383 0           foreach my $input (@$inputarray) {
384 0 0         if ($input =~ /SEQUENCE=(.*)/) {$sequencelength=length($1)}
  0            
385             }
386            
387 0 0         if (!$args{$key}) {$args{$key}="0," . $sequencelength}
  0 0          
388             elsif ($args{$key} !~ /\,/) {
389 0           my $length_of_included = $sequencelength-$args{$key};
390 0           $args{$key} .= ",".$length_of_included;
391             }
392             }
393             elsif (uc($key) eq "PRIMER_MIN_SIZE") {
394             # minimum size must be less than MAX size and greater than zero
395 0 0         if (exists $args{"PRIMER_MAX_SIZE"}) {
396 0 0         unless ($args{"PRIMER_MAX_SIZE"} > $args{"PRIMER_MIN_SIZE"}) {
397 0           $self->warn('Maximum primer size (PRIMER_MAX_SIZE) must be greater than minimum primer size (PRIMER_MIN_SIZE)');
398             }
399             }
400 0 0         if ($args{$key} < 0) {
401 0           $self->warn('Minimum primer size (PRIMER_MIN_SIZE) must be greater than 0');
402             }
403             }
404             elsif ($key eq "PRIMER_MAX_SIZE") {
405 0 0         if ($args{$key}>35) {$self->warn('Maximum primer size (PRIMER_MAX_SIZE) must be less than 35')}
  0            
406             }
407             elsif (uc($key) eq "SEQUENCE") {
408             # Add seqobject if not present, since it is checked for by Bio::Tools::Primer3->next_primer()
409 0 0         $self->{'seqobject'}=Bio::Seq->new(-seq=>$args{$key}) if not defined($self->{'seqobject'});
410             }
411              
412             # need a check to see whether this is already in the array
413             # and finally add the argument to the list.
414              
415 0           my $toadd=uc($key)."=".$args{$key};
416 0           my $replaced; # don't add it if it is replacing something!
417             my @new_array;
418 0           foreach my $input (@$inputarray) {
419 0           my ($array_key, $array_value) = split '=', $input;
420 0 0         if (uc($array_key) eq uc($key)) {push @new_array, $toadd; $replaced=1}
  0            
  0            
421 0           else {push @new_array, $input}
422             }
423 0 0         unless ($replaced) {push @new_array, $toadd}
  0            
424 0           @$inputarray=@new_array;
425              
426 0 0         if ($self->{'verbose'}) {print STDERR "Updated ",
  0            
427             uc($key), " to $args{$key}\n"}
428 0           $added_args++;
429             }
430              
431 0           $self->{'primer3_input'}=$inputarray;
432 0           return $added_args;
433             }
434              
435             =head2 run()
436              
437             Title : run()
438             Usage : $primer3->run();
439             Function: Run the primer3 program with the arguments that you have supplied.
440             Returns : A Bio::Tools::Primer3 object containing the results.
441             Args : None.
442             Note : See the Bio::Tools::Primer3 documentation for those functions.
443              
444             =cut
445              
446             sub run {
447 0     0 1   my($self) = @_;
448 0           my $executable = $self->executable;
449 0           my $input = $self->{'primer3_input'};
450 0 0 0       unless ($executable && -e $executable) {
451 0 0         $self->throw("Executable was not found. Do not know where primer3 is!") if !$executable;
452 0           $self->throw("$executable was not found. Do not know where primer3 is!");
453 0           exit(-1);
454             }
455              
456             # note that I write this to a temp file because we need both read
457             # and write access to primer3, therefore,
458             # we can't use a simple pipe.
459              
460 0 0         if ($self->{'verbose'}) {print STDERR "TRYING\n",
461 0           join "\n", @{$self->{'primer3_input'}}, "=\n"}
  0            
462              
463             # make a temporary file and print the instructions to it.
464 0           my ($temphandle, $tempfile) = $self->io->tempfile;
465 0           print $temphandle join "\n", @{$self->{'primer3_input'}}, "=\n";
  0            
466 0           close($temphandle);
467              
468 0           my $executable_command = $executable;
469 0 0         if ( $executable =~ m{^[^\'\"]+(.+)[^\'\"]+$} ) {
470 0           $executable_command = "\"$executable\" < \"$tempfile\"|";
471             }
472              
473 0 0         open (RESULTS, $executable_command) || $self->throw("Can't open RESULTS");
474 0 0         if ($self->{'_outfilename'}) {
475             # I can't figure out how to use either of these to write the results out.
476             # neither work, what am I doing wrong or missing in the docs?
477             # $self->{output}=$self->_initialize_io(-file=>$self->{'outfile'});
478             # $self->{output}=$self->io;
479             # OK, for now, I will just do it myself, because I need this to
480             # check the parser :)
481             open (OUT, ">".$self->{'_outfilename'}) ||
482 0 0         $self->throw("Can't open ".$self->{'_outfilename'}." for writing");
483             }
484              
485 0           my @results;
486 0           while () {
487 0 0         if ($self->{'_outfilename'}) {
488             # this should work, but isn't
489             #$self->{output}->_print($_);
490 0           print OUT $_;
491             }
492 0           chomp;
493 0 0         next if( $_ eq '='); # skip over bolderio record terminator
494 0           my ($return, $value) = split('=',$_);
495 0           $self->{'results'}->{$return} = $value;
496             }
497 0           close RESULTS;
498              
499             # close the output file
500 0 0         if ($self->{'_outfilename'}) {
501 0           close OUT;
502             }
503              
504 0           $self->cleanup;
505             # convert the results to individual results
506 0           $self->{results_obj} = Bio::Tools::Primer3->new;
507 0           $self->{results_obj}->_set_variable('results', $self->{results});
508 0           $self->{results_obj}->_set_variable('seqobject', $self->{seqobject});
509              
510             # Bio::Tools::Primer3::_separate needs a hash of the primer3 arguments,
511             # with the arg as the key and the value as the value (surprise!).
512 0           my %input_hash = map {split '='} @{$self->{'primer3_input'}};
  0            
  0            
513 0           $self->{results_obj}->_set_variable('input_options', \%input_hash);
514 0           $self->{results_separated}= $self->{results_obj}->_separate();
515 0           return $self->{results_obj};
516             }
517              
518             =head2 arguments()
519              
520             Title : arguments()
521             Usage : $hashref = $primer3->arguments();
522             Function: Describes the options that you can set through Bio::Tools::Run::Primer3,
523             with a brief (one line) description of what they are and their
524             default values
525             Returns : A string (if an argument is supplied) or a reference to a hash.
526             Args : If supplied with an argument will return a string of its
527             description.
528             If no arguments are supplied, will return all the arguments as a
529             reference to a hash
530             Notes : Much of this is taken from the primer3 README file, and you should
531             read that file for a more detailed description.
532              
533             =cut
534              
535             sub arguments {
536 0     0 1   my ($self, $required) = @_;
537 0 0         unless ($self->{'input_options'}) {$self->_input_args}
  0            
538 0 0         if ($required) {return ${$self->{'input_options'}}{'$required'}}
  0            
  0            
539 0           else {return $self->{'input_options'}}
540             }
541              
542             =head2 version
543              
544             Title : version
545             Usage : $v = $prog->version();
546             Function: Determine the version number of the program
547             Example :
548             Returns : float or undef
549             Args : none
550              
551             =cut
552              
553             sub version {
554 0     0 1   my ($self) = @_;
555 0 0         return unless my $exe = $self->executable;
556 0 0         if (!defined $self->{'_progversion'}) {
557 0           my $string = `$exe -about 2>&1`;
558 0           my $v;
559 0 0         if ($string =~ m{primer3\s+release\s+([\d\.]+)}) {
560 0           $self->{'_progversion'} = $1;
561             }
562             }
563 0   0       return $self->{'_progversion'} || undef;
564             }
565              
566             =head2 _input_args()
567              
568             Title : _input_args()
569             Usage : an internal method to set the input arguments for Primer3
570             Function: Define a hash with keys for each of the input arguments and values
571             as a short one line description
572             Returns : A reference to a hash.
573             Args : None.
574             Notes : Much of this is taken from the primer3 README file, and you should
575             read that file for a more detailed description.
576              
577             =cut
578              
579             sub _input_args {
580 0     0     my($self) = shift;
581             # just return functions that we can set and what they are
582 0           my %hash=(
583             'PRIMER_SEQUENCE_ID'=>'(string, optional) an id. Optional. Note must be present if PRIMER_FILE_FLAG is set',
584             'SEQUENCE'=>'(nucleotide sequence, REQUIRED) The sequence itself. Cannot contain newlines',
585             'INCLUDED_REGION'=>'(interval, optional) Where to pick primers from. In form ,. Based on zero indexing!',
586             'TARGET'=>'(interval list, default empty) Regions that must be included in the product. The value should be a space-separated list of ,',
587             'EXCLUDED_REGION'=>'(interval list, default empty) Regions that must NOT be included in the product. The value should be a space-separated list of ,',
588             'PRIMER_COMMENT'=>'(string) This is ignored, so we will just save, and return it',
589             'PRIMER_SEQUENCE_QUALITY'=>'(quality list, default empty) A list of space separated integers with one per base. Could adapt a Phred object to this.',
590             'PRIMER_LEFT_INPUT'=>'(nucleotide sequence, default empty) If you know the left primer sequence, put it here',
591             'PRIMER_RIGHT_INPUT'=>'(nucleotide sequence, default empty) If you know the right primer sequence, put it here',
592             'PRIMER_START_CODON_POSITION'=>'(int, default -1000000) Location of known start codons for designing in frame primers.',
593             'PRIMER_PICK_ANYWAY'=>'boolean, default 0) Pick a primer, even if we have violated some constraints.',
594             'PRIMER_MISPRIMING_LIBRARY'=>'(string, optional) A file containing sequences to avoid amplifying. Should be fasta format, but see primer3 docs for constraints.',
595             'PRIMER_MAX_MISPRIMING'=>'(decimal,9999.99, default 12.00) Weighting for PRIMER_MISPRIMING_LIBRARY',
596             'PRIMER_PAIR_MAX_MISPRIMING'=>'(decimal,9999.99, default 24.00 Weighting for PRIMER_MISPRIMING_LIBRARY',
597             'PRIMER_PRODUCT_MAX_TM'=>'(float, default 1000000.0) The maximum allowed Tm of the product.',
598             'PRIMER_PRODUCT_MIN_TM'=>'(float, default -1000000.0) The minimum allowed Tm of the product',
599             'PRIMER_EXPLAIN_FLAG'=>'(boolean, default 0) If set it will print a bunch of information out.',
600             'PRIMER_PRODUCT_SIZE_RANGE'=>'(size range list, default 100-300) space separated list of product sizes eg - -',
601            
602             'PRIMER_DEFAULT_PRODUCT' => '(size range list, default 100-300)',
603             'PRIMER_PICK_INTERNAL_OLIGO'=>'(boolean, default 0) if set, a hybridization probe will be selected',
604             'PRIMER_GC_CLAMP'=>'(int, default 0) Number of Gs and Cs at the 3 prime end.',
605             'PRIMER_OPT_SIZE'=>'(int, default 20) Optimal primer size. Primers will be close to this value in length',
606             'PRIMER_DEFAULT_SIZE' => '(int, default 20)',
607             'PRIMER_MIN_SIZE'=>'(int, default 18) Minimum size. Must be 0 < PRIMER_MIN_SIZE < PRIMER_MAX_SIZE ',
608             'PRIMER_MAX_SIZE'=>'(int, default 27) Maximum size. Must be < 35.',
609             'PRIMER_OPT_TM'=>'(float, default 60.0C) Optimum Tm of a primer.',
610             'PRIMER_MIN_TM'=>'(float, default 57.0C) Minimum Tm of a primer',
611             'PRIMER_MAX_TM'=>'(float, default 63.0C) Maximum Tm of a primer',
612             'PRIMER_MAX_DIFF_TM'=>'(float, default 100.0C) acceptable difference in Tms',
613             'PRIMER_MIN_GC'=>'(float, default 20.0%) Minimum allowable GCs',
614             'PRIMER_OPT_GC_PERCENT'=>'(float, default 50.0%) Optimal GCs',
615             'PRIMER_MAX_GC'=>'(float, default 80.0%) Maximum allowable GCs',
616             'PRIMER_SALT_CONC'=>'(float, default 50.0 mM) Salt concentration required for Tm calcs.',
617             'PRIMER_DNA_CONC'=>'(float, default 50.0 nM) DNA concentration required for Tm calcs. ',
618             'PRIMER_NUM_NS_ACCEPTED'=>'(int, default 0) Maximum number of unknown bases (N) allowable in any primer.',
619             'PRIMER_SELF_ANY'=>'(decimal,9999.99, default 8.00) Maximum aligment score for within and between primers when checking for hairpin loops',
620             'PRIMER_SELF_END'=>'(decimal 9999.99, default 3.00) Maximum aligment score for within and between primers when checking for primer dimers',
621             'PRIMER_FILE_FLAG'=>'(boolean, default 0) Output .for and .rev with all acceptable forward and reverse primers',
622             'PRIMER_MAX_POLY_X'=>'(int, default 5) The maximum allowable length of a mononucleotide repeat.',
623             'PRIMER_LIBERAL_BASE'=>'(boolean, default 0) Use IUPAC codes (well, just change them to N). Note must also set PRIMER_NUM_NS_ACCEPTED',
624             'PRIMER_NUM_RETURN'=>'(int, default 5) Number of primers to return',
625             'PRIMER_FIRST_BASE_INDEX'=>'(int, default 0) Index of the first base. Do not change this or allow it to be changed, as we will have to mess with subseqs and whatnot.',
626             'PRIMER_MIN_QUALITY'=>'(int, default 0) Minimum sequence quality calculated from PRIMER_SEQUENCE_QUALITY',
627             'PRIMER_MIN_END_QUALITY'=>'(int, default 0) Minimum sequence quality calculated from PRIMER_SEQUENCE_QUALITY at 5 prime 5 bases',
628             'PRIMER_QUALITY_RANGE_MIN'=>'(int, default 0) Minimum sequence quality calculated from PRIMER_SEQUENCE_QUALITY',
629             'PRIMER_QUALITY_RANGE_MAX'=>'(int, default 100) Maximum sequence quality calculated from PRIMER_SEQUENCE_QUALITY',
630             'PRIMER_MAX_END_STABILITY'=>'(float 999.9999, default 100.0) Maximum stability for the five 3 prime bases of a primer. Bigger numbers mean more stable 3 prime ends.',
631             'PRIMER_PRODUCT_OPT_TM'=>'(float, default 0.0) Optimum melting temperature for the PCR product. 0 means no optimum.',
632             'PRIMER_PRODUCT_OPT_SIZE'=>'(int, default 0) Optimum size for the PCR product. 0 means no optimum.',
633             'PRIMER_TASK'=>'(string, default pick_pcr_primers) Choose from pick_pcr_primers, pick_pcr_primers_and_hyb_probe, pick_left_only, pick_right_only, pick_hyb_probe_only',
634             'PRIMER_WT_TM_GT'=>'(float, default 1.0) Penalty weight for primers with Tm over PRIMER_OPT_TM.',
635             'PRIMER_WT_TM_LT'=>'(float, default 1.0) Penalty weight for primers with Tm under PRIMER_OPT_TM.',
636             'PRIMER_WT_SIZE_LT'=>'(float, default 1.0) Penalty weight for primers shorter than PRIMER_OPT_SIZE.',
637             'PRIMER_WT_SIZE_GT'=>'(float, default 1.0) Penalty weight for primers longer than PRIMER_OPT_SIZE.',
638             'PRIMER_WT_GC_PERCENT_LT'=>'(float, default 1.0) Penalty weight for primers with GC percent greater than PRIMER_OPT_GC_PERCENT.',
639             'PRIMER_WT_GC_PERCENT_GT'=>'(float, default 1.0) Penalty weight for primers with GC percent greater than PRIMER_OPT_GC_PERCENT.',
640             'PRIMER_WT_COMPL_ANY'=>'(float, default 0.0)',
641             'PRIMER_WT_COMPL_END'=>'(float, default 0.0)',
642             'PRIMER_WT_NUM_NS'=>'(float, default 0.0)',
643             'PRIMER_WT_REP_SIM'=>'(float, default 0.0)',
644             'PRIMER_WT_SEQ_QUAL'=>'(float, default 0.0)',
645             'PRIMER_WT_END_QUAL'=>'(float, default 0.0)',
646             'PRIMER_WT_POS_PENALTY'=>'(float, default 0.0)',
647             'PRIMER_WT_END_STABILITY'=>'(float, default 0.0)',
648             'PRIMER_PAIR_WT_PR_PENALTY'=>'(float, default 1.0)',
649             'PRIMER_PAIR_WT_IO_PENALTY'=>'(float, default 0.0)',
650             'PRIMER_PAIR_WT_DIFF_TM'=>'(float, default 0.0)',
651             'PRIMER_PAIR_WT_COMPL_ANY'=>'(float, default 0.0)',
652             'PRIMER_PAIR_WT_COMPL_END'=>'(float, default 0.0)',
653             'PRIMER_PAIR_WT_PRODUCT_TM_LT'=>'(float, default 0.0)',
654             'PRIMER_PAIR_WT_PRODUCT_TM_GT'=>'(float, default 0.0)',
655             'PRIMER_PAIR_WT_PRODUCT_SIZE_GT'=>'(float, default 0.0)',
656             'PRIMER_PAIR_WT_PRODUCT_SIZE_LT'=>'(float, default 0.0)',
657             'PRIMER_PAIR_WT_REP_SIM'=>'(float, default 0.0)',
658             'PRIMER_INTERNAL_OLIGO_EXCLUDED_REGION'=>'(interval list, default empty) Internal oligos must ignore these regions',
659             'PRIMER_INTERNAL_OLIGO_INPUT'=>'(nucleotide sequence, default empty) Known sequence of an internal oligo',
660             'PRIMER_INTERNAL_OLIGO_OPT_SIZE'=>'(int, default 20)',
661             'PRIMER_INTERNAL_OLIGO_MIN_SIZE'=>'(int, default 18)',
662             'PRIMER_INTERNAL_OLIGO_MAX_SIZE'=>'(int, default 27)',
663             'PRIMER_INTERNAL_OLIGO_OPT_TM'=>'(float, default 60.0 degrees C)',
664             'PRIMER_INTERNAL_OLIGO_OPT_GC_PERCENT'=>'(float, default 50.0%)',
665             'PRIMER_INTERNAL_OLIGO_MIN_TM'=>'(float, default 57.0 degrees C)',
666             'PRIMER_INTERNAL_OLIGO_MAX_TM'=>'(float, default 63.0 degrees C)',
667             'PRIMER_INTERNAL_OLIGO_MIN_GC'=>'(float, default 20.0%)',
668             'PRIMER_INTERNAL_OLIGO_MAX_GC'=>'(float, default 80.0%)',
669             'PRIMER_INTERNAL_OLIGO_SALT_CONC'=>'(float, default 50.0 mM)',
670             'PRIMER_INTERNAL_OLIGO_DNA_CONC'=>'(float, default 50.0 nM)',
671             'PRIMER_INTERNAL_OLIGO_SELF_ANY'=>'(decimal 9999.99, default 12.00)',
672             'PRIMER_INTERNAL_OLIGO_MAX_POLY_X'=>'(int, default 5)',
673             'PRIMER_INTERNAL_OLIGO_SELF_END'=>'(decimal 9999.99, default 12.00)',
674             'PRIMER_INTERNAL_OLIGO_MISHYB_LIBRARY'=>'(string, optional)',
675             'PRIMER_INTERNAL_OLIGO_MAX_MISHYB'=>'(decimal,9999.99, default 12.00)',
676             'PRIMER_INTERNAL_OLIGO_MIN_QUALITY'=>'(int, default 0)',
677             'PRIMER_IO_WT_TM_GT'=>'(float, default 1.0)',
678             'PRIMER_IO_WT_TM_LT'=>'(float, default 1.0)',
679             'PRIMER_IO_WT_GC_PERCENT_GT'=>'(float, default 1.0)',
680             'PRIMER_IO_WT_GC_PERCENT_LT'=>'(float, default 1.0)',
681             'PRIMER_IO_WT_SIZE_LT'=>'(float, default 1.0)',
682             'PRIMER_IO_WT_SIZE_GT'=>'(float, default 1.0)',
683             'PRIMER_IO_WT_COMPL_ANY'=>'(float, default 0.0)',
684             'PRIMER_IO_WT_COMPL_END'=>'(float, default 0.0)',
685             'PRIMER_IO_WT_NUM_NS'=>'(float, default 0.0)',
686             'PRIMER_IO_WT_REP_SIM'=>'(float, default 0.0)',
687             'PRIMER_IO_WT_SEQ_QUAL'=>'(float, default 0.0)',
688             'PRIMER_IO_WT_END_QUAL'=>'(float, default 0.0)',
689             'PRIMER_INSIDE_PENALTY' => '(float, default -1.0)',
690             'PRIMER_INTERNAL_OLIGO_MAX_TEMPLATE_MISHYB' => '(decimal 9999.99, default 12.00)',
691             'PRIMER_OUTSIDE_PENALTY' => '(float, default 0.0)',
692             'PRIMER_LIB_AMBIGUITY_CODES_CONSENSUS' => '(boolean, default 1)',
693             'PRIMER_MAX_TEMPLATE_MISPRIMING' => '(decimal,9999.99, default -1.00)',
694             'PRIMER_PAIR_MAX_TEMPLATE_MISPRIMING' => '(decimal,9999.99, default -1.00)',
695             'PRIMER_PAIR_WT_TEMPLATE_MISPRIMING' => '(float, default 0.0)',
696             'PRIMER_WT_TEMPLATE_MISPRIMING' => '(float, default 0.0)'
697             );
698 0           $self->{'input_options'}=\%hash;
699 0           return \%hash;
700             }
701              
702             1;