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