[Bioperl-l] primer3, SeqIO::primer3, PrimedSeq, and SeqFeature::Primer

Chad Matsalla chad@sausage.usask.ca
Fri, 9 Aug 2002 00:12:27 -0600 (CST)


Hello to all from sunny Edmonton (ha!),

I frequently work with the primer3 program to design primers. This, of
course, led to the consideration of SeqIO and other modules that I could
use to:

1. create input files for primer3
2. parse output files from primer3
3. run primer3


I have commited several modules and would like to get opinions on how
this type of subsystem might be constructed and how it should behave.

After some discussions with Hilmar at ISMB (thanks Hilmar!), I have
either completely or partially implemented the above in this way:

1. There will be a Bio::Tools::Run::Primer3 that will handle:
a) the construction of input files that will be used by primer3 to
design primers
b) the actual running of primer3.

I have included some sample code that models how I think that this
should work[1].

2. There will be a Bio::SeqFeature::Primer that will model primers
placed on a sequence. Bio::SeqFeature::Primer will also contain data
that pertains to things that primer3 returns for each primer when they
are designed.

3. There will be a Bio::Seq::PrimedSeq that will contain attributes that
pertain to the target sequence-primer complex. PrimedSeq will contain at
least the following features:
a) a Seq object representing the target sequence
b) two Bio::SeqFeature::Primer objects representing the primer sequences
and related data
c) another Seq object representing the amplified sequence if the caller
requests it.
d) information that was provided by primer3 pertaining to the
primer-sequence complex.

4. There will be a Bio::SeqIO::primer3 that will read the outputfiles
from primer3 and return a stream of Bio::Seq::PrimedSeq objects. I have
included sample code[2].


Does anybody have any comments? I will be working on this for the next
couple of days and committing things so that there is code to determine
if this scheme will work in general.

Thanks,

Chad Matsalla


Code fragments- note that these do not work at this time but are
representative of how i think these modules should behave.

[1] Code for constructing primer3 input files and then running primer3

my $primerhandle = new Bio::Tools::Run::Primer3(
	-path_to_primer3 => '/usr/local/bin/primer3');

my $target_sequence = new Bio::Tools::Seq(
	-seq => 'atcgatctacgtcgtagtagctgatcta',
	-display_id => 'chads_kewl_sequence');

my $target_sequence2 = new Bio::Tools::Seq(
	-seq => 'atgctacgtacgtagctagtgatcgtgtacac',
	-display_id => 'chads_other_sequence');

$primerhandle->add_target( -seq => $target_sequence,
	-amplification_region_start => 6,
	-amplification_region_length => 18 );

$primerhandle->add_target( -seq => $target_sequence2,
	-amplification_region_start => 10,
	-amplification_target_length => 8);

        # i plan the writing of the output file to be optional.
$primerhandle->write_output_file(-name => 'chads_primer_input.txt');
$primerhandle->run_primer3(-infile => 'chads_primer_input.txt',
	-outfile => 'chads_primer_output.txt');


[2] Code for parsing primer3 output files

my $primerstream = new Bio::SeqIO(
	-file => "<chads_primer_output.txt",
	-format => 'primer3');

my ($error,$current ,@all_primers);
while ($current = $primerstream->next_seq()) {
        if ($error = $current_primer->get_left_primer()->get_error() ) {
             print("The left primer could not be constructed because: ");
             print($current->get_left_primer()->get_error()."\n");
        }
        else {
                print("The left primer sequence is: ");
                print( $current->get_left_primer()->get_seq()."\n");
        }
}