[Bioperl-guts-l] bioperl-live/Bio/Tools Pseudowise.pm,1.6,1.7
Jason Stajich
jason at pub.open-bio.org
Sun Sep 25 14:34:28 EDT 2005
Update of /home/repository/bioperl/bioperl-live/Bio/Tools
In directory pub.open-bio.org:/tmp/cvs-serv12840/Bio/Tools
Modified Files:
Pseudowise.pm
Log Message:
rewritten parser
Index: Pseudowise.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/Pseudowise.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Pseudowise.pm 16 Jan 2003 22:41:33 -0000 1.6
--- Pseudowise.pm 25 Sep 2005 18:34:26 -0000 1.7
***************
*** 1,5 ****
# BioPerl module for Bio::Tools::Pseudowise
#
! # Copyright Fugu Team
#
# You may distribute this module under the same terms as perl itself
--- 1,7 ----
# BioPerl module for Bio::Tools::Pseudowise
#
! # $Id$
! #
! # Copyright Jason Stajich, Fugu Team
#
# You may distribute this module under the same terms as perl itself
***************
*** 22,27 ****
=head1 DESCRIPTION
! Pseudowise is a pseudogene prediction program written by Ewan Birney as part of the
! Wise Package. This module is the parser for the output of the program.
http://www.sanger.ac.uk/software/wise2
--- 24,30 ----
=head1 DESCRIPTION
! Pseudowise is a pseudogene prediction program written by Ewan Birney
! as part of the Wise Package. This module is the parser for the output
! of the program.
http://www.sanger.ac.uk/software/wise2
***************
*** 41,53 ****
Report bugs to the Bioperl bug tracking system to help us keep track
! the bugs and their resolution. Bug reports can be submitted via email
! or the web:
- bioperl-bugs at bio.perl.org
http://bugzilla.bioperl.org/
! =head1 AUTHOR - Fugu Team
! Describe contact details here
=head1 APPENDIX
--- 44,57 ----
Report bugs to the Bioperl bug tracking system to help us keep track
! the bugs and their resolution. Bug reports can be submitted via the
! web:
http://bugzilla.bioperl.org/
! =head1 AUTHOR - Jason Stajich
! Previous committed by the Fugu Team
!
! Re-written by Jason Stajich jason-at-bioperl-dot-org
=head1 APPENDIX
***************
*** 112,115 ****
--- 116,139 ----
}
+ =head2 next_feature
+
+ Title : next_feature
+ Usage : $seqfeature = $obj->next_feature();
+ Function: Returns the next feature available in the analysis result, or
+ undef if there are no more features.
+ Example :
+ Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
+ more features.
+ Args : none
+
+ See Also L<Bio::SeqFeatureI>
+
+ =cut
+
+ sub next_feature {
+ return shift->next_prediction(@_);
+ }
+
+
=head2 next_prediction
***************
*** 123,141 ****
Example :
Returns : a Bio::SeqFeature::Generic
! Args :
=cut
sub next_prediction {
! my ($self,$filehandle) = @_;
! my $gene;
!
# if the prediction section hasn't been parsed yet, we do this now
! $self->_parse_predictions($filehandle) unless $self->_predictions_parsed();
# get next gene structure
! $gene = $self->_prediction();
!
! return $gene;
}
--- 147,163 ----
Example :
Returns : a Bio::SeqFeature::Generic
! Args : none
!
! See Also L<Bio::SeqFeature::Generic>
=cut
sub next_prediction {
! my ($self) = @_;
# if the prediction section hasn't been parsed yet, we do this now
! $self->_parse_predictions unless $self->_predictions_parsed;
# get next gene structure
! return $self->_prediction();
}
***************
*** 152,205 ****
sub _parse_predictions {
! my ($self, $filehandle) = @_;
my $gene;
my @genes;
- #The big parsing loop - parses exons and predicted peptides
- while (<$filehandle>)
- {
- if (/Gene/i)
- {
- $gene = new Bio::SeqFeature::Generic (
- -primary => 'pseudogene',
- -source => 'pseudowise');
- push @genes, $gene;
! while(<$filehandle>) {
! my @gene_elements = split;
! my $no = scalar(@gene_elements);
! if ((/Gene/i) && $no == 3) {
! my @element = split;
! my $no = scalar(@element);
! my $gene_start = $element[1];
! my $gene_end = $element[2];
! $gene->start($gene_start);
! $gene->end($gene_end);
! }
! elsif (/Exon/i) {
! my @element = split;
! my $no = scalar(@element);
! my $exon_start = $element[1];
! my $exon_end = $element[2];
! my $exon_phase = $element[4];
! my $exon = new Bio::SeqFeature::Generic (
! -start => $exon_start,
! -end => $exon_end,
! -primary => 'exon',
! -source => 'pseudowise',
! -frame => $exon_phase);
! $gene->add_sub_SeqFeature($exon);
! }
! elsif ((/Gene/i) && $no != 3) {
! $gene = new Bio::SeqFeature::Generic (
! -primary => 'pseudogene',
! -source => 'pseudowise');
! push @genes, $gene;
! }
! }
! }
}
$self->_add_prediction(\@genes);
$self->_predictions_parsed(1);
-
}
--- 174,225 ----
sub _parse_predictions {
! my ($self) = @_;
my $gene;
my @genes;
! local $/= "\n";
! local($_);
! my %tags;
! while (defined( $_ = $self->_readline)){
! if( /^(Total codons|\S+)\s+:\s+(\S+)/ ) {
! $tags{$1} = $2;
! } elsif(m!^//! ) {
! if( $gene ) {
! $gene = undef;
! %tags = ();
! }
! } elsif (/Gene\s+(\d+)\s*$/i) {
! $gene = Bio::SeqFeature::Generic->new
! ( -primary => 'pseudogene',
! -source => 'pseudowise',
! -tag => \%tags);
! push @genes, $gene;
! } elsif( /Gene\s+(\d+)\s+(\d+)/i ) {
! if( $1 < $2 ) {
! $gene->start($1);
! $gene->end($2);
! $gene->strand(1);
! } else {
! $gene->start($2);
! $gene->end($1);
! $gene->strand(-1);
! }
! } elsif (/Exon\s+(\d+)\s+(\d+)\s+phase\s+(\S+)/i) {
! my ($s,$e,$st) = ($1,$2,1);
! if( $s > $e) {
! ($s,$e,$st)=($e,$s,-1);
! }
! my $exon = Bio::SeqFeature::Generic->new
! ( -start => $s,
! -end => $e,
! -strand => $st,
! -primary => 'exon',
! -source => 'pseudowise',
! -tag => {'frame' => $3});
! $gene->add_sub_SeqFeature($exon);
! }
}
$self->_add_prediction(\@genes);
$self->_predictions_parsed(1);
}
***************
*** 216,222 ****
sub _prediction {
my ($self) = @_;
!
! return undef unless(exists($self->{'_preds'}) && @{$self->{'_preds'}});
! return shift(@{$self->{'_preds'}});
}
--- 236,240 ----
sub _prediction {
my ($self) = @_;
! return shift(@{$self->{'_preds'} || []});
}
***************
*** 233,241 ****
sub _add_prediction {
my ($self, $gene) = @_;
! if(! exists($self->{'_preds'})) {
! $self->{'_preds'} = [];
}
- push(@{$self->{'_preds'}}, $gene);
}
--- 251,261 ----
sub _add_prediction {
my ($self, $gene) = @_;
+ $self->{'_preds'} ||= [];
! if( ref($gene) =~ /ARRAY/ ) {
! push(@{$self->{'_preds'}}, @$gene);
! } else {
! push(@{$self->{'_preds'}}, $gene);
}
}
More information about the Bioperl-guts-l
mailing list