1# 2# BioPerl module for Bio::Tools::Primer::Feature 3# 4# Please direct questions and support issues to <bioperl-l@bioperl.org> 5# 6# Cared for by Ewan Birney <birney@ebi.ac.uk> 7# 8# Copyright Ewan Birney 9# 10# You may distribute this module under the same terms as perl itself 11 12# POD documentation - main docs before the code 13 14=head1 NAME 15 16Bio::Tools::Primer::Feature - position of a single primer 17 18=head1 SYNOPSIS 19 20 use Bio::Tools::Primer::Feature; 21 22 my $pf = Bio::Tools::Primer::Feature->new( -start => $start, -end => $end, -strand => $strand); 23 $pf->attach_seq($seq); 24 25 # is a SeqFeatureI 26 27 print "primer starts at ",$pf->start," with sequence ",$pf->seq->seq(),"\n"; 28 29 # helper functions 30 31 print "GC percentage ",$pf->gc(),"\n"; 32 print "has inversion of size 4 at ",$pf->inversion(4),"\n"; 33 34 35 36=head1 DESCRIPTION 37 38Primer Features represents one primer in a primer pair. This object is 39mainly for designing primers, and probably principly used in the 40primer design system 41 42=head1 FEEDBACK 43 44=head2 Mailing Lists 45 46User feedback is an integral part of the evolution of this and other 47Bioperl modules. Send your comments and suggestions preferably to 48the Bioperl mailing list. Your participation is much appreciated. 49 50 bioperl-l@bioperl.org - General discussion 51 http://bioperl.org/wiki/Mailing_lists - About the mailing lists 52 53=head2 Support 54 55Please direct usage questions or support issues to the mailing list: 56 57I<bioperl-l@bioperl.org> 58 59rather than to the module maintainer directly. Many experienced and 60reponsive experts will be able look at the problem and quickly 61address it. Please include a thorough description of the problem 62with code and data examples if at all possible. 63 64=head2 Reporting Bugs 65 66Report bugs to the Bioperl bug tracking system to help us keep track 67of the bugs and their resolution. Bug reports can be submitted via the 68web: 69 70 https://github.com/bioperl/bioperl-live/issues 71 72=head1 AUTHOR - Ewan Birney 73 74Email birney-at-ebi.ac.uk 75 76=head1 APPENDIX 77 78The rest of the documentation details each of the object methods. 79Internal methods are usually preceded with a _ 80 81=cut 82 83 84# Let the code begin... 85 86 87 88package Bio::Tools::Primer::Feature; 89$Bio::Tools::Primer::Feature::VERSION = '1.7.7'; 90use base qw(Bio::SeqFeature::Generic); 91 92 93 94sub new { 95 my ( $caller, @args) = @_; 96 my ($self) = $caller->SUPER::new(@args); 97 98 # done - we hope 99 return $self; 100} 101 102sub gc_percent { 103 my $self = shift; 104 105 my $seq = $self->seq(); 106 107 if( !defined $seq ) { 108 $self->throw("Primer feature has no attached sequence, can't calculate GC"); 109 } 110 111 my $str = $seq->seq(); 112 113 my $count = $str =~ tr/GCgc/GCgc/; 114 115 return $count*100.0 / $seq->length; 116} 117 118sub inversion { 119 my $self = shift; 120 my $size = shift; 121 122 if( !defined $size ) { 123 $self->throw("Must have size paramter in inversion"); 124 } 125 126 my $seq = $self->seq(); 127 128 if( !defined $seq ) { 129 $self->throw("Primer feature has no attached sequence, can't calculate inversion"); 130 } 131 132 my $len = $seq->length - $size; 133 134 my $str = $seq->seq(); 135 136 foreach my $i ( 0 .. $len ) { 137 my $revstr = substr($str,$i,$size); 138 my $orig = $revstr; 139 $revstr = reverse $revstr; 140 $revstr = s/[^ATGCNatgcn]/N/g; 141 142 $revstr =~ tr/ATGCNatgcn/TACGNtacgn/; 143 144 if( $str =~ /$revstr/ ) { 145 return $orig; 146 } 147 } 148 149 return; 150} 151 1521; 153