import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.bin.Cache;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenMarkovModel;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
import jalview.gui.Help.HelpId;
import jalview.gui.StructureViewer.ViewerType;
+import jalview.hmmer.HMMBuildThread;
import jalview.io.FileFormatI;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
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";
public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
showUnconserved
.setSelected(Cache.getDefault("SHOW_UNCONSERVED", false));
showOccupancy.setSelected(Cache.getDefault(SHOW_OCCUPANCY, false));
- showGroupConsensus.setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS",
- false));
- showGroupConservation.setSelected(Cache.getDefault(
- "SHOW_GROUP_CONSERVATION", false));
- showConsensHistogram.setSelected(Cache.getDefault(
- "SHOW_CONSENSUS_HISTOGRAM", true));
- showConsensLogo.setSelected(Cache.getDefault("SHOW_CONSENSUS_LOGO",
- false));
+ showGroupConsensus
+ .setSelected(Cache.getDefault("SHOW_GROUP_CONSENSUS", false));
+ showGroupConservation.setSelected(
+ Cache.getDefault("SHOW_GROUP_CONSERVATION", false));
+ showConsensHistogram.setSelected(
+ 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.setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP",
- true));
+ showNpTooltip
+ .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
+ showDbRefTooltip
+ .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
String[] fonts = java.awt.GraphicsEnvironment
.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
- fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN
- + ""));
+ fontStyleCB.setSelectedItem(
+ Cache.getDefault("FONT_STYLE", Font.PLAIN + ""));
smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
- scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA,
- false));
+ scaleProteinToCdna
+ .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false));
idItalics.setSelected(Cache.getDefault("ID_ITALICS", true));
protColour.setSelectedItem(newProp != null ? newProp : oldProp);
newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
- minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
- Color.orange));
- maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
- Color.red));
+ minColour.setBackground(
+ Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
+ maxColour.setBackground(
+ Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
/*
* Set Structure tab defaults.
addSecondaryStructure.setEnabled(structSelected);
addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false));
addTempFactor.setEnabled(structSelected);
- structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
- ViewerType.JMOL.name()));
+ structViewer.setSelectedItem(
+ Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name()));
chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
chimeraPath.addActionListener(new ActionListener()
{
SortOrder.DESCENDING));
sortKeys.add(new RowSorter.SortKey(m.getSelectedColumn(),
SortOrder.DESCENDING));
- sortKeys.add(new RowSorter.SortKey(m.getNameColumn(),
- SortOrder.ASCENDING));
+ sortKeys.add(
+ new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING));
sorter.setSortKeys(sortKeys);
sorter.sort();
-
+
// set up filtering
ActionListener onReset;
onReset = new ActionListener()
@Override
public void changedUpdate(DocumentEvent e)
{
- sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
- + filterTB.getText()));
+ sorter.setRowFilter(RowFilter
+ .regexFilter(caseInsensitiveFlag + filterTB.getText()));
}
@Override
public void removeUpdate(DocumentEvent e)
{
- sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
- + filterTB.getText()));
+ sorter.setRowFilter(RowFilter
+ .regexFilter(caseInsensitiveFlag + filterTB.getText()));
}
@Override
public void insertUpdate(DocumentEvent e)
{
- sorter.setRowFilter(RowFilter.regexFilter(caseInsensitiveFlag
- + filterTB.getText()));
+ sorter.setRowFilter(RowFilter
+ .regexFilter(caseInsensitiveFlag + filterTB.getText()));
}
});
// set up list selection functionality
- linkUrlTable.getSelectionModel().addListSelectionListener(
- new UrlListSelectionHandler());
+ linkUrlTable.getSelectionModel()
+ .addListSelectionListener(new UrlListSelectionHandler());
// set up radio buttons
int onClickCol = ((UrlLinkTableModel) linkUrlTable.getModel())
.getPrimaryColumn();
String onClickName = linkUrlTable.getColumnName(onClickCol);
- linkUrlTable.getColumn(onClickName).setCellRenderer(
- new RadioButtonRenderer());
+ linkUrlTable.getColumn(onClickName)
+ .setCellRenderer(new RadioButtonRenderer());
linkUrlTable.getColumn(onClickName)
.setCellEditor(new RadioButtonEditor());
if (linkUrlTable.getModel().getColumnClass(column)
.equals(Boolean.class))
{
- TableColumn tableColumn = linkUrlTable.getColumnModel().getColumn(
- column);
+ TableColumn tableColumn = linkUrlTable.getColumnModel()
+ .getColumn(column);
int preferredWidth = tableColumn.getMinWidth();
TableCellRenderer cellRenderer = linkUrlTable.getCellRenderer(0,
pileupjv.setSelected(Cache.getDefault("PILEUP_JVSUFFIX", true));
pirjv.setSelected(Cache.getDefault("PIR_JVSUFFIX", true));
modellerOutput.setSelected(Cache.getDefault("PIR_MODELLER", false));
- embbedBioJSON.setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON",
- true));
+ embbedBioJSON
+ .setSelected(Cache.getDefault("EXPORT_EMBBED_BIOJSON", true));
/*
* Set Editing tab defaults
*/
- autoCalculateConsCheck.setSelected(Cache.getDefault(
- "AUTO_CALC_CONSENSUS", true));
+ autoCalculateConsCheck
+ .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true));
padGaps.setSelected(Cache.getDefault("PAD_GAPS", false));
sortByTree.setSelected(Cache.getDefault("SORT_BY_TREE", false));
Cache.applicationProperties.setProperty("SHOW_IDENTITY",
Boolean.toString(identity.isSelected()));
- Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB
- .getSelectedItem().toString());
+ Cache.applicationProperties.setProperty("GAP_SYMBOL",
+ gapSymbolCB.getSelectedItem().toString());
- Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB
- .getSelectedItem().toString());
- Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB
- .getSelectedItem().toString());
- Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB
- .getSelectedItem().toString());
+ Cache.applicationProperties.setProperty("FONT_NAME",
+ fontNameCB.getSelectedItem().toString());
+ Cache.applicationProperties.setProperty("FONT_STYLE",
+ fontStyleCB.getSelectedItem().toString());
+ Cache.applicationProperties.setProperty("FONT_SIZE",
+ fontSizeCB.getSelectedItem().toString());
Cache.applicationProperties.setProperty("ID_ITALICS",
Boolean.toString(idItalics.isSelected()));
Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE",
Boolean.toString(startupCheckbox.isSelected()));
- Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
- .getSelectedItem().toString());
+ Cache.applicationProperties.setProperty("SORT_ALIGNMENT",
+ sortby.getSelectedItem().toString());
// convert description of sort order to enum name for save
SequenceAnnotationOrder annSortOrder = SequenceAnnotationOrder
}
final boolean showAutocalcFirst = sortAutocalc.getSelectedIndex() == 0;
- Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE, Boolean
- .valueOf(showAutocalcFirst).toString());
+ Cache.applicationProperties.setProperty(SHOW_AUTOCALC_ABOVE,
+ Boolean.valueOf(showAutocalcFirst).toString());
/*
* Save Colours settings
*/
- Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
- .getSelectedItem().toString());
- Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
- .getSelectedItem().toString());
+ Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT,
+ protColour.getSelectedItem().toString());
+ Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC,
+ nucColour.getSelectedItem().toString());
Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
minColour.getBackground());
Cache.setColourProperty("ANNOTATIONCOLOUR_MAX",
{
frame.updateHMMERStatus(hmmerStatus);
}
- if (hmmerStatus)
- {
- String ver = getHMMERVersion();
- Cache.setProperty("HMMER_VERSION", ver);
- }
trimTermini.setSelected(Cache.getDefault("TRIM_TERMINI", false));
Boolean.toString(useRnaView.isSelected()));
Cache.applicationProperties.setProperty(STRUCT_FROM_PDB,
Boolean.toString(structFromPdb.isSelected()));
- Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
- .getSelectedItem().toString());
+ Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY,
+ structViewer.getSelectedItem().toString());
Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
Cache.applicationProperties.setProperty("MAP_WITH_SIFTS",
Boolean.toString(siftsMapping.isSelected()));
public void startupFileTextfield_mouseClicked()
{
String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
- JalviewFileChooser chooser = JalviewFileChooser.forRead(
- Cache.getProperty("LAST_DIRECTORY"), fileFormat);
+ JalviewFileChooser chooser = JalviewFileChooser
+ .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat);
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle(MessageManager
- .getString("label.select_startup_file"));
+ chooser.setDialogTitle(
+ MessageManager.getString("label.select_startup_file"));
int value = chooser.showOpenDialog(this);
Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
format.getName());
}
- startupFileTextfield.setText(chooser.getSelectedFile()
- .getAbsolutePath());
+ startupFileTextfield
+ .setText(chooser.getSelectedFile().getAbsolutePath());
}
}
{
if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
MessageManager.getString("label.new_sequence_url_link"),
- JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
+ JvOptionPane.OK_CANCEL_OPTION, -1,
+ null) == JvOptionPane.OK_OPTION)
{
if (link.checkValid())
{
if (((UrlLinkTableModel) linkUrlTable.getModel())
.isUniqueName(link.getName()))
{
- ((UrlLinkTableModel) linkUrlTable.getModel()).insertRow(
- link.getName(), link.getURL());
+ ((UrlLinkTableModel) linkUrlTable.getModel())
+ .insertRow(link.getName(), link.getURL());
valid = true;
}
else
{
if (JvOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
MessageManager.getString("label.edit_sequence_url_link"),
- JvOptionPane.OK_CANCEL_OPTION, -1, null) == JvOptionPane.OK_OPTION)
+ JvOptionPane.OK_CANCEL_OPTION, -1,
+ null) == JvOptionPane.OK_OPTION)
{
if (link.checkValid())
{
((UrlLinkTableModel) linkUrlTable.getModel()).removeRow(modelIndex);
}
-
@Override
public void defaultBrowser_mouseClicked(MouseEvent e)
{
JFileChooser chooser = new JFileChooser(".");
- chooser.setDialogTitle(MessageManager
- .getString("label.select_default_browser"));
+ chooser.setDialogTitle(
+ MessageManager.getString("label.select_default_browser"));
int value = chooser.showOpenDialog(this);
}
} catch (NumberFormatException x)
{
- JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
- .getString("warn.user_defined_width_requirements"),
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager
+ .getString("warn.user_defined_width_requirements"),
MessageManager.getString("label.invalid_id_column_width"),
JvOptionPane.WARNING_MESSAGE);
userIdWidth.setText("");
{
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)
}
return false;
}
-
- File hmmbuild = new File(path + "/binaries/hmmbuild.exe");
- {
- if (!hmmbuild.canExecute())
+ AlignmentI alignment = new Alignment(
+ new SequenceI[]
+ { new Sequence("test", "WLWL", 0, 3) });
+ if (canExecute(folder + "/hmmbuild"))
{
- message += MessageManager.getString("label.hmmbuild_not_found")
- + "\n";
- missing++;
+ validateHMMBuild(alignment);
}
+ else
+ {
+ message += MessageManager.getString("label.hmmbuild_not_found")
+ + "\n";
+ missing++;
}
- File hmmalign = new File(path + "/binaries/hmmalign.exe");
- {
- if (!hmmalign.canExecute())
+
+ if (canExecute(folder + "/hmmalign"))
{
- message += MessageManager.getString("label.hmmalign_not_found")
- + "\n";
- missing++;
+
}
+ else
+ {
+ message += MessageManager.getString("label.hmmalign_not_found")
+ + "\n";
+ missing++;
}
- File hmmsearch = new File(path + "/binaries/hmmsearch.exe");
- {
- if (!hmmsearch.canExecute())
+
+ if (canExecute(folder + "/hmmsearch"))
{
- message += MessageManager.getString("label.hmmsearch_not_found")
- + "\n";
- missing++;
+
}
+ else
+ {
+ message += MessageManager.getString("label.hmmsearch_not_found")
+ + "\n";
+ missing++;
+ }
}
if (missing > 0)
}
}
+ 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;
}
- private String getHMMERVersion()
+ /**
+ * Runs hmmbuild to check if it is working. While doing this it parses the
+ * version of HMMER.
+ *
+ * @param frame
+ * @return
+ */
+ public boolean validateHMMBuild(AlignmentI alignment)
{
- File file = new File(hmmerPath.getText() + "/release-notes.txt");
- Scanner scanner = null;
- try
+ HMMBuildThread hmmbuild = new HMMBuildThread(alignment);
+ hmmbuild.hmmbuildWaitTillComplete();
+ SequenceI hmmSeq = alignment.getSequenceAt(0);
+ HiddenMarkovModel hmm;
+ if (hmmSeq.isHMMConsensusSequence() && hmmSeq.getHMM() != null)
+ {
+ hmm = hmmSeq.getHMM();
+
+ if (hmm.getNumberOfSymbols() < 1)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+
+ String header = hmm.getFileHeader();
+ if (header == null)
{
- scanner = new Scanner(file);
- } catch (IOException e)
+ return false;
+ }
+ else
{
- e.printStackTrace();
- return null;
+ Scanner scanner = new Scanner(header);
+ scanner.next();
+ String string = scanner.next();
+ String version = string.substring(1);
+ Cache.setProperty("HMMER_VERSION", version);
+ scanner.close();
+
}
- scanner.next();
- String res = scanner.next();
- scanner.close();
- return res;
+ return true;
}
+
private boolean validateHMMERPath()
{
return validateHMMERPath(true);
if (!found)
{
String[] options = { "OK", "Help" };
- int showHelp = JvOptionPane.showInternalOptionDialog(
- Desktop.desktop,
+ int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
JvSwingUtils.wrapTooltip(true,
MessageManager.getString("label.chimera_missing")),
"", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
return name.hashCode() + code.hashCode();
}
}
-
+
private class UrlListSelectionHandler implements ListSelectionListener
{
editLink.setEnabled(false);
}
}
-}
+ }
}