maint: restructure to use Dist::Zilla
[bioperl-live.git] / lib / Bio / Tools / Eponine.pm
blob98282363135c65c083bbdfecf7a00d461b84cbe9
2 # BioPerl module for Bio::Tools::Eponine
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Tania Oh <gisoht@nus.edu.sg>
8 # Copyright Tania Oh
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::Tools::Eponine - Results of one Eponine run
18 =head1 SYNOPSIS
20 use Bio::Tools::Eponine;
21 use strict;
22 my $seq = "/data/seq.fa";
23 my $threshold = "0.999";
24 my @params = ( -seq => $seq,
25 -threshold => $threshold);
27 my $factory = Bio::Tools::Run::Eponine->new(@params);
28 # run eponine against fasta
29 my $r = $factory->run_eponine($seq);
30 my $parser = Bio::Tools::Eponine->new($r);
32 while (my $feat = $parser->next_prediction){
33 #$feat contains array of SeqFeature
34 foreach my $orf($feat) {
35 print $orf->seq_id. "\n";
39 =head1 DESCRIPTION
41 Parser for Eponine, a probabilistic transcription start site detector
42 optimized for mammalian genomic sequence. This module inherits off
43 Bio::Tools::AnalysisResult and therefore implements
44 Bio::SeqAnalysisParserI (see L<Bio::Tools::AnalysisResult> and
45 L<Bio::SeqAnalysisParserI>).
47 =head1 FEEDBACK
49 =head2 Mailing Lists
51 User feedback is an integral part of the evolution of this and other
52 Bioperl modules. Send your comments and suggestions preferably to one
53 of the Bioperl mailing lists. Your participation is much appreciated.
55 bioperl-l@bioperl.org - General discussion
56 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
58 =head2 Support
60 Please direct usage questions or support issues to the mailing list:
62 I<bioperl-l@bioperl.org>
64 rather than to the module maintainer directly. Many experienced and
65 reponsive experts will be able look at the problem and quickly
66 address it. Please include a thorough description of the problem
67 with code and data examples if at all possible.
69 =head2 Reporting Bugs
71 Report bugs to the Bioperl bug tracking system to help us keep track
72 the bugs and their resolution. Bug reports can be submitted via the
73 web:
75 https://github.com/bioperl/bioperl-live/issues
77 =head1 AUTHOR - Tania Oh
79 E<lt>gisoht-at-nus.edu.sgE<gt>
81 =head1 APPENDIX
83 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
85 =cut
88 # Let the code begin...
91 package Bio::Tools::Eponine;
92 use strict;
94 use Bio::Tools::Prediction::Gene;
95 use Bio::Tools::Prediction::Exon;
97 use base qw(Bio::Tools::AnalysisResult);
99 sub _initialize_state {
100 my($self,@args) = @_;
102 # first call the inherited method!
103 my $make = $self->SUPER::_initialize_state(@args);
105 # handle our own parameters
107 # our private state variables
108 $self->{'_preds_parsed'} = 0;
109 #array of Bio::SeqFeatures
110 $self->{'_flist'} =[];
113 =head2 analysis_method
115 Usage : $mzef->analysis_method();
116 Purpose : Inherited method. Overridden to ensure that the name matches
117 /mzef/i.
118 Returns : String
119 Argument : n/a
121 =cut
123 #-------------
124 sub analysis_method {
125 #-------------
126 my ($self, $method) = @_;
127 if($method && ($method !~ /epo/i)) {
128 $self->throw("method $method not supported in " . ref($self));
130 return $self->SUPER::analysis_method($method);
133 =head2 next_feature
135 Title : next_feature
136 Usage : while($gene = $mzef->next_feature()) {
137 # do something
139 Function: Returns the next gene structure prediction of the MZEF result
140 file. Call this method repeatedly until FALSE is returned.
142 The returned object is actually a SeqFeatureI implementing object.
143 This method is required for classes implementing the
144 SeqAnalysisParserI interface, and is merely an alias for
145 next_prediction() at present.
147 Note that with the present version of MZEF there will only be one
148 object returned, because MZEF does not predict individual genes
149 but just potential internal exons.
150 Example :
151 Returns : A Bio::Tools::Prediction::Gene object.
152 Args :
154 =cut
156 sub next_feature {
157 my ($self,@args) = @_;
158 # even though next_prediction doesn't expect any args (and this method
159 # does neither), we pass on args in order to be prepared if this changes
160 # ever
161 return $self->next_prediction(@args);
164 =head2 next_prediction
166 Title : next_prediction
167 Usage : while($gene = $mzef->next_prediction()) {
168 # do something
170 Function: Returns the next gene structure prediction of the MZEF result
171 file. Call this method repeatedly until FALSE is returned.
173 Note that with the present version of MZEF there will only be one
174 object returned, because MZEF does not predict individual genes
175 but just potential internal exons.
176 Example :
177 Returns : A Bio::Tools::Prediction::Gene object.
178 Args :
180 =cut
182 sub next_prediction {
183 my ($self) = @_;
184 my $gene;
186 # if the prediction section hasn't been parsed yet, we do this now
187 $self->_parse_predictions() unless $self->_predictions_parsed();
189 # return the next gene structure (transcript)
190 return $self->_prediction();
193 =head2 _parse_predictions
195 Title : _parse_predictions()
196 Usage : $obj->_parse_predictions()
197 Function: Parses the prediction section. Automatically called by
198 next_prediction() if not yet done.
199 Example :
200 Returns :
202 =cut
204 sub _parse_predictions {
205 my ($self) = @_;
207 while(defined($_ = $self->_readline())) {
208 if (! /^\#/){ #ignore introductory lines
210 my @element = split;
211 my (%feature);
212 $feature {name} = $element[0];
213 $feature {score} = $element[5];
214 $feature {start} = $element[3];
215 $feature {end} = $element[4];
216 $feature {strand} = $element[6];
217 $feature {source}= 'Eponine';
218 $feature {primary}= 'TSS';
219 $feature {program} = 'eponine-scan';
220 $feature {program_version} = '2';
222 $self->create_feature(\%feature);
223 next;
227 $self->_predictions_parsed(1);
230 =head2 create_feature
232 Title : create_feature
233 Usage : obj->create_feature($feature)
234 Function: Returns an array of features
235 Returns : Returns an array of features
236 Args : none
238 =cut
240 sub create_feature {
241 my ($self, $feat) = @_;
242 #create and fill Bio::EnsEMBL::Seqfeature object
244 my $tss = Bio::SeqFeature::Generic->new
245 ( -seq_id => $feat->{'name'},
246 -start => $feat->{'start'},
247 -end => $feat->{'end'},
248 -strand => $feat->{'strand'},
249 -score => $feat->{'score'},
250 -source_tag => $feat->{'source'},
251 -primary_tag => $feat->{'primary'});
255 if ($tss) {
256 # add to _flist
257 push(@{$self->{'_flist'}}, $tss);
260 #print $tss->gff_string;
268 =head2 _prediction
270 Title : _prediction()
271 Usage : $gene = $obj->_prediction()
272 Function: internal
273 Example :
274 Returns :
276 =cut
278 sub _prediction {
279 my ($self) = @_;
281 return unless(exists($self->{'_flist'}) && @{$self->{'_flist'}});
282 return shift(@{$self->{'_flist'}});
285 =head2 _predictions_parsed
287 Title : _predictions_parsed
288 Usage : $obj->_predictions_parsed
289 Function: internal
290 Example :
291 Returns : TRUE or FALSE
293 =cut
295 sub _predictions_parsed {
296 my ($self, $val) = @_;
298 $self->{'_preds_parsed'} = $val if $val;
299 # array of pre-parsed predictions
300 if(! exists($self->{'_preds_parsed'})) {
301 $self->{'_preds_parsed'} = 0;
303 return $self->{'_preds_parsed'};