2 package org.forester.msa;
4 import java.io.BufferedReader;
6 import java.io.IOException;
7 import java.io.InputStream;
8 import java.io.InputStreamReader;
11 import org.forester.io.parsers.FastaParser;
12 import org.forester.util.ExternalProgram;
13 import org.forester.util.ForesterUtil;
15 public final class MafftOLD implements MsaInferrer {
17 private String _error;
18 private int _exit_code;
19 private final String _path_to_prg;
21 public static MsaInferrer createInstance( final String path_to_prg ) {
22 return new MafftOLD( path_to_prg );
25 private MafftOLD( final String path_to_prg ) {
26 _path_to_prg = new String( path_to_prg );
31 public Object clone() {
32 throw new NoSuchMethodError();
36 public String getErrorDescription() {
41 public int getExitCode() {
46 public Msa infer( final File path_to_input_seqs, final List<String> opts ) throws IOException, InterruptedException {
48 final String[] my_opts = new String[ opts.size() + 1 ];
49 for( int i = 0; i < opts.size(); i++ ) {
50 my_opts[ i ] = opts.get( i );
52 my_opts[ opts.size() ] = path_to_input_seqs.getAbsolutePath();
53 final ExternalProgram mafft_prg = new ExternalProgram( _path_to_prg );
54 mafft_prg.launch( my_opts );
55 // _exit_code = mafft_prg.waitFor();
56 // if ( _exit_code != 0 ) {
57 // throw new IOException( "MAFFT failed, exit code: " + _exit_code );
59 final BufferedReader r = new BufferedReader( new InputStreamReader( mafft_prg.getErrorStream() ) );
60 final StringBuffer error_sb = new StringBuffer();
62 while ( ( line = r.readLine() ) != null ) {
63 error_sb.append( line );
64 error_sb.append( ForesterUtil.LINE_SEPARATOR );
67 if ( error_sb.length() > 0 ) {
68 _error = error_sb.toString();
69 throw new IOException( "MAFFT failed" );
71 final InputStream is = mafft_prg.getInputStream();
72 final Msa msa = FastaParser.parseMsa( is );