Bio::Tools
Primer3
Summary
Bio::Tools::Primer3 - Create input for and work with the output from the
program primer3
Package variables
Privates (from "my" definitions)
$dumper = new Dumpvalue
Included modules
Inherit
Synopsis
Chad will put synopses here by the end of the second week of october, 2002.
Description
Bio::Tools::Primer3 creates the input files needed to design primers using
primer3 and provides mechanisms to access data in the primer3 output files.
Methods
Methods description
Title : new()
Usage :
Function:
Returns :
Args :
Notes : |
Title : next_primer()
Usage : $primer3 = $stream->next_primer()
Function: returns the next primer in the stream
Returns : Bio::Seq::PrimedSeq containing:
- 2 Bio::SeqFeature::Primer representing the primers
- 1 Bio::Seq representing the target sequence
- 1 Bio::Seq representing the amplified region
Args : NONE
Notes : |
Title : _create_primer_features()
Usage : &_create_primer_features()
Function: This is an internal method used by next_seq() to create the
Bio::SeqFeature::Primer objects necessary to represent the primers
themselves.
Returns : An array of 2 Bio::SeqFeature::Primer objects.
Args : None.
Notes : This is an internal method. Do not call this method. |
Title : get_amplified_region()
Usage : $primer->get_amplified_region()
Function: Returns a Bio::Seq object representing the sequence amplified
Returns : (I think) A Bio::Seq object
Args : None.
Notes : This is not implemented at this time.
Note to chad: implement this simple getter.
Developer notes: There obviously isn't a way for a single primer to know about
its amplified region unless it is paired with another primer. At this time
these object will generally be created with another so I will put in this
method. If there is no sequence null is returned.
THIS DOES NOT BELONG HERE. Put this into something else. |
Title : get_amplification_error()
Usage :
Function:
Returns :
Args :
Notes :
Developer Notes:
THIS DOES NOT BELONG HERE. Put this into something else. |
Title : _set_target()
Usage : &_set_target($self);
Function:
Returns :
Args :
Notes :
Developer Notes: Really I have no idea why I put this in here.
It can is referenced by new_deprecated and by run_primer3 |
Title : _read_file($self,$filename)
Usage :
Function:
Returns : A scalar containing the contents of $filename
Args : $self and the name of a file to parse.
Notes :
Developer notes: Honestly, I have no idea what this is for. |
Title : _parse_report()
Usage : &_parse_report($self,$filename);
Function: Parse a primer3 outfile and place everything into an object under
{primers} with PRIMER_SEQUENCE_ID being the name of the keys for the
{primers} hash.
Returns : Nothing.
Args : $self and the name of a file to parse.
Notes : |
Title : _construct_empty()
Usage : &_construct_empty($self);
Function: Construct an empty object that will be used to construct a primer3
input "file" so that it can be run.
Returns :
Args :
Notes : |
Title : add_target(%stuff)
Usage : $o_primer->add_target(%stuff);
Function: Add an target to the infile constructor.
Returns :
Args : A hash. Looks something like this:
$o_primer2->add_target(
-PRIMER_SEQUENCE_ID => "sN11902",
-PRIMER_COMMENT => "3831",
-SEQUENCE => "some_sequence",
-TARGET => "513,26",
-PRIMER_PRODUCT_SIZE_RANGE => "100-500",
-PRIMER_FILE_FLAG => "0",
-PRIMER_LIBERAL_BASE => "1",
-PRIMER_NUM_RETURN => "1",
-PRIMER_FIRST_BASE_INDEX => "1",
-PRIMER_EXPLAIN_FLAG => "1");
The add_target() method does not validate the things you put into
this parameter hash. Read the docs for Primer3 to see which fields
do what and how they should be used.
Notes : To design primers, first create a new CSM::Primer3 object with the
-construct_infile parameter. Then, add targets using this method
(add_target()) with the target hash as above in the Args: section.
Be careful. No validation will be done here. All of those parameters
will be fed straight into primer3.
Once you are done adding targets, invoke the function run_primer3().
Then retrieve the results using something like a loop around the array
from get_primer_sequence_IDs(); |
Title : get_primer_sequence_IDs()
Usage : $o_phred->get_primer_sequence_IDs();
Function: Return the primer sequence ID's. These normally correspond to
the name of a sequence in a database but can be whatever was used when
the primer3 infile was constructed.
Returns : An array containing the names of the primer sequence ID's
Args : None.
Notes : This would be used as the basis for an iterator to loop around each
primer that was designed. |
Title : dump_hash()
Usage : $o_primer->dump_hash();
Function: Dump out the CSM::Primer3 object.
Returns : Nothing.
Args : None.
Notes : Used extensively in debugging. |
Title : dump_infile_hash()
Usage : $o_primer->dump_infile_hash();
Function: Dump out the contents of the infile hash.
Returns : Nothing.
Args : None.
Notes : Used for debugging the construction of the infile. |
Methods code
sub new
{ my($class,@args) = @_;
my $self = $class->SUPER::new(@args);
my($filename) = $self->_rearrange([qw(FILE)],@args);
if (!$filename) {
print("Ahh grasshopper, you are planning to create a primer3 infile\n");
return $self;
}
$self->{filename} = $filename;
if (!-f $filename) {
print("That file doesn't exist. Bah.\n");
}
$self->_initialize_io( -file => $filename );
return $self;} |
sub next_primer
{ my $self = shift;
my $fh = $self->_fh();
my ($line,%primer);
while ($line = $self->_readline()) {
chomp ($line);
last if ($line =~ /^=/);
$line =~ m/(^.*)\=(.*$)/;
$primer{$1} = $2;
}
my ($left,$right) = &_create_primer_features(\%primer);
my $sequence = Bio::Seq->new(-seq => $primer{SEQUENCE},
-id => $primer{PRIMER_SEQUENCE_ID});
my $primedseq = new Bio::Seq::PrimedSeq(
-target_sequence => $sequence,
-left_primer => $left,
-right_primer => $right,
-primer_sequence_id => $primer{PRIMER_SEQUENCE_ID},
-primer_comment => $primer{PRIMER_COMMENT},
-target => $primer{TARGET},
-primer_product_size_range => $primer{PRIMER_PRODUCT_SIZE_RANGE},
-primer_file_flag => $primer{PRIMER_FILE_FLAG},
-primer_liberal_base => $primer{PRIMER_LIBERAL_BASE},
-primer_num_return => $primer{PRIMER_NUM_RETURN},
-primer_first_base_index => $primer{PRIMER_FIRST_BASE_INDEX},
-primer_explain_flag => $primer{PRIMER_EXPLAIN_FLAG},
-primer_pair_compl_any => $primer{PRIMER_PAIR_COMPL_ANY},
-primer_pair_compl_end => $primer{PRIMER_PAIR_COMPL_END},
-primer_product_size => $primer{PRIMER_PRODUCT_SIZE}
);
return $primedseq;} |
sub _create_primer_features
{ my $rdat = shift;
my (%left,%right,$updir,$downdir,$var,$trunc);
my @variables = qw(
PRIMER_DIRECTION
PRIMER_DIRECTION_END_STABILITY
PRIMER_DIRECTION_EXPLAIN
PRIMER_DIRECTION_GC_PERCENT
PRIMER_DIRECTION_PENALTY
PRIMER_DIRECTION_SELF_ANY
PRIMER_DIRECTION_SELF_END
PRIMER_DIRECTION_SEQUENCE
PRIMER_DIRECTION_TM
PRIMER_FIRST_BASE_INDEX
);
foreach $updir (qw(LEFT RIGHT)) {
my %dat;
foreach (@variables) {
($var = $_) =~ s/DIRECTION/$updir/e;
if (/^PRIMER_DIRECTION$/) {
$trunc = "PRIMER";
}
elsif (/^PRIMER_FIRST_BASE_INDEX/) {
$trunc = "FIRST_BASE_INDEX";
}
else {
($trunc = $_) =~ s/PRIMER_DIRECTION_//;
}
$dat{"-$trunc"} = $rdat->{$var};
}
if ($updir eq "LEFT") {
%left = %dat;
$left{-id} = $rdat->{PRIMER_SEQUENCE_ID}."-left";
}
else {
%right = %dat;
$right{-id} = $rdat->{PRIMER_SEQUENCE_ID}."-right";
}
}
my $primer_left = new Bio::SeqFeature::Primer(%left);
my $primer_right = new Bio::SeqFeature::Primer(%right);
return($primer_left,$primer_right);} |
sub get_amplified_region
{ my ($self) = @_;
}
} |
sub get_amplification_error
{ my $primer = $_[1];
my $error = $Primer3::primers{$primer}{PRIMER_ERROR};
if ($error) { return $error; }
else { return "Some error that primer3 didn't define.\n"; }} |
sub _set_target
{ my $self = shift;
my ($sequence,$primer,$primer_left,$primer_right,$position_left,$position_right,$boggle);
$boggle = 1;
foreach $primer (sort keys %{$self->{primers}}) {
$sequence = $self->{primers}{$primer}{SEQUENCE};
$primer_left = $self->{primers}{$primer}{PRIMER_LEFT};
$primer_right = $self->{primers}{$primer}{PRIMER_RIGHT};
if (!$primer_left) {
$self->{primers}{$primer}{design_failed} = "1";
}
else {
$primer_left =~ m/(.*)\,(.*)/;
$position_left = $1+$2-1;
$primer_right =~ m/(.*)\,(.*)/;
$position_right = $1-$2;
$self->{primers}{$primer}{left} = $position_left;
$self->{primers}{$primer}{right} = $position_right;
$self->{primers}{$primer}{amplified} = substr($sequence,$position_left,$position_right-$position_left);
}
}} |
sub _parse_report
{ my ($self,$outputs) = @_;
my ($sequence_name,$line,$counter,$variable_name,$variable_value);
my @output = split/\n/,$outputs;
foreach $line (@output) {
next if ($line =~ /^\=/);
if ($line =~ m/^PRIMER_SEQUENCE_ID/) {
$line =~ m/(\S+)=(.*$)/;
$variable_name = $1;
$sequence_name = $2;
$variable_value = $2;
}
else {
$line =~ m/(\S+)=(.*$)/;
$variable_name = $1;
$variable_value = $2;
}
$self->{primers}{$sequence_name}{$variable_name} = $variable_value;
} }
} |
sub _construct_empty
{ my $self = shift;
$self->{inputs} = {};
return;} |
sub add_target
{ my ($self,%args) = @_;
my ($currkey,$renamed,$sequence_id,$value);
if (!$args{-PRIMER_SEQUENCE_ID}) {
print("You cannot add an element to the primer3 infile without specifying the PRIMER_SEQUENCE_ID. Sorry.\n");
}
else {
$sequence_id = $args{-PRIMER_SEQUENCE_ID};
foreach $currkey (keys %args) {
next if ($currkey eq "-PRIMER_SEQUENCE_ID");
($renamed = $currkey) =~ s/-//;
$value = $args{$currkey};
if ($renamed eq "SEQUENCE") { $value =~ s/\n//g; }
$self->{infile}{$sequence_id}{$renamed} = $value;
}
}} |
sub get_primer_sequence_IDs
{ my $self = shift;
return sort keys %{$self->{primers}};
}
} |
sub dump_hash
{ my $self = shift;
my $dumper = new Dumpvalue;
$dumper->dumpValue($self);
}
} |
sub dump_infile_hash
{ my $self = shift;
my $dumper = new Dumpvalue;
$dumper->dumpValue($self->{infile});} |
General documentation
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://www.bioperl.org/MailList.html - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/
| AUTHOR - Chad Matsalla | Top |
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
Title :
Usage :
Function:
Returns :
Args :
Notes :
Title : This is a place holder so chad can cut and paste
Usage :
Function:
Returns :
Args :
Notes :
perl(1).