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(),
18 c.getPathToLocalFastme(),
19 c.getPathToLocalRaxml(),
20 c.getPathToLocalClustalOmega() );
23 public boolean canDoMsa() {
24 return ( getPathToLocalMafft() != null );
27 public File getPathToLocalMafft() {
28 return _path_to_local_mafft;
31 public File getPathToLocalFastme() {
32 return _path_to_local_fastme;
35 public File getPathToLocalRaxml() {
36 return _path_to_local_raxml;
39 private final static File createLocalPath( final File path, final String name ) {
40 if ( ( path != null ) && path.canExecute() && !path.isDirectory() ) {
43 final File p1 = new File( name );
44 if ( p1.canExecute() && !p1.isDirectory() ) {
47 for( final String path_str : DEFAULT_PATHS ) {
49 final File p2 = new File( path_str + name );
50 if ( p2.canExecute() && !p2.isDirectory() ) {
53 final File p3 = new File( path_str + name + ".exe" );
54 if ( p3.canExecute() && !p3.isDirectory() ) {
57 final File p4 = new File( path_str + name + ".bat" );
58 if ( p4.canExecute() && !p4.isDirectory() ) {
62 catch ( final Exception e ) {
68 private InferenceManager( final File path_to_local_mafft,
69 final File path_to_local_fastme,
70 final File path_to_local_raxml,
71 final File path_to_local_clustalo ) {
72 _path_to_local_mafft = createLocalPath( path_to_local_mafft, "mafft" );
73 _path_to_local_fastme = createLocalPath( path_to_local_fastme, "fastme" );
74 _path_to_local_raxml = createLocalPath( path_to_local_raxml, "raxml" );