| 1 | # | ||||||||||
| 2 | # BioPerl module for Bio::SeqFeature::Primer | ||||||||||
| 3 | # | ||||||||||
| 4 | # This is the original copyright statement. I have relied on Chad's module | ||||||||||
| 5 | # extensively for this module. | ||||||||||
| 6 | # | ||||||||||
| 7 | # Copyright (c) 1997-2001 bioperl, Chad Matsalla. All Rights Reserved. | ||||||||||
| 8 | # This module is free software; you can redistribute it and/or | ||||||||||
| 9 | # modify it under the same terms as Perl itself. | ||||||||||
| 10 | # | ||||||||||
| 11 | # Copyright Chad Matsalla | ||||||||||
| 12 | # | ||||||||||
| 13 | # You may distribute this module under the same terms as perl itself | ||||||||||
| 14 | # POD documentation - main docs before the code | ||||||||||
| 15 | # | ||||||||||
| 16 | # But I have modified lots of it, so I guess I should add: | ||||||||||
| 17 | # | ||||||||||
| 18 | # Copyright (c) 2003 bioperl, Rob Edwards. All Rights Reserved. | ||||||||||
| 19 | # This module is free software; you can redistribute it and/or | ||||||||||
| 20 | # modify it under the same terms as Perl itself. | ||||||||||
| 21 | # | ||||||||||
| 22 | # Copyright Rob Edwards | ||||||||||
| 23 | # | ||||||||||
| 24 | # You may distribute this module under the same terms as perl itself | ||||||||||
| 25 | # POD documentation - main docs before the code | ||||||||||
| 26 | |||||||||||
| 27 | =head1 NAME | ||||||||||
| 28 | |||||||||||
| 29 | Bio::SeqFeature::Primer - Primer Generic SeqFeature | ||||||||||
| 30 | |||||||||||
| 31 | =head1 SYNOPSIS | ||||||||||
| 32 | |||||||||||
| 33 | use Bio::SeqFeature::Primer; | ||||||||||
| 34 | |||||||||||
| 35 | # Primer object with explicitly-defined sequence object or sequence string | ||||||||||
| 36 | my $primer = Bio::SeqFeature::Primer->new( -seq => 'ACGTAGCT' ); | ||||||||||
| 37 | $primer->display_name('test_id'); | ||||||||||
| 38 | print "These are the details of the primer:\n". | ||||||||||
| 39 | "Name: ".$primer->display_name."\n". | ||||||||||
| 40 | "Tag: ".$primer->primary_tag."\n". # always 'Primer' | ||||||||||
| 41 | "Sequence: ".$primer->seq->seq."\n". | ||||||||||
| 42 | "Tm: ".$primer->Tm."\n\n"; # melting temperature | ||||||||||
| 43 | |||||||||||
| 44 | # Primer object with implicit sequence object | ||||||||||
| 45 | # It is a lighter approach for when the primer location on a template is known | ||||||||||
| 46 | use Bio::Seq; | ||||||||||
| 47 | my $template = Bio::Seq->new( -seq => 'ACGTAGCTCTTTTCATTCTGACTGCAACG' ); | ||||||||||
| 48 | $primer = Bio::SeqFeature::Primer->new( -start => 1, -end =>5, -strand => 1 ); | ||||||||||
| 49 | $template->add_SeqFeature($primer); | ||||||||||
| 50 | print "Primer sequence is: ".$primer->seq->seq."\n"; | ||||||||||
| 51 | # Primer sequence is 'ACGTA' | ||||||||||
| 52 | |||||||||||
| 53 | =head1 DESCRIPTION | ||||||||||
| 54 | |||||||||||
| 55 | This module handles PCR primer sequences. The L<Bio::SeqFeature::Primer> object | ||||||||||
| 56 | is a L<Bio::SeqFeature::Subseq> object that can additionally contain a primer | ||||||||||
| 57 | sequence and its coordinates on a template sequence. The primary_tag() for this | ||||||||||
| 58 | object is 'Primer'. A method is provided to calculate the melting temperature Tm | ||||||||||
| 59 | of the primer. L<Bio::SeqFeature::Primer> objects are useful to build | ||||||||||
| 60 | L<Bio::Seq::PrimedSeq> amplicon objects such as the ones returned by | ||||||||||
| 61 | L<Bio::Tools::Primer3>. | ||||||||||
| 62 | |||||||||||
| 63 | =head1 FEEDBACK | ||||||||||
| 64 | |||||||||||
| 65 | =head2 Mailing Lists | ||||||||||
| 66 | |||||||||||
| 67 | User feedback is an integral part of the evolution of this and other | ||||||||||
| 68 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||
| 69 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||
| 70 | |||||||||||
| 71 | bioperl-l@bioperl.org - General discussion | ||||||||||
| 72 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||
| 73 | |||||||||||
| 74 | =head2 Support | ||||||||||
| 75 | |||||||||||
| 76 | Please direct usage questions or support issues to the mailing list: | ||||||||||
| 77 | |||||||||||
| 78 | I<bioperl-l@bioperl.org> | ||||||||||
| 79 | |||||||||||
| 80 | rather than to the module maintainer directly. Many experienced and | ||||||||||
| 81 | reponsive experts will be able look at the problem and quickly | ||||||||||
| 82 | address it. Please include a thorough description of the problem | ||||||||||
| 83 | with code and data examples if at all possible. | ||||||||||
| 84 | |||||||||||
| 85 | =head2 Reporting Bugs | ||||||||||
| 86 | |||||||||||
| 87 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||
| 88 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||
| 89 | web: | ||||||||||
| 90 | |||||||||||
| 91 | https://github.com/bioperl/bioperl-live/issues | ||||||||||
| 92 | |||||||||||
| 93 | =head1 AUTHOR | ||||||||||
| 94 | |||||||||||
| 95 | Rob Edwards, redwards@utmem.edu | ||||||||||
| 96 | |||||||||||
| 97 | The original concept and much of the code was written by | ||||||||||
| 98 | Chad Matsalla, bioinformatics1@dieselwurks.com | ||||||||||
| 99 | |||||||||||
| 100 | =head1 APPENDIX | ||||||||||
| 101 | |||||||||||
| 102 | The rest of the documentation details each of the object | ||||||||||
| 103 | methods. Internal methods are usually preceded with a _ | ||||||||||
| 104 | |||||||||||
| 105 | =cut | ||||||||||
| 106 | |||||||||||
| 107 | |||||||||||
| 108 | package Bio::SeqFeature::Primer; | ||||||||||
| 109 | 8 | $Bio::SeqFeature::Primer::VERSION = '1.7.8'; | |||||||||
| 110 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 111 | |||||||||||
| 112 | 8 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 113 | |||||||||||
| 114 | 8 | ▶ | use Bio::PrimarySeq; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 115 | 8 | ▶ | use Bio::Tools::SeqStats; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 116 | |||||||||||
| 117 | 8 | ▶ | use base qw(Bio::SeqFeature::SubSeq); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 118 | |||||||||||
| 119 | |||||||||||
| 120 | =head2 new() | ||||||||||
| 121 | |||||||||||
| 122 | Title : new() | ||||||||||
| 123 | Usage : my $primer = Bio::SeqFeature::Primer( -seq => $seq_object ); | ||||||||||
| 124 | Function: Instantiate a new Bio::SeqFeature::Primer object | ||||||||||
| 125 | Returns : A Bio::SeqFeature::Primer object | ||||||||||
| 126 | Args : -seq , a sequence object or a sequence string (optional) | ||||||||||
| 127 | -id , the ID to give to the primer sequence, not feature (optional) | ||||||||||
| 128 | |||||||||||
| 129 | =cut | ||||||||||
| 130 | |||||||||||
| 131 | 40 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 132 | 40 | my ($class, %args) = @_; | |||||||||
| 133 | |||||||||||
| 134 | # Legacy stuff | ||||||||||
| 135 | 40 | my $sequence = delete $args{-sequence}; | |||||||||
| 136 | 40 | ▶ | if ($sequence) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 137 | 1 | Carp::carp("Constructing a Bio::SeqFeature::Primer with -sequence is" | |||||||||
| 138 | . " deprecated. Use -seq instead."); | ||||||||||
| 139 | 1 | $args{-seq} = $sequence; | |||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | # Initialize Primer object | ||||||||||
| 143 | 40 | my $self = $class->SUPER::new(%args); | |||||||||
| 144 | 40 | my ($id) = $self->_rearrange([qw(ID)], %args); | |||||||||
| 145 | 40 | ▶ | $id && $self->seq->id($id); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 146 | 40 | $self->primary_tag('Primer'); | |||||||||
| 147 | 40 | return $self; | |||||||||
| 148 | } | ||||||||||
| 149 | |||||||||||
| 150 | |||||||||||
| 151 | # Bypass B::SF::Generic's location() when a string is passed (for compatibility) | ||||||||||
| 152 | |||||||||||
| 153 | 181 | ▶ | sub location { | ||||||||
|
Subroutine
location: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 154 | 181 | my ($self, $location) = @_; | |||||||||
| 155 | 181 | ▶ | if ($location) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 156 | 1 | ▶ | if ( not ref $location ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 157 | # Use location as a string for backward compatibility | ||||||||||
| 158 | 1 | Carp::carp("Passing a string to location() is deprecated. Pass a" | |||||||||
| 159 | . " Bio::Location::Simple object or use start() and" | ||||||||||
| 160 | . " end() instead."); | ||||||||||
| 161 | 1 | $self->{'_location'} = $location; | |||||||||
| 162 | } else { | ||||||||||
| 163 | 0 | $self->SUPER::location($location); | |||||||||
| 164 | } | ||||||||||
| 165 | } | ||||||||||
| 166 | 181 | return $self->SUPER::location; | |||||||||
| 167 | } | ||||||||||
| 168 | |||||||||||
| 169 | |||||||||||
| 170 | =head2 Tm() | ||||||||||
| 171 | |||||||||||
| 172 | Title : Tm() | ||||||||||
| 173 | Usage : my $tm = $primer->Tm(-salt => 0.05, -oligo => 0.0000001); | ||||||||||
| 174 | Function: Calculate the Tm (melting temperature) of the primer | ||||||||||
| 175 | Returns : A scalar containing the Tm. | ||||||||||
| 176 | Args : -salt : set the Na+ concentration on which to base the calculation | ||||||||||
| 177 | (default=0.05 molar). | ||||||||||
| 178 | : -oligo : set the oligo concentration on which to base the | ||||||||||
| 179 | calculation (default=0.00000025 molar). | ||||||||||
| 180 | Notes : Calculation of Tm as per Allawi et. al Biochemistry 1997 | ||||||||||
| 181 | 36:10581-10594. Also see documentation at | ||||||||||
| 182 | http://www.idtdna.com/Scitools/Scitools.aspx as they use this | ||||||||||
| 183 | formula and have a couple nice help pages. These Tm values will be | ||||||||||
| 184 | about are about 0.5-3 degrees off from those of the idtdna web tool. | ||||||||||
| 185 | I don't know why. | ||||||||||
| 186 | |||||||||||
| 187 | This was suggested by Barry Moore (thanks!). See the discussion on | ||||||||||
| 188 | the bioperl-l with the subject "Bio::SeqFeature::Primer Calculating | ||||||||||
| 189 | the PrimerTM" | ||||||||||
| 190 | |||||||||||
| 191 | =cut | ||||||||||
| 192 | |||||||||||
| 193 | 2 | ▶ | sub Tm { | ||||||||
|
Subroutine
Tm: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 194 | 2 | my ($self, %args) = @_; | |||||||||
| 195 | 2 | my $salt_conc = 0.05; # salt concentration (molar units) | |||||||||
| 196 | 2 | my $oligo_conc = 0.00000025; # oligo concentration (molar units) | |||||||||
| 197 | 2 | ▶ | if ($args{'-salt'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 198 | # Accept object defined salt concentration | ||||||||||
| 199 | 1 | $salt_conc = $args{'-salt'}; | |||||||||
| 200 | } | ||||||||||
| 201 | 2 | ▶ | if ($args{'-oligo'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 202 | # Accept object defined oligo concentration | ||||||||||
| 203 | 1 | $oligo_conc = $args{'-oligo'}; | |||||||||
| 204 | } | ||||||||||
| 205 | 2 | my $seqobj = $self->seq(); | |||||||||
| 206 | 2 | my $length = $seqobj->length(); | |||||||||
| 207 | 2 | my $sequence = uc $seqobj->seq(); | |||||||||
| 208 | 2 | my @dinucleotides; | |||||||||
| 209 | my $enthalpy; | ||||||||||
| 210 | 2 | my $entropy; | |||||||||
| 211 | # Break sequence string into an array of all possible dinucleotides | ||||||||||
| 212 | 2 | ▶ | while ($sequence =~ /(.)(?=(.))/g) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 213 | 40 | push @dinucleotides, $1.$2; | |||||||||
| 214 | } | ||||||||||
| 215 | # Build a hash with the thermodynamic values | ||||||||||
| 216 | 2 | my %thermo_values = ('AA' => {'enthalpy' => -7.9, | |||||||||
| 217 | 'entropy' => -22.2}, | ||||||||||
| 218 | 'AC' => {'enthalpy' => -8.4, | ||||||||||
| 219 | 'entropy' => -22.4}, | ||||||||||
| 220 | 'AG' => {'enthalpy' => -7.8, | ||||||||||
| 221 | 'entropy' => -21}, | ||||||||||
| 222 | 'AT' => {'enthalpy' => -7.2, | ||||||||||
| 223 | 'entropy' => -20.4}, | ||||||||||
| 224 | 'CA' => {'enthalpy' => -8.5, | ||||||||||
| 225 | 'entropy' => -22.7}, | ||||||||||
| 226 | 'CC' => {'enthalpy' => -8, | ||||||||||
| 227 | 'entropy' => -19.9}, | ||||||||||
| 228 | 'CG' => {'enthalpy' => -10.6, | ||||||||||
| 229 | 'entropy' => -27.2}, | ||||||||||
| 230 | 'CT' => {'enthalpy' => -7.8, | ||||||||||
| 231 | 'entropy' => -21}, | ||||||||||
| 232 | 'GA' => {'enthalpy' => -8.2, | ||||||||||
| 233 | 'entropy' => -22.2}, | ||||||||||
| 234 | 'GC' => {'enthalpy' => -9.8, | ||||||||||
| 235 | 'entropy' => -24.4}, | ||||||||||
| 236 | 'GG' => {'enthalpy' => -8, | ||||||||||
| 237 | 'entropy' => -19.9}, | ||||||||||
| 238 | 'GT' => {'enthalpy' => -8.4, | ||||||||||
| 239 | 'entropy' => -22.4}, | ||||||||||
| 240 | 'TA' => {'enthalpy' => -7.2, | ||||||||||
| 241 | 'entropy' => -21.3}, | ||||||||||
| 242 | 'TC' => {'enthalpy' => -8.2, | ||||||||||
| 243 | 'entropy' => -22.2}, | ||||||||||
| 244 | 'TG' => {'enthalpy' => -8.5, | ||||||||||
| 245 | 'entropy' => -22.7}, | ||||||||||
| 246 | 'TT' => {'enthalpy' => -7.9, | ||||||||||
| 247 | 'entropy' => -22.2}, | ||||||||||
| 248 | 'A' => {'enthalpy' => 2.3, | ||||||||||
| 249 | 'entropy' => 4.1}, | ||||||||||
| 250 | 'C' => {'enthalpy' => 0.1, | ||||||||||
| 251 | 'entropy' => -2.8}, | ||||||||||
| 252 | 'G' => {'enthalpy' => 0.1, | ||||||||||
| 253 | 'entropy' => -2.8}, | ||||||||||
| 254 | 'T' => {'enthalpy' => 2.3, | ||||||||||
| 255 | 'entropy' => 4.1} | ||||||||||
| 256 | ); | ||||||||||
| 257 | # Loop through dinucleotides and calculate cumulative enthalpy and entropy values | ||||||||||
| 258 | 2 | for (@dinucleotides) { | |||||||||
| 259 | 40 | $enthalpy += $thermo_values{$_}{enthalpy}; | |||||||||
| 260 | 40 | $entropy += $thermo_values{$_}{entropy}; | |||||||||
| 261 | } | ||||||||||
| 262 | # Account for initiation parameters | ||||||||||
| 263 | 2 | $enthalpy += $thermo_values{substr($sequence, 0, 1)}{enthalpy}; | |||||||||
| 264 | 2 | $entropy += $thermo_values{substr($sequence, 0, 1)}{entropy}; | |||||||||
| 265 | 2 | $enthalpy += $thermo_values{substr($sequence, -1, 1)}{enthalpy}; | |||||||||
| 266 | 2 | $entropy += $thermo_values{substr($sequence, -1, 1)}{entropy}; | |||||||||
| 267 | # Symmetry correction | ||||||||||
| 268 | 2 | $entropy -= 1.4; | |||||||||
| 269 | 2 | my $r = 1.987; # molar gas constant | |||||||||
| 270 | 2 | my $tm = $enthalpy * 1000 / ($entropy + ($r * log($oligo_conc))) - 273.15 + (12* (log($salt_conc)/log(10))); | |||||||||
| 271 | |||||||||||
| 272 | 2 | return $tm; | |||||||||
| 273 | } | ||||||||||
| 274 | |||||||||||
| 275 | =head2 Tm_estimate | ||||||||||
| 276 | |||||||||||
| 277 | Title : Tm_estimate | ||||||||||
| 278 | Usage : my $tm = $primer->Tm_estimate(-salt => 0.05); | ||||||||||
| 279 | Function: Estimate the Tm (melting temperature) of the primer | ||||||||||
| 280 | Returns : A scalar containing the Tm. | ||||||||||
| 281 | Args : -salt set the Na+ concentration on which to base the calculation. | ||||||||||
| 282 | Notes : This is only an estimate of the Tm that is kept in for comparative | ||||||||||
| 283 | reasons. You should probably use Tm instead! | ||||||||||
| 284 | |||||||||||
| 285 | This Tm calculations are taken from the Primer3 docs: They are | ||||||||||
| 286 | based on Bolton and McCarthy, PNAS 84:1390 (1962) | ||||||||||
| 287 | as presented in Sambrook, Fritsch and Maniatis, | ||||||||||
| 288 | Molecular Cloning, p 11.46 (1989, CSHL Press). | ||||||||||
| 289 | |||||||||||
| 290 | Tm = 81.5 + 16.6(log10([Na+])) + .41*(%GC) - 600/length | ||||||||||
| 291 | |||||||||||
| 292 | where [Na+] is the molar sodium concentration, %GC is the | ||||||||||
| 293 | %G+C of the sequence, and length is the length of the sequence. | ||||||||||
| 294 | |||||||||||
| 295 | However.... I can never get this calculation to give me the same result | ||||||||||
| 296 | as primer3 does. Don't ask why, I never figured it out. But I did | ||||||||||
| 297 | want to include a Tm calculation here because I use these modules for | ||||||||||
| 298 | other things besides reading primer3 output. | ||||||||||
| 299 | |||||||||||
| 300 | The primer3 calculation is saved as 'PRIMER_LEFT_TM' or 'PRIMER_RIGHT_TM' | ||||||||||
| 301 | and this calculation is saved as $primer->Tm so you can get both and | ||||||||||
| 302 | average them! | ||||||||||
| 303 | |||||||||||
| 304 | =cut | ||||||||||
| 305 | |||||||||||
| 306 | 2 | ▶ | sub Tm_estimate { | ||||||||
|
Subroutine
Tm_estimate: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 307 | |||||||||||
| 308 | # This should probably be put into seqstats as it is more generic, but what the heck. | ||||||||||
| 309 | |||||||||||
| 310 | 2 | my ($self, %args) = @_; | |||||||||
| 311 | 2 | my $salt = 0.2; | |||||||||
| 312 | 2 | ▶ | if ($args{'-salt'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 313 | 1 | $salt = $args{'-salt'} | |||||||||
| 314 | }; | ||||||||||
| 315 | 2 | my $seqobj = $self->seq(); | |||||||||
| 316 | 2 | my $length = $seqobj->length(); | |||||||||
| 317 | 2 | my $seqdata = Bio::Tools::SeqStats->count_monomers($seqobj); | |||||||||
| 318 | 2 | my $gc=$$seqdata{'G'} + $$seqdata{'C'}; | |||||||||
| 319 | 2 | my $percent_gc = ($gc/$length)*100; | |||||||||
| 320 | |||||||||||
| 321 | 2 | my $tm = 81.5+(16.6*(log($salt)/log(10)))+(0.41*$percent_gc) - (600/$length); | |||||||||
| 322 | |||||||||||
| 323 | 2 | return $tm; | |||||||||
| 324 | } | ||||||||||
| 325 | |||||||||||
| 326 | =head2 primary_tag, source_tag, location, start, end, strand... | ||||||||||
| 327 | |||||||||||
| 328 | The documentation of L<Bio::SeqFeature::Generic> describes all the methods that | ||||||||||
| 329 | L<Bio::SeqFeature::Primer> object inherit. | ||||||||||
| 330 | |||||||||||
| 331 | =cut | ||||||||||
| 332 | |||||||||||
| 333 | 8 | 1; | |||||||||