1

Bellow is a Bash script that I create and execute through java. It utilises several different scripts to produce statistics for RNA-Seq data. My problem is that when the script is executed it reaches the second stage of the script before the processes stops (the program does not error out, the required programs just stop processing). I have tried running the created script separately from the command line and it completes with no errors. An suggestions would be appreciated.

 String Trans_ref = 
"#!/bin/bash \n" +
"mkdir -p "+Output+"/"+Sample+"_RSEM \n" +
"cd "+Output+"/"+Sample+"_RSEM \n" +
"PATH=$PATH:"+RSEMprep+" \n" +
"export PATH=$PATH \n" + 
""+RSEMprep+"/rsem-prepare-reference --no-polyA --bowtie "+Output+"/Trans_CDHIT.fast Trans_CDHIT.RSEM \n" +    
""+RSEMprep+"/rsem-calculate-expression --paired-end -p "+CPU+" "+Output+"/SRR617145_1.fastq "+Output+"/SRR617145_2.fastq Trans_CDHIT.RSEM Trans_CDHIT.genes.results  \n"+
""+Trinprep+"/util/misc/count_features_given_MIN_FPKM_threshold.pl "+Output+"/"+Sample+"_RSEM/RSEM.genes.results > "+Output+"/"+Sample+"_RSEM/cumul_counts.txt \n"+
""+Trinprep+"/util/filter_fasta_by_rsem_values.pl --rsem_output= "+Output+"/"+Sample+"_RSEM/RSEM.isoforms.results --fasta="+Output+"/Trans_CDHIT.fasta -t 100 --output="+Output+"/"+Sample+"_RSEM/Trans_RSEMfilters.fasta \n" +
""+Trinprep+"/util/bowtie_PE_separate_then_join.pl --seqType fq --left "+Output+"/"+Sample+"_1.fasta --right "+Output+"/"+Sample+"_2.fasta --target "+Output+"/Trans_CDHIT.fasta --aligner bowtie --SS_lib_type FR -- -p 4 --all --best --strata -m 300 \n";  


    System.out.println(Trans_ref);

    FileUtils.writeStringToFile(new File(Output+"/TranRSEM"), Trans_ref);
    StringBuffer Trim = new StringBuffer();

    String cmd = (Output+"/TranRSEM");


Process p;

try{
    p = Runtime.getRuntime().exec(new String[]{"/bin/sh","-c", cmd});

    p.waitFor();

    BufferedReader reader1 = 
                    new BufferedReader(new InputStreamReader(p.getInputStream()));

        System.out.println("Merg Finished");

    } catch (Exception e) {
    e.printStackTrace();


    }
  • Have you set executable permissions for `Output+"/TranRSEM"` using ` file.setExecutable(true);`? Could you also post the produced shell script? – Erik E. Lorenz Aug 11 '14 at 08:44
  • 1. Try adding 'set -x' after the '#!/bin/bash' to see which command is the last one to be executed. 2. Also, maybe simplifying it a little bit can also help, why not exec your script directly like `...exec(cmd);`? 3. Another thing is that Output must be a non-relative path - I'm guessing it is, or the script wouldn't run at all. 4. My last advice to you is try capturing the error & output of your command as shown [here](http://stackoverflow.com/a/5711150/3374591) – ArnonZ Aug 11 '14 at 08:50
  • In the line containing `filter_fasta_[...]`, there seems to be an extra space in the arguments after the equals symbol: `--rsem_output= "+Output+"/"+Sample+`. A good argument parser should be fine, however. – Erik E. Lorenz Aug 11 '14 at 08:50
  • @ErikE.Lorenz - I have made it executable using that method unfortunately I must of deleted it while editing the post sorry. – mr.g.prescott Aug 11 '14 at 09:44
  • @Arnon Zilca - I will condense my code and try the set -x, but the error output will not happen a java is still waiting (p.waitFor()) the script to complete as the script. the processes when run from within java stop processing but it never registers as being finished (e.g. errors out etc) – mr.g.prescott Aug 11 '14 at 09:49

1 Answers1

0

To All

Thankyou very much for your comments

I managed to solve the problem. I discovered it was a java memory limitation. I solved this by using the Xmx20000m command in the project properties in my IDE (netbeans).

this appears to have solved my problem.