X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fmsa%2FMafft.java;h=ae9fdf11a0ee9bc18240513c58ed0d38d6e2b8e1;hb=fda4b2cd36f7c4d7edf6381268ebcf5fbbc77297;hp=7e4e4c02b39537b20ab36674b57e5d9e3f0ce9cf;hpb=e86d89ccaf293b3e50d16db81d8e151c37c5fdb1;p=jalview.git diff --git a/forester/java/src/org/forester/msa/Mafft.java b/forester/java/src/org/forester/msa/Mafft.java index 7e4e4c0..ae9fdf1 100644 --- a/forester/java/src/org/forester/msa/Mafft.java +++ b/forester/java/src/org/forester/msa/Mafft.java @@ -21,36 +21,36 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester 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.util.ForesterUtil; +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 Mafft implements MsaInferrer { +public final class Mafft extends MsaInferrer { private final static String DEFAULT_PARAMETERS = "--maxiterate 1000 --localpair"; 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 Mafft( path_to_prg ); } - - private Mafft( final String path_to_prg ) throws IOException { - if ( !SystemCommandExecutor.isExecuteableFile( new File( path_to_prg ) ) ) { + if ( !isInstalled( path_to_prg ) ) { throw new IOException( "cannot execute MAFFT with \"" + path_to_prg + "\"" ); } _path_to_prg = new String( path_to_prg ); @@ -62,11 +62,6 @@ public final class Mafft implements MsaInferrer { } @Override - public Object clone() { - throw new NoSuchMethodError(); - } - - @Override public String getErrorDescription() { return _error; } @@ -77,6 +72,18 @@ public final class Mafft implements MsaInferrer { } @Override + public Msa infer( final List seqs, final List opts ) throws IOException, InterruptedException { + final File file = File.createTempFile( "__mafft_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();