2 package org.forester.archaeopteryx.tools;
6 import org.forester.archaeopteryx.Configuration;
8 public final class InferenceManager {
10 private final static String DEFAULT_PATHS[] = { "C:\\Program Files\\", "C:\\Program Files (x86)\\", "/bin/",
11 "/usr/local/bin/", "/usr/bin/" };
12 private final File _path_to_local_mafft;
13 private final File _path_to_local_fastme;
14 private final File _path_to_local_raxml;
16 public static InferenceManager createInstance( final Configuration c ) {
17 return new InferenceManager( c.getpathToLocalMafft(), c.getPathToLocalFastme(), c.getPathToLocalRaxml() );
20 public boolean canDoMsa() {
21 return ( getPathToLocalMafft() != null );
24 public File getPathToLocalMafft() {
25 return _path_to_local_mafft;
28 public File getPathToLocalFastme() {
29 return _path_to_local_fastme;
32 public File getPathToLocalRaxml() {
33 return _path_to_local_raxml;
36 private final static File createLocalPath( final File path, final String name ) {
37 if ( ( path != null ) && path.canExecute() && !path.isDirectory() ) {
40 final File p1 = new File( name );
41 if ( p1.canExecute() && !p1.isDirectory() ) {
44 for( final String path_str : DEFAULT_PATHS ) {
46 final File p2 = new File( path_str + name );
47 if ( p2.canExecute() && !p2.isDirectory() ) {
50 final File p3 = new File( path_str + name + ".exe" );
51 if ( p3.canExecute() && !p3.isDirectory() ) {
54 final File p4 = new File( path_str + name + ".bat" );
55 if ( p4.canExecute() && !p4.isDirectory() ) {
59 catch ( final Exception e ) {
65 private InferenceManager( final File path_to_local_mafft,
66 final File path_to_local_fastme,
67 final File path_to_local_raxml ) {
68 _path_to_local_mafft = createLocalPath( path_to_local_mafft, "mafft" );
69 _path_to_local_fastme = createLocalPath( path_to_local_fastme, "fastme" );
70 _path_to_local_raxml = createLocalPath( path_to_local_raxml, "raxml" );