Bio/Tools/Pseudowise.pm

filter: Statementstmt 85.8% 73 / 85 Branchbran 78.5% 22 / 28 Conditioncond 28.5% 2 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 88.2% 15 / 17 Podpod 100% 3 / 3 totaltotal 79.8% 115 / 144 CC 18 SCAR 16.6
CC
18
Cov
81%
analysis_method
12.0
_parse_predictions
10.2
_add_prediction
3.4
CRAP 5.2
« Bio/Matrix/PSM/PsmHeader.pm ↑ Summary Bio/TreeIO/TreeEventBuilder.pm »
1 # BioPerl module for Bio::Tools::Pseudowise
2 #
3 #
4 # Copyright Jason Stajich, Fugu Team
5 #
6 # You may distribute this module under the same terms as perl itself
7  
8 # POD documentation - main docs before the code
9  
10 =head1 NAME
11  
12 Bio::Tools::Pseudowise - Results of one Pseudowise run
13  
14 =head1 SYNOPSIS
15  
16 use Bio::Tools::Pseudowise;
17  
18 my $parser = Bio::Tools::Pseudowise->new(-file=>"pw.out");
19 while(my $feat = $parser->next_result){
20 push @feat, $feat;
21 }
22  
23 =head1 DESCRIPTION
24  
25 Pseudowise is a pseudogene prediction program written by Ewan Birney
26 as part of the Wise Package. This module is the parser for the output
27 of the program.
28  
29 http://www.sanger.ac.uk/software/wise2
30  
31 =head1 FEEDBACK
32  
33 =head2 Mailing Lists
34  
35 User feedback is an integral part of the evolution of this and other
36 Bioperl modules. Send your comments and suggestions preferably to one
37 of the Bioperl mailing lists. Your participation is much appreciated.
38  
39 bioperl-l@bioperl.org - General discussion
40 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
41  
42 =head2 Support
43  
44 Please direct usage questions or support issues to the mailing list:
45  
46 I<bioperl-l@bioperl.org>
47  
48 rather than to the module maintainer directly. Many experienced and
49 reponsive experts will be able look at the problem and quickly
50 address it. Please include a thorough description of the problem
51 with code and data examples if at all possible.
52  
53 =head2 Reporting Bugs
54  
55 Report bugs to the Bioperl bug tracking system to help us keep track
56 the bugs and their resolution. Bug reports can be submitted via the
57 web:
58  
59 https://github.com/bioperl/bioperl-live/issues
60  
61 =head1 AUTHOR - Jason Stajich
62  
63 Previous committed by the Fugu Team
64  
65 Re-written by Jason Stajich jason-at-bioperl-dot-org
66  
67 =head1 APPENDIX
68  
69 The rest of the documentation details each of the object methods.
70 Internal methods are usually preceded with a _
71  
72 =cut
73  
74  
75 # Let the code begin...
76  
77  
78 package Bio::Tools::Pseudowise;
79 2 $Bio::Tools::Pseudowise::VERSION = '1.7.8';
80 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 2 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83 2 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 2 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 2 ▶use Bio::SeqFeature::Gene::Exon;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 2 ▶use Bio::SeqFeature::FeaturePair;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 2 ▶use Bio::SeqFeature::Gene::Transcript;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 2 ▶use Bio::SeqFeature::Gene::GeneStructure;
Subroutine BEGIN: called CC=1 SCAR=0.0
89  
90 2 ▶use base qw(Bio::Tools::AnalysisResult);
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 1 ▶sub _initialize_state {
Subroutine _initialize_state: called CC=1 SCAR=0.0
93 1 my ($self,@args) = @_;
94  
95 # first call the inherited method!
96 1 $self->SUPER::_initialize_state(@args);
97  
98 # our private state variables
99 1 $self->{'_preds_parsed'} = 0;
100 1 $self->{'_has_cds'} = 0;
101 # array of pre-parsed predictions
102 1 $self->{'_preds'} = [];
103 # seq stack
104 1 $self->{'_seqstack'} = [];
105 }
106  
107 =head2 analysis_method
108  
109 Usage : $pseudowise->analysis_method();
110 Purpose : Inherited method. Overridden to ensure that the name matches
111 /pseudowise/i.
112 Returns : String
113 Argument : n/a
114  
115 =cut
116  
117 #-------------
118 0 ▶sub analysis_method {
Subroutine analysis_method: not called CC=3 SCAR=24.8
Pod documented
119 #-------------
120 0 my ($self, $method) = @_;
121 0 ▶ if($method && ($method !~ /pseudowise/i)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method and not $method =~ /pseudowise/i) 0 0 0
Condition0%0/3
$method and not $method =~ /pseudowise/i
!ll&&!rl&&r
000
MC/DC0%0/2
$method and not $method =~ /pseudowise/i
$method not $method =~ /pseudowise/i
Truth table0%0/3
A and not(B)
A= $methodB= not $method =~ /pseudowise/i
ABresult
0X0
100
111
122 0 $self->throw("method $method not supported in " . ref($self));
123 }
124 0 return $self->SUPER::analysis_method($method);
125 }
126  
127 =head2 next_feature
128  
129 Title : next_feature
130 Usage : $seqfeature = $obj->next_feature();
131 Function: Returns the next feature available in the analysis result, or
132 undef if there are no more features.
133 Example :
134 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
135 more features.
136 Args : none
137  
138 See Also L<Bio::SeqFeatureI>
139  
140 =cut
141  
142 0 ▶sub next_feature {
Subroutine next_feature: not called CC=1 SCAR=6.9
Pod documented
143 0 return shift->next_prediction(@_);
144 }
145  
146  
147 =head2 next_prediction
148  
149 Title : next_prediction
150 Usage : while($gene = $pseudowise->next_prediction()) {
151 # do something
152 }
153 Function: Returns the gene of the Pseudowise result
154 file. Call this method repeatedly until FALSE is returned.
155  
156 Example :
157 Returns : a Bio::SeqFeature::Generic
158 Args : none
159  
160 See Also L<Bio::SeqFeature::Generic>
161  
162 =cut
163  
164 2 ▶sub next_prediction {
Subroutine next_prediction: called CC=2 SCAR=6.9
Pod documented
165 2 my ($self) = @_;
166 # if the prediction section hasn't been parsed yet, we do this now
167 2 ▶ $self->_parse_predictions unless $self->_predictions_parsed;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_predictions_parsed 1 1 2
168  
169 # get next gene structure
170 2 return $self->_prediction();
171 }
172  
173 =head2 _parse_predictions
174  
175 Title : _parse_predictions()
176 Usage : $obj->_parse_predictions()
177 Function: Parses the prediction section. Automatically called by
178 next_prediction() if not yet done.
179 Example :
180 Returns :
181  
182 =cut
183  
184 1 ▶sub _parse_predictions {
Subroutine _parse_predictions: called CC=10 SCAR=23.3
185 1 my ($self) = @_;
186 1 my $gene;
187 my @genes;
188  
189 1 local $/= "\n";
190 1 local($_);
191 1 my %tags;
192 1 ▶ while (defined( $_ = $self->_readline)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 16 1 17
193 16 ▶ if( /^(Total codons|\S+)\s+:\s+(\S+)/ ) {
Branch: 5 branches
BranchTrueFalseTotal
if (/^(Total codons|\S+)\s+:\s+(\S+)/) { } 9 7 16
elsif (m[^//]) { } 2 5 7
elsif (/Gene\s+(\d+)\s*$/i) { } 1 4 5
elsif (/Gene\s+(\d+)\s+(\d+)/i) { } 1 3 4
elsif (/Exon\s+(\d+)\s+(\d+)\s+phase\s+(\S+)/i) { } 2 1 3
194 9 $tags{$1} = $2;
195 } elsif(m!^//! ) {
196 2 ▶ if( $gene ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gene) 1 1 2
197 1 $gene = undef;
198 1 %tags = ();
199 }
200 } elsif (/Gene\s+(\d+)\s*$/i) {
201 1 $gene = Bio::SeqFeature::Generic->new
202 ( -primary => 'pseudogene',
203 -source => 'pseudowise',
204 -tag => \%tags);
205 1 push @genes, $gene;
206 } elsif( /Gene\s+(\d+)\s+(\d+)/i ) {
207 1 ▶ if( $1 < $2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 < $2) { } 1 0 1
208 1 $gene->start($1);
209 1 $gene->end($2);
210 1 $gene->strand(1);
211 } else {
212 0 $gene->start($2);
213 0 $gene->end($1);
214 0 $gene->strand(-1);
215 }
216 } elsif (/Exon\s+(\d+)\s+(\d+)\s+phase\s+(\S+)/i) {
217 2 my ($s,$e,$st) = ($1,$2,1);
218 2 ▶ if( $s > $e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $e) 0 2 2
219 0 ($s,$e,$st)=($e,$s,-1);
220 }
221 2 my $exon = Bio::SeqFeature::Generic->new
222 ( -start => $s,
223 -end => $e,
224 -strand => $st,
225 -primary => 'exon',
226 -source => 'pseudowise',
227 -tag => {'frame' => $3});
228 2 $gene->add_sub_SeqFeature($exon);
229 }
230 }
231 1 $self->_add_prediction(\@genes);
232 1 $self->_predictions_parsed(1);
233 }
234  
235 =head1 _prediction
236  
237 Title : _prediction()
238 Usage : $gene = $obj->_prediction()
239 Function: internal
240 Example :
241 Returns :
242  
243 =cut
244  
245 2 ▶sub _prediction {
Subroutine _prediction: called CC=2 SCAR=7.1
246 2 my ($self) = @_;
247 2 ▶ return shift(@{$self->{'_preds'} || []});
Condition50%1/2
$self->{'_preds'} || []
l!l
20
MC/DC0%0/1
$self->{'_preds'} || []
$self->{'_preds'}
Truth table50%1/2
A
A= $self->{'_preds'}
Aresult
11
00
248 }
249  
250 =head2 _add_prediction
251  
252 Title : _add_prediction()
253 Usage : $obj->_add_prediction($gene)
254 Function: internal
255 Example :
256 Returns :
257  
258 =cut
259  
260 1 ▶sub _add_prediction {
Subroutine _add_prediction: called CC=3 SCAR=12.3
261 1 my ($self, $gene) = @_;
262 1 ▶ $self->{'_preds'} ||= [];
Condition50%1/2
$self->{"_preds"} ||= []
l!l
10
MC/DC0%0/1
$self->{"_preds"} ||= []
$self->{"_preds"}
Truth table50%1/2
A
A= $self->{"_preds"}
Aresult
11
00
263  
264 1 ▶ if( ref($gene) =~ /ARRAY/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($gene) =~ /ARRAY/) { } 1 0 1
265 1 push(@{$self->{'_preds'}}, @$gene);
266 } else {
267 0 push(@{$self->{'_preds'}}, $gene);
268 }
269 }
270  
271 =head2 _predictions_parsed
272  
273 Title : _predictions_parsed
274 Usage : $obj->_predictions_parsed
275 Function: internal
276 Example :
277 Returns : TRUE or FALSE
278  
279 =cut
280  
281 3 ▶sub _predictions_parsed {
Subroutine _predictions_parsed: called CC=3 SCAR=11.3
282 3 my ($self, $val) = @_;
283  
284 3 ▶ $self->{'_preds_parsed'} = $val if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 1 2 3
285 3 ▶ if(! exists($self->{'_preds_parsed'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_preds_parsed"}) 0 3 3
286 0 $self->{'_preds_parsed'} = 0;
287 }
288 3 return $self->{'_preds_parsed'};
289 }
290  
291 2 1;
« Bio/Matrix/PSM/PsmHeader.pm ↑ Summary Bio/TreeIO/TreeEventBuilder.pm »