label.group_hmmbuild = Build HMM from Group
label.hmmsearch = hmmsearch
label.hmmer_location = HMMER Binaries Installation Location
-warn.null_hmm = Please ensure the alignment contains a hidden Markov model.
+label.cygwin_location = Cygwin Binaries Installation Location (Windows)
+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
warn.no_selected_hmm = Please select a hidden Markov model sequence.
label.hmmer = HMMER
label.trim_termini = Trim Non-Matching Termini
label.trim_termini_desc = If true, non-matching regions on either end of the resulting alignment are removed.
-label.no_of_sequences = Sequences Returned
-label.freq_alignment = Use Alignment Background Frequencies
-label.freq_uniprot = Use Uniprot Background Frequencies
-label.hmmalign_label = hmmalign Options
-label.hmmsearch_label = hmmsearch Options
-label.hmmbuild_not_found = The hmmbuild binary was not found
-label.hmmalign_not_found = The hmmalign binary was not found
-label.hmmsearch_not_found = The hmmsearch binary was not found
+label.no_of_sequences = Number of sequences returned
+label.freq_alignment = Use alignment background frequencies
+label.freq_uniprot = Use Uniprot background frequencies
+label.hmmalign_label = hmmalign options
+label.hmmsearch_label = hmmsearch options
+label.executable_not_found = The ''{0}'' executable file was not found
warn.hmm_command_failed = hmm command not found
label.invalid_folder = Invalid Folder
label.folder_not_exists = HMMER binaries not found. \n Please enter the path to the HMMER binaries (if installed).
import jalview.urls.api.UrlProviderFactoryI;
import jalview.urls.api.UrlProviderI;
import jalview.urls.desktop.DesktopUrlProviderFactory;
+import jalview.util.FileUtils;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.UrlConstants;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
+import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.RowFilter;
import javax.swing.RowSorter;
public static final String HMMER_PATH = "HMMER_PATH";
+ public static final String CYGWIN_PATH = "CYGWIN_PATH";
+
public static final String HMMSEARCH_DB_PATHS = "HMMSEARCH_DB_PATHS";
public static final String HMMSEARCH_DBS = "HMMSEARCH_DBS";
@Override
public void actionPerformed(ActionEvent e)
{
- validateHMMERPath(true);
+ validateHmmerPath();
}
});
hmmerPath.addFocusListener(new FocusAdapter()
@Override
public void focusLost(FocusEvent e)
{
- validateHMMERPath(true);
+ validateHmmerPath();
+ }
+ });
+ cygwinPath.setText(Cache.getProperty(CYGWIN_PATH));
+ cygwinPath.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ validateCygwinPath();
+ }
+ });
+ cygwinPath.addFocusListener(new FocusAdapter()
+ {
+ @Override
+ public void focusLost(FocusEvent e)
+ {
+ validateCygwinPath();
}
});
Boolean.toString(hmmerBackgroundUniprot.isSelected()));
Cache.applicationProperties.setProperty("SEQUENCES_TO_KEEP",
hmmerSequenceCount.getText());
- Cache.applicationProperties.setProperty(HMMER_PATH,
- hmmerPath.getText());
+ Cache.setOrRemove(HMMER_PATH, hmmerPath.getText());
+ Cache.setOrRemove(CYGWIN_PATH, cygwinPath.getText());
AlignFrame[] frames = Desktop.getAlignFrames();
if (frames != null && frames.length > 0)
{
}
/**
- * Returns true if hmmer path is to a folder that contains an executable
- * hmmbuild or hmmbuild.exe, else false (optionally after showing a warning
- * dialog)
+ * Returns true if the given text field contains a path to a folder that
+ * contains an executable with the given name, else false (after showing a
+ * warning dialog). The executable name will be tried with .exe appended if not
+ * found.
+ *
+ * @param textField
+ * @param executable
*/
- @Override
- protected boolean validateHMMERPath(boolean showWarning)
+ protected boolean validateExecutablePath(JTextField textField, String executable)
{
- String folder = hmmerPath.getText().trim();
+ String folder = textField.getText().trim();
- if (HmmerCommand.getExecutable(HmmerCommand.HMMBUILD, folder) != null)
+ if (FileUtils.getExecutable(executable, folder) != null)
{
return true;
}
- if (showWarning && folder.length() > 0)
+ if (folder.length() > 0)
{
JvOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.getString("label.hmmbuild_not_found"),
+ MessageManager.formatMessage("label.executable_not_found",
+ executable),
MessageManager.getString("label.invalid_folder"),
JvOptionPane.ERROR_MESSAGE);
}
}
}
+ @Override
+ protected void validateHmmerPath()
+ {
+ validateExecutablePath(hmmerPath, HmmerCommand.HMMBUILD);
+ }
+
+ @Override
+ protected void validateCygwinPath()
+ {
+ validateExecutablePath(cygwinPath, "run");
+ }
+
public class OptionsParam
{
private String name;
import jalview.gui.SplitFrame;
import jalview.io.DataSourceType;
import jalview.io.StockholmFile;
+import jalview.util.FileUtils;
import jalview.util.MessageManager;
import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
import jalview.ws.params.ArgumentI;
Hashtable sequencesHash = stashSequences(seqs);
try
{
- File modelFile = createTempFile("hmm", ".hmm");
- File alignmentFile = createTempFile("output", ".sto");
- File resultFile = createTempFile("input", ".sto");
+ File modelFile = FileUtils.createTempFile("hmm", ".hmm");
+ File alignmentFile = FileUtils.createTempFile("output", ".sto");
+ File resultFile = FileUtils.createTempFile("input", ".sto");
exportStockholm(seqs, alignmentFile.getAbsoluteFile(), null);
exportHmm(hmm, modelFile.getAbsoluteFile());
import jalview.io.DataSourceType;
import jalview.io.FileParse;
import jalview.io.StockholmFile;
+import jalview.util.FileUtils;
import jalview.util.MessageManager;
import jalview.ws.params.ArgumentI;
import jalview.ws.params.simple.BooleanOption;
try
{
- File hmmFile = createTempFile("hmm", ".hmm");
- File hitsAlignmentFile = createTempFile("hitAlignment", ".sto");
- File searchOutputFile = createTempFile("searchOutput", ".sto");
+ File hmmFile = FileUtils.createTempFile("hmm", ".hmm");
+ File hitsAlignmentFile = FileUtils.createTempFile("hitAlignment",
+ ".sto");
+ File searchOutputFile = FileUtils.createTempFile("searchOutput",
+ ".sto");
exportHmm(hmm, hmmFile.getAbsoluteFile());
* no external database specified for search, so
* export current alignment as 'database' to search
*/
- databaseFile = createTempFile("database", ".sto");
+ databaseFile = FileUtils.createTempFile("database", ".sto");
AlignmentI al = af.getViewport().getAlignment();
AlignmentI copy = new Alignment(al);
SequenceI hmms = copy.getHmmConsensus();
import jalview.gui.Preferences;
import jalview.io.HMMFile;
import jalview.io.StockholmFile;
+import jalview.util.FileUtils;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import jalview.ws.params.ArgumentI;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
*/
public static boolean isHmmerAvailable()
{
- File exec = getExecutable(HMMBUILD, Cache.getProperty(Preferences.HMMER_PATH));
+ File exec = FileUtils.getExecutable(HMMBUILD,
+ Cache.getProperty(Preferences.HMMER_PATH));
return exec != null;
}
public boolean runCommand(List<String> command)
throws IOException
{
+ List<String> commands = Platform.isWindows() ? wrapWithCygwin(command)
+ : command;
+
try
{
- ProcessBuilder pb = new ProcessBuilder(command);
+ ProcessBuilder pb = new ProcessBuilder(commands);
pb.redirectErrorStream(true); // merge syserr to sysout
final Process p = pb.start();
new Thread(new Runnable()
}).start();
p.waitFor();
- return p.exitValue() == 0; // 0 is success, by convention
+ int exitValue = p.exitValue();
+ if (exitValue != 0)
+ {
+ Cache.log.error("Command failed, return code = " + exitValue);
+ Cache.log.error("Command/args were: " + commands.toString());
+ }
+ return exitValue == 0; // 0 is success, by convention
} catch (Exception e)
{
e.printStackTrace();
}
/**
+ * Converts the given command to a Cygwin "run" command wrapper
+ *
+ * @param command
+ * @return
+ */
+ protected List<String> wrapWithCygwin(List<String> command)
+ {
+ File runCygwin = FileUtils.getExecutable("run",
+ Cache.getProperty(Preferences.CYGWIN_PATH));
+ if (runCygwin == null)
+ {
+ Cache.log.error("Cygwin shell not found");
+ return command;
+ }
+
+ List<String> wrapped = new ArrayList<>();
+ wrapped.add(runCygwin.getAbsolutePath());
+ if (!command.isEmpty())
+ {
+ wrapped.add(command.get(0));
+ // wrapped.add("--quote");
+ StringBuilder args = new StringBuilder();
+ for (String arg : command.subList(1, command.size()))
+ {
+ args.append(" ").append(arg);
+ }
+ wrapped.add(args.toString());
+ }
+ // TODO this doesn't yet pass parameters successfully
+
+ return wrapped;
+ }
+
+ /**
* Exports an alignment, and reference (RF) annotation if present, to the
* specified file, in Stockholm format
*
protected String getCommandPath(String cmd)
{
String binariesFolder = Cache.getProperty(Preferences.HMMER_PATH);
- File file = getExecutable(cmd, binariesFolder);
+ File file = FileUtils.getExecutable(cmd, binariesFolder);
if (file == null && af != null)
{
JvOptionPane.showInternalMessageDialog(af,
}
/**
- * 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;
- }
-
- /**
- * A convenience method to create a temporary file that is deleted on exit of
- * the JVM
- *
- * @param prefix
- * @param suffix
- * @return
- * @throws IOException
- */
- protected File createTempFile(String prefix, String suffix)
- throws IOException
- {
- File f = File.createTempFile(prefix, suffix);
- f.deleteOnExit();
- return f;
-
- }
-
- /**
* Exports an HMM to the specified file
*
* @param hmm
import jalview.gui.JvSwingUtils;
import jalview.gui.StructureViewer.ViewerType;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import java.awt.BorderLayout;
import java.awt.Color;
protected JTextField hmmerPath = new JTextField();
+ protected JTextField cygwinPath = new JTextField();
+
/*
* DAS Settings tab
*/
private JPanel initHMMERTab()
{
hmmerTab.setLayout(null);
+ final int lineSpacing = 20;
- JLabel installationLocation = new JLabel(
+ /*
+ * path to hmmer binaries folder
+ */
+ JLabel hmmerLocation = new JLabel(
MessageManager.getString("label.hmmer_location"));
- installationLocation.setFont(LABEL_FONT);
- installationLocation.setBounds(new Rectangle(22, 10, 250, 23));
- hmmerPath.setBounds(new Rectangle(22, 30, 300, 23));
+ hmmerLocation.setFont(LABEL_FONT);
+ int xPos = 22;
+ int yPos = 10;
+ hmmerLocation.setBounds(new Rectangle(xPos, yPos, 250, 23));
+ yPos += lineSpacing;
+ hmmerPath.setBounds(new Rectangle(xPos, yPos, 300, 23));
hmmerPath.addMouseListener(new MouseAdapter()
{
@Override
if (chosen != null)
{
hmmerPath.setText(chosen);
+ validateHmmerPath();
}
}
}
});
+ hmmerTab.add(hmmerLocation);
+ hmmerTab.add(hmmerPath);
- JLabel hmmalign = new JLabel(
- MessageManager.getString("label.hmmalign_label"));
- hmmalign.setFont(LABEL_FONT);
- hmmalign.setBounds(new Rectangle(22, 50, 200, 23));
+ /*
+ * path to Cygwin binaries folder (for Windows)
+ */
+ if (Platform.isWindows())
+ {
+ JLabel cygwinLocation = new JLabel(
+ MessageManager.getString("label.cygwin_location"));
+ cygwinLocation.setFont(LABEL_FONT);
+ yPos += lineSpacing * 2;
+ cygwinLocation.setBounds(new Rectangle(xPos, yPos, 250, 23));
+ yPos += lineSpacing;
+ cygwinPath.setBounds(new Rectangle(xPos, yPos, 300, 23));
+ cygwinPath.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mouseClicked(MouseEvent e)
+ {
+ if (e.getClickCount() == 2)
+ {
+ String chosen = openFileChooser(true);
+ if (chosen != null)
+ {
+ cygwinPath.setText(chosen);
+ validateCygwinPath();
+ }
+ }
+ }
+ });
+ hmmerTab.add(cygwinLocation);
+ hmmerTab.add(cygwinPath);
+ }
+ /*
+ * preferences for hmmalign
+ */
+ yPos += lineSpacing * 2;
+ JPanel alignOptions = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ JvSwingUtils.createTitledBorder(alignOptions,
+ MessageManager.getString("label.hmmalign_label"), true);
+ yPos += lineSpacing;
hmmrTrimTermini.setFont(LABEL_FONT);
hmmrTrimTermini.setText(MessageManager.getString("label.trim_termini"));
- hmmrTrimTermini.setBounds(new Rectangle(22, 70, 200, 23));
-
- JLabel hmmsearch = new JLabel(
- MessageManager.getString("label.hmmsearch_label"));
- hmmsearch.setFont(LABEL_FONT);
- hmmsearch.setBounds(new Rectangle(22, 90, 200, 23));
+ alignOptions.add(hmmrTrimTermini);
+ hmmerTab.add(alignOptions);
+ alignOptions.setBounds(new Rectangle(xPos, yPos, 300, 43));
+ /*
+ * preferences for hmmsearch
+ */
+ yPos += lineSpacing * 3;
+ JPanel searchOptions = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ JvSwingUtils.createTitledBorder(searchOptions,
+ MessageManager.getString("label.hmmsearch_label"), true);
+ searchOptions.setBounds(new Rectangle(xPos, yPos, 300, 43));
JLabel sequencesToKeep = new JLabel(
MessageManager.getString("label.no_of_sequences"));
sequencesToKeep.setFont(LABEL_FONT);
- sequencesToKeep.setBounds(new Rectangle(22, 110, 125, 23));
- hmmerSequenceCount.setBounds(new Rectangle(150, 110, 40, 23));
+ // hmmerSequenceCount.setBounds(new Rectangle(xPos + 250, yPos, 60, 23));
+ searchOptions.add(sequencesToKeep);
+ searchOptions.add(hmmerSequenceCount);
+ hmmerTab.add(searchOptions);
ButtonGroup backgroundFreqSource = new ButtonGroup();
backgroundFreqSource.add(hmmerBackgroundUniprot);
backgroundFreqSource.add(hmmerBackgroundAlignment);
backgroundFreqSource.setSelected(hmmerBackgroundUniprot.getModel(), true);
+ /*
+ * preferences for Information Content annotation
+ */
+ yPos += lineSpacing * 3;
hmmerBackgroundUniprot.setText(MessageManager.getString("label.freq_uniprot"));
hmmerBackgroundUniprot.setFont(LABEL_FONT);
- hmmerBackgroundUniprot.setBounds(new Rectangle(22, 130, 255, 23));
+ hmmerBackgroundUniprot.setBounds(new Rectangle(xPos, yPos, 255, 23));
+ yPos += lineSpacing;
hmmerBackgroundAlignment.setText(MessageManager.getString("label.freq_alignment"));
hmmerBackgroundAlignment.setFont(LABEL_FONT);
- hmmerBackgroundAlignment.setBounds(new Rectangle(22, 150, 300, 23));
+ hmmerBackgroundAlignment.setBounds(new Rectangle(xPos, yPos, 300, 23));
hmmerTab.add(hmmerBackgroundUniprot);
hmmerTab.add(hmmerBackgroundAlignment);
- hmmerTab.add(hmmalign);
- hmmerTab.add(hmmsearch);
- hmmerTab.add(installationLocation);
- hmmerTab.add(hmmerPath);
- hmmerTab.add(hmmrTrimTermini);
- hmmerTab.add(sequencesToKeep);
- hmmerTab.add(sequencesToKeep);
- hmmerTab.add(hmmerSequenceCount);
return hmmerTab;
}
return false;
}
- protected boolean validateHMMERPath(boolean showWarning)
- {
- return false;
- }
-
/**
* Initialises the Visual tabbed panel.
*
}
- public void hmmerPath_actionPerformed(ActionEvent e)
+ protected void validateHmmerPath()
{
+ }
+ protected void validateCygwinPath()
+ {
}
}
}
/**
- * Check if we are on a Microsoft plaform...
+ * Check if we are on a Microsoft platform...
*
* @return true if we have to cope with another platform variation
*/