X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fmsa%2FClustalOmega.java;h=938fc7849c53dab506f2f2c64807e4708e4b83b0;hb=862ca59d36af9ccbed3ef284b497f9c04263ba97;hp=80e73b7c7f32fc2ae7e094b185f9194fe06a46a7;hpb=e86d89ccaf293b3e50d16db81d8e151c37c5fdb1;p=jalview.git diff --git a/forester/java/src/org/forester/msa/ClustalOmega.java b/forester/java/src/org/forester/msa/ClustalOmega.java index 80e73b7..938fc78 100644 --- a/forester/java/src/org/forester/msa/ClustalOmega.java +++ b/forester/java/src/org/forester/msa/ClustalOmega.java @@ -25,32 +25,33 @@ package org.forester.msa; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.forester.io.parsers.FastaParser; +import org.forester.io.writers.SequenceWriter; +import org.forester.io.writers.SequenceWriter.SEQ_FORMAT; +import org.forester.sequence.Sequence; import org.forester.util.SystemCommandExecutor; -public final class ClustalOmega implements MsaInferrer { +public final class ClustalOmega extends MsaInferrer { private final static String DEFAULT_PARAMETERS = ""; private String _error; private int _exit_code; private final String _path_to_prg; - - public static MsaInferrer createInstance( final String path_to_prg ) throws IOException { return new ClustalOmega( path_to_prg ); } - - private ClustalOmega( final String path_to_prg ) throws IOException { - if ( !SystemCommandExecutor.isExecuteableFile( new File( path_to_prg ) ) ) { - throw new IOException( "cannot execute MAFFT with \"" + path_to_prg + "\"" ); + if ( !isInstalled( path_to_prg ) ) { + throw new IOException( "cannot execute Clustal Omega with \"" + path_to_prg + "\"" ); } _path_to_prg = new String( path_to_prg ); init(); @@ -61,11 +62,6 @@ public final class ClustalOmega implements MsaInferrer { } @Override - public Object clone() { - throw new NoSuchMethodError(); - } - - @Override public String getErrorDescription() { return _error; } @@ -76,6 +72,18 @@ public final class ClustalOmega implements MsaInferrer { } @Override + public Msa infer( final List seqs, final List opts ) throws IOException, InterruptedException { + final File file = File.createTempFile( "__clustalo_input_", ".fasta" ); + file.deleteOnExit(); + final BufferedWriter writer = new BufferedWriter( new FileWriter( file ) ); + SequenceWriter.writeSeqs( seqs, writer, SEQ_FORMAT.FASTA, 100 ); + writer.close(); + final Msa msa = infer( file, opts ); + file.delete(); + return msa; + } + + @Override public Msa infer( final File path_to_input_seqs, final List opts ) throws IOException, InterruptedException { init(); final List my_opts = new ArrayList(); @@ -94,8 +102,8 @@ public final class ClustalOmega implements MsaInferrer { } final StringBuilder stdout = command_executor.getStandardOutputFromCommand(); if ( ( stdout == null ) || ( stdout.length() < 2 ) ) { - throw new IOException( "Clustal Omega program did not produce any output\nCommand:\n" + my_opts + "\nError:\n" - + stderr ); + throw new IOException( "Clustal Omega program did not produce any output\nCommand:\n" + my_opts + + "\nError:\n" + stderr ); } final Msa msa = FastaParser.parseMsa( stdout.toString() ); return msa;