Bio/Tools/EPCR.pm

filter: Statementstmt 100% 44 / 44 Branchbran 81.8% 18 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 5 / 5 totaltotal 95.0% 76 / 80 CC 12 SCAR 12.3
CC
12
Cov
94%
next_feature
6.0
new
4.2
source
2.0
CRAP 3.4
« Bio/Seq/SeqFactory.pm ↑ Summary Bio/Tools/TandemRepeatsFinder.pm »
1 #
2 # BioPerl module for Bio::Tools::EPCR
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Jason Stajich <jason-at-bioperl.org>
7 #
8 # Copyright Jason Stajich
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  
16 Bio::Tools::EPCR - Parse ePCR output and make features
17  
18 =head1 SYNOPSIS
19  
20 # A simple annotation pipeline wrapper for ePCR data
21 # assuming ePCR data is already generated in file seq1.epcr
22 # and sequence data is in fasta format in file called seq1.fa
23  
24 use Bio::Tools::EPCR;
25 use Bio::SeqIO;
26 my $parser = Bio::Tools::EPCR->new(-file => 'seq1.epcr');
27 my $seqio = Bio::SeqIO->new(-format => 'fasta', -file => 'seq1.fa');
28 my $seq = $seqio->next_seq || die("cannot get a seq object from SeqIO");
29  
30 while( my $feat = $parser->next_feature ) {
31 # add EPCR annotation to a sequence
32 $seq->add_SeqFeature($feat);
33 }
34 my $seqout = Bio::SeqIO->new(-format => 'embl');
35 $seqout->write_seq($seq);
36  
37  
38 =head1 DESCRIPTION
39  
40 This object serves as a parser for ePCR data, creating a
41 Bio::SeqFeatureI for each ePCR hit. These can be processed or added
42 as annotation to an existing Bio::SeqI object for the purposes of
43 automated annotation.
44  
45 =head1 FEEDBACK
46  
47 =head2 Mailing Lists
48  
49 User feedback is an integral part of the evolution of this and other
50 Bioperl modules. Send your comments and suggestions preferably to
51 the Bioperl mailing list. Your participation is much appreciated.
52  
53 bioperl-l@bioperl.org - General discussion
54 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
55  
56 =head2 Support
57  
58 Please direct usage questions or support issues to the mailing list:
59  
60 I<bioperl-l@bioperl.org>
61  
62 rather than to the module maintainer directly. Many experienced and
63 reponsive experts will be able look at the problem and quickly
64 address it. Please include a thorough description of the problem
65 with code and data examples if at all possible.
66  
67 =head2 Reporting Bugs
68  
69 Report bugs to the Bioperl bug tracking system to help us keep track
70 of the bugs and their resolution. Bug reports can be submitted via the
71 web:
72  
73 https://github.com/bioperl/bioperl-live/issues
74  
75 =head1 AUTHOR - Jason Stajich
76  
77 Email jason-at-bioperl.org
78  
79 =head1 APPENDIX
80  
81 The rest of the documentation details each of the object methods.
82 Internal methods are usually preceded with a _
83  
84 =cut
85  
86  
87 # Let the code begin...
88  
89  
90 package Bio::Tools::EPCR;
91 3 $Bio::Tools::EPCR::VERSION = '1.7.8';
92 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
93  
94 3 ▶use Bio::SeqFeature::FeaturePair;
Subroutine BEGIN: called CC=1 SCAR=0.0
95 3 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
96  
97 3 ▶use base qw(Bio::Root::Root Bio::SeqAnalysisParserI Bio::Root::IO);
Subroutine BEGIN: called CC=1 SCAR=0.0
98  
99 =head2 new
100  
101 Title : new
102 Usage : my $epcr = Bio::Tools::EPCR->new(-file => $file,
103 -primary => $fprimary,
104 -source => $fsource,
105 -groupclass => $fgroupclass);
106 Function: Initializes a new EPCR parser
107 Returns : Bio::Tools::EPCR
108 Args : -fh => filehandle
109 OR
110 -file => filename
111  
112 -primary => a string to be used as the common value for
113 each features '-primary' tag. Defaults to
114 'sts'. (This in turn maps to the GFF 'type'
115 tag (aka 'method')).
116  
117 -source => a string to be used as the common value for
118 each features '-source' tag. Defaults to
119 'e-PCR'. (This in turn maps to the GFF 'source'
120 tag)
121  
122 -groupclass => a string to be used as the name of the tag
123 which will hold the sts marker namefirst
124 attribute. Defaults to 'name'.
125  
126 =cut
127  
128 2 ▶sub new {
Subroutine new: called CC=4 SCAR=14.2
Pod documented
129 2 my($class,@args) = @_;
130  
131 2 my $self = $class->SUPER::new(@args);
132 2 my ($primary, $source,
133 $groupclass) = $self->_rearrange([qw(PRIMARY
134 SOURCE
135 GROUPCLASS)],@args);
136 2 ▶ $self->primary(defined $primary ? $primary : 'sts');
Branch: 1 branch
BranchTrueFalseTotal
defined $primary ? : 0 2 2
137 2 ▶ $self->source(defined $source ? $source : 'e-PCR');
Branch: 1 branch
BranchTrueFalseTotal
defined $source ? : 0 2 2
138 2 ▶ $self->groupclass(defined $groupclass ? $groupclass : 'name');
Branch: 1 branch
BranchTrueFalseTotal
defined $groupclass ? : 0 2 2
139  
140 2 $self->_initialize_io(@args);
141 2 return $self;
142 }
143  
144 =head2 next_feature
145  
146 Title : next_feature
147 Usage : $seqfeature = $obj->next_feature();
148 Function: Returns the next feature available in the analysis result, or
149 undef if there are no more features.
150 Example :
151 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
152 more features.
153 Args : none
154  
155 =cut
156  
157 16 ▶sub next_feature {
Subroutine next_feature: called CC=6 SCAR=17.9
Pod documented
158 16 my ($self) = @_;
159 16 my $line = $self->_readline;
160 16 ▶ return unless defined($line);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line 2 14 16
161 14 chomp($line);
162 14 my($seqname,$location,$mkrname, $rest) = split(/\s+/,$line,4);
163
164 14 my ($start,$end) = ($location =~ /(\S+)\.\.(\S+)/);
165  
166 # `e-PCR -direct` results code match strand in $rest as (+) and (-). Decode it if present.
167 14 my $strandsign;
168 14 ▶ if ($rest =~ m/^\(([+-])\)(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest =~ /^\(([+-])\)(.*)$/) { } 12 2 14
169 12 ($strandsign,$rest) = ($1, $2);
170 } else {
171 2 $strandsign = "?";
172 }
173 14 ▶ my $strand = $strandsign eq "+" ? 1 : $strandsign eq "-" ? -1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$strandsign eq '+' ? : 6 8 14
$strandsign eq '-' ? : 6 2 8
174  
175 14 ▶ my $markerfeature = Bio::SeqFeature::Generic->new
Branch: 1 branch
BranchTrueFalseTotal
$rest ? : 14 0 14
176 ( '-start' => $start,
177 '-end' => $end,
178 '-strand' => $strand,
179 '-source' => $self->source,
180 '-primary' => $self->primary,
181 '-seq_id' => $seqname,
182 '-tag' => {
183 $self->groupclass => $mkrname,
184 ($rest ? ('Note' => $rest ) : ()),
185 });
186 #$markerfeature->add_tag_value('Note', $rest) if defined $rest;
187 14 return $markerfeature;
188 }
189  
190 =head2 source
191  
192 Title : source
193 Usage : $obj->source($newval)
194 Function:
195 Example :
196 Returns : value of source (a scalar)
197 Args : on set, new value (a scalar or undef, optional)
198  
199  
200 =cut
201  
202 16 ▶sub source{
Subroutine source: called CC=2 SCAR=6.9
Pod documented
203 16 my $self = shift;
204 16 ▶ return $self->{'_source'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 14 16
205 14 return $self->{'_source'};
206 }
207  
208 =head2 primary
209  
210 Title : primary
211 Usage : $obj->primary($newval)
212 Function:
213 Example :
214 Returns : value of primary (a scalar)
215 Args : on set, new value (a scalar or undef, optional)
216  
217  
218 =cut
219  
220 16 ▶sub primary{
Subroutine primary: called CC=2 SCAR=6.9
Pod documented
221 16 my $self = shift;
222 16 ▶ return $self->{'_primary'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 14 16
223 14 return $self->{'_primary'};
224 }
225  
226 =head2 groupclass
227  
228 Title : groupclass
229 Usage : $obj->groupclass($newval)
230 Function:
231 Example :
232 Returns : value of groupclass (a scalar)
233 Args : on set, new value (a scalar or undef, optional)
234  
235  
236 =cut
237  
238 16 ▶sub groupclass{
Subroutine groupclass: called CC=2 SCAR=6.9
Pod documented
239 16 my $self = shift;
240  
241 16 ▶ return $self->{'_groupclass'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 14 16
242 14 return $self->{'_groupclass'};
243 }
244  
245 3 1;
« Bio/Seq/SeqFactory.pm ↑ Summary Bio/Tools/TandemRepeatsFinder.pm »