3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 # Cared for by Tania Oh
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
15 Bio::Tools::Run::Eponine - Object for execution of the Eponine which
16 is a mammalian TSS predictor
20 use Bio::Tools::Run::Eponine;
22 my $seq = "/data/seq.fa";
23 my $threshold = "0.999";
24 my @params = ( '-seq' => $seq,
25 '-threshold' => $threshold,
26 '-epojar' => '/usr/local/bin/eponine-scan.jar',
27 '-java' => '/usr/local/bin/java');
29 my $factory = Bio::Tools::Run::Eponine->new(@params);
30 # run eponine against fasta
31 my $r = $factory->run($seq);
32 my $parser = Bio::Tools::Eponine->new($r);
34 while (my $feat = $parser->next_prediction){
35 #$feat contains array of SeqFeature
36 foreach my $orf($feat){
37 print $orf->seqname. "\n";
41 # Various additional options and input formats are available. See
42 # the DESCRIPTION section for details.
46 wrapper for eponine, a mammalian TSS predictor.
48 The environment variable EPONINEDIR must be set to point at either the
49 directory which contains eponine-scan.jar or directly at the jar which
50 eponine-scan classfiles. NOTE: EPONINEDIR must point at the real file
57 User feedback is an integral part of the evolution of this and other
58 Bioperl modules. Send your comments and suggestions preferably to one
59 of the Bioperl mailing lists. Your participation is much appreciated.
61 bioperl-l@bioperl.org - General discussion
62 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
66 Please direct usage questions or support issues to the mailing list:
68 I<bioperl-l@bioperl.org>
70 rather than to the module maintainer directly. Many experienced and
71 reponsive experts will be able look at the problem and quickly
72 address it. Please include a thorough description of the problem
73 with code and data examples if at all possible.
77 Report bugs to the Bioperl bug tracking system to help us keep track
78 the bugs and their resolution. Bug reports can be submitted via the
81 http://redmine.open-bio.org/projects/bioperl/
85 Email gisoht@nus.edu.sg
89 The rest of the documentation details each of the object
90 methods. Internal methods are usually preceded with a _
94 package Bio
::Tools
::Run
::Eponine
;
96 #tgot to take inmore parameters
98 use vars
qw($AUTOLOAD @ISA @EPONINE_PARAMS %EPONINE_PARAMS
99 $EPOJAR $JAVA $PROGRAMDIR $PROGRAMNAME $PROGRAM
100 $TMPDIR $TMPOUTFILE $DEFAULT_THRESHOLD
104 use Bio::Tools::Eponine;
107 use Bio::Tools::Run::WrapperBase;
108 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
111 $DEFAULT_THRESHOLD = 50;
112 $PROGRAMNAME = 'java';
113 $EPOJAR = 'eponine-scan.jar';
115 if( ! defined $PROGRAMDIR ) {
116 $PROGRAMDIR = $ENV{'JAVA_HOME'} || $ENV{'JAVA_DIR'};
118 if (defined $PROGRAMDIR) {
119 foreach my $progname ( [qw(java)],[qw(bin java)] ) {
120 my $f = Bio
::Root
::IO
->catfile($PROGRAMDIR, @
$progname);
121 if( -e
$f && -x
$f ) {
128 if( $ENV{'EPONINEDIR'} ) {
129 if ( -d
$ENV{'EPONINEDIR'} ) {
130 $EPOJAR = Bio
::Root
::IO
->catfile($ENV{'EPONINEDIR'}, $EPOJAR)
131 } elsif(-e
$ENV{'EPONINEDIR'}) {
132 $EPOJAR = $ENV{'EPONINEDIR'};
139 %EPONINE_PARAMS = ('SEQ' => '/tmp/test.fa',
140 'THRESHOLD' => '0.999',
141 'EPOJAR' => '/usr/local/bin/eponine-scan.jar',
142 'JAVA' => '/usr/java/jre1.3.1_02/bin/java');
144 @EPONINE_PARAMS=qw(SEQ THRESHOLD JAVA EPOJAR);
146 foreach my $attr ( @EPONINE_PARAMS)
147 { $OK_FIELD{$attr}++; }
152 my $attr = $AUTOLOAD;
153 $self->debug( "************ attr: $attr\n");
156 $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
157 $self->{$attr} = shift if @_;
158 return $self->{$attr};
162 my ($caller, @args) = @_;
164 my $self = $caller->SUPER::new
(@args);
165 # so that tempfiles are cleaned up
173 ($TMPDIR) = $self->tempdir(CLEANUP
=>1);
175 ($tfh,$TMPOUTFILE) = $self->io->tempfile(-dir
=> $TMPDIR);
180 $value = shift @args;
181 next if( $attr =~ /^-/ ); # don't want named parameters
182 if ($attr =~/JAVA/i) {
186 if ($attr =~ /EPOJAR/i){
190 if ($attr =~ /THRESHOLD/i){
194 if ($attr =~ /SEQ/i){
198 $self->$attr($value);
201 $self->{'_java'} = undef; # location of java vm
202 $self->{'_epojar'} = undef; # location of eponine-scan.jar executable JAR file.
203 $self->{'_threshold'} = 0.999; # minimum posterior for filtering predictions
204 $self->{'_filename'} = undef; #location of seq
205 $seq = $EPONINE_PARAMS{'seq'} unless defined $seq;
206 $threshold = $EPONINE_PARAMS{'threshold'} unless defined $threshold;
207 if (! defined $epojar && defined $EPOJAR) {
211 $epojar = $EPONINE_PARAMS{'epojar'} unless defined $epojar;
213 if (! defined $java && defined $PROGRAM) {
217 $java = $EPONINE_PARAMS{'JAVA'} unless defined $java;
219 $self->filename($seq) if ($seq);
226 $self->epojar($epojar) if (defined $epojar);
228 if (defined $threshold && $threshold >=0 ){
229 $self->threshold($threshold);
231 $self->threshold($DEFAULT_THRESHOLD);
240 Usage : $obj->java('/usr/opt/java130/bin/java');
241 Function: Get/set method for the location of java VM
242 Args : File path (optional)
246 sub executable
{ shift->java(@_); }
249 my ($self, $exe,$warn) = @_;
252 $self->{'_pathtojava'} = $exe;
255 unless( defined $self->{'_pathtojava'} ) {
256 if( $PROGRAM && -e
$PROGRAM && -x
$PROGRAM ) {
257 $self->{'_pathtojava'} = $PROGRAM;
260 if( ( $exe = $self->io->exists_exe($PROGRAMNAME) ) &&
262 $self->{'_pathtojava'} = $exe;
264 $self->warn("Cannot find executable for $PROGRAMNAME") if $warn;
265 $self->{'_pathtojava'} = undef;
269 $self->{'_pathtojava'};
276 Usage : $obj->epojar('/some/path/to/eponine-scan.jar');
277 Function: Get/set method for the location of the eponine-scan executable JAR
278 Args : Path (optional)
283 my ($self, $location) = @_;
286 unless( $location ) {
287 $self->warn("eponine-scan.jar not found at $location: $!\n");
290 $self->{'_epojar'} = $location ;
292 return $self->{'_epojar'};
300 Usage : my $threshold = $self->threshold
301 Function: Get/Set the threshold for Eponine
303 Args : b/w 0.9 and 1.0
308 my ($self, $threshold) = @_;
309 if (defined $threshold) {
310 $self->{'_threshold'} = $threshold ;
312 return $self->{'_threshold'};
320 Usage : my @genes = $self->run($seq)
321 Function: runs Eponine and creates an array of features
322 Returns : An Array of SeqFeatures
323 Args : A Bio::PrimarySeqI
328 my ($self,$seq) = @_;
329 my $infile = $self->_setinput($seq);
330 my @tss = $self->_run_eponine($infile);
338 Usage : Alias for run()
343 return shift->run(@_);
349 Usage : Internal function, not to be called directly
350 Function: writes input sequence to file and return the file name
358 my ($self,$seq) = @_;
363 my ($tfh1,$inputfile) = $self->tempfile(-dir
=>$TMPDIR);
364 my $in = Bio
::SeqIO
->new(-fh
=> $tfh1 , '-format' => 'Fasta');
365 $in->write_seq($seq);
374 Usage : $obj->_run_eponine()
375 Function: execs the Java VM to run eponine
382 my ($self,$infile) = @_;
383 my $result = $TMPOUTFILE;
386 $self->debug( "Running eponine-scan\n");
387 my ($java,$epojar) = ( $self->java,
389 unless( defined $java && -e
$java && -x
$java ) {
390 $self->warn("Cannot find java");
393 if (! defined $epojar) { $self->warn("Don't know the name of the Eponine jar file"); return; }
395 $self->warn("Cannot find Eponine jar: $epojar - either you specified an incorrect path in\nEPONINEDIR or it was not in the current working directory");
398 my $cmd = $self->java.' -jar '.$self->epojar.' -seq '.$infile.' -threshold '.$self->threshold." > ".$result;
399 $self->throw("Error running eponine-scan on ".$self->filename.
400 " \n Check your java version, it has to be version 1.2 or later. Eponine crashed ($cmd) crashed: $? \n")
403 #parse results even though it's wierd.. thought parser and wrapper should be separate
404 my $epoParser = Bio
::Tools
::Eponine
->new(-file
=>$result);
406 while (my $tss = $epoParser->next_prediction()){