in reply to Re: Calling Java using system()
in thread Calling Java using system()

Hi,

Rewriting did not work.

The program I am using is called ProtTest - it is a Java application. http://darwin.uvigo.es/software/prottest3/prottest3.html

I am able to run this program for a single file, but I have a huge number of files and I want to loop them processing one bye one

So this is the snippet I wrote:

my @ctl = glob("/users/sophix/Desktop/prottest3/prottest3/*.aa"); my ($ctltrimmed, $ctlfile, $ctlfiletrimmed); foreach my $ctlfile (@ctl) { if ($ctlfile =~ m/prottest3\/prottest3\/(\S+).aa$/) {$ctlfiletrimm +ed = $1;} my $out = system("/users/sophix/Desktop/prottest3/prottest3/java.e +xe -jar prottest-3.0.jar -i " . $ctltrimmed . "-t " . $ctltrimmed . " +\.trees" . "-o " . $ctltrimmed . "\.out" . "-all -verbose -all-matric +es -threads 3 -G -F -all-distributions -ncat 4"); }

Replies are listed 'Best First'.
Re^3: Calling Java using system()
by roboticus (Chancellor) on Jun 24, 2011 at 20:15 UTC

    sophix:

    It looks like you ignored saberworks' suggestion. Your java.exe is probably not in the directory you specified. First change directories, then execute the code. Something like (untested):

    chdir("/usrs/sophix/Desktop/prottest3/prottest3"); my @ctl = glob("*.aa"); my ($ctltrimmed, $ctlfile, $ctlfiletrimmed); foreach my $ctlfile (@ctl) { if ($ctlfile =~ m/(\S+).aa$/) { $ctlfiletrimmed = $1; } my $out = system("java -jar prottest-3.0.jar -i " . $ctltrimmed . "-t " . $ctltrimmed . "\.trees" . "-o " . $ctltrimmed . "\.out" . "-all -verbose -all-matrices " . "-threads 3 -G -F -all-distributions -ncat 4"); }

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.