Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Tools/Eponine.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: Eponine.pm,v 1.7 2002/10/22 07:38:45 lapp Exp $ | |
| 2 # | |
| 3 # BioPerl module for Bio::Tools::Eponine | |
| 4 # | |
| 5 # Cared for by Tania Oh <gisoht@nus.edu.sg> | |
| 6 # | |
| 7 # Copyright Tania Oh | |
| 8 # | |
| 9 # You may distribute this module under the same terms as perl itself | |
| 10 | |
| 11 # POD documentation - main docs before the code | |
| 12 | |
| 13 =head1 NAME | |
| 14 | |
| 15 Bio::Tools::Eponine - Results of one Eponine run | |
| 16 | |
| 17 =head1 SYNOPSIS | |
| 18 | |
| 19 use Bio::Tools::Run::Eponine; | |
| 20 use strict; | |
| 21 my $seq = "/data/seq.fa"; | |
| 22 my $threshold = "0.999"; | |
| 23 my @params = ( '-seq' => $seq, | |
| 24 '-threshold' => $threshold); | |
| 25 | |
| 26 my $factory = Bio::Tools::Run::Eponine->new(@params); | |
| 27 # run eponine against fasta | |
| 28 my $r = $factory->run_eponine($seq); | |
| 29 my $parser = Bio::Tools::Eponine->new($r); | |
| 30 | |
| 31 while (my $feat = $parser->next_prediction){ | |
| 32 #$feat contains array of SeqFeature | |
| 33 foreach my $orf($feat) { | |
| 34 print $orf->seq_id. "\n"; | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 =head1 DESCRIPTION | |
| 39 | |
| 40 Parser for Eponine, a probabilistic transcription start site detector | |
| 41 optimized for mammalian genomic sequence. This module inherits off | |
| 42 Bio::Tools::AnalysisResult and therefore implements | |
| 43 Bio::SeqAnalysisParserI (see L<Bio::Tools::AnalysisResult> and | |
| 44 L<Bio::SeqAnalysisParserI>). | |
| 45 | |
| 46 =head1 FEEDBACK | |
| 47 | |
| 48 =head2 Mailing Lists | |
| 49 | |
| 50 User feedback is an integral part of the evolution of this and other | |
| 51 Bioperl modules. Send your comments and suggestions preferably to one | |
| 52 of the Bioperl mailing lists. Your participation is much appreciated. | |
| 53 | |
| 54 bioperl-l@bioperl.org - General discussion | |
| 55 http://bio.perl.org/MailList.html - About the mailing lists | |
| 56 | |
| 57 =head2 Reporting Bugs | |
| 58 | |
| 59 Report bugs to the Bioperl bug tracking system to help us keep track | |
| 60 the bugs and their resolution. Bug reports can be submitted via email | |
| 61 or the web: | |
| 62 | |
| 63 bioperl-bugs@bio.perl.org | |
| 64 http://bugzilla.bioperl.org/ | |
| 65 | |
| 66 =head1 AUTHOR - Tania Oh | |
| 67 | |
| 68 | |
| 69 Describe contact details here | |
| 70 | |
| 71 =head1 APPENDIX | |
| 72 | |
| 73 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ | |
| 74 | |
| 75 =cut | |
| 76 | |
| 77 | |
| 78 # Let the code begin... | |
| 79 | |
| 80 | |
| 81 package Bio::Tools::Eponine; | |
| 82 use vars qw(@ISA); | |
| 83 use strict; | |
| 84 | |
| 85 use Bio::Tools::AnalysisResult; | |
| 86 use Bio::Tools::Prediction::Gene; | |
| 87 use Bio::Tools::Prediction::Exon; | |
| 88 | |
| 89 @ISA = qw(Bio::Tools::AnalysisResult); | |
| 90 | |
| 91 sub _initialize_state { | |
| 92 my($self,@args) = @_; | |
| 93 | |
| 94 # first call the inherited method! | |
| 95 my $make = $self->SUPER::_initialize_state(@args); | |
| 96 | |
| 97 # handle our own parameters | |
| 98 | |
| 99 # our private state variables | |
| 100 $self->{'_preds_parsed'} = 0; | |
| 101 #array of Bio::SeqFeatures | |
| 102 $self->{'_flist'} =[]; | |
| 103 } | |
| 104 | |
| 105 =head2 analysis_method | |
| 106 | |
| 107 Usage : $mzef->analysis_method(); | |
| 108 Purpose : Inherited method. Overridden to ensure that the name matches | |
| 109 /mzef/i. | |
| 110 Returns : String | |
| 111 Argument : n/a | |
| 112 | |
| 113 =cut | |
| 114 | |
| 115 #------------- | |
| 116 sub analysis_method { | |
| 117 #------------- | |
| 118 my ($self, $method) = @_; | |
| 119 if($method && ($method !~ /epo/i)) { | |
| 120 $self->throw("method $method not supported in " . ref($self)); | |
| 121 } | |
| 122 return $self->SUPER::analysis_method($method); | |
| 123 } | |
| 124 | |
| 125 =head2 next_feature | |
| 126 | |
| 127 Title : next_feature | |
| 128 Usage : while($gene = $mzef->next_feature()) { | |
| 129 # do something | |
| 130 } | |
| 131 Function: Returns the next gene structure prediction of the MZEF result | |
| 132 file. Call this method repeatedly until FALSE is returned. | |
| 133 | |
| 134 The returned object is actually a SeqFeatureI implementing object. | |
| 135 This method is required for classes implementing the | |
| 136 SeqAnalysisParserI interface, and is merely an alias for | |
| 137 next_prediction() at present. | |
| 138 | |
| 139 Note that with the present version of MZEF there will only be one | |
| 140 object returned, because MZEF does not predict individual genes | |
| 141 but just potential internal exons. | |
| 142 Example : | |
| 143 Returns : A Bio::Tools::Prediction::Gene object. | |
| 144 Args : | |
| 145 | |
| 146 =cut | |
| 147 | |
| 148 sub next_feature { | |
| 149 my ($self,@args) = @_; | |
| 150 # even though next_prediction doesn't expect any args (and this method | |
| 151 # does neither), we pass on args in order to be prepared if this changes | |
| 152 # ever | |
| 153 return $self->next_prediction(@args); | |
| 154 } | |
| 155 | |
| 156 =head2 next_prediction | |
| 157 | |
| 158 Title : next_prediction | |
| 159 Usage : while($gene = $mzef->next_prediction()) { | |
| 160 # do something | |
| 161 } | |
| 162 Function: Returns the next gene structure prediction of the MZEF result | |
| 163 file. Call this method repeatedly until FALSE is returned. | |
| 164 | |
| 165 Note that with the present version of MZEF there will only be one | |
| 166 object returned, because MZEF does not predict individual genes | |
| 167 but just potential internal exons. | |
| 168 Example : | |
| 169 Returns : A Bio::Tools::Prediction::Gene object. | |
| 170 Args : | |
| 171 | |
| 172 =cut | |
| 173 | |
| 174 sub next_prediction { | |
| 175 my ($self) = @_; | |
| 176 my $gene; | |
| 177 | |
| 178 # if the prediction section hasn't been parsed yet, we do this now | |
| 179 $self->_parse_predictions() unless $self->_predictions_parsed(); | |
| 180 | |
| 181 # return the next gene structure (transcript) | |
| 182 return $self->_prediction(); | |
| 183 } | |
| 184 | |
| 185 =head2 _parse_predictions | |
| 186 | |
| 187 Title : _parse_predictions() | |
| 188 Usage : $obj->_parse_predictions() | |
| 189 Function: Parses the prediction section. Automatically called by | |
| 190 next_prediction() if not yet done. | |
| 191 Example : | |
| 192 Returns : | |
| 193 | |
| 194 =cut | |
| 195 | |
| 196 sub _parse_predictions { | |
| 197 my ($self) = @_; | |
| 198 | |
| 199 while(defined($_ = $self->_readline())) { | |
| 200 if (! /^\#/){ #ignore introductory lines | |
| 201 | |
| 202 my @element = split; | |
| 203 my (%feature); | |
| 204 $feature {name} = $element[0]; | |
| 205 $feature {score} = $element[5]; | |
| 206 $feature {start} = $element[3]; | |
| 207 $feature {end} = $element[4]; | |
| 208 $feature {strand} = $element[6]; | |
| 209 $feature {source}= 'Eponine'; | |
| 210 $feature {primary}= 'TSS'; | |
| 211 $feature {program} = 'eponine-scan'; | |
| 212 $feature {program_version} = '2'; | |
| 213 | |
| 214 $self->create_feature(\%feature); | |
| 215 next; | |
| 216 | |
| 217 } | |
| 218 } | |
| 219 $self->_predictions_parsed(1); | |
| 220 } | |
| 221 | |
| 222 =head2 create_feature | |
| 223 | |
| 224 Title : create_feature | |
| 225 Usage : obj->create_feature($feature) | |
| 226 Function: Returns an array of features | |
| 227 Returns : Returns an array of features | |
| 228 Args : none | |
| 229 | |
| 230 =cut | |
| 231 | |
| 232 sub create_feature { | |
| 233 my ($self, $feat) = @_; | |
| 234 #create and fill Bio::EnsEMBL::Seqfeature object | |
| 235 | |
| 236 my $tss = Bio::SeqFeature::Generic->new | |
| 237 ( -seq_id => $feat->{'name'}, | |
| 238 -start => $feat->{'start'}, | |
| 239 -end => $feat->{'end'}, | |
| 240 -strand => $feat->{'strand'}, | |
| 241 -score => $feat->{'score'}, | |
| 242 -source_tag => $feat->{'source'}, | |
| 243 -primary_tag => $feat->{'primary'}); | |
| 244 | |
| 245 | |
| 246 | |
| 247 if ($tss) { | |
| 248 # add to _flist | |
| 249 push(@{$self->{'_flist'}}, $tss); | |
| 250 } | |
| 251 | |
| 252 #print $tss->gff_string; | |
| 253 } | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 =head2 _prediction | |
| 261 | |
| 262 Title : _prediction() | |
| 263 Usage : $gene = $obj->_prediction() | |
| 264 Function: internal | |
| 265 Example : | |
| 266 Returns : | |
| 267 | |
| 268 =cut | |
| 269 | |
| 270 sub _prediction { | |
| 271 my ($self) = @_; | |
| 272 | |
| 273 return undef unless(exists($self->{'_flist'}) && @{$self->{'_flist'}}); | |
| 274 return shift(@{$self->{'_flist'}}); | |
| 275 } | |
| 276 | |
| 277 =head2 _predictions_parsed | |
| 278 | |
| 279 Title : _predictions_parsed | |
| 280 Usage : $obj->_predictions_parsed | |
| 281 Function: internal | |
| 282 Example : | |
| 283 Returns : TRUE or FALSE | |
| 284 | |
| 285 =cut | |
| 286 | |
| 287 sub _predictions_parsed { | |
| 288 my ($self, $val) = @_; | |
| 289 | |
| 290 $self->{'_preds_parsed'} = $val if $val; | |
| 291 # array of pre-parsed predictions | |
| 292 if(! exists($self->{'_preds_parsed'})) { | |
| 293 $self->{'_preds_parsed'} = 0; | |
| 294 } | |
| 295 return $self->{'_preds_parsed'}; | |
| 296 } | |
| 297 | |
| 298 | |
| 299 1; |
