Tools/Run/Eponine.pm

filter: Statementstmt 20.0% 31 / 155 Branchbran 3.8% 3 / 78 Conditioncond 3.3% 1 / 30 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 41.1% 7 / 17 Podpod 100% 7 / 7 totaltotal 16.0% 49 / 305 CC 52 SCAR 50.4
CC
52
Cov
13%
new
420.0
java
90.0
_run_eponine
72.0
CRAP 154.1
« Tools/Run/Hmmer.pm ↑ Summary Tools/Run/Alignment/Muscle.pm »
1 #
2 # Please direct questions and support issues to <bioperl-l@bioperl.org>
3 #
4 # Cared for by Tania Oh
5 #
6 # Copyright Tania Oh
7 #
8 # You may distribute this module under the same terms as perl itself
9  
10 # POD documentation - main docs before the code
11  
12 =head1 NAME
13  
14 Bio::Tools::Run::Eponine - Object for execution of the Eponine which
15 is a mammalian TSS predictor
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 '-epojar' => '/usr/local/bin/eponine-scan.jar',
26 '-java' => '/usr/local/bin/java');
27  
28 my $factory = Bio::Tools::Run::Eponine->new(@params);
29 # run eponine against fasta
30 my $r = $factory->run($seq);
31 my $parser = Bio::Tools::Eponine->new($r);
32  
33 while (my $feat = $parser->next_prediction){
34 #$feat contains array of SeqFeature
35 foreach my $orf($feat){
36 print $orf->seqname. "\n";
37 }
38 }
39  
40 # Various additional options and input formats are available. See
41 # the DESCRIPTION section for details.
42  
43 =head1 DESCRIPTION
44  
45 wrapper for eponine, a mammalian TSS predictor.
46  
47 The environment variable EPONINEDIR must be set to point at either the
48 directory which contains eponine-scan.jar or directly at the jar which
49 eponine-scan classfiles. NOTE: EPONINEDIR must point at the real file
50 not a symlink.
51  
52 =head1 FEEDBACK
53  
54 =head2 Mailing Lists
55  
56 User feedback is an integral part of the evolution of this and other
57 Bioperl modules. Send your comments and suggestions preferably to one
58 of the Bioperl mailing lists. Your participation is much appreciated.
59  
60 bioperl-l@bioperl.org - General discussion
61 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
62  
63 =head2 Support
64  
65 Please direct usage questions or support issues to the mailing list:
66  
67 I<bioperl-l@bioperl.org>
68  
69 rather than to the module maintainer directly. Many experienced and
70 reponsive experts will be able look at the problem and quickly
71 address it. Please include a thorough description of the problem
72 with code and data examples if at all possible.
73  
74 =head2 Reporting Bugs
75  
76 Report bugs to the Bioperl bug tracking system to help us keep track
77 the bugs and their resolution. Bug reports can be submitted via the
78 web:
79  
80 http://redmine.open-bio.org/projects/bioperl/
81  
82 =head1 AUTHOR
83  
84 Email gisoht@nus.edu.sg
85  
86 =head1 APPENDIX
87  
88 The rest of the documentation details each of the object
89 methods. Internal methods are usually preceded with a _
90  
91 =cut
92  
93 package Bio::Tools::Run::Eponine;
94  
95 #tgot to take inmore parameters
96  
97 1 ▶use vars qw($AUTOLOAD @ISA @EPONINE_PARAMS %EPONINE_PARAMS
Subroutine BEGIN: called CC=1 SCAR=0.0
98 $EPOJAR $JAVA $PROGRAMDIR $PROGRAMNAME $PROGRAM
99 $TMPDIR $TMPOUTFILE $DEFAULT_THRESHOLD
100 1 %OK_FIELD);
101 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
102  
103 1 ▶use Bio::Tools::Eponine;
Subroutine BEGIN: called CC=1 SCAR=0.0
104 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
105 1 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
106 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
107 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
108  
109 1 ▶BEGIN {
Subroutine BEGIN: called CC=12 SCAR=38.9
110 1 $DEFAULT_THRESHOLD = 50;
111 1 $PROGRAMNAME = 'java';
112 1 $EPOJAR = 'eponine-scan.jar';
113  
114 1 ▶ if( ! defined $PROGRAMDIR ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Bio::Tools::Run::Eponine::PROGRAMDIR) 1 0 1
115 1 ▶ $PROGRAMDIR = $ENV{'JAVA_HOME'} || $ENV{'JAVA_DIR'};
Condition33%1/3
$ENV{'JAVA_HOME'} || $ENV{'JAVA_DIR'}
l!l&&r!l&&!r
001
MC/DC0%0/2
$ENV{'JAVA_HOME'} || $ENV{'JAVA_DIR'}
$ENV{'JAVA_HOME'} $ENV{'JAVA_DIR'}
Truth table33%1/3
A || B
A= $ENV{'JAVA_HOME'}B= $ENV{'JAVA_DIR'}
ABresult
1X1
011
000
116 }
117 1 ▶ if (defined $PROGRAMDIR) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Bio::Tools::Run::Eponine::PROGRAMDIR) 0 1 1
118 0 foreach my $progname ( [qw(java)],[qw(bin java)] ) {
119 0 my $f = Bio::Root::IO->catfile($PROGRAMDIR, @$progname);
120 0 ▶ if( -e $f && -x $f ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $f and -x $f) 0 0 0
Condition0%0/3
-e $f and -x $f
!ll&&!rl&&r
000
MC/DC0%0/2
-e $f and -x $f
-e $f -x $f
Truth table0%0/3
A and B
A= -e $fB= -x $f
ABresult
0X0
100
111
121 0 $PROGRAM = $f;
122 0 last;
123 }
124 }
125 }
126  
127 1 ▶ if( $ENV{'EPONINEDIR'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"EPONINEDIR"}) 0 1 1
128 0 ▶ if ( -d $ENV{'EPONINEDIR'} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (-d $ENV{'EPONINEDIR'}) { } 0 0 0
elsif (-e $ENV{'EPONINEDIR'}) { } 0 0 0
129 0 $EPOJAR = Bio::Root::IO->catfile($ENV{'EPONINEDIR'}, $EPOJAR)
130 } elsif(-e $ENV{'EPONINEDIR'}) {
131 0 $EPOJAR = $ENV{'EPONINEDIR'};
132 }
133 0 ▶ if ( ! -e $EPOJAR) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $Bio::Tools::Run::Eponine::EPOJAR) 0 0 0
134 0 $EPOJAR =undef;
135 }
136 }
137  
138 1 %EPONINE_PARAMS = ('SEQ' => '/tmp/test.fa',
139 'THRESHOLD' => '0.999',
140 'EPOJAR' => '/usr/local/bin/eponine-scan.jar',
141 'JAVA' => '/usr/java/jre1.3.1_02/bin/java');
142  
143 1 @EPONINE_PARAMS=qw(SEQ THRESHOLD JAVA EPOJAR);
144  
145 1 foreach my $attr ( @EPONINE_PARAMS)
146 4 { $OK_FIELD{$attr}++; }
147 }
148  
149 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
150 0 my $self = shift;
151 0 my $attr = $AUTOLOAD;
152 0 $self->debug( "************ attr: $attr\n");
153 0 $attr =~ s/.*:://;
154 0 $attr = uc $attr;
155 0 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Eponine::OK_FIELD{$attr} 0 0 0
156 0 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
157 0 return $self->{$attr};
158 }
159  
160 0 ▶sub new {
Subroutine new: not called CC=20 SCAR=60.4
Pod documented
161 0 my ($caller, @args) = @_;
162 # chained new
163 0 my $self = $caller->SUPER::new(@args);
164 # so that tempfiles are cleaned up
165  
166 0 my $java;
167 my $seq;
168 0 my $threshold;
169 0 my $epojar;
170  
171 0 my ($attr, $value);
172 0 ($TMPDIR) = $self->tempdir(CLEANUP=>1);
173 0 my $tfh;
174 0 ($tfh,$TMPOUTFILE) = $self->io->tempfile(-dir => $TMPDIR);
175 0 close($tfh);
176 0 undef $tfh;
177 0 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 0 0
178 0 $attr = shift @args;
179 0 $value = shift @args;
180 0 ▶ next if( $attr =~ /^-/ ); # don't want named parameters
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ 0 0 0
181 0 ▶ if ($attr =~/JAVA/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /JAVA/i) 0 0 0
182 0 $java = $value;
183 0 next;
184 }
185 0 ▶ if ($attr =~ /EPOJAR/i){
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /EPOJAR/i) 0 0 0
186 0 $epojar = $value;
187 0 next;
188 }
189 0 ▶ if ($attr =~ /THRESHOLD/i){
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /THRESHOLD/i) 0 0 0
190 0 $threshold = $value;
191 0 next;
192 }
193 0 ▶ if ($attr =~ /SEQ/i){
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /SEQ/i) 0 0 0
194 0 $seq = $value;
195 0 next;
196 }
197 0 $self->$attr($value);
198 }
199  
200 0 $self->{'_java'} = undef; # location of java vm
201 0 $self->{'_epojar'} = undef; # location of eponine-scan.jar executable JAR file.
202 0 $self->{'_threshold'} = 0.999; # minimum posterior for filtering predictions
203 0 $self->{'_filename'} = undef; #location of seq
204 0 ▶ $seq = $EPONINE_PARAMS{'seq'} unless defined $seq;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $seq 0 0 0
205 0 ▶ $threshold = $EPONINE_PARAMS{'threshold'} unless defined $threshold;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $threshold 0 0 0
206 0 ▶ if (! defined $epojar && defined $EPOJAR) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $epojar and defined $Bio::Tools::Run::Eponine::EPOJAR) { } 0 0 0
Condition0%0/3
not defined $epojar and defined $Bio::Tools::Run::Eponine::EPOJAR
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $epojar and defined $Bio::Tools::Run::Eponine::EPOJAR
not defined $epojar defined $Bio::Tools::Run::Eponine::EPOJAR
Truth table0%0/3
not(A) and B
A= not defined $epojarB= defined $Bio::Tools::Run::Eponine::EPOJAR
ABresult
0X0
100
111
207 0 $epojar = $EPOJAR;
208 }
209 else {
210 0 ▶ $epojar = $EPONINE_PARAMS{'epojar'} unless defined $epojar;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $epojar 0 0 0
211 }
212 0 ▶ if (! defined $java && defined $PROGRAM) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $java and defined $Bio::Tools::Run::Eponine::PROGRAM) { } 0 0 0
Condition0%0/3
not defined $java and defined $Bio::Tools::Run::Eponine::PROGRAM
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $java and defined $Bio::Tools::Run::Eponine::PROGRAM
not defined $java defined $Bio::Tools::Run::Eponine::PROGRAM
Truth table0%0/3
not(A) and B
A= not defined $javaB= defined $Bio::Tools::Run::Eponine::PROGRAM
ABresult
0X0
100
111
213 0 $java = $PROGRAM;
214 }
215 else {
216 0 ▶ $java = $EPONINE_PARAMS{'JAVA'} unless defined $java;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $java 0 0 0
217 }
218 0 ▶ $self->filename($seq) if ($seq);
Branch: 1 branch
BranchTrueFalseTotal
if $seq 0 0 0
219  
220 0 ▶ if (-x $java) {
Branch: 1 branch
BranchTrueFalseTotal
if (-x $java) 0 0 0
221 # full path assumed
222 0 $self->java($java);
223 }
224
225 0 ▶ $self->epojar($epojar) if (defined $epojar);
Branch: 1 branch
BranchTrueFalseTotal
if defined $epojar 0 0 0
226
227 0 ▶ if (defined $threshold && $threshold >=0 ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $threshold and $threshold >= 0) { } 0 0 0
Condition0%0/3
defined $threshold and $threshold >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $threshold and $threshold >= 0
defined $threshold $threshold >= 0
Truth table0%0/3
A and B
A= defined $thresholdB= $threshold >= 0
ABresult
0X0
100
111
228 0 $self->threshold($threshold);
229 } else {
230 0 $self->threshold($DEFAULT_THRESHOLD);
231 }
232
233 0 return $self;
234 }
235  
236 =head2 java
237  
238 Title : java
239 Usage : $obj->java('/usr/opt/java130/bin/java');
240 Function: Get/set method for the location of java VM
241 Args : File path (optional)
242  
243 =cut
244  
245 0 ▶sub executable { shift->java(@_); }
Subroutine executable: not called CC=1 SCAR=6.9
Pod documented
246  
247 0 ▶sub java {
Subroutine java: not called CC=9 SCAR=45.0
Pod documented
248 0 my ($self, $exe,$warn) = @_;
249  
250 0 ▶ if( defined $exe ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $exe) 0 0 0
251 0 $self->{'_pathtojava'} = $exe;
252 }
253  
254 0 ▶ unless( defined $self->{'_pathtojava'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_pathtojava"}) 0 0 0
255 0 ▶ if( $PROGRAM && -e $PROGRAM && -x $PROGRAM ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Bio::Tools::Run::Eponine::PROGRAM and -e $Bio::Tools::Run::Eponine::PROGRAM and -x $Bio::Tools::Run::Eponine::PROGRAM) { } 0 0 0
Condition0%0/6
$Bio::Tools::Run::Eponine::PROGRAM and -e $Bio::Tools::Run::Eponine::PROGRAM and -x $Bio::Tools::Run::Eponine::PROGRAM
!ll&&!rl&&r
000
$Bio::Tools::Run::Eponine::PROGRAM and -e $Bio::Tools::Run::Eponine::PROGRAM
!ll&&!rl&&r
000
MC/DC0%0/3
$Bio::Tools::Run::Eponine::PROGRAM and -e $Bio::Tools::Run::Eponine::PROGRAM and -x $Bio::Tools::Run::Eponine::PROGRAM
$Bio::Tools::Run::Eponine::PROGRAM -e $Bio::Tools::Run::Eponine::PROGRAM -x $Bio::Tools::Run::Eponine::PROGRAM
Truth table0%0/4
A and B and C
A= $Bio::Tools::Run::Eponine::PROGRAMB= -e $Bio::Tools::Run::Eponine::PROGRAMC= -x $Bio::Tools::Run::Eponine::PROGRAM
ABCresult
0XX0
10X0
1100
1111
256 0 $self->{'_pathtojava'} = $PROGRAM;
257 } else {
258 0 my $exe;
259 0 ▶ if( ( $exe = $self->io->exists_exe($PROGRAMNAME) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($exe = $self->io->exists_exe($Bio::Tools::Run::Eponine::PROGRAMNAME) and -x $exe) { } 0 0 0
Condition0%0/3
$exe = $self->io->exists_exe($Bio::Tools::Run::Eponine::PROGRAMNAME) and -x $exe
!ll&&!rl&&r
000
MC/DC0%0/2
$exe = $self->io->exists_exe($Bio::Tools::Run::Eponine::PROGRAMNAME) and -x $exe
$exe = $self->io->exists_exe($Bio::Tools::Run::Eponine::PROGRAMNAME) -x $exe
Truth table0%0/3
A and B
A= $exe = $self->io->exists_exe($Bio::Tools::Run::Eponine::PROGRAMNAME)B= -x $exe
ABresult
0X0
100
111
260 -x $exe ) {
261 0 $self->{'_pathtojava'} = $exe;
262 } else {
263 0 ▶ $self->warn("Cannot find executable for $PROGRAMNAME") if $warn;
Branch: 1 branch
BranchTrueFalseTotal
if $warn 0 0 0
264 0 $self->{'_pathtojava'} = undef;
265 }
266 }
267 }
268 0 $self->{'_pathtojava'};
269 }
270  
271  
272 =head2 epojar
273  
274 Title : epojar
275 Usage : $obj->epojar('/some/path/to/eponine-scan.jar');
276 Function: Get/set method for the location of the eponine-scan executable JAR
277 Args : Path (optional)
278  
279 =cut
280  
281 0 ▶sub epojar {
Subroutine epojar: not called CC=3 SCAR=24.8
Pod documented
282 0 my ($self, $location) = @_;
283 0 ▶ if ($location)
Branch: 1 branch
BranchTrueFalseTotal
if ($location) 0 0 0
284 {
285 0 ▶ unless( $location ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($location) 0 0 0
286 0 $self->warn("eponine-scan.jar not found at $location: $!\n");
287 0 return;
288 }
289 0 $self->{'_epojar'} = $location ;
290 }
291 0 return $self->{'_epojar'};
292 }
293  
294  
295  
296 =head2 threshold
297  
298 Title : threshold
299 Usage : my $threshold = $self->threshold
300 Function: Get/Set the threshold for Eponine
301 Returns : string
302 Args : b/w 0.9 and 1.0
303  
304 =cut
305  
306 0 ▶sub threshold{
Subroutine threshold: not called CC=2 SCAR=17.9
Pod documented
307 0 my ($self, $threshold) = @_;
308 0 ▶ if (defined $threshold) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $threshold) 0 0 0
309 0 $self->{'_threshold'} = $threshold ;
310 }
311 0 return $self->{'_threshold'};
312  
313 }
314  
315  
316 =head2 run
317  
318 Title : run
319 Usage : my @genes = $self->run($seq)
320 Function: runs Eponine and creates an array of features
321 Returns : An Array of SeqFeatures
322 Args : A Bio::PrimarySeqI
323  
324 =cut
325  
326 0 ▶sub run{
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
327 0 my ($self,$seq) = @_;
328 0 my $infile = $self->_setinput($seq);
329 0 my @tss = $self->_run_eponine($infile);
330 0 return @tss;
331  
332 }
333  
334 =head2 predict_TSS
335  
336 Title : predict_TSS
337 Usage : Alias for run()
338  
339 =cut
340  
341 0 ▶sub predict_TSS {
Subroutine predict_TSS: not called CC=1 SCAR=6.9
Pod documented
342 0 return shift->run(@_);
343 }
344  
345 =head2 _setinput()
346  
347 Title : _setinput
348 Usage : Internal function, not to be called directly
349 Function: writes input sequence to file and return the file name
350 Example :
351 Returns : string
352 Args :
353  
354 =cut
355  
356 0 ▶sub _setinput {
Subroutine _setinput: not called CC=2 SCAR=17.9
357 0 my ($self,$seq) = @_;
358 #better be a file
359 0 ▶ if(!ref $seq){
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $seq) 0 0 0
360 0 return $seq;
361 }
362 0 my ($tfh1,$inputfile) = $self->tempfile(-dir=>$TMPDIR);
363 0 my $in = Bio::SeqIO->new(-fh=> $tfh1 , '-format' => 'Fasta');
364 0 $in->write_seq($seq);
365 0 close($tfh1);
366 0 undef $tfh1;
367 0 return ($inputfile);
368 }
369  
370 =head2 _run_eponine
371  
372 Title : run_eponine
373 Usage : $obj->_run_eponine()
374 Function: execs the Java VM to run eponine
375 Returns : none
376 Args : none
377  
378 =cut
379  
380 0 ▶sub _run_eponine {
Subroutine _run_eponine: not called CC=8 SCAR=42.8
381 0 my ($self,$infile) = @_;
382 0 my $result = $TMPOUTFILE;
383 0 my @tss;
384 #run eponine
385 0 $self->debug( "Running eponine-scan\n");
386 0 my ($java,$epojar) = ( $self->java,
387 $self->epojar);
388 0 ▶ unless( defined $java && -e $java && -x $java ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $java and -e $java and -x $java) 0 0 0
Condition0%0/6
defined $java and -e $java and -x $java
!ll&&!rl&&r
000
defined $java and -e $java
!ll&&!rl&&r
000
MC/DC0%0/3
defined $java and -e $java and -x $java
defined $java -e $java -x $java
Truth table0%0/4
A and B and C
A= defined $javaB= -e $javaC= -x $java
ABCresult
0XX0
10X0
1100
1111
389 0 $self->warn("Cannot find java");
390 0 return;
391 }
392 0 ▶ if (! defined $epojar) { $self->warn("Don't know the name of the Eponine jar file"); return; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $epojar) 0 0 0
393 0 ▶ if (! -e $epojar) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $epojar) 0 0 0
394 0 $self->warn("Cannot find Eponine jar: $epojar - either you specified an incorrect path in\nEPONINEDIR or it was not in the current working directory");
395 0 return;
396 }
397 0 my $cmd = $self->java.' -jar '.$self->epojar.' -seq '.$infile.' -threshold '.$self->threshold." > ".$result;
398 0 ▶ $self->throw("Error running eponine-scan on ".$self->filename.
Branch: 1 branch
BranchTrueFalseTotal
if system $cmd 0 0 0
399 " \n Check your java version, it has to be version 1.2 or later. Eponine crashed ($cmd) crashed: $? \n")
400 if (system ($cmd));
401
402 #parse results even though it's wierd.. thought parser and wrapper should be separate
403 0 my $epoParser = Bio::Tools::Eponine->new(-file =>$result);
404
405 0 ▶ while (my $tss = $epoParser->next_prediction()){
Branch: 1 branch
BranchTrueFalseTotal
if (my $tss = $epoParser->next_prediction) 0 0 0
406 0 push (@tss, $tss);
407 }
408 0 return @tss;
409 }
410  
411 1 1;
412 __END__
« Tools/Run/Hmmer.pm ↑ Summary Tools/Run/Alignment/Muscle.pm »