X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FPreferences.java;h=e55acf97ddfc776d5298ab8e71cf104f0af558e2;hb=71b0134718413dd9179768fa51e26170684c2f2c;hp=6fdaa0d52b3636af656ef536ed1759b933ff4978;hpb=75d0279984e769ace9e422376b4104a4522cf0c3;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 6fdaa0d..e55acf9 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,13 +49,14 @@ 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; import java.util.List; import javax.help.HelpSetException; -import javax.swing.JButton; import javax.swing.JColorChooser; import javax.swing.JFileChooser; import javax.swing.JInternalFrame; @@ -103,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"; @@ -110,6 +118,14 @@ public class Preferences extends GPreferences public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY"; + public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START"; + + public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP"; + + public static final String GAP_COLOUR = "GAP_COLOUR"; + + public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR"; + private static final int MIN_FONT_SIZE = 1; private static final int MAX_FONT_SIZE = 30; @@ -200,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)); @@ -222,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 @@ -308,10 +359,21 @@ public class Preferences extends GPreferences Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange)); maxColour.setBackground( Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red)); + + /* + * Set overview panel defaults + */ gapColour.setBackground( - Cache.getDefaultColour("GAP_COLOUR", Color.lightGray)); + Cache.getDefaultColour(GAP_COLOUR, + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP)); hiddenColour.setBackground( - Cache.getDefaultColour("HIDDEN_COLOUR", Color.darkGray)); + Cache.getDefaultColour(HIDDEN_COLOUR, + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN)); + useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false)); + gapLabel.setEnabled(!useLegacyGap.isSelected()); + gapColour.setEnabled(!useLegacyGap.isSelected()); + showHiddenAtStart + .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, true)); /* * Set Structure tab defaults. @@ -509,6 +571,8 @@ public class Preferences extends GPreferences userIdWidthlabel.setEnabled(!autoIdWidth.isSelected()); Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH"); userIdWidth.setText(wi == null ? "" : wi.toString()); + // TODO: refactor to use common enum via FormatAdapter and allow extension + // for new flat file formats blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true)); clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true)); fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true)); @@ -590,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, @@ -636,6 +704,49 @@ 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()); + Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground()); + Cache.applicationProperties.setProperty(USE_LEGACY_GAP, + Boolean.toString(useLegacyGap.isSelected())); + Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START, + Boolean.toString(showHiddenAtStart.isSelected())); + + /* * Save Structure settings */ Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN, @@ -868,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 @@ -1040,29 +1153,60 @@ public class Preferences extends GPreferences } @Override - public void gapColour_actionPerformed(JButton btn) + public void gapColour_actionPerformed(JPanel gap) { - Color col = JColorChooser.showDialog(this, - MessageManager.getString("label.select_gap_colour"), - gapColour.getForeground()); - if (col != null) + if (!useLegacyGap.isSelected()) { - btn.setForeground(col); + Color col = JColorChooser.showDialog(this, + MessageManager.getString("label.select_gap_colour"), + gapColour.getBackground()); + if (col != null) + { + gap.setBackground(col); + } + gap.repaint(); } - btn.repaint(); } @Override - public void hiddenColour_actionPerformed(JButton btn) + public void hiddenColour_actionPerformed(JPanel hidden) { Color col = JColorChooser.showDialog(this, MessageManager.getString("label.select_hidden_colour"), - hiddenColour.getForeground()); + hiddenColour.getBackground()); if (col != null) { - btn.setForeground(col); + hidden.setBackground(col); + } + hidden.repaint(); + } + + @Override + protected void useLegacyGaps_actionPerformed(ActionEvent e) + { + boolean enabled = useLegacyGap.isSelected(); + if (enabled) + { + gapColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP); + } + else + { + gapColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP); } - btn.repaint(); + gapColour.setEnabled(!enabled); + gapLabel.setEnabled(!enabled); + } + + @Override + protected void resetOvDefaults_actionPerformed(ActionEvent e) + { + useLegacyGap.setSelected(false); + useLegacyGaps_actionPerformed(null); + showHiddenAtStart.setSelected(true); + hiddenColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN); } @Override @@ -1118,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