Configuration _configuration;
JMenuItem _remove_branch_color_item;
Options _options;
- InferenceManager _inference_manager;
+ InferenceManager _inference_manager;
final ProcessPool _process_pool;
MainFrame() {
void setInferenceManager( final InferenceManager i ) {
_inference_manager = i;
}
-
+
public InferenceManager getInferenceManager() {
return _inference_manager;
}
-
-
+
void setSelectedTypeInTypeMenu( final PHYLOGENY_GRAPHICS_TYPE type ) {
setTypeMenuToAllUnselected();
switch ( type ) {
.setToolTipText( "Basic phylogenetic inference including multiple sequence alignment" );
}
else {
- _inference_menu.add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences (no program found)" ) );
+ _inference_menu
+ .add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences (no program found)" ) );
customizeJMenuItem( _inference_from_seqs_item );
_inference_from_seqs_item.setEnabled( false );
}
if ( ( path != null ) && path.canExecute() && !path.isDirectory() ) {
return path;
}
- File p1 = new File( name );
+ final File p1 = new File( name );
if ( p1.canExecute() && !p1.isDirectory() ) {
return p1;
}
private Msa runMAFFT( final File input_seqs, final List<String> opts ) throws IOException, InterruptedException {
Msa msa = null;
- final MsaInferrer mafft = Mafft.createInstance( _mf.getInferenceManager().getPathToLocalMafft().getCanonicalPath());
+ final MsaInferrer mafft = Mafft.createInstance( _mf.getInferenceManager().getPathToLocalMafft()
+ .getCanonicalPath() );
try {
msa = mafft.infer( input_seqs, opts );
}
}
return msa;
}
-
- private Msa runClustalOmega( final File input_seqs, final List<String> opts ) throws IOException, InterruptedException {
+
+ private Msa runClustalOmega( final File input_seqs, final List<String> opts ) throws IOException,
+ InterruptedException {
Msa msa = null;
- final MsaInferrer clustalo = ClustalOmega.createInstance(_mf.getInferenceManager().getPathToLocalClustalo().getCanonicalPath());
+ final MsaInferrer clustalo = ClustalOmega.createInstance( _mf.getInferenceManager().getPathToLocalClustalo()
+ .getCanonicalPath() );
try {
msa = clustalo.infer( input_seqs, opts );
}
import org.forester.io.parsers.FastaParser;
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();
}
@Override
- public Object clone() {
- throw new NoSuchMethodError();
- }
-
- @Override
public String getErrorDescription() {
return _error;
}
}
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;
import java.util.List;
import org.forester.io.parsers.FastaParser;
-import org.forester.util.ForesterUtil;
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 );
}
@Override
- public Object clone() {
- throw new NoSuchMethodError();
- }
-
- @Override
public String getErrorDescription() {
return _error;
}
+++ /dev/null
-
-package org.forester.msa;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.List;
-
-import org.forester.io.parsers.FastaParser;
-import org.forester.util.ExternalProgram;
-import org.forester.util.ForesterUtil;
-
-public final class MafftOLD implements MsaInferrer {
-
- private String _error;
- private int _exit_code;
- private final String _path_to_prg;
-
- public static MsaInferrer createInstance( final String path_to_prg ) {
- return new MafftOLD( path_to_prg );
- }
-
- private MafftOLD( final String path_to_prg ) {
- _path_to_prg = new String( path_to_prg );
- init();
- }
-
- @Override
- public Object clone() {
- throw new NoSuchMethodError();
- }
-
- @Override
- public String getErrorDescription() {
- return _error;
- }
-
- @Override
- public int getExitCode() {
- return _exit_code;
- }
-
- @Override
- public Msa infer( final File path_to_input_seqs, final List<String> opts ) throws IOException, InterruptedException {
- init();
- final String[] my_opts = new String[ opts.size() + 1 ];
- for( int i = 0; i < opts.size(); i++ ) {
- my_opts[ i ] = opts.get( i );
- }
- my_opts[ opts.size() ] = path_to_input_seqs.getAbsolutePath();
- final ExternalProgram mafft_prg = new ExternalProgram( _path_to_prg );
- mafft_prg.launch( my_opts );
- // _exit_code = mafft_prg.waitFor();
- // if ( _exit_code != 0 ) {
- // throw new IOException( "MAFFT failed, exit code: " + _exit_code );
- // }
- final BufferedReader r = new BufferedReader( new InputStreamReader( mafft_prg.getErrorStream() ) );
- final StringBuffer error_sb = new StringBuffer();
- String line = null;
- while ( ( line = r.readLine() ) != null ) {
- error_sb.append( line );
- error_sb.append( ForesterUtil.LINE_SEPARATOR );
- }
- r.close();
- if ( error_sb.length() > 0 ) {
- _error = error_sb.toString();
- throw new IOException( "MAFFT failed" );
- }
- final InputStream is = mafft_prg.getInputStream();
- final Msa msa = FastaParser.parseMsa( is );
- is.close();
- return msa;
- }
-
- private void init() {
- _error = null;
- _exit_code = -100;
- }
-}
import java.io.IOException;
import java.util.List;
-public interface MsaInferrer {
+import org.forester.util.SystemCommandExecutor;
- public String getErrorDescription();
+public abstract class MsaInferrer {
- public int getExitCode();
+ public abstract String getErrorDescription();
- public Msa infer( File path_to_input_seqs, List<String> opts ) throws IOException, InterruptedException;
+ public abstract int getExitCode();
+
+ public static boolean isInstalled( final String path_to_prg ) {
+ return SystemCommandExecutor.isExecuteableFile( new File( path_to_prg ) );
+ }
+
+ @Override
+ public Object clone() {
+ throw new NoSuchMethodError();
+ }
+
+ public abstract Msa infer( File path_to_input_seqs, List<String> opts ) throws IOException, InterruptedException;
}
System.out.println( "failed." );
failed++;
}
- if ( Mafft.isInstalled() ) {
+ //----
+ String path = "";
+ final String os = ForesterUtil.OS_NAME.toLowerCase();
+ if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
+ path = "/usr/local/bin/mafft";
+ }
+ else if ( os.indexOf( "win" ) >= 0 ) {
+ path = "C:\\Program Files\\mafft-win\\mafft.bat";
+ }
+ else {
+ path = "/home/czmasek/bin/mafft";
+ }
+ if ( Mafft.isInstalled( path ) ) {
System.out.print( "MAFFT (external program): " );
if ( Test.testMafft() ) {
System.out.println( "OK." );
System.out.println( "failed [will not count towards failed tests]" );
}
}
+ //----
System.out.print( "Next nodes with collapsed: " );
if ( Test.testNextNodeWithCollapsing() ) {
System.out.println( "OK." );
opts.add( "1000" );
opts.add( "--localpair" );
opts.add( "--quiet" );
-
-
- String path = "";
- final String os = ForesterUtil.OS_NAME.toLowerCase();
- if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
- path = "/usr/local/bin/mafft";
- }
- else if ( os.indexOf( "win" ) >= 0 ) {
- path = "C:\\Program Files\\mafft-win\\mafft.bat";
- }
- else {
- path = "/home/czmasek/bin/mafft";
- }
-
+ String path = "";
+ final String os = ForesterUtil.OS_NAME.toLowerCase();
+ if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
+ path = "/usr/local/bin/mafft";
+ }
+ else if ( os.indexOf( "win" ) >= 0 ) {
+ path = "C:\\Program Files\\mafft-win\\mafft.bat";
+ }
+ else {
+ path = "/home/czmasek/bin/mafft";
+ }
Msa msa = null;
final MsaInferrer mafft = Mafft.createInstance( path );
msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
}
}
- public static boolean isWindowns () {
- return ForesterUtil.OS_NAME.toLowerCase().indexOf( "win" ) > -1;
+ public static boolean isWindowns() {
+ return ForesterUtil.OS_NAME.toLowerCase().indexOf( "win" ) > -1;
}
-
+
final public static String getForesterLibraryInformation() {
return "forester " + ForesterConstants.FORESTER_VERSION + " (" + ForesterConstants.FORESTER_DATE + ")";
}