The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.




  # design some primers.
  # the output will be put into temp.out
  use Bio::Tools::Run::Primer3Redux;
  use Bio::SeqIO;

  my $seqio = Bio::SeqIO->new(-file=>'data/dna1.fa');
  my $seq = $seqio->next_seq;

  my $primer3 = Bio::Tools::Run::Primer3Redux->new(-outfile => "temp.out",
                                            -path => "/usr/bin/primer3_core");

  # or after the fact you can change the program_name

  unless ($primer3->executable) {
    print STDERR "primer3 can not be found. Is it installed?\n";

  # set the maximum and minimum Tm of the primer
  $primer3->add_targets('PRIMER_MIN_TM'=>56, 'PRIMER_MAX_TM'=>90);

  # Design the primers. This runs primer3 and returns a
  # Bio::Tools::Primer3::result object with the results
  # Primer3 can run in several modes (see explanation for
  # 'PRIMER_TASK' in the primer3 doccumentation). To run a task,
  # either call it by its PRIMER_TASK name as in these examples:
  $pcr_primer_results = $primer3->pick_pcr_primers($seq);
  $pcr_and_hyb_results = $primer3->pick_pcr_primers_and_hyb_probe( $seq );
  $check_results = $primer3->check_primers();

  # Alternatively, explicitly set the PRIMER_TASK parameter and
  # use the generic 'run' method (this is mainly here for backwards
  # compatibility) :
  $primer3->PRIMER_TASK( 'pick_left_only' );
  $result = $primer3->run( $seq );

  # If no task is set and the 'run' method is called, primer3 will default to
  # pick pcr primers.

  # see the Bio::Tools::Primer3Redux POD for
  # things that you can get from this. For example:

  print "There were ", $results->num_primer_pairs, " primer pairs\n";


Bio::Tools::Run::Primer3Redux creates the input files needed to design primers using primer3 and provides mechanisms to access data in the primer3 output files.

This module a refactoring of the original BioPerl primer3 tools, themselves a refactoring of the original Primer3 module written by Rob Edwards. See my @ALLOWED_TASKS = qw( pick_pcr_primers pick_detection_primers check_primers pick_primer_list pick_sequencing_primers pick_cloning_primers pick_discriminative_primers pick_pcr_primers_and_hyb_probe pick_left_only pick_right_only pick_hyb_probe_only ); for details and to download the software. This module should work for primer3 release 1 and above but is not guaranteed to work with earlier versions.


Bio::Tools::Run::Primer3Redux - Create input for and work with the output from the program primer3


Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated.                  - General discussion             - About the mailing lists


Please direct usage questions or support issues to the mailing list:

rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web:


Chris Fields cjfields-at-bioperl-dot-org

Refactored from the original Primer3 parser by Rob Edwards, which in turn was based heavily on work of Chad Matsalla.


Rob Edwards Chad Matsalla Shawn Hoon Jason Stajich Brian Osborne Chris Fields cjfields-at-bioperl-dot-org Frank Schwach




The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


 Title   : new()
 Usage   : my $primer3 = Bio::Tools::Run::Primer3->new(-file=>$file) to read
           a primer3 output file.
           my $primer3 = Bio::Tools::Run::Primer3->new(-seq=>sequence object)
           design primers against sequence
 Function: Start primer3 working and adds a sequence. At the moment it
           will not clear out the old sequence, but I suppose it should.
 Returns : Does not return anything. If called with a filename will allow
           you to retrieve the results
 Args    : -outfile : file name send output results to
           -path    : path to primer3 executable
           -p3_settings_file :(optional) path to the settings file. Supported only by primer3 version 2 or above.
           -verbose :(optional) boolean value to set verbose output.


 Title   : program_name
 Usage   : $primer3->program_name()
 Function: holds the program name
 Returns:  string
 Args    : None


 Title   : program_dir
 Usage   : $primer3->program_dir($dir)
 Function: returns the program directory, which may also be obtained from ENV variable.
 Returns :  string
 Args    :


 Title   : version
 Usage   : $v = $prog->version();
 Function: Determine the version number of the program
 Example :
 Returns : float or undef
 Args    : none


 Title   : set_parameters()
 Usage   : $primer3->set_parameters(key=>value)
 Function: Sets parameters for the input file
 Returns : Returns the number of arguments added
 Args    : See the primer3 docs.
 Notes   : To set individual parameters use the associated method:


 Title    : get_parameters
 Usage    : $obj->get_parameters
 Function :
 Returns  :
 Args     :


 Title   : reset_parameters()
 Usage   : $primer3->reset_parameters()
 Function: Resets all parameters to be undef
 Returns : none
 Args    : none; to reset specific targets call the specific method for that
           target (i.e. $primer3->PRIMER_MAX_TM(undef))


 Title  : p3settingsfile()
 Usage  : $primer3->p3settingsfile($file_path);
 Function   : Getter/Setter for the Primer3 settings file.
 Returns    : A string containing the path of the named settings file.
 Args   : $file_path A valid file path to the settings file.
 Note   : This argument only works in primer3 version 2 or above.


 Title   : run
 Usage   : $primer3->run;
 Function: Generic run method for the primer3 program. The PRIMER_TASK
           must be defined either in the parameter set or it defaults to
 Returns : A Bio::Tools::Primer3 object containing the results.
           See the Bio::Tools::Primer3 documentation for those functions.
 Args    : Bio::Seq object(s) to use as SEQUENCE_TEMPLATE(s)


 Title   : _do_run
 Usage   : INTERNAL
 Function: Generate input file and run the primer3 program.
 Returns : A Bio::Tools::Primer3 object containing the results.
           See the Bio::Tools::Primer3 documentation for those functions.
 Args    : sequence or ref to array of sequences, [task]
           If 'task' given, parameter 'PRIMER_TASK' is set to the given task,
           otherwise, the 'PRIMER_TASK' parameter is used to detmine what to do.
           If that too isn't set the primer3 will default to pick_pcr_primers


cjfields <>


This software is copyright (c) 2011 by Chris Fields.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.