t/AlignIO/AlignIO.t: fix number of tests in plan (fixup c523e6bed866)
[bioperl-live.git] / Bio / Tools / Primer / Feature.pm
blobb758a9b90f79844fa8f1b7c71668053502c50d79
2 # BioPerl module for Bio::Tools::Primer::Feature
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Ewan Birney <birney@ebi.ac.uk>
8 # Copyright Ewan Birney
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::Tools::Primer::Feature - position of a single primer
18 =head1 SYNOPSIS
20 use Bio::Tools::Primer::Feature;
22 my $pf = Bio::Tools::Primer::Feature->new( -start => $start, -end => $end, -strand => $strand);
23 $pf->attach_seq($seq);
25 # is a SeqFeatureI
27 print "primer starts at ",$pf->start," with sequence ",$pf->seq->seq(),"\n";
29 # helper functions
31 print "GC percentage ",$pf->gc(),"\n";
32 print "has inversion of size 4 at ",$pf->inversion(4),"\n";
36 =head1 DESCRIPTION
38 Primer Features represents one primer in a primer pair. This object is
39 mainly for designing primers, and probably principly used in the
40 primer design system
42 =head1 FEEDBACK
44 =head2 Mailing Lists
46 User feedback is an integral part of the evolution of this and other
47 Bioperl modules. Send your comments and suggestions preferably to
48 the Bioperl mailing list. Your participation is much appreciated.
50 bioperl-l@bioperl.org - General discussion
51 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
53 =head2 Support
55 Please direct usage questions or support issues to the mailing list:
57 I<bioperl-l@bioperl.org>
59 rather than to the module maintainer directly. Many experienced and
60 reponsive experts will be able look at the problem and quickly
61 address it. Please include a thorough description of the problem
62 with code and data examples if at all possible.
64 =head2 Reporting Bugs
66 Report bugs to the Bioperl bug tracking system to help us keep track
67 of the bugs and their resolution. Bug reports can be submitted via the
68 web:
70 https://github.com/bioperl/bioperl-live/issues
72 =head1 AUTHOR - Ewan Birney
74 Email birney-at-ebi.ac.uk
76 =head1 APPENDIX
78 The rest of the documentation details each of the object methods.
79 Internal methods are usually preceded with a _
81 =cut
84 # Let the code begin...
88 package Bio::Tools::Primer::Feature;
90 use base qw(Bio::SeqFeature::Generic);
94 sub new {
95 my ( $caller, @args) = @_;
96 my ($self) = $caller->SUPER::new(@args);
98 # done - we hope
99 return $self;
102 sub gc_percent {
103 my $self = shift;
105 my $seq = $self->seq();
107 if( !defined $seq ) {
108 $self->throw("Primer feature has no attached sequence, can't calculate GC");
111 my $str = $seq->seq();
113 my $count = $str =~ tr/GCgc/GCgc/;
115 return $count*100.0 / $seq->length;
118 sub inversion {
119 my $self = shift;
120 my $size = shift;
122 if( !defined $size ) {
123 $self->throw("Must have size paramter in inversion");
126 my $seq = $self->seq();
128 if( !defined $seq ) {
129 $self->throw("Primer feature has no attached sequence, can't calculate inversion");
132 my $len = $seq->length - $size;
134 my $str = $seq->seq();
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;
142 $revstr =~ tr/ATGCNatgcn/TACGNtacgn/;
144 if( $str =~ /$revstr/ ) {
145 return $orig;
149 return;