X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;fp=src%2Fjalview%2Fgui%2FPreferences.java;h=df35b5e707c7863cd942bff808da3f9d7c942b63;hb=04a4d60a50394d846d0479c442facebe360b5b9c;hp=aa8369a0678f8c0029832663e4a7e1acbf0c5b52;hpb=653e250e0a2a5dd455ae4c52794c4ce0de340418;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index aa8369a..df35b5e 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -24,6 +24,7 @@ import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.bin.Cache; import jalview.gui.Help.HelpId; import jalview.gui.StructureViewer.ViewerType; +import jalview.hmmer.HmmerCommand; import jalview.io.FileFormatI; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; @@ -48,6 +49,8 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.awt.event.MouseEvent; import java.io.File; import java.util.ArrayList; @@ -102,6 +105,12 @@ public class Preferences extends GPreferences public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY"; public static final String CHIMERA_PATH = "CHIMERA_PATH"; + + public static final String HMMER_PATH = "HMMER_PATH"; + + public static final String HMMSEARCH_DB_PATHS = "HMMSEARCH_DB_PATHS"; + + public static final String HMMSEARCH_DBS = "HMMSEARCH_DBS"; public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS"; @@ -207,6 +216,38 @@ public class Preferences extends GPreferences frame.setMinimumSize(new Dimension(width, height)); /* + * Set HMMER tab defaults + */ + hmmrTrimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false)); + if (Cache.getDefault("USE_UNIPROT", false)) + { + hmmerBackgroundUniprot.setSelected(true); + } + else + { + hmmerBackgroundAlignment.setSelected(true); + } + hmmerSequenceCount + .setText(Cache.getProperty("SEQUENCES_TO_KEEP")); + hmmerPath.setText(Cache.getProperty(HMMER_PATH)); + hmmerPath.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + validateHMMERPath(true); + } + }); + hmmerPath.addFocusListener(new FocusAdapter() + { + @Override + public void focusLost(FocusEvent e) + { + validateHMMERPath(true); + } + }); + + /* * Set Visual tab defaults */ seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true)); @@ -229,6 +270,9 @@ public class Preferences extends GPreferences Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true)); showConsensLogo .setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO", false)); + showInformationHistogram.setSelected( + Cache.getDefault("SHOW_INFORMATION_HISTOGRAM", true)); + showHMMLogo.setSelected(Cache.getDefault("SHOW_HMM_LOGO", false)); showNpTooltip .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true)); showDbRefTooltip @@ -525,7 +569,7 @@ public class Preferences extends GPreferences autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false)); userIdWidth.setEnabled(!autoIdWidth.isSelected()); userIdWidthlabel.setEnabled(!autoIdWidth.isSelected()); - Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH"); + Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH"); userIdWidth.setText(wi == null ? "" : wi.toString()); // TODO: refactor to use common enum via FormatAdapter and allow extension // for new flat file formats @@ -610,6 +654,10 @@ public class Preferences extends GPreferences Boolean.toString(showConsensHistogram.isSelected())); Cache.applicationProperties.setProperty("SHOW_CONSENSUS_LOGO", Boolean.toString(showConsensLogo.isSelected())); + Cache.applicationProperties.setProperty("SHOW_INFORMATION_HISTOGRAM", + Boolean.toString(showConsensHistogram.isSelected())); + Cache.applicationProperties.setProperty("SHOW_HMM_LOGO", + Boolean.toString(showHMMLogo.isSelected())); Cache.applicationProperties.setProperty("ANTI_ALIAS", Boolean.toString(smoothFont.isSelected())); Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA, @@ -656,6 +704,39 @@ public class Preferences extends GPreferences maxColour.getBackground()); /* + * Save HMMER settings + */ + Cache.applicationProperties.setProperty("TRIM_TERMINI", + Boolean.toString(hmmrTrimTermini.isSelected())); + Cache.applicationProperties.setProperty("USE_UNIPROT", + Boolean.toString(hmmerBackgroundUniprot.isSelected())); + Cache.applicationProperties.setProperty("SEQUENCES_TO_KEEP", + hmmerSequenceCount.getText()); + Cache.applicationProperties.setProperty(HMMER_PATH, + hmmerPath.getText()); + AlignFrame[] frames = Desktop.getAlignFrames(); + if (frames != null && frames.length > 0) + { + for (AlignFrame f : frames) + { + f.updateHMMERStatus(); + } + } + + hmmrTrimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false)); + if (Cache.getDefault("USE_UNIPROT", false)) + { + hmmerBackgroundUniprot.setSelected(true); + } + else + { + hmmerBackgroundAlignment.setSelected(true); + } + hmmerSequenceCount + .setText(Cache.getProperty("SEQUENCES_TO_KEEP")); + hmmerPath.setText(Cache.getProperty(HMMER_PATH)); + + /* * Save Overview settings */ Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground()); @@ -784,7 +865,7 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH", Boolean.toString(autoIdWidth.isSelected())); userIdWidth_actionPerformed(); - Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH", + Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH", userIdWidth.getText()); /* @@ -898,6 +979,8 @@ public class Preferences extends GPreferences && (identity.isSelected() || showGroupConsensus.isSelected())); showConsensLogo.setEnabled(annotations.isSelected() && (identity.isSelected() || showGroupConsensus.isSelected())); + showInformationHistogram.setEnabled(annotations.isSelected()); + showHMMLogo.setEnabled(annotations.isSelected()); } @Override @@ -1179,6 +1262,53 @@ public class Preferences extends GPreferences } return true; } + + /** + * 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) + */ + @Override + protected boolean validateHMMERPath(boolean showWarning) + { + String folder = hmmerPath.getText().trim(); + + if (HmmerCommand.getExecutable(HmmerCommand.HMMBUILD, folder) != null) + { + return true; + } + if (showWarning && folder.length() > 0) + { + JvOptionPane.showInternalMessageDialog(Desktop.desktop, + MessageManager.getString("label.hmmbuild_not_found"), + MessageManager.getString("label.invalid_folder"), + JvOptionPane.ERROR_MESSAGE); + } + return false; + } + + /** + * 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; + } /** * If Chimera is selected, check it can be found on default or user-specified