1 # BioPerl module for Bio::Tools::Pseudowise
4 # Copyright Jason Stajich, Fugu Team
6 # You may distribute this module under the same terms as perl itself
8 # POD documentation - main docs before the code
12 Bio::Tools::Pseudowise - Results of one Pseudowise run
16 use Bio::Tools::Pseudowise;
18 my $parser = Bio::Tools::Pseudowise->new(-file=>"pw.out");
19 while(my $feat = $parser->next_result){
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
29 http://www.sanger.ac.uk/software/wise2
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.
39 bioperl-l@bioperl.org - General discussion
40 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44 Please direct usage questions or support issues to the mailing list:
46 I<bioperl-l@bioperl.org>
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.
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
59 https://github.com/bioperl/bioperl-live/issues
61 =head1 AUTHOR - Jason Stajich
63 Previous committed by the Fugu Team
65 Re-written by Jason Stajich jason-at-bioperl-dot-org
69 The rest of the documentation details each of the object methods.
70 Internal methods are usually preceded with a _
75 # Let the code begin...
78 package Bio
::Tools
::Pseudowise
;
83 use Bio
::SeqFeature
::Generic
;
84 use Bio
::SeqFeature
::Gene
::Exon
;
85 use Bio
::SeqFeature
::FeaturePair
;
86 use Bio
::SeqFeature
::Gene
::Transcript
;
87 use Bio
::SeqFeature
::Gene
::GeneStructure
;
89 use base
qw(Bio::Tools::AnalysisResult);
91 sub _initialize_state
{
92 my ($self,@args) = @_;
94 # first call the inherited method!
95 $self->SUPER::_initialize_state
(@args);
97 # our private state variables
98 $self->{'_preds_parsed'} = 0;
99 $self->{'_has_cds'} = 0;
100 # array of pre-parsed predictions
101 $self->{'_preds'} = [];
103 $self->{'_seqstack'} = [];
106 =head2 analysis_method
108 Usage : $pseudowise->analysis_method();
109 Purpose : Inherited method. Overridden to ensure that the name matches
117 sub analysis_method
{
119 my ($self, $method) = @_;
120 if($method && ($method !~ /pseudowise/i)) {
121 $self->throw("method $method not supported in " . ref($self));
123 return $self->SUPER::analysis_method
($method);
129 Usage : $seqfeature = $obj->next_feature();
130 Function: Returns the next feature available in the analysis result, or
131 undef if there are no more features.
133 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
137 See Also L<Bio::SeqFeatureI>
142 return shift->next_prediction(@_);
146 =head2 next_prediction
148 Title : next_prediction
149 Usage : while($gene = $pseudowise->next_prediction()) {
152 Function: Returns the gene of the Pseudowise result
153 file. Call this method repeatedly until FALSE is returned.
156 Returns : a Bio::SeqFeature::Generic
159 See Also L<Bio::SeqFeature::Generic>
163 sub next_prediction
{
165 # if the prediction section hasn't been parsed yet, we do this now
166 $self->_parse_predictions unless $self->_predictions_parsed;
168 # get next gene structure
169 return $self->_prediction();
172 =head2 _parse_predictions
174 Title : _parse_predictions()
175 Usage : $obj->_parse_predictions()
176 Function: Parses the prediction section. Automatically called by
177 next_prediction() if not yet done.
183 sub _parse_predictions
{
191 while (defined( $_ = $self->_readline)){
192 if( /^(Total codons|\S+)\s+:\s+(\S+)/ ) {
199 } elsif (/Gene\s+(\d+)\s*$/i) {
200 $gene = Bio
::SeqFeature
::Generic
->new
201 ( -primary
=> 'pseudogene',
202 -source
=> 'pseudowise',
205 } elsif( /Gene\s+(\d+)\s+(\d+)/i ) {
215 } elsif (/Exon\s+(\d+)\s+(\d+)\s+phase\s+(\S+)/i) {
216 my ($s,$e,$st) = ($1,$2,1);
218 ($s,$e,$st)=($e,$s,-1);
220 my $exon = Bio
::SeqFeature
::Generic
->new
225 -source
=> 'pseudowise',
226 -tag
=> {'frame' => $3});
227 $gene->add_sub_SeqFeature($exon);
230 $self->_add_prediction(\
@genes);
231 $self->_predictions_parsed(1);
236 Title : _prediction()
237 Usage : $gene = $obj->_prediction()
246 return shift(@
{$self->{'_preds'} || []});
249 =head2 _add_prediction
251 Title : _add_prediction()
252 Usage : $obj->_add_prediction($gene)
259 sub _add_prediction
{
260 my ($self, $gene) = @_;
261 $self->{'_preds'} ||= [];
263 if( ref($gene) =~ /ARRAY/ ) {
264 push(@
{$self->{'_preds'}}, @
$gene);
266 push(@
{$self->{'_preds'}}, $gene);
270 =head2 _predictions_parsed
272 Title : _predictions_parsed
273 Usage : $obj->_predictions_parsed
276 Returns : TRUE or FALSE
280 sub _predictions_parsed
{
281 my ($self, $val) = @_;
283 $self->{'_preds_parsed'} = $val if $val;
284 if(! exists($self->{'_preds_parsed'})) {
285 $self->{'_preds_parsed'} = 0;
287 return $self->{'_preds_parsed'};