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;
15 private final File _path_to_local_clustalo;
17 public static InferenceManager createInstance( final Configuration c ) {
18 return new InferenceManager( c.getpathToLocalMafft(),
19 c.getPathToLocalFastme(),
20 c.getPathToLocalRaxml(),
21 c.getPathToLocalClustalOmega() );
24 public boolean canDoMsa() {
25 return ( getPathToLocalMafft() != null ) || ( getPathToLocalClustalo() != null );
28 public File getPathToLocalMafft() {
29 return _path_to_local_mafft;
32 public File getPathToLocalFastme() {
33 return _path_to_local_fastme;
36 public File getPathToLocalRaxml() {
37 return _path_to_local_raxml;
40 public File getPathToLocalClustalo() {
41 return _path_to_local_clustalo;
44 private final static File createLocalPath( final File path, final String name ) {
45 if ( ( path != null ) && path.canExecute() && !path.isDirectory() ) {
48 final File p1 = new File( name );
49 if ( p1.canExecute() && !p1.isDirectory() ) {
52 for( final String path_str : DEFAULT_PATHS ) {
54 final File p2 = new File( path_str + name );
55 if ( p2.canExecute() && !p2.isDirectory() ) {
58 final File p3 = new File( path_str + name + ".exe" );
59 if ( p3.canExecute() && !p3.isDirectory() ) {
62 final File p4 = new File( path_str + name + ".bat" );
63 if ( p4.canExecute() && !p4.isDirectory() ) {
67 catch ( final Exception e ) {
73 private InferenceManager( final File path_to_local_mafft,
74 final File path_to_local_fastme,
75 final File path_to_local_raxml,
76 final File path_to_local_clustalo ) {
77 _path_to_local_mafft = createLocalPath( path_to_local_mafft, "mafft" );
78 _path_to_local_fastme = createLocalPath( path_to_local_fastme, "fastme" );
79 _path_to_local_raxml = createLocalPath( path_to_local_raxml, "raxml" );
80 _path_to_local_clustalo = createLocalPath( path_to_local_clustalo, "clustalo" );