From 5b0d4841f42582d761e1a3ec853efbb8be346441 Mon Sep 17 00:00:00 2001 From: TZVanaalten Date: Tue, 15 Aug 2017 17:05:15 +0100 Subject: [PATCH] JAL-2629 add checks for executing hmmer commands as .exe --- resources/lang/Messages.properties | 6 ++-- src/jalview/gui/Preferences.java | 50 +++++++++++++++++++++++---------- src/jalview/hmmer/HMMAlignThread.java | 10 +++++-- src/jalview/hmmer/HMMBuildThread.java | 10 +++++-- src/jalview/hmmer/HMMERCommands.java | 6 ++-- 5 files changed, 57 insertions(+), 25 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 891a8ac..56e9913 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -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 diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 7a231bc..0546264 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -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"); diff --git a/src/jalview/hmmer/HMMAlignThread.java b/src/jalview/hmmer/HMMAlignThread.java index 303b58b..fb6c38e 100644 --- a/src/jalview/hmmer/HMMAlignThread.java +++ b/src/jalview/hmmer/HMMAlignThread.java @@ -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"); diff --git a/src/jalview/hmmer/HMMBuildThread.java b/src/jalview/hmmer/HMMBuildThread.java index 5d55f84..ed074a8 100644 --- a/src/jalview/hmmer/HMMBuildThread.java +++ b/src/jalview/hmmer/HMMBuildThread.java @@ -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) diff --git a/src/jalview/hmmer/HMMERCommands.java b/src/jalview/hmmer/HMMERCommands.java index 4f1dbc6..e3fcd69 100644 --- a/src/jalview/hmmer/HMMERCommands.java +++ b/src/jalview/hmmer/HMMERCommands.java @@ -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; -- 1.7.10.2