~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to Bio/SeqFeature/Amplicon.pm

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# BioPerl module for Bio::SeqFeature::Amplicon
 
3
#
 
4
# Please direct questions and support issues to <bioperl-l@bioperl.org> 
 
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<Bio::SeqFeature::Subseq> 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<bioperl-l@bioperl.org>
 
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://redmine.open-bio.org/projects/bioperl/
 
72
 
 
73
=head1 AUTHOR
 
74
 
 
75
Florent Angly <florent.angly@gmail.com>
 
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
use strict;
 
88
 
 
89
use base qw(Bio::SeqFeature::SubSeq);
 
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
    my ($class, @args) = @_;
 
105
    my $self = $class->SUPER::new(@args);
 
106
    my ($fwd_primer, $rev_primer) =
 
107
        $self->_rearrange([qw(FWD_PRIMER REV_PRIMER)], @args);
 
108
    $fwd_primer && $self->fwd_primer($fwd_primer);
 
109
    $rev_primer && $self->rev_primer($rev_primer);
 
110
    return $self;
 
111
}  
 
112
 
 
113
 
 
114
sub _primer {
 
115
    # Get or set a primer. Type is either 'fwd' or 'rev'.
 
116
    my ($self, $type, $primer) = @_;
 
117
    if (defined $primer) {
 
118
        if ( not(ref $primer) || not $primer->isa('Bio::SeqFeature::Primer') ) {
 
119
            $self->throw("Expected a primer object but got a '".ref($primer)."'\n");
 
120
        }
 
121
        if ( not defined $self->location ) {
 
122
            $self->throw("Location of $type primer on amplicon is not known. ".
 
123
                "Use start(), end() or location() to set it.");
 
124
        }
 
125
        $primer->primary_tag($type.'_primer');
 
126
        $self->add_SeqFeature($primer);
 
127
    }
 
128
    return (grep { $_->primary_tag eq $type.'_primer' } $self->get_SeqFeatures)[0];
 
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
    my ($self, $primer) = @_;
 
147
    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
    my ($self, $primer) = @_;
 
164
    return $self->_primer('rev', $primer);
 
165
}
 
166
 
 
167
 
 
168
1;