File Coverage

Bio/SeqFeature/Amplicon.pm
Criterion Covered Total %
statement 24 26 92.3
branch 7 10 70.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 3 3 100.0
total 41 48 85.4


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::SeqFeature::Amplicon
3             #
4             # Please direct questions and support issues to
5             #
6             # Copyright Florent Angly
7             #
8             # You may distribute this module under the same terms as perl itself
9              
10              
11             =head1 NAME
12              
13             Bio::SeqFeature::Amplicon - Amplicon feature
14              
15             =head1 SYNOPSIS
16              
17             # Amplicon with explicit sequence
18             use Bio::SeqFeature::Amplicon;
19             my $amplicon = Bio::SeqFeature::Amplicon->new(
20             -seq => $seq_object,
21             -fwd_primer => $primer_object_1,
22             -rev_primer => $primer_object_2,
23             );
24              
25             # Amplicon with implicit sequence
26             use Bio::Seq;
27             my $template = Bio::Seq->new( -seq => 'AAAAACCCCCGGGGGTTTTT' );
28             $amplicon = Bio::SeqFeature::Amplicon->new(
29             -start => 6,
30             -end => 15,
31             );
32             $template->add_SeqFeature($amplicon);
33             print "Amplicon start : ".$amplicon->start."\n";
34             print "Amplicon end : ".$amplicon->end."\n";
35             print "Amplicon sequence: ".$amplicon->seq->seq."\n";
36             # Amplicon sequence should be 'CCCCCGGGGG'
37              
38             =head1 DESCRIPTION
39              
40             Bio::SeqFeature::Amplicon extends L to represent an
41             amplicon sequence and optional primer sequences.
42              
43             =head1 FEEDBACK
44              
45             =head2 Mailing Lists
46              
47             User feedback is an integral part of the evolution of this and other
48             Bioperl modules. Send your comments and suggestions preferably to one
49             of the Bioperl mailing lists. Your participation is much appreciated.
50              
51             bioperl-l@bioperl.org - General discussion
52             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
53              
54             =head2 Support
55              
56             Please direct usage questions or support issues to the mailing list:
57              
58             I
59              
60             rather than to the module maintainer directly. Many experienced and
61             reponsive experts will be able look at the problem and quickly
62             address it. Please include a thorough description of the problem
63             with code and data examples if at all possible.
64              
65             =head2 Reporting Bugs
66              
67             Report bugs to the Bioperl bug tracking system to help us keep track
68             the bugs and their resolution. Bug reports can be submitted via
69             the web:
70              
71             https://github.com/bioperl/bioperl-live/issues
72              
73             =head1 AUTHOR
74              
75             Florent Angly
76              
77             =head1 APPENDIX
78              
79             The rest of the documentation details each of the object
80             methods. Internal methods are usually preceded with a _
81              
82             =cut
83              
84              
85             package Bio::SeqFeature::Amplicon;
86              
87 2     2   906 use strict;
  2         4  
  2         53  
88              
89 2     2   9 use base qw(Bio::SeqFeature::SubSeq);
  2         3  
  2         620  
90              
91             =head2 new
92              
93             Title : new()
94             Usage : my $amplicon = Bio::SeqFeature::Amplicon( -seq => $seq_object );
95             Function: Instantiate a new Bio::SeqFeature::Amplicon object
96             Args : -seq , the sequence object or sequence string of the amplicon (optional)
97             -fwd_primer , a Bio::SeqFeature primer object with specified location on amplicon (optional)
98             -rev_primer , a Bio::SeqFeature primer object with specified location on amplicon (optional)
99             Returns : A Bio::SeqFeature::Amplicon object
100              
101             =cut
102              
103             sub new {
104 25     25 1 1021 my ($class, @args) = @_;
105 25         90 my $self = $class->SUPER::new(@args);
106 25         78 my ($fwd_primer, $rev_primer) =
107             $self->_rearrange([qw(FWD_PRIMER REV_PRIMER)], @args);
108 25 100       65 $fwd_primer && $self->fwd_primer($fwd_primer);
109 25 50       43 $rev_primer && $self->rev_primer($rev_primer);
110 25         69 return $self;
111             }
112              
113              
114             sub _primer {
115             # Get or set a primer. Type is either 'fwd' or 'rev'.
116 8     8   16 my ($self, $type, $primer) = @_;
117 8 100       18 if (defined $primer) {
118 3 50 33     22 if ( not(ref $primer) || not $primer->isa('Bio::SeqFeature::Primer') ) {
119 0         0 $self->throw("Expected a primer object but got a '".ref($primer)."'\n");
120             }
121 3 50       10 if ( not defined $self->location ) {
122 0         0 $self->throw("Location of $type primer on amplicon is not known. ".
123             "Use start(), end() or location() to set it.");
124             }
125 3         11 $primer->primary_tag($type.'_primer');
126 3         11 $self->add_SeqFeature($primer);
127             }
128 8         33 return (grep { $_->primary_tag eq $type.'_primer' } $self->get_SeqFeatures)[0];
  11         22  
129             }
130              
131              
132             =head2 fwd_primer
133              
134             Title : fwd_primer
135             Usage : my $primer = $feat->fwd_primer();
136             Function: Get or set the forward primer. When setting it, the primary tag
137             'fwd_primer' is added to the primer and its start, stop and strand
138             attributes are set if needed, assuming that the forward primer is
139             at the beginning of the amplicon and the reverse primer at the end.
140             Args : A Bio::SeqFeature::Primer object (optional)
141             Returns : A Bio::SeqFeature::Primer object
142              
143             =cut
144              
145             sub fwd_primer {
146 5     5 1 9 my ($self, $primer) = @_;
147 5         14 return $self->_primer('fwd', $primer);
148             }
149              
150              
151             =head2 rev_primer
152              
153             Title : rev_primer
154             Usage : my $primer = $feat->rev_primer();
155             Function: Get or set the reverse primer. When setting it, the primary tag
156             'rev_primer' is added to the primer.
157             Args : A Bio::SeqFeature::Primer object (optional)
158             Returns : A Bio::SeqFeature::Primer object
159              
160             =cut
161              
162             sub rev_primer {
163 3     3 1 8 my ($self, $primer) = @_;
164 3         6 return $self->_primer('rev', $primer);
165             }
166              
167              
168             1;