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
;
84 use Bio
::SeqFeature
::Generic
;
85 use Bio
::SeqFeature
::Gene
::Exon
;
86 use Bio
::SeqFeature
::FeaturePair
;
87 use Bio
::SeqFeature
::Gene
::Transcript
;
88 use Bio
::SeqFeature
::Gene
::GeneStructure
;
90 use base
qw(Bio::Tools::AnalysisResult);
92 sub _initialize_state
{
93 my ($self,@args) = @_;
95 # first call the inherited method!
96 $self->SUPER::_initialize_state
(@args);
98 # our private state variables
99 $self->{'_preds_parsed'} = 0;
100 $self->{'_has_cds'} = 0;
101 # array of pre-parsed predictions
102 $self->{'_preds'} = [];
104 $self->{'_seqstack'} = [];
107 =head2 analysis_method
109 Usage : $pseudowise->analysis_method();
110 Purpose : Inherited method. Overridden to ensure that the name matches
118 sub analysis_method
{
120 my ($self, $method) = @_;
121 if($method && ($method !~ /pseudowise/i)) {
122 $self->throw("method $method not supported in " . ref($self));
124 return $self->SUPER::analysis_method
($method);
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.
134 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
138 See Also L<Bio::SeqFeatureI>
143 return shift->next_prediction(@_);
147 =head2 next_prediction
149 Title : next_prediction
150 Usage : while($gene = $pseudowise->next_prediction()) {
153 Function: Returns the gene of the Pseudowise result
154 file. Call this method repeatedly until FALSE is returned.
157 Returns : a Bio::SeqFeature::Generic
160 See Also L<Bio::SeqFeature::Generic>
164 sub next_prediction
{
166 # if the prediction section hasn't been parsed yet, we do this now
167 $self->_parse_predictions unless $self->_predictions_parsed;
169 # get next gene structure
170 return $self->_prediction();
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
{
192 while (defined( $_ = $self->_readline)){
193 if( /^(Total codons|\S+)\s+:\s+(\S+)/ ) {
200 } elsif (/Gene\s+(\d+)\s*$/i) {
201 $gene = Bio
::SeqFeature
::Generic
->new
202 ( -primary
=> 'pseudogene',
203 -source
=> 'pseudowise',
206 } elsif( /Gene\s+(\d+)\s+(\d+)/i ) {
216 } elsif (/Exon\s+(\d+)\s+(\d+)\s+phase\s+(\S+)/i) {
217 my ($s,$e,$st) = ($1,$2,1);
219 ($s,$e,$st)=($e,$s,-1);
221 my $exon = Bio
::SeqFeature
::Generic
->new
226 -source
=> 'pseudowise',
227 -tag
=> {'frame' => $3});
228 $gene->add_sub_SeqFeature($exon);
231 $self->_add_prediction(\
@genes);
232 $self->_predictions_parsed(1);
237 Title : _prediction()
238 Usage : $gene = $obj->_prediction()
247 return shift(@
{$self->{'_preds'} || []});
250 =head2 _add_prediction
252 Title : _add_prediction()
253 Usage : $obj->_add_prediction($gene)
260 sub _add_prediction
{
261 my ($self, $gene) = @_;
262 $self->{'_preds'} ||= [];
264 if( ref($gene) =~ /ARRAY/ ) {
265 push(@
{$self->{'_preds'}}, @
$gene);
267 push(@
{$self->{'_preds'}}, $gene);
271 =head2 _predictions_parsed
273 Title : _predictions_parsed
274 Usage : $obj->_predictions_parsed
277 Returns : TRUE or FALSE
281 sub _predictions_parsed
{
282 my ($self, $val) = @_;
284 $self->{'_preds_parsed'} = $val if $val;
285 if(! exists($self->{'_preds_parsed'})) {
286 $self->{'_preds_parsed'} = 0;
288 return $self->{'_preds_parsed'};