| 1 | # | ||||||||||
| 2 | # BioPerl module for Bio::Tools::Genomewise | ||||||||||
| 3 | # | ||||||||||
| 4 | # Copyright Jason Stajich <jason-at-bioperl.org> | ||||||||||
| 5 | # | ||||||||||
| 6 | # You may distribute this module under the same terms as perl itself | ||||||||||
| 7 | # | ||||||||||
| 8 | # POD documentation - main docs before the code | ||||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Bio::Tools::Genomewise - Results of one Genomewise run | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | use Bio::Tools::Genomewise; | ||||||||||
| 17 | my $gw = Bio::Tools::Genomewise(-file=>"genomewise.out"); | ||||||||||
| 18 | |||||||||||
| 19 | while (my $gene = $gw->next_prediction){ | ||||||||||
| 20 | my @transcripts = $gene->transcripts; | ||||||||||
| 21 | foreach my $t(@transcripts){ | ||||||||||
| 22 | my @exons = $t->exons; | ||||||||||
| 23 | foreach my $e(@exons){ | ||||||||||
| 24 | print $e->start." ".$e->end."\n"; | ||||||||||
| 25 | } | ||||||||||
| 26 | } | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | =head1 DESCRIPTION | ||||||||||
| 30 | |||||||||||
| 31 | This is the parser for the output of Genewise. It takes either a file | ||||||||||
| 32 | handle or a file name and returns a | ||||||||||
| 33 | Bio::SeqFeature::Gene::GeneStructure object. You will need to specify | ||||||||||
| 34 | the proper target sequence id on the object with the | ||||||||||
| 35 | $feature-E<gt>seq_id($seqid). | ||||||||||
| 36 | |||||||||||
| 37 | =head1 FEEDBACK | ||||||||||
| 38 | |||||||||||
| 39 | =head2 Mailing Lists | ||||||||||
| 40 | |||||||||||
| 41 | User feedback is an integral part of the evolution of this and other | ||||||||||
| 42 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||
| 43 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||
| 44 | |||||||||||
| 45 | bioperl-l@bioperl.org - General discussion | ||||||||||
| 46 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||
| 47 | |||||||||||
| 48 | =head2 Support | ||||||||||
| 49 | |||||||||||
| 50 | Please direct usage questions or support issues to the mailing list: | ||||||||||
| 51 | |||||||||||
| 52 | I<bioperl-l@bioperl.org> | ||||||||||
| 53 | |||||||||||
| 54 | rather than to the module maintainer directly. Many experienced and | ||||||||||
| 55 | reponsive experts will be able look at the problem and quickly | ||||||||||
| 56 | address it. Please include a thorough description of the problem | ||||||||||
| 57 | with code and data examples if at all possible. | ||||||||||
| 58 | |||||||||||
| 59 | =head2 Reporting Bugs | ||||||||||
| 60 | |||||||||||
| 61 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||
| 62 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||
| 63 | web: | ||||||||||
| 64 | |||||||||||
| 65 | https://github.com/bioperl/bioperl-live/issues | ||||||||||
| 66 | |||||||||||
| 67 | =head1 AUTHOR - Fugu Team, Jason Stajich | ||||||||||
| 68 | |||||||||||
| 69 | Email: fugui-at-worf.fugu-sg.org | ||||||||||
| 70 | jason-at-bioperl-dot-org | ||||||||||
| 71 | |||||||||||
| 72 | =head1 APPENDIX | ||||||||||
| 73 | |||||||||||
| 74 | The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ | ||||||||||
| 75 | |||||||||||
| 76 | =cut | ||||||||||
| 77 | |||||||||||
| 78 | |||||||||||
| 79 | # Let the code begin... | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | package Bio::Tools::Genomewise; | ||||||||||
| 83 | 4 | $Bio::Tools::Genomewise::VERSION = '1.7.8'; | |||||||||
| 84 | 4 | ▶ | use vars qw($Srctag); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 85 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 86 | |||||||||||
| 87 | 4 | ▶ | use Bio::Tools::AnalysisResult; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 88 | 4 | ▶ | use Bio::SeqFeature::Generic; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 89 | 4 | ▶ | use Bio::SeqFeature::Gene::Exon; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 90 | 4 | ▶ | use Bio::SeqFeature::FeaturePair; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 91 | 4 | ▶ | use Bio::SeqFeature::Gene::Transcript; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 92 | 4 | ▶ | use Bio::SeqFeature::Gene::GeneStructure; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 93 | |||||||||||
| 94 | 4 | ▶ | use base qw(Bio::Tools::Genewise); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 95 | |||||||||||
| 96 | 4 | $Srctag = 'genomewise'; | |||||||||
| 97 | |||||||||||
| 98 | =head2 new | ||||||||||
| 99 | |||||||||||
| 100 | Title : new | ||||||||||
| 101 | Usage : $obj->new(-file=>"genewise.out"); | ||||||||||
| 102 | $obj->new(-fh=>\*GW); | ||||||||||
| 103 | Function: Constructor for genomewise wrapper. Takes either a file or filehandle | ||||||||||
| 104 | Example : | ||||||||||
| 105 | Returns : L<Bio::Tools::Genomewise> | ||||||||||
| 106 | |||||||||||
| 107 | =cut | ||||||||||
| 108 | |||||||||||
| 109 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 110 | 2 | my($class,@args) = @_; | |||||||||
| 111 | 2 | my $self = $class->SUPER::new(@args); | |||||||||
| 112 | 2 | return $self; | |||||||||
| 113 | } | ||||||||||
| 114 | |||||||||||
| 115 | =head2 _get_strand | ||||||||||
| 116 | |||||||||||
| 117 | Title : _get_strand | ||||||||||
| 118 | Usage : $obj->_get_strand | ||||||||||
| 119 | Function: takes start and end values, swap them if start>end and returns end | ||||||||||
| 120 | Example : | ||||||||||
| 121 | Returns :$start,$end,$strand | ||||||||||
| 122 | |||||||||||
| 123 | =cut | ||||||||||
| 124 | |||||||||||
| 125 | =head2 score | ||||||||||
| 126 | |||||||||||
| 127 | Title : score | ||||||||||
| 128 | Usage : $obj->score | ||||||||||
| 129 | Function: get/set for score info | ||||||||||
| 130 | Example : | ||||||||||
| 131 | Returns : a score value | ||||||||||
| 132 | |||||||||||
| 133 | =cut | ||||||||||
| 134 | |||||||||||
| 135 | =head2 _prot_id | ||||||||||
| 136 | |||||||||||
| 137 | Title : _prot_id | ||||||||||
| 138 | Usage : $obj->_prot_id | ||||||||||
| 139 | Function: get/set for protein id | ||||||||||
| 140 | Example : | ||||||||||
| 141 | Returns :a protein id | ||||||||||
| 142 | |||||||||||
| 143 | =cut | ||||||||||
| 144 | |||||||||||
| 145 | =head2 _target_id | ||||||||||
| 146 | |||||||||||
| 147 | Title : _target_id | ||||||||||
| 148 | Usage : $obj->_target_id | ||||||||||
| 149 | Function: get/set for genomic sequence id | ||||||||||
| 150 | Example : | ||||||||||
| 151 | Returns :a target id | ||||||||||
| 152 | |||||||||||
| 153 | =cut | ||||||||||
| 154 | |||||||||||
| 155 | |||||||||||
| 156 | =head2 next_prediction | ||||||||||
| 157 | |||||||||||
| 158 | Title : next_prediction | ||||||||||
| 159 | Usage : while($gene = $genewise->next_prediction()) { | ||||||||||
| 160 | # do something | ||||||||||
| 161 | } | ||||||||||
| 162 | Function: Returns the gene structure prediction of the Genomewise result | ||||||||||
| 163 | file. Call this method repeatedly until FALSE is returned. | ||||||||||
| 164 | |||||||||||
| 165 | Example : | ||||||||||
| 166 | Returns : a Bio::SeqFeature::Gene::GeneStructure object | ||||||||||
| 167 | Args : | ||||||||||
| 168 | |||||||||||
| 169 | =cut | ||||||||||
| 170 | |||||||||||
| 171 | |||||||||||
| 172 | 8 | ▶ | sub next_prediction { | ||||||||
|
Subroutine
next_prediction: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||
| 173 | 8 | my ($self) = @_; | |||||||||
| 174 | |||||||||||
| 175 | 8 | my $genes; | |||||||||
| 176 | 8 | ▶ | while ($_ = $self->_readline) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 177 | 8 | $self->debug( $_ ); | |||||||||
| 178 | 8 | ▶ | last if m{^//}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 179 | |||||||||||
| 180 | 6 | ▶ | if( /^Gene\s+\d+\s*$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 181 | 6 | $genes = Bio::SeqFeature::Gene::GeneStructure->new | |||||||||
| 182 | (-source => $Srctag, | ||||||||||
| 183 | -seq_id => $self->_target_id, # if this had been specified | ||||||||||
| 184 | ); | ||||||||||
| 185 | 6 | $_ = $self->_readline; | |||||||||
| 186 | 6 | $self->debug( $_ ); | |||||||||
| 187 | |||||||||||
| 188 | 6 | ▶ | unless ( /^Gene\s+(\d+)\s+(\d+)\s*$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 189 | 0 | $self->warn("Unparseable genomewise output"); | |||||||||
| 190 | 0 | last; | |||||||||
| 191 | } | ||||||||||
| 192 | 6 | my $transcript = Bio::SeqFeature::Gene::Transcript->new | |||||||||
| 193 | (-source => $Srctag, | ||||||||||
| 194 | -seq_id => $self->_target_id, # if this had been specified | ||||||||||
| 195 | -start => $1, | ||||||||||
| 196 | -end => $2, | ||||||||||
| 197 | ); | ||||||||||
| 198 | 6 | my $nbr = 1; | |||||||||
| 199 | 6 | ▶ | while( $_ = $self->_readline ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 200 | 26 | $self->debug( $_ ); | |||||||||
| 201 | |||||||||||
| 202 | 26 | ▶ | unless( m/^\s+Exon\s+(\d+)\s+(\d+)\s+phase\s+(\d+)/ ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 203 | 6 | $self->_pushback($_); | |||||||||
| 204 | 6 | last; | |||||||||
| 205 | } | ||||||||||
| 206 | 20 | my ($e_start,$e_end,$phase,$e_strand) = ($1,$2,$3); | |||||||||
| 207 | |||||||||||
| 208 | 20 | ($e_start,$e_end,$e_strand) = $self->_get_strand($e_start, | |||||||||
| 209 | $e_end); | ||||||||||
| 210 | 20 | ▶ | $transcript->strand($e_strand) unless $transcript->strand != 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 211 | |||||||||||
| 212 | 20 | my $exon = Bio::SeqFeature::Gene::Exon->new | |||||||||
| 213 | (-seq_id=>$self->_target_id, | ||||||||||
| 214 | -source => $Srctag, | ||||||||||
| 215 | -start=>$e_start, | ||||||||||
| 216 | -end=>$e_end, | ||||||||||
| 217 | -frame => $phase, | ||||||||||
| 218 | -strand=>$e_strand); | ||||||||||
| 219 | 20 | $exon->add_tag_value("Exon",$nbr++); | |||||||||
| 220 | 20 | $exon->add_tag_value('phase',$phase); | |||||||||
| 221 | 20 | $transcript->add_exon($exon); | |||||||||
| 222 | } | ||||||||||
| 223 | 6 | $genes->add_transcript($transcript); | |||||||||
| 224 | 6 | last; # only process a single gene at a time | |||||||||
| 225 | } | ||||||||||
| 226 | } | ||||||||||
| 227 | 8 | return $genes; | |||||||||
| 228 | } | ||||||||||
| 229 | |||||||||||
| 230 | 4 | 1; | |||||||||