package jalview.hmmer;
+import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenMarkovModel;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.gui.JvOptionPane;
+import jalview.gui.Preferences;
import jalview.io.HMMFile;
import jalview.io.StockholmFile;
+import jalview.util.MessageManager;
import java.io.BufferedReader;
import java.io.File;
import java.util.List;
/**
- * Contains multiple commands and methods frequently used to run hmmbuild,
- * hmmalign and hmmsearch
+ * Base class for hmmbuild, hmmalign and hmmsearch
*
* @author TZVanaalten
*
*/
-public class HMMERCommands
+public class HmmerCommand
{
- // Path of hmmer binaries directory
- String HMMERFOLDER = "/Documents/";
+ public static final String HMMBUILD = "hmmbuild";
- public String JALVIEWDIRECTORY = System.getProperty("user.dir") + "/";
-
- public final String HMMALIGN = "/hmmalign ";
-
- public final String HMMBUILD = "/hmmbuild ";
-
- public final String HMMSEARCH = "/hmmsearch ";
+ public String JALVIEWDIRECTORY = System.getProperty("user.dir")
+ + File.separator;
public String OUTPUTALIGNMENT;
List<SequenceI> hmmSeqs;
+ protected AlignFrame af;
+
+ public static boolean isHmmerAvailable()
+ {
+ File exec = getExecutable(HMMBUILD, Cache.getProperty(Preferences.HMMER_PATH));
+ return exec != null;
+ }
+
/**
* Uniquifies the sequences when exporting and stores their details in a
* hashtable.
if (seqs != null)
{
AlignmentI newAl = new Alignment(seqs);
- if (stoLocation != null)
+ if (stoLocation != null && al != null)
{
for (AlignmentAnnotation annot : al.getAlignmentAnnotation())
{
{
this.hmmSeqs = hmmSeqs;
}
+
+ /**
+ * Answers the full path to the given hmmer executable, or null if file cannot
+ * be found or is not executable
+ *
+ * @param cmd
+ * command short name e.g. hmmalign
+ * @return
+ */
+ protected String getCommandRoot(String cmd)
+ {
+ String binariesFolder = Cache.getProperty(Preferences.HMMER_PATH);
+ File file = getExecutable(cmd, binariesFolder);
+ if (file == null && af != null)
+ {
+ JvOptionPane.showInternalMessageDialog(af,
+ MessageManager.getString("warn.hmm_command_failed"));
+ }
+
+ return file == null ? null : file.getAbsolutePath();
+ }
+
+ /**
+ * Answers the executable file for the given hmmer command, or null if not
+ * found or not executable. The path to the executable is the command name
+ * prefixed by the hmmer binaries folder path, optionally with .exe appended.
+ *
+ * @param cmd
+ * hmmer command short name, for example hmmbuild
+ * @param binaryPath
+ * parent folder containing hmmer executables
+ * @return
+ */
+ public static File getExecutable(String cmd, String binaryPath)
+ {
+ File file = new File(binaryPath, cmd);
+ if (!file.canExecute())
+ {
+ file = new File(binaryPath, cmd + ".exe");
+ {
+ if (!file.canExecute())
+ {
+ file = null;
+ }
+ }
+ }
+ return file;
+ }
}