Bio/Tools/Grail.pm

filter: Statementstmt 26.9% 17 / 63 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 41.6% 5 / 12 Podpod 100% 2 / 2 totaltotal 23.5% 24 / 102 CC 12 SCAR 25.0
CC
12
Cov
20%
next_prediction
30.0
_prediction
12.0
_predictions_parsed
12.0
CRAP 12.1
« Bio/TreeIO/lintree.pm ↑ Summary Bio/Search/Result/PullResultI.pm »
1 #
2 # BioPerl module for Bio::Tools::Grail
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::Grail - Results of one Grail run
17  
18 =head1 SYNOPSIS
19  
20 $grail = Bio::Tools::Grail->new(-file => 'result.grail');
21 # filehandle:
22 $grail = Bio::Tools::Grail->new( -fh => \*INPUT );
23  
24 # parse the results
25 while($gene = $grail->next_prediction()) {
26 # $gene is an instance of Bio::Tools::Prediction::Gene
27  
28 # $gene->exons() returns an array of
29 # Bio::Tools::Prediction::Exon objects
30 # all exons:
31 @exon_arr = $gene->exons();
32  
33 # initial exons only
34 @init_exons = $gene->exons('Initial');
35 # internal exons only
36 @intrl_exons = $gene->exons('Internal');
37 # terminal exons only
38 @term_exons = $gene->exons('Terminal');
39 # singleton exons only -- should be same as $gene->exons() because
40 # there are no other exons supposed to exist in this structure
41 @single_exons = $gene->exons('Single');
42 }
43  
44 # essential if you gave a filename at initialization (otherwise the file
45 # will stay open)
46 $genscan->close();
47  
48 =head1 DESCRIPTION
49  
50 The Grail module provides a parser for Grail gene structure prediction
51 output.
52  
53  
54 =head1 FEEDBACK
55  
56 =head2 Mailing Lists
57  
58 User feedback is an integral part of the evolution of this and other
59 Bioperl modules. Send your comments and suggestions preferably to one
60 of the Bioperl mailing lists. Your participation is much appreciated.
61  
62 bioperl-l@bioperl.org - General discussion
63 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
64  
65 =head2 Support
66  
67 Please direct usage questions or support issues to the mailing list:
68  
69 I<bioperl-l@bioperl.org>
70  
71 rather than to the module maintainer directly. Many experienced and
72 reponsive experts will be able look at the problem and quickly
73 address it. Please include a thorough description of the problem
74 with code and data examples if at all possible.
75  
76 =head2 Reporting Bugs
77  
78 Report bugs to the Bioperl bug tracking system to help us keep track
79 the bugs and their resolution. Bug reports can be submitted via the
80 web:
81  
82 https://github.com/bioperl/bioperl-live/issues
83  
84 =head1 AUTHOR - Jason Stajich
85  
86 Email jason-at-bioperl.org
87  
88 =head1 APPENDIX
89  
90 The rest of the documentation details each of the object
91 methods. Internal methods are usually preceded with a _
92  
93 =cut
94  
95 # Let the code begin...
96  
97 package Bio::Tools::Grail;
98 1 $Bio::Tools::Grail::VERSION = '1.7.8';
99 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
100  
101 1 ▶use Bio::Tools::Prediction::Gene;
Subroutine BEGIN: called CC=1 SCAR=0.0
102 1 ▶use Bio::Tools::Prediction::Exon;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 1 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 1 ▶use base qw(Bio::Root::IO Bio::Root::Root);
Subroutine BEGIN: called CC=1 SCAR=0.0
106  
107 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
108 0 my($class,@args) = @_;
109  
110 0 my $self = $class->SUPER::new(@args);
111 0 $self->_initialize_io(@args);
112  
113 0 return $self;
114 }
115  
116 =head2 next_prediction
117  
118 Title : next_prediction
119 Usage : while($gene = $grail->next_prediction()) {
120 # do something
121 }
122 Function: Returns the next gene structure prediction of the Grail result
123 file. Call this method repeatedly until FALSE is returned.
124  
125 Example :
126 Returns : A Bio::Tools::Prediction::Gene object.
127 Args :
128  
129 =cut
130  
131 0 ▶sub next_prediction {
Subroutine next_prediction: not called CC=5 SCAR=34.0
Pod documented
132 0 my ($self) = @_;
133
134 # get next gene structure
135 0 my $gene = $self->_prediction();
136  
137 0 ▶ if($gene) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gene) 0 0 0
138 # fill in predicted protein, and if available the predicted CDS
139 #
140 0 my ($id, $seq);
141 # use the seq stack if there's a seq on it
142 0 my $seqobj = pop(@{$self->{'_seqstack'}});
143 0 ▶ if(! $seqobj) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seqobj) 0 0 0
144 # otherwise read from input stream
145 0 ($id, $seq) = $self->_read_fasta_seq();
146 0 $seqobj = Bio::PrimarySeq->new('-seq' => $seq,
147 '-display_id' => $id,
148 '-alphabet' => "protein");
149 }
150 # check that prediction number matches the prediction number
151 # indicated in the sequence id (there may be incomplete gene
152 # predictions that contain only signals with no associated protein
153 # and CDS, like promoters, poly-A sites etc)
154 0 $gene->primary_tag() =~ /[^0-9]([0-9]+)$/;
155 0 my $prednr = $1;
156 0 ▶ if($seqobj->display_id() !~ /_predicted_\w+_$prednr\|/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $seqobj->display_id =~ /_predicted_\w+_$prednr\|/) { } 0 0 0
157 # this is not our sequence, so push back for the next prediction
158 0 push(@{$self->{'_seqstack'}}, $seqobj);
159 } else {
160 0 $gene->predicted_protein($seqobj);
161 # CDS prediction, too?
162 0 ▶ if($self->_has_cds()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_has_cds) 0 0 0
163 0 ($id, $seq) = $self->_read_fasta_seq();
164 0 $seqobj = Bio::PrimarySeq->new('-seq' => $seq,
165 '-display_id' => $id,
166 '-alphabet' => "dna");
167 0 $gene->predicted_cds($seqobj);
168 }
169 }
170 }
171 0 return $gene;
172 }
173  
174 =head2 _parse_predictions
175  
176 Title : _parse_predictions()
177 Usage : $obj->_parse_predictions()
178 Function: Parses the prediction section. Automatically called by
179 next_prediction() if not yet done.
180 Example :
181 Returns :
182  
183 =cut
184  
185 0 ▶sub _parse_predictions {
Subroutine _parse_predictions: not called CC=1 SCAR=6.9
186 0 my ($self) = @_;
187  
188 # code needs to go here
189
190 0 $self->_predictions_parsed(1);
191 }
192  
193 =head2 _prediction
194  
195 Title : _prediction()
196 Usage : $gene = $obj->_prediction()
197 Function: internal
198 Example :
199 Returns :
200  
201 =cut
202  
203 0 ▶sub _prediction {
Subroutine _prediction: not called CC=3 SCAR=24.8
204 0 my ($self) = @_;
205  
206 0 ▶ return unless(exists($self->{'_preds'}) && @{$self->{'_preds'}});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_preds"} and @{$self->{"_preds"};} 0 0 0
Condition0%0/3
exists $self->{"_preds"} and @{$self->{"_preds"};}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"_preds"} and @{$self->{"_preds"};}
exists $self->{"_preds"} @{$self->{"_preds"};}
Truth table0%0/3
A and B
A= exists $self->{"_preds"}B= @{$self->{"_preds"};}
ABresult
0X0
100
111
207 0 return shift(@{$self->{'_preds'}});
208 }
209  
210 =head2 _add_prediction
211  
212 Title : _add_prediction()
213 Usage : $obj->_add_prediction($gene)
214 Function: internal
215 Example :
216 Returns :
217  
218 =cut
219  
220 0 ▶sub _add_prediction {
Subroutine _add_prediction: not called CC=2 SCAR=17.9
221 0 my ($self, $gene) = @_;
222  
223 0 ▶ if(! exists($self->{'_preds'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_preds"}) 0 0 0
224 0 $self->{'_preds'} = [];
225 }
226 0 push(@{$self->{'_preds'}}, $gene);
227 }
228  
229 =head2 _predictions_parsed
230  
231 Title : _predictions_parsed
232 Usage : $obj->_predictions_parsed
233 Function: internal
234 Example :
235 Returns : TRUE or FALSE
236  
237 =cut
238  
239 0 ▶sub _predictions_parsed {
Subroutine _predictions_parsed: not called CC=3 SCAR=24.8
240 0 my ($self, $val) = @_;
241  
242 0 ▶ $self->{'_preds_parsed'} = $val if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 0 0 0
243 0 ▶ if(! exists($self->{'_preds_parsed'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_preds_parsed"}) 0 0 0
244 0 $self->{'_preds_parsed'} = 0;
245 }
246 0 return $self->{'_preds_parsed'};
247 }
248  
249 =head2 _has_cds
250  
251 Title : _has_cds()
252 Usage : $obj->_has_cds()
253 Function: Whether or not the result contains the predicted CDSs, too.
254 Example :
255 Returns : TRUE or FALSE
256  
257 =cut
258  
259 0 ▶sub _has_cds {
Subroutine _has_cds: not called CC=3 SCAR=24.8
260 0 my ($self, $val) = @_;
261  
262 0 ▶ $self->{'_has_cds'} = $val if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 0 0 0
263 0 ▶ if(! exists($self->{'_has_cds'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_has_cds"}) 0 0 0
264 0 $self->{'_has_cds'} = 0;
265 }
266 0 return $self->{'_has_cds'};
267 }
268  
269 1 1;
« Bio/TreeIO/lintree.pm ↑ Summary Bio/Search/Result/PullResultI.pm »