2 # BioPerl module for Bio::Tools::Grail
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason-at-bioperl.org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Tools::Grail - Results of one Grail run
20 $grail = Bio::Tools::Grail->new(-file => 'result.grail');
22 $grail = Bio::Tools::Grail->new( -fh => \*INPUT );
25 while($gene = $grail->next_prediction()) {
26 # $gene is an instance of Bio::Tools::Prediction::Gene
28 # $gene->exons() returns an array of
29 # Bio::Tools::Prediction::Exon objects
31 @exon_arr = $gene->exons();
34 @init_exons = $gene->exons('Initial');
36 @intrl_exons = $gene->exons('Internal');
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');
44 # essential if you gave a filename at initialization (otherwise the file
50 The Grail module provides a parser for Grail gene structure prediction
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.
62 bioperl-l@bioperl.org - General discussion
63 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
67 Please direct usage questions or support issues to the mailing list:
69 I<bioperl-l@bioperl.org>
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.
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
82 https://github.com/bioperl/bioperl-live/issues
84 =head1 AUTHOR - Jason Stajich
86 Email jason-at-bioperl.org
90 The rest of the documentation details each of the object
91 methods. Internal methods are usually preceded with a _
95 # Let the code begin...
97 package Bio
::Tools
::Grail
;
100 use Bio
::Tools
::Prediction
::Gene
;
101 use Bio
::Tools
::Prediction
::Exon
;
104 use base
qw(Bio::Root::IO Bio::Root::Root);
107 my($class,@args) = @_;
109 my $self = $class->SUPER::new
(@args);
110 $self->_initialize_io(@args);
115 =head2 next_prediction
117 Title : next_prediction
118 Usage : while($gene = $grail->next_prediction()) {
121 Function: Returns the next gene structure prediction of the Grail result
122 file. Call this method repeatedly until FALSE is returned.
125 Returns : A Bio::Tools::Prediction::Gene object.
130 sub next_prediction
{
133 # get next gene structure
134 my $gene = $self->_prediction();
137 # fill in predicted protein, and if available the predicted CDS
140 # use the seq stack if there's a seq on it
141 my $seqobj = pop(@
{$self->{'_seqstack'}});
143 # otherwise read from input stream
144 ($id, $seq) = $self->_read_fasta_seq();
145 $seqobj = Bio
::PrimarySeq
->new('-seq' => $seq,
146 '-display_id' => $id,
147 '-alphabet' => "protein");
149 # check that prediction number matches the prediction number
150 # indicated in the sequence id (there may be incomplete gene
151 # predictions that contain only signals with no associated protein
152 # and CDS, like promoters, poly-A sites etc)
153 $gene->primary_tag() =~ /[^0-9]([0-9]+)$/;
155 if($seqobj->display_id() !~ /_predicted_\w+_$prednr\|/) {
156 # this is not our sequence, so push back for the next prediction
157 push(@
{$self->{'_seqstack'}}, $seqobj);
159 $gene->predicted_protein($seqobj);
160 # CDS prediction, too?
161 if($self->_has_cds()) {
162 ($id, $seq) = $self->_read_fasta_seq();
163 $seqobj = Bio
::PrimarySeq
->new('-seq' => $seq,
164 '-display_id' => $id,
165 '-alphabet' => "dna");
166 $gene->predicted_cds($seqobj);
173 =head2 _parse_predictions
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.
184 sub _parse_predictions
{
187 # code needs to go here
189 $self->_predictions_parsed(1);
194 Title : _prediction()
195 Usage : $gene = $obj->_prediction()
205 return unless(exists($self->{'_preds'}) && @
{$self->{'_preds'}});
206 return shift(@
{$self->{'_preds'}});
209 =head2 _add_prediction
211 Title : _add_prediction()
212 Usage : $obj->_add_prediction($gene)
219 sub _add_prediction
{
220 my ($self, $gene) = @_;
222 if(! exists($self->{'_preds'})) {
223 $self->{'_preds'} = [];
225 push(@
{$self->{'_preds'}}, $gene);
228 =head2 _predictions_parsed
230 Title : _predictions_parsed
231 Usage : $obj->_predictions_parsed
234 Returns : TRUE or FALSE
238 sub _predictions_parsed
{
239 my ($self, $val) = @_;
241 $self->{'_preds_parsed'} = $val if $val;
242 if(! exists($self->{'_preds_parsed'})) {
243 $self->{'_preds_parsed'} = 0;
245 return $self->{'_preds_parsed'};
251 Usage : $obj->_has_cds()
252 Function: Whether or not the result contains the predicted CDSs, too.
254 Returns : TRUE or FALSE
259 my ($self, $val) = @_;
261 $self->{'_has_cds'} = $val if $val;
262 if(! exists($self->{'_has_cds'})) {
263 $self->{'_has_cds'} = 0;
265 return $self->{'_has_cds'};