Question: Calling muscle as a Java process
gravatar for Bioaln
4.3 years ago by
Bioaln340 wrote:

Hello. I'm developing a Java application, which at some point calls a MSA algorithm. Currently, I'm using muscle. I'm trying to call this process from within java app, there are no errors, yet there is no output! Is there a syntax problem I am not aware of?



try {
            System.out.println("Opening muscle analysis..");
            Runtime runTime = Runtime.getRuntime();
            Process process = runTime.exec(new String[]{
        } catch (IOException e) {

Thank you very much

muscle java external process • 1.3k views
ADD COMMENTlink modified 4.3 years ago by Pierre Lindenbaum126k • written 4.3 years ago by Bioaln340

Following code works defintely:

public void execute(String[] command)
    try {
        ProcessBuilder pb = new ProcessBuilder(command);
        Process p = pb.start();
        BufferedReader br = new BufferedReader(new InputStreamReader(
        String out = "";
        while ((out = br.readLine()) != null)

    } catch (Exception e) {


How to call it: execute(new String[]{"muscle","-in", "input.fa" , "-out" , "output.fa"});

ADD REPLYlink written 3.8 years ago by MeepMania0
gravatar for Pierre Lindenbaum
4.3 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum126k wrote:

check muscle is in the PATH, you may need to consumme the stdout and the stderr and wait for the end of the process ( don't use destroy but waitFor). A shorter way to do this is:

Runtime.getRuntime().exec("/path/to/muscle -in "+"test1.fasta"+" -out "+"out12.fa");
ADD COMMENTlink modified 3 months ago by RamRS25k • written 4.3 years ago by Pierre Lindenbaum126k

Thanks, I actually experimented a bit with destroy(), and it was the main problem, but thanks again :)

ADD REPLYlink modified 3 months ago by RamRS25k • written 4.3 years ago by Bioaln340
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1642 users visited in the last hour