++ed by:

11 PAUSE users
14 non-PAUSE users.

Christopher Fields
and 1 contributors


Bio::Seq::PrimedSeq - A representation of a sequence and two primers flanking a target region


  # The easiest way to use this is probably either, (i), get the
  # output from Bio::Tools::Run::Primer3, Bio::Tools::Primer3, or 
  # Bio::Tools::PCRSimulation:

      # For example, start with a fasta file
      use Bio::SeqIO;
      use Bio::Tools::Run::Primer3;

      my $file = shift || die "need a file to read";
      my $seqin = Bio::SeqIO->new(-file => $file);
      my $seq = $seqin->next_seq;

      # use primer3 to design some primers
      my $primer3run = Bio::Tools::Run::Primer3->new(-seq => $seq);
      $primer3run -> run; # run it with the default parameters

      # create a file to write the results to
      my $seqout = Bio::SeqIO->new(-file => ">primed_sequence.gbk", 
                                   -format => 'genbank');

      # now just get all the results and write them out.
      while (my $results = $primer3run->next_primer) {

  # Or, (ii), to create a genbank file for a sequence and its cognate
  # primers:

     use Bio::SeqIO;
     use Bio::Seq::PrimedSeq;

     # have a sequence file ($file) with the template, and two primers
     # that match it, in fasta format

     my $file = shift || die "$0 <file>";
     my $seqin = Bio::SeqIO->new(-file => $file);

     # read three sequences
     my ($template, $leftprimer, $rightprimer) =
           ($seqin->next_seq, $seqin->next_seq, $seqin->next_seq);
     # set up the primed sequence object
     my $primedseq = Bio::Seq::PrimedSeq->new(-seq => $template, 
                                              -left_primer => $leftprimer,
                                              -right_primer => $rightprimer);
     # open a file for output
     my $seqout = Bio::SeqIO->new(-file => ">primed_sequence.gbk",
                                  -format => 'genbank');
     # print the sequence out

  # This should output a genbank file with the two primers labeled.


This module is a slightly glorified capsule containing a primed sequence. It was created to address the fact that a primer is more than a seqfeature and there need to be ways to represent the primer-sequence complex and the behaviors and attributes that are associated with the complex.

The primers are represented as Bio::SeqFeature::Primer objects, and should be instantiated first.

A simple way to create a PrimedSeq object is as follows:

  my $primedseq = Bio::Seq::PrimedSeq->new(
          -seq          => $seq,  # Bio::Seq object,
          -left_primer  => $left, # Bio::SeqFeature::Primer object,
          -right_primer => $right # Bio::SeqFeature::Primer object,

From the PrimedSeq object you should be able to retrieve information about melting temperatures and what not on each of the primers and the amplicon.

This is based on the PrimedSeq.pm module started by Chad Matsalla, with additions/improvements by Rob Edwards.


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.

  bioperl-l@bioperl.org                  - General discussion
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

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:



Rob Edwards, redwards@utmem.edu

Based on a module written by Chad Matsalla, bioinformatics1@dieselwurks.com


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


 Title   : new()
 Usage   : $primed_sequence = Bio::SeqFeature::Primer->new( 
                                     -seq => $sequence,
                                     -left_primer => $left_primer,
                                     -right_primer => $right_primer);
 Function: A constructor for an object representing a primed sequence 
 Returns : A Bio::Seq::PrimedSeq object
 Args    :  -seq => a Bio::Seq object (required)
            -left_primer => a Bio::SeqFeature::Primer object (required)
            -right_primer => a Bio::SeqFeature::Primer object (required)

           Many other parameters can be included including all of the output
           parameters from the primer3 program. At the moment most of these
           parameters will not do anything.


 Title   : get_primer();
 Usage   : $primer = $primedseq->get_primer(l, left, left_primer, 
           -left_primer) to return the left primer or 
                $primer = $primedseq->get_primer(r, right, right_primer, 
           -right_primer) to return the right primer or
                $primer = $primedseq->get_primer(b, both, both_primers, 
           to return the left primer, right primer array
 Function: A getter for the left primer in thie PrimedSeq object.
 Returns : A Bio::SeqFeature::Primer object
 Args    : Either of (l, left, left_primer, -left_primer) to get left 
           Either of (r, right, right_primer, -right_primer) to get 
           right primer
                Either of (b, both, both_primers, -both_primers) to get 
           both primers. 
           Note that this is plural. [default]


 Title   : annotated_sequence
 Usage   : $annotated_sequence_object = $primedseq->annotated_sequence()
 Function: Get an annotated sequence object containg the left and right 
 Returns : An annotated sequence object or 0 if not defined.
 Args    : 
 Note    : Use this method to return a sequence object that you can write
           out (e.g. in GenBank format). See the example above.


 Title   : amplicon
 Usage   : my $amplicon = $primedseq->amplicon()
 Function: Retrieve the amplicon as a sequence object
 Returns : A seq object. To get the sequence use $amplicon->seq
 Args    : None
 Note    : 


 Title   : seq
 Usage   : my $seqobj = $primedseq->seq()
 Function: Retrieve the target sequence as a sequence object
 Returns : A seq object. To get the sequence use $seqobj->seq
 Args    : None
 Note    : 


 Title   : _place_seqs
 Usage   : $self->_place_seqs()
 Function: An internal method to place the primers on the sequence and 
           set up the ranges of the sequences
 Returns : Nothing
 Args    : None
 Note    : Internal use only


 Title   : _set_seqfeature
 Usage   : $self->_set_seqfeature()
 Function: An internal method to create Bio::SeqFeature::Generic objects
           for the primed seq
 Returns : Nothing
 Args    : None
 Note    : Internal use only. Should only call this once left and right 
           primers have been placed on the sequence. This will then set 
           them as sequence features so hopefully we can get a nice output 
           with write_seq.