JAL-2629 add checks for executing hmmer commands as .exe
authorTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Tue, 15 Aug 2017 16:05:15 +0000 (17:05 +0100)
committerTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Tue, 15 Aug 2017 16:05:15 +0000 (17:05 +0100)
resources/lang/Messages.properties
src/jalview/gui/Preferences.java
src/jalview/hmmer/HMMAlignThread.java
src/jalview/hmmer/HMMBuildThread.java
src/jalview/hmmer/HMMERCommands.java

index 891a8ac..56e9913 100644 (file)
@@ -1320,11 +1320,11 @@ label.hmmbuild = hmmbuild
 label.hmmbuild_group = Build HMM from Selected Group
 label.group_hmmbuild = Build HMM from Group
 label.hmmsearch = hmmsearch
-label.change_hmmer_location = HMMER Installation Location
+label.change_hmmer_location = HMMER Binaries Installation Location
 warn.null_hmm = Please ensure the alignment contains a hidden Markov model.
 label.ignore_below_background_frequency = Ignore Below Background Frequency
 label.information_description = Information content, measured in bits
-label.enter_location = Please enter the path of your HMMER folder.
+label.enter_location = Please enter the path of your HMMER binaries folder.
 label.invalid_hmmer_folder = The folder that you selected does not contain the necessary HMMER binaries.
 warn.no_selected_hmm = Please select a hidden Markov model sequence.
 label.select_hmm = Select HMM
@@ -1342,5 +1342,5 @@ label.hmmsearch_not_found = The hmmsearch binary was not found.
 warn.hmmbuild_failed = hmmbuild was not found. 
 warn.align_failed = hmmalign was not found.
 label.invalid_folder = Invalid Folder
-label.folder_not_exists = HMMER not found. \n Please enter the path to HMMER (if installed).
+label.folder_not_exists = HMMER binaries not found. \n Please enter the path to the HMMER binaries (if installed).
 label.hmmer_installed = HMMER installed
\ No newline at end of file
index 7a231bc..0546264 100755 (executable)
@@ -1193,10 +1193,10 @@ public class Preferences extends GPreferences
   {
     int missing = 0;
     String message = "";
-    String path = hmmerPath.getText().trim();
-    if (path.length() > 0)
+    String folder = hmmerPath.getText().trim();
+    if (folder.length() > 0)
     {
-      File f = new File(path);
+      File f = new File(folder);
       if (!f.exists())
       {
         if (showDialog)
@@ -1208,30 +1208,23 @@ public class Preferences extends GPreferences
         }
         return false;
       }
-
-      File hmmbuild = new File(path + "/binaries/hmmbuild");
-      {
-        if (!hmmbuild.canExecute())
+      if (!canExecute(folder + "/hmmbuild"))
         {
           message += MessageManager.getString("label.hmmbuild_not_found")
                   + "\n";
           missing++;
         }
-      }
 
-      File hmmalign = new File(path + "/binaries/hmmalign");
-      {
-        if (!hmmalign.canExecute())
+
+      if (!canExecute(folder + "/hmmalign"))
         {
           message += MessageManager.getString("label.hmmalign_not_found")
                   + "\n";
           missing++;
         }
-      }
 
-      File hmmsearch = new File(path + "/binaries/hmmsearch");
-      {
-        if (!hmmsearch.canExecute())
+
+      if (!canExecute(folder + "/hmmsearch"))
         {
           message += MessageManager.getString("label.hmmsearch_not_found")
                   + "\n";
@@ -1265,10 +1258,37 @@ public class Preferences extends GPreferences
         }
       }
 
+    return true;
+  }
+
+  /**
+   * Checks if a file can be executed
+   * 
+   * @param path
+   *          the path to the file
+   * @return
+   */
+  public boolean canExecute(String path)
+  {
+    File file = new File(path);
+    if (!file.canExecute())
+    {
+      file = new File(path + ".exe");
+      {
+        if (!file.canExecute())
+        {
+          return false;
+        }
+      }
     }
     return true;
   }
 
+  /**
+   * Gets the current version of hmmer
+   * 
+   * @return
+   */
   private String getHMMERVersion()
   {
     File file = new File(hmmerPath.getText() + "/release-notes");
index 303b58b..fb6c38e 100644 (file)
@@ -165,10 +165,16 @@ public class HMMAlignThread implements Runnable
 
   private boolean runCommand() throws IOException, InterruptedException
   {
-    File file = new File(cmds.HMMERFOLDER + "/binaries/hmmalign");
+    File file = new File(cmds.HMMERFOLDER + "/hmmalign");
     if (!file.canExecute())
     {
-      return false;
+      file = new File(cmds.HMMERFOLDER + "/hmmalign.exe");
+      {
+        if (!file.canExecute())
+        {
+          return false;
+        }
+      }
     }
     String command = cmds.HMMERFOLDER + cmds.HMMALIGN;
     String version = Cache.getProperty("HMMER_VERSION");
index 5d55f84..ed074a8 100644 (file)
@@ -149,10 +149,16 @@ public class HMMBuildThread implements Runnable
   
   private boolean runCommand() throws IOException, InterruptedException
   {
-    File file = new File(cmds.HMMERFOLDER + "/binaries/hmmbuild");
+    File file = new File(cmds.HMMERFOLDER + "/hmmbuild");
     if (!file.canExecute())
     {
-      return false;
+      file = new File(cmds.HMMERFOLDER + "/hmmbuild.exe");
+      {
+        if (!file.canExecute())
+        {
+          return false;
+        }
+      }
     }
     String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.NAME;
     if (forGroup)
index 4f1dbc6..e3fcd69 100644 (file)
@@ -24,11 +24,11 @@ public class HMMERCommands
   public String JALVIEWDIRECTORY = System.getProperty("user.dir")
           + "/";
 
-  public final String HMMALIGN = "/binaries/hmmalign ";
+  public final String HMMALIGN = "/hmmalign ";
 
-  public final String HMMBUILD = "/binaries/hmmbuild ";
+  public final String HMMBUILD = "/hmmbuild ";
 
-  public final String HMMSEARCH = "/binaries/hmmsearch ";
+  public final String HMMSEARCH = "/hmmsearch ";
 
   public String HMMBUFFER;