From 5e22c6b15dc429055036c19fcfc48c16d37d7ad0 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 17 Apr 2018 18:38:54 +0100 Subject: [PATCH] JAL-2629 choice of hmm profile now a parameter not a selection, apis simplified --- resources/lang/Messages.properties | 21 +--- resources/lang/Messages_es.properties | 1 - src/jalview/datamodel/Alignment.java | 29 ++--- src/jalview/datamodel/SequenceCollectionI.java | 10 +- src/jalview/datamodel/SequenceGroup.java | 32 +++-- src/jalview/gui/AlignFrame.java | 95 +++++--------- src/jalview/gui/OptsAndParamsPage.java | 130 ++++++++++---------- src/jalview/gui/PopupMenu.java | 24 ---- src/jalview/hmmer/HMMAlign.java | 19 +-- src/jalview/hmmer/HMMBuild.java | 13 +- src/jalview/hmmer/HMMERParamStore.java | 60 +++++++-- src/jalview/hmmer/HMMSearch.java | 41 +++--- src/jalview/hmmer/HmmerCommand.java | 29 ++++- src/jalview/io/FileLoader.java | 1 - src/jalview/jbgui/GPreferences.java | 4 +- src/jalview/schemes/HmmerColourScheme.java | 15 +-- src/jalview/schemes/HmmerGlobalBackground.java | 9 +- src/jalview/schemes/HmmerLocalBackground.java | 15 ++- src/jalview/workers/InformationThread.java | 29 +++-- .../ws/params/simple/LogarithmicParameter.java | 49 ++++---- test/jalview/hmmer/HMMERTest.java | 18 +-- .../jalview/schemes/HmmerGlobalBackgroundTest.java | 1 - test/jalview/schemes/HmmerLocalBackgroundTest.java | 1 - utils/i18nAnt.xml | 2 +- 24 files changed, 318 insertions(+), 330 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index b3afc6a..4fe5ada 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -885,7 +885,6 @@ label.error_unsupported_owwner_user_colour_scheme = Unsupported owner for User C label.save_alignment_to_file = Save Alignment to file label.save_features_to_file = Save Features to File label.save_annotation_to_file = Save Annotation to File -label.no_features_on_alignment = No features found on alignment label.save_pdb_file = Save PDB File label.save_text_to_file = Save Text to File label.save_state = Save State @@ -1373,21 +1372,16 @@ label.most_polymer_residues = Most Polymer Residues label.cached_structures = Cached Structures label.free_text_search = Free Text Search label.hmmalign = hmmalign +label.use_hmm = HMM profile to use label.hmmbuild = hmmbuild -label.hmmbuild_group = Build HMM from Selected Group -label.group_hmmbuild = Build HMM from Group label.hmmsearch = hmmsearch label.installation = Installation label.hmmer_location = HMMER Binaries Installation Location label.cygwin_location = Cygwin Binaries Installation Location (Windows) label.information_annotation = Information Annotation -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.select_hmm = Select HMM -warn.no_sequence_data = No sequence data found. -warn.empty_grp_or_alignment = An empty group or alignment was found. +warn.no_hmm = No Hidden Markov model found.\nRun hmmbuild or load an HMM file first. label.no_sequences_found = No matching sequences, or an error occurred. label.hmmer = HMMER label.trim_termini = Trim Non-Matching Termini @@ -1395,14 +1389,11 @@ label.trim_termini_desc = If true, non-matching regions on either end of the res 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.hmmalign_options = hmmalign options +label.hmmsearch_options = hmmsearch options label.executable_not_found = The ''{0}'' executable file was not found -warn.hmm_command_failed = hmm command not found +warn.command_failed = {0} failed label.invalid_folder = Invalid Folder -label.folder_not_exists = HMMER binaries not found. \n Please enter the path to the HMMER binaries (if installed). -label.hmmer_installed = HMMER installed -label.hmmer_no_sequences_found = No sequences found label.number_of_results = Number of Results to Return label.auto_align_seqs = Automatically Align Fetched Sequences label.use_accessions = Return Accessions @@ -1417,10 +1408,8 @@ label.seq_e_value_desc = The E-value cutoff for returned sequences (hmmsearch -E label.seq_score_desc = The score threshold for returned sequences label.dom_e_value_desc = The E-value cutoff for returned domains (hmmsearch -domE) label.dom_score_desc = The score threshold for returned domains -label.not_enough_sequences = There are not enough sequences to run {0} label.add_database = Add Database label.this_alignment = This alignment -warn.file_not_exists = File does not exist warn.invalid_format = This is not a valid database file format. The current supported formats are Fasta, Stockholm and Pfam. label.database_for_hmmsearch = The database hmmsearch will search through label.use_reference = Use Reference Annotation diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index ee7e4fe..6dfefa3 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -808,7 +808,6 @@ label.error_unsupported_owwner_user_colour_scheme = Propietario no soportado par label.save_alignment_to_file = Guardar Alineamiento en fichero label.save_features_to_file = Guardar Características en un fichero label.save_annotation_to_file = Guardar Anotación en un fichero -label.no_features_on_alignment = No se han encontrado características en el alineamiento label.save_pdb_file = Guardar fichero PDB label.save_text_to_file = Guardar Texto en un fichero label.save_state = Guardar estado diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 6b100ea..e3b4c64 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -53,8 +53,6 @@ public class Alignment implements AlignmentI private List sequences; - private SequenceI hmmConsensus; - protected List groups; protected char gapCharacter = '-'; @@ -1956,18 +1954,6 @@ public class Alignment implements AlignmentI } @Override - public SequenceI getHmmConsensus() - { - return hmmConsensus; - } - - @Override - public void setHmmConsensus(SequenceI hmmConsensus) - { - this.hmmConsensus = hmmConsensus; - } - - @Override public void setupJPredAlignment() { SequenceI repseq = getSequenceAt(0); @@ -2078,4 +2064,19 @@ public class Alignment implements AlignmentI } } } + + @Override + public List getHmmSequences() + { + List result = new ArrayList<>(); + for (int i = 0; i < sequences.size(); i++) + { + SequenceI seq = sequences.get(i); + if (seq.hasHMMProfile()) + { + result.add(seq); + } + } + return result; + } } diff --git a/src/jalview/datamodel/SequenceCollectionI.java b/src/jalview/datamodel/SequenceCollectionI.java index ee4b844..a280079 100644 --- a/src/jalview/datamodel/SequenceCollectionI.java +++ b/src/jalview/datamodel/SequenceCollectionI.java @@ -72,14 +72,10 @@ public interface SequenceCollectionI boolean isNucleotide(); /** - * Returns the HMM consensus sequence (if any) for the collection, or null + * Returns the (possibly empty) list of HMM consensus sequences in the + * collection * * @return */ - SequenceI getHmmConsensus(); - - /** - * Sets the HMM consensus sequence for the collection - */ - void setHmmConsensus(SequenceI hmmSeq); + List getHmmSequences(); } diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 2cf673c..b558f40 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -88,11 +88,6 @@ public class SequenceGroup implements AnnotatedCollectionI */ private SequenceI seqrep; - /* - * HMM consensus sequence for group (if any) - */ - private SequenceI hmmConsensus; - private int width = -1; /* @@ -1599,18 +1594,6 @@ public class SequenceGroup implements AnnotatedCollectionI hmmNormaliseSequenceLogo = state; } - @Override - public SequenceI getHmmConsensus() - { - return hmmConsensus; - } - - @Override - public void setHmmConsensus(SequenceI hmmSeq) - { - this.hmmConsensus = hmmSeq; - } - public ProfilesI getConsensusData() { return consensusProfiles; @@ -1626,4 +1609,19 @@ public class SequenceGroup implements AnnotatedCollectionI this.hmmProfiles = hmmProfiles; } + @Override + public List getHmmSequences() + { + List result = new ArrayList<>(); + for (int i = 0; i < sequences.size(); i++) + { + SequenceI seq = sequences.get(i); + if (seq.hasHMMProfile()) + { + result.add(seq); + } + } + return result; + } + } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index a317106..bcb8423 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -54,7 +54,6 @@ import jalview.datamodel.AlignmentOrder; import jalview.datamodel.AlignmentView; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; -import jalview.datamodel.HiddenMarkovModel; import jalview.datamodel.HiddenSequences; import jalview.datamodel.PDBEntry; import jalview.datamodel.SeqCigar; @@ -106,7 +105,6 @@ import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.params.ArgumentI; import jalview.ws.params.ParamDatastoreI; import jalview.ws.params.WsParamSetI; -import jalview.ws.params.simple.Option; import jalview.ws.seqfetcher.DbSourceProxy; import java.awt.BorderLayout; @@ -185,10 +183,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignViewport viewport; public AlignViewControllerI avc; - /* - * The selected HMM for this align frame - */ - SequenceI selectedHMMSequence; List alignPanels = new ArrayList<>(); @@ -1030,19 +1024,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { return; } - List args = new ArrayList<>(); - if (withDefaults) - { - // todo: construct this in HMMERPreset? - String argName = MessageManager.getString("label.hmmbuild_for"); - String argValue = MessageManager.getString("label.alignment"); - args.add( - new Option(argName, null, false, null, argValue, null, null)); - } - else + + /* + * get default parameters, and optionally show a dialog + * to allow them to be modified + */ + ParamDatastoreI store = HMMERParamStore.forBuild(viewport); + List args = store.getServiceParameters(); + + if (!withDefaults) { WsParamSetI set = new HMMERPreset(); - ParamDatastoreI store = HMMERParamStore.forBuild(viewport); WsJobParameters params = new WsJobParameters(store, set, args); if (params.showRunDialog()) { @@ -1063,11 +1055,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { return; } - List args = new ArrayList<>(); + + /* + * get default parameters, and optionally show a dialog + * to allow them to be modified + */ + ParamDatastoreI store = HMMERParamStore.forAlign(viewport); + List args = store.getServiceParameters(); + if (!withDefaults) { WsParamSetI set = new HMMERPreset(); - ParamDatastoreI store = HMMERParamStore.forAlign(viewport); WsJobParameters params = new WsJobParameters(store, set, args); if (params.showRunDialog()) { @@ -1088,11 +1086,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { return; } - List args = new ArrayList<>(); + + /* + * get default parameters, and (if requested) show + * dialog to allow modification + */ + ParamDatastoreI store = HMMERParamStore.forSearch(viewport); + List args = store.getServiceParameters(); + if (!withDefaults) { WsParamSetI set = new HMMERPreset(); - ParamDatastoreI store = HMMERParamStore.forSearch(viewport); WsJobParameters params = new WsJobParameters(store, set, args); if (params.showRunDialog()) { @@ -1108,16 +1112,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * Checks if the frame has a selected hidden Markov model + * Checks if the alignment has at least one hidden Markov model, if not shows + * a dialog advising to run hmmbuild or load an HMM profile * * @return */ private boolean checkForHMM() { - if (getSelectedHMM() == null) + if (viewport.getAlignment().getHmmSequences().isEmpty()) { JOptionPane.showMessageDialog(this, - MessageManager.getString("warn.no_selected_hmm")); + MessageManager.getString("warn.no_hmm")); return false; } return true; @@ -1134,7 +1139,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (getViewport().getAlignment().getSequences().size() < required) { JOptionPane.showMessageDialog(this, - MessageManager.getString("warn.not_enough_sequences")); + MessageManager.getString("label.not_enough_sequences")); return false; } return true; @@ -1181,7 +1186,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, else { JOptionPane.showMessageDialog(this, - MessageManager.getString("warn.not_enough_sequences")); + MessageManager.getString("label.not_enough_sequences")); } } @@ -5807,44 +5812,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, hmmerMenu.setEnabled(HmmerCommand.isHmmerAvailable()); } - /** - * Returns the selected hidden Markov model. - * - * @return - */ - public HiddenMarkovModel getSelectedHMM() - { - if (selectedHMMSequence == null) - { - return null; - } - return selectedHMMSequence.getHMM(); - } - - /** - * Returns the selected hidden Markov model. - * - * @return - */ - public SequenceI getSelectedHMMSequence() - { - return selectedHMMSequence; - } - - /** - * Sets the selected hidden Markov model - * - * @param selectedHMM - */ - public void setSelectedHMMSequence(SequenceI selectedHMM) - { - this.selectedHMMSequence = selectedHMM; - hmmAlign.setText(MessageManager.getString("label.hmmalign") + " to " - + selectedHMM.getHMM().getName()); - hmmSearch.setText(MessageManager.getString("label.hmmsearch") + " with " - + selectedHMM.getHMM().getName()); - } - @Override public void hmmerMenu_actionPerformed(ActionEvent e) { diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index 482f122..3e09a35 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -20,13 +20,14 @@ */ package jalview.gui; +import static jalview.ws.params.simple.LogarithmicParameter.LOGSLIDERSCALE; + import jalview.util.MessageManager; import jalview.ws.params.ArgumentI; import jalview.ws.params.OptionI; import jalview.ws.params.ParameterI; import jalview.ws.params.ValueConstrainI; import jalview.ws.params.ValueConstrainI.ValueType; -import jalview.ws.params.simple.BooleanOption; import jalview.ws.params.simple.LogarithmicParameter; import java.awt.BorderLayout; @@ -37,12 +38,13 @@ import java.awt.GridLayout; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.net.URL; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -73,11 +75,29 @@ import net.miginfocom.swing.MigLayout; */ public class OptsAndParamsPage { - /** + public static final int PARAM_WIDTH = 340; + + public static final int PARAM_HEIGHT = 150; + + public static final int PARAM_CLOSEDHEIGHT = 80; + + URL linkImageURL = getClass().getResource("/images/link.gif"); + + Map optSet = new LinkedHashMap<>(); + + Map paramSet = new LinkedHashMap<>(); + + /* * compact or verbose style parameters */ boolean compact = false; + OptsParametersContainerI poparent; + + /** + * A class that models a panel rendering a single option (checkbox or choice + * list) + */ public class OptionBox extends JPanel implements MouseListener, ActionListener { @@ -95,13 +115,14 @@ public class OptsAndParamsPage JLabel optlabel = new JLabel(); - JComboBox val = new JComboBox(); + JComboBox val = new JComboBox<>(); public OptionBox(OptionI opt) { option = opt; setLayout(new BorderLayout()); enabled.setSelected(opt.isRequired()); // TODO: lock required options + // enabled.setEnabled(!opt.isRequired()); enabled.setFont(new Font("Verdana", Font.PLAIN, 11)); enabled.setText(""); enabled.setText(opt.getName()); @@ -129,7 +150,7 @@ public class OptsAndParamsPage } } add(enabled, BorderLayout.NORTH); - for (Object str : opt.getPossibleValues()) + for (String str : opt.getPossibleValues()) { val.addItem(str); } @@ -272,9 +293,13 @@ public class OptsAndParamsPage } + /** + * A class that models a panel rendering a single parameter + */ public class ParamBox extends JPanel implements ChangeListener, ActionListener, MouseListener { + private static final float SLIDERSCALE = 1000f; boolean isLogarithmic; @@ -282,7 +307,7 @@ public class OptsAndParamsPage boolean choice = false; - JComboBox choicebox; + JComboBox choicebox; JPanel controlPanel = new JPanel(); @@ -582,15 +607,16 @@ public class OptsAndParamsPage { if (!isLogarithmic) { - valueField.setText("" + ((integ) ? ("" + slider.getValue()) - : ("" + slider.getValue() / 1000f))); + /* + * set (int or float formatted) text field value + */ + valueField.setText(integ ? String.valueOf(slider.getValue()) + : String.valueOf(slider.getValue() / SLIDERSCALE)); } else { - Double base = ((LogarithmicParameter) parameter).getBase(); - Double value = Math.pow( - base, - slider.getValue() / 1000000f); + double base = ((LogarithmicParameter) parameter).getBase(); + double value = Math.pow(base, slider.getValue() / LOGSLIDERSCALE); valueField.setText(formatDouble(value)); } checkIfModified(); @@ -598,14 +624,17 @@ public class OptsAndParamsPage } - public String formatDouble(Double value) + /** + * Answers the value formatted as a string to 3 decimal places - in + * scientific notation if the value is less than 0.001 + * + * @param value + * @return + */ + public String formatDouble(double value) { - String string = String.format("%3.3f", value); - if (value < 0.001) - { - string = String.format("%3.3e", value); - } - return string; + String format = value < 0.001 ? "%3.3e" : "%3.3f"; + return String.format(format, value); } public void updateControls(ParameterI parm) @@ -616,7 +645,7 @@ public class OptsAndParamsPage { if (choice) { - choicebox = new JComboBox(); + choicebox = new JComboBox<>(); choicebox.addActionListener(this); controlPanel.add(choicebox, BorderLayout.CENTER); } @@ -626,14 +655,8 @@ public class OptsAndParamsPage slider.addChangeListener(this); valueField = new JTextField(); valueField.addActionListener(this); - valueField.addKeyListener(new KeyListener() + valueField.addKeyListener(new KeyAdapter() { - - @Override - public void keyTyped(KeyEvent e) - { - } - @Override public void keyReleased(KeyEvent e) { @@ -645,16 +668,10 @@ public class OptsAndParamsPage } } } - - @Override - public void keyPressed(KeyEvent e) - { - } }); - valueField.setPreferredSize(new Dimension(60, 25)); + valueField.setPreferredSize(new Dimension(80, 25)); controlPanel.add(slider, BorderLayout.WEST); controlPanel.add(valueField, BorderLayout.EAST); - } } @@ -664,8 +681,7 @@ public class OptsAndParamsPage { if (init) { - List vals = parm.getPossibleValues(); - for (Object val : vals) + for (String val : parm.getPossibleValues()) { choicebox.addItem(val); } @@ -680,9 +696,10 @@ public class OptsAndParamsPage { if (parm instanceof LogarithmicParameter) { - Double base = ((LogarithmicParameter) parm).getBase(); - Double value = Math.pow(base, - Double.parseDouble(parm.getValue()) / 1000000); + double base = ((LogarithmicParameter) parm).getBase(); + // double value = Math.pow(base, + // Double.parseDouble(parm.getValue()) / LOGSLIDERSCALE); + double value = Double.parseDouble(parm.getValue()); valueField.setText(formatDouble(value)); } else @@ -725,8 +742,8 @@ public class OptsAndParamsPage } } catch (Exception e) { + System.err.println(e.getMessage()); } - ; // update value field to reflect any bound checking we performed. valueField.setText("" + iVal); if (validator.getMin() != null && validator.getMax() != null) @@ -743,16 +760,15 @@ public class OptsAndParamsPage } else if (isLogarithmic) { - double eValue; dVal = 0d; try { valueField.setText(valueField.getText().trim()); - eValue = Double.valueOf(valueField.getText()); + double eValue = Double.valueOf(valueField.getText()); dVal = Math.log(eValue) / Math .log(((LogarithmicParameter) parameter).getBase()) - * 1000000; + * LOGSLIDERSCALE; if (validator.getMin() != null && validator.getMin().doubleValue() > dVal) @@ -761,7 +777,7 @@ public class OptsAndParamsPage // TODO: provide visual indication that hard limit was reached for // this parameter // update value field to reflect any bound checking we performed. - valueField.setText("" + formatDouble(eValue)); + valueField.setText(formatDouble(eValue)); } if (validator.getMax() != null && validator.getMax().doubleValue() < dVal) @@ -770,12 +786,12 @@ public class OptsAndParamsPage // TODO: provide visual indication that hard limit was reached for // this parameter // update value field to reflect any bound checking we performed. - valueField.setText("" + formatDouble(eValue)); + valueField.setText(formatDouble(eValue)); } } catch (Exception e) { } - ; + if (validator.getMin() != null && validator.getMax() != null) { slider.getModel().setRangeProperties((int) (dVal), 1, @@ -817,12 +833,12 @@ public class OptsAndParamsPage } catch (Exception e) { } - ; + if (validator.getMin() != null && validator.getMax() != null) { - slider.getModel().setRangeProperties((int) (fVal * 1000f), 1, - (int) (validator.getMin().floatValue() * 1000f), - 1 + (int) (validator.getMax().floatValue() * 1000f), + slider.getModel().setRangeProperties((int) (fVal * SLIDERSCALE), 1, + (int) (validator.getMin().floatValue() * SLIDERSCALE), + 1 + (int) (validator.getMax().floatValue() * SLIDERSCALE), true); } else @@ -848,12 +864,6 @@ public class OptsAndParamsPage } } - public static final int PARAM_WIDTH = 340; - - public static final int PARAM_HEIGHT = 150; - - public static final int PARAM_CLOSEDHEIGHT = 80; - public OptsAndParamsPage(OptsParametersContainerI paramContainer) { this(paramContainer, false); @@ -888,12 +898,6 @@ public class OptsAndParamsPage mnu.show(invoker, x, y); } - URL linkImageURL = getClass().getResource("/images/link.gif"); - - Map optSet = new java.util.LinkedHashMap<>(); - - Map paramSet = new java.util.LinkedHashMap<>(); - public Map getOptSet() { return optSet; @@ -914,8 +918,6 @@ public class OptsAndParamsPage this.paramSet = paramSet; } - OptsParametersContainerI poparent; - OptionBox addOption(OptionI opt) { OptionBox cb = optSet.get(opt.getName()); diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index e62853d..a3a2422 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -360,21 +360,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener }); add(menuItem); - if (sequence.hasHMMProfile()) - { - JMenuItem selectHMM = new JCheckBoxMenuItem(); - selectHMM.setText(MessageManager.getString("label.select_hmm")); - selectHMM.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - selectHMM_actionPerformed(sequence); - } - }); - add(selectHMM); - } - if (alignPanel.av.getSelectionGroup() != null && alignPanel.av.getSelectionGroup().getSize() > 1) { @@ -1368,15 +1353,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener jMenu1.add(displayNonconserved); } - protected void selectHMM_actionPerformed(SequenceI seq) - { - // TODO move this to Viewport - if (seq.hasHMMProfile()) - { - ap.alignFrame.setSelectedHMMSequence(seq); - } - } - /** * Constructs the entries for the colour menu */ diff --git a/src/jalview/hmmer/HMMAlign.java b/src/jalview/hmmer/HMMAlign.java index 163e85b..492e71c 100644 --- a/src/jalview/hmmer/HMMAlign.java +++ b/src/jalview/hmmer/HMMAlign.java @@ -64,12 +64,7 @@ public class HMMAlign extends HmmerCommand @Override public void run() { - HiddenMarkovModel hmm = af.getSelectedHMM(); - if (hmm == null) - { - System.err.println("Can't run hmmalign as no HMM profile selected"); - return; - } + HiddenMarkovModel hmm = getHmmProfile(); long msgId = System.currentTimeMillis(); af.setProgressBar(MessageManager.getString("status.running_hmmalign"), @@ -97,8 +92,8 @@ public class HMMAlign extends HmmerCommand boolean ran = runCommand(modelFile, alignmentFile, resultFile); if (!ran) { - JvOptionPane.showInternalMessageDialog(af, - MessageManager.getString("warn.hmmalign_failed")); + JvOptionPane.showInternalMessageDialog(af, MessageManager + .formatMessage("warn.command_failed", "hmmalign")); return; } @@ -212,14 +207,6 @@ public class HMMAlign extends HmmerCommand al.setDataset(dataset); } - /* - * hack to ensure hmm set on alignment - */ - if (al.getSequenceAt(0).hasHMMProfile()) - { - al.setHmmConsensus(al.getSequenceAt(0)); - } - displayInNewFrame(al, allOrders, hidden, title); } diff --git a/src/jalview/hmmer/HMMBuild.java b/src/jalview/hmmer/HMMBuild.java index c596cec..d5c17fc 100644 --- a/src/jalview/hmmer/HMMBuild.java +++ b/src/jalview/hmmer/HMMBuild.java @@ -188,6 +188,8 @@ public class HMMBuild extends HmmerCommand boolean ran = runCommand(alignmentFile, hmmFile, ac); if (!ran) { + JvOptionPane.showInternalMessageDialog(af, MessageManager + .formatMessage("warn.command_failed", "hmmbuild")); return; } importData(hmmFile, ac); @@ -215,8 +217,8 @@ public class HMMBuild extends HmmerCommand */ void deleteHmmSequences(AnnotatedCollectionI ac) { - SequenceI hmmSeq = ac.getHmmConsensus(); - if (hmmSeq != null) + List hmmSeqs = ac.getHmmSequences(); + for (SequenceI hmmSeq : hmmSeqs) { if (ac instanceof SequenceGroup) { @@ -359,17 +361,10 @@ public class HMMBuild extends HmmerCommand alignment.insertSequenceAt(topIndex, hmmSeq); ac.setSeqrep(hmmSeq); grp.addSequence(hmmSeq, false); - grp.setHmmConsensus(hmmSeq); } else { alignment.insertSequenceAt(0, hmmSeq); - alignment.setHmmConsensus(hmmSeq); - } - - if (af.getSelectedHMM() == null) - { - af.setSelectedHMMSequence(hmmSeq); } } } diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java index d12475a..9c52f97 100644 --- a/src/jalview/hmmer/HMMERParamStore.java +++ b/src/jalview/hmmer/HMMERParamStore.java @@ -1,6 +1,7 @@ package jalview.hmmer; import jalview.bin.Cache; +import jalview.datamodel.SequenceI; import jalview.gui.Preferences; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; @@ -95,6 +96,8 @@ public final class HMMERParamStore implements ParamDatastoreI */ private void getHMMSearchParams(List args) { + addChoiceOfHmm(args); + args.add(new IntegerParameter( MessageManager.getString("label.number_of_results"), MessageManager.getString("label.number_of_results_desc"), true, @@ -102,7 +105,7 @@ public final class HMMERParamStore implements ParamDatastoreI String names = Cache.getProperty(Preferences.HMMSEARCH_DBS); if (names != null && !names.isEmpty()) { - Collection databases = new ArrayList<>(); + List databases = new ArrayList<>(); databases.add(MessageManager.getString("label.this_alignment")); Scanner nameScanner = new Scanner(names); @@ -143,8 +146,8 @@ public final class HMMERParamStore implements ParamDatastoreI false, true, null)); args.add(new LogarithmicParameter( MessageManager.getString("label.seq_e_value"), - MessageManager.getString("label.seq_e_value_desc"), false, -3d, - -37.92977945, 1d, 10d)); + MessageManager.getString("label.seq_e_value_desc"), false, 1D, + 1E-38, 10D, 10D)); /* args.add(new DoubleParameter( MessageManager.getString("label.seq_score"), @@ -153,8 +156,10 @@ public final class HMMERParamStore implements ParamDatastoreI */ args.add(new LogarithmicParameter( MessageManager.getString("label.dom_e_value"), - MessageManager.getString("label.dom_e_value_desc"), false, -3d, - -37.92977945, 1d, 10d)); + // MessageManager.getString("label.dom_e_value_desc"), false, -3d, + // -37.92977945, 1d, 10d)); + MessageManager.getString("label.dom_e_value_desc"), false, 1D, + 1E-38, 10D, 10D)); /* args.add(new DoubleParameter( MessageManager.getString("label.dom_score"), @@ -172,6 +177,8 @@ public final class HMMERParamStore implements ParamDatastoreI */ private void getHMMAlignParams(List args) { + addChoiceOfHmm(args); + boolean def = Cache.getDefault(Preferences.HMMALIGN_TRIM_TERMINI, false); args.add(new BooleanOption( @@ -181,6 +188,29 @@ public final class HMMERParamStore implements ParamDatastoreI } /** + * Adds an argument representing the choice of HMM sequences (profiles) + * against which to perform align or search, provided more than one is found + * + * @param args + */ + protected void addChoiceOfHmm(List args) + { + List hmms = viewport.getAlignment().getHmmSequences(); + if (!hmms.isEmpty()) + { + List options = new ArrayList<>(); + for (SequenceI hmmSeq : hmms) + { + options.add(hmmSeq.getName()); + } + String defseq = options.get(0); + Option option = new Option(MessageManager.getString("label.use_hmm"), + "", true, defseq, defseq, options, null); + args.add(option); + } + } + + /** * Answers default parameters for hmmbuild, taking into account any configured * as user preferences * @@ -188,9 +218,19 @@ public final class HMMERParamStore implements ParamDatastoreI */ private void getHMMBuildParams(List args) { - args.add(new StringParameter(MessageManager.getString("label.hmm_name"), - MessageManager.getString("label.hmm_name_desc"), true, "")); - // todo only enable Use Reference Annotation if RF is present + /* + * name to give the computed alignment HMM consensus sequence + * (Jalview constructs group HMM consensus sequence names) + */ + String defValue = "Alignment_HMM"; + StringParameter nameParam = new StringParameter(MessageManager.getString("label.hmm_name"), + MessageManager.getString("label.hmm_name_desc"), true, defValue, + defValue); + args.add(nameParam); + + /* + * only enable Use Reference Annotation if RF is present + */ if (viewport.hasReferenceAnnotation()) { args.add(new BooleanOption( @@ -199,12 +239,14 @@ public final class HMMERParamStore implements ParamDatastoreI true, true, null)); } + /* + * choice of whether to compute HMM for alignment and/or group(s) + */ Collection options = new ArrayList<>(); options.add(MessageManager.getString("label.alignment")); options.add(MessageManager.getString("label.groups_and_alignment")); options.add(MessageManager.getString("label.groups")); options.add(MessageManager.getString("label.selected_group")); - args.add(new Option(MessageManager.getString("label.hmmbuild_for"), MessageManager.getString("label.hmmbuild_for_desc"), true, MessageManager.getString("label.alignment"), diff --git a/src/jalview/hmmer/HMMSearch.java b/src/jalview/hmmer/HMMSearch.java index 6f73f2f..7738cb5 100644 --- a/src/jalview/hmmer/HMMSearch.java +++ b/src/jalview/hmmer/HMMSearch.java @@ -1,5 +1,6 @@ package jalview.hmmer; +import jalview.bin.Cache; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -15,12 +16,14 @@ import jalview.util.FileUtils; import jalview.util.MessageManager; import jalview.ws.params.ArgumentI; import jalview.ws.params.simple.BooleanOption; +import jalview.ws.params.simple.Option; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Scanner; @@ -28,6 +31,8 @@ import javax.swing.JOptionPane; public class HMMSearch extends HmmerCommand { + private static final String PARAMNAME_NO_OF_RESULTS = MessageManager.getString("label.number_of_results"); + static final String HMMSEARCH = "hmmsearch"; boolean realign = false; @@ -57,15 +62,15 @@ public class HMMSearch extends HmmerCommand @Override public void run() { - HiddenMarkovModel hmm = af.getSelectedHMM(); + HiddenMarkovModel hmm = getHmmProfile(); if (hmm == null) { - JOptionPane.showMessageDialog(af, - MessageManager.getString("warn.no_selected_hmm")); + // shouldn't happen if we got this far + Cache.log.error("Error: no hmm for hmmsearch"); return; } - SequenceI hmmSeq = af.getSelectedHMMSequence(); + SequenceI hmmSeq = hmm.getConsensusSequence();// af.getSelectedHMMSequence(); long msgId = System.currentTimeMillis(); af.setProgressBar(MessageManager.getString("status.running_hmmsearch"), msgId); @@ -83,8 +88,8 @@ public class HMMSearch extends HmmerCommand boolean ran = runCommand(searchOutputFile, hitsAlignmentFile, hmmFile); if (!ran) { - JvOptionPane.showInternalMessageDialog(af, - MessageManager.getString("warn.hmmsearch_failed")); + JvOptionPane.showInternalMessageDialog(af, MessageManager + .formatMessage("warn.command_failed", "hmmsearch")); return; } @@ -197,15 +202,16 @@ public class HMMSearch extends HmmerCommand { /* * no external database specified for search, so - * export current alignment as 'database' to search + * export current alignment as 'database' to search, + * excluding any HMM consensus sequences it contains */ databaseFile = FileUtils.createTempFile("database", ".sto"); AlignmentI al = af.getViewport().getAlignment(); AlignmentI copy = new Alignment(al); - SequenceI hmms = copy.getHmmConsensus(); - if (hmms != null) + List hmms = copy.getHmmSequences(); + for (SequenceI hmmSeq : hmms) { - copy.deleteSequence(hmms); + copy.deleteSequence(hmmSeq); } exportStockholm(copy.getSequencesArray(), databaseFile, null); // StockholmFile stoFile = new StockholmFile(copy); @@ -253,10 +259,17 @@ public class HMMSearch extends HmmerCommand hmmAndSeqs[0] = hmmSeq; System.arraycopy(seqs, 0, hmmAndSeqs, 1, seqCount); - AlignmentI alignment = new Alignment(hmmAndSeqs); - AlignFrame frame = new AlignFrame(alignment, 1, 1); - frame.setSelectedHMMSequence(hmmSeq); + /* + * and align the search results to the HMM profile + */ + AlignmentI al = new Alignment(hmmAndSeqs); + AlignFrame frame = new AlignFrame(al, 1, 1); List alignArgs = new ArrayList<>(); + String defSeq = hmmSeq.getName(); + List options = Collections.singletonList(defSeq); + Option option = new Option(MessageManager.getString("label.use_hmm"), + "", true, defSeq, defSeq, options, null); + alignArgs.add(option); if (trim) { alignArgs.add(new BooleanOption( @@ -264,7 +277,7 @@ public class HMMSearch extends HmmerCommand MessageManager.getString("label.trim_termini_desc"), true, true, true, null)); } - HMMAlign hmmalign = new HMMAlign(frame, alignArgs); + HmmerCommand hmmalign = new HMMAlign(frame, alignArgs); hmmalign.run(); frame = null; hmmTemp.delete(); diff --git a/src/jalview/hmmer/HmmerCommand.java b/src/jalview/hmmer/HmmerCommand.java index 9bec181..8888c20 100644 --- a/src/jalview/hmmer/HmmerCommand.java +++ b/src/jalview/hmmer/HmmerCommand.java @@ -254,8 +254,8 @@ public abstract class HmmerCommand implements Runnable File file = FileUtils.getExecutable(cmd, binariesFolder); if (file == null && af != null) { - JvOptionPane.showInternalMessageDialog(af, - MessageManager.getString("warn.hmm_command_failed")); + JvOptionPane.showInternalMessageDialog(af, MessageManager + .formatMessage("label.executable_not_found", cmd)); } return file == null ? null : file.getAbsolutePath(); @@ -279,4 +279,29 @@ public abstract class HmmerCommand implements Runnable writer.close(); } } + + /** + * Answers the HMM profile for the profile sequence the user selected (default + * is just the first HMM sequence in the alignment) + * + * @return + */ + protected HiddenMarkovModel getHmmProfile() + { + String alignToParamName = MessageManager.getString("label.use_hmm"); + for (ArgumentI arg : params) + { + String name = arg.getName(); + if (name.equals(alignToParamName)) + { + String seqName = arg.getValue(); + SequenceI hmmSeq = alignment.findName(seqName); + if (hmmSeq.hasHMMProfile()) + { + return hmmSeq.getHMM(); + } + } + } + return null; + } } diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 720abc9..798875f 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -432,7 +432,6 @@ public class FileLoader implements Runnable */ alignment.deleteSequence(alignment.getAbsoluteHeight() - 1); alignment.insertSequenceAt(0, seq); - alignment.setHmmConsensus(seq); } viewport.getAlignPanel().adjustAnnotationHeight(); viewport.updateSequenceIdColours(); diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index d74cf73..7b2dff5 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -500,7 +500,7 @@ public class GPreferences extends JPanel JPanel alignOptionsPanel = new JPanel(new MigLayout()); // new FlowLayout(FlowLayout.LEFT)); JvSwingUtils.createTitledBorder(alignOptionsPanel, - MessageManager.getString("label.hmmalign_label"), true); + MessageManager.getString("label.hmmalign_options"), true); hmmerTab.add(alignOptionsPanel); hmmrTrimTermini = new JCheckBox(); hmmrTrimTermini.setFont(LABEL_FONT); @@ -513,7 +513,7 @@ public class GPreferences extends JPanel JPanel searchOptions = new JPanel(new MigLayout()); // FlowLayout(FlowLayout.LEFT)); JvSwingUtils.createTitledBorder(searchOptions, - MessageManager.getString("label.hmmsearch_label"), true); + MessageManager.getString("label.hmmsearch_options"), true); hmmerTab.add(searchOptions); JLabel sequencesToKeep = new JLabel( MessageManager.getString("label.no_of_sequences")); diff --git a/src/jalview/schemes/HmmerColourScheme.java b/src/jalview/schemes/HmmerColourScheme.java index 9ea468d..0f81ec1 100644 --- a/src/jalview/schemes/HmmerColourScheme.java +++ b/src/jalview/schemes/HmmerColourScheme.java @@ -8,6 +8,7 @@ import jalview.util.ColorUtils; import jalview.util.Comparison; import java.awt.Color; +import java.util.List; import java.util.Map; /** @@ -45,15 +46,15 @@ public abstract class HmmerColourScheme extends ResidueColourScheme private Map frequencies; /** - * Constructor given a Hidden Markov Model consensus sequence. This provides - * the HMM profile from which we can read the emission probabilities that - * determine the colour. + * Constructor given a list of Hidden Markov Model consensus sequences. The + * first sequence provides the HMM profile from which we can read the emission + * probabilities that determine the colour. * - * @param consensusSeq + * @param hmmSeqs */ - public HmmerColourScheme(SequenceI consensusSeq) + public HmmerColourScheme(List hmmSeqs) { - hmmSeq = consensusSeq; + hmmSeq = hmmSeqs.isEmpty() ? null : hmmSeqs.get(0); hmm = hmmSeq == null ? null : hmmSeq.getHMM(); } @@ -171,7 +172,7 @@ public abstract class HmmerColourScheme extends ResidueColourScheme @Override public boolean isApplicableTo(AnnotatedCollectionI ac) { - return ac.getHmmConsensus() != null; + return !ac.getHmmSequences().isEmpty(); } protected Map getFrequencies() diff --git a/src/jalview/schemes/HmmerGlobalBackground.java b/src/jalview/schemes/HmmerGlobalBackground.java index d5508f1..31bcadf 100644 --- a/src/jalview/schemes/HmmerGlobalBackground.java +++ b/src/jalview/schemes/HmmerGlobalBackground.java @@ -1,6 +1,7 @@ package jalview.schemes; import jalview.datamodel.AnnotatedCollectionI; +import jalview.datamodel.SequenceCollectionI; /** * An HMM colour scheme that uses global ('Uniprot') background frequencies for @@ -18,13 +19,13 @@ public class HmmerGlobalBackground extends HmmerColourScheme private static final float MAX_LOG_RATIO = 4.519f; /** - * Constructor given a Hidden Markov Model + * Constructor given a sequence collection * - * @param markov + * @param ac */ - public HmmerGlobalBackground(AnnotatedCollectionI ac) + public HmmerGlobalBackground(SequenceCollectionI ac) { - super(ac.getHmmConsensus()); + super(ac.getHmmSequences()); String alphabetType = getHmm() == null ? ResidueProperties.ALPHABET_AMINO : getHmm().getAlphabetType(); diff --git a/src/jalview/schemes/HmmerLocalBackground.java b/src/jalview/schemes/HmmerLocalBackground.java index 19cf080..2fe775c 100644 --- a/src/jalview/schemes/HmmerLocalBackground.java +++ b/src/jalview/schemes/HmmerLocalBackground.java @@ -2,6 +2,7 @@ package jalview.schemes; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.ResidueCount; +import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; import java.util.HashMap; @@ -19,15 +20,13 @@ public class HmmerLocalBackground extends HmmerColourScheme float logTotalCount; /** - * Constructor given a Hidden Markov Model + * Constructor given a sequence collection * - * @param sg - * - * @param markov + * @param ac */ public HmmerLocalBackground(AnnotatedCollectionI ac) { - super(ac.getHmmConsensus()); + super(ac.getHmmSequences()); countFrequencies(ac); } @@ -48,9 +47,9 @@ public class HmmerLocalBackground extends HmmerColourScheme * Counts and stores the relative frequency of every residue in the alignment * (apart from any HMM consensus sequences) * - * @param sg + * @param sc */ - public void countFrequencies(AnnotatedCollectionI sg) + public void countFrequencies(SequenceCollectionI sc) { // TODO or total counts in Consensus Profile (how do we get at it?)? Map freqs = new HashMap<>(); @@ -59,7 +58,7 @@ public class HmmerLocalBackground extends HmmerColourScheme * count symbols, excluding any HMM consensus sequences */ ResidueCount counts = new ResidueCount(); - List seqs = sg.getSequences(); + List seqs = sc.getSequences(); for (SequenceI seq : seqs) { if (!seq.hasHMMProfile()) diff --git a/src/jalview/workers/InformationThread.java b/src/jalview/workers/InformationThread.java index d42598c..cf42425 100644 --- a/src/jalview/workers/InformationThread.java +++ b/src/jalview/workers/InformationThread.java @@ -129,10 +129,10 @@ public class InformationThread extends AlignCalcWorker /* * alignment HMM profile */ - SequenceI seq = alignment.getHmmConsensus(); - if (seq != null) + List seqs = alignment.getHmmSequences(); + if (!seqs.isEmpty()) { - HiddenMarkovModel hmm = seq.getHMM(); + HiddenMarkovModel hmm = seqs.get(0).getHMM(); ProfilesI hmmProfiles = AAFrequency.calculateHMMProfiles(hmm, width, 0, width, alignViewport.isIgnoreBelowBackground(), alignViewport.isInfoLetterHeight()); @@ -145,10 +145,10 @@ public class InformationThread extends AlignCalcWorker List groups = alignment.getGroups(); for (SequenceGroup group : groups) { - seq = group.getHmmConsensus(); - if (seq != null) + seqs = group.getHmmSequences(); + if (!seqs.isEmpty()) { - HiddenMarkovModel hmm = seq.getHMM(); + HiddenMarkovModel hmm = seqs.get(0).getHMM(); ProfilesI hmmProfiles = AAFrequency.calculateHMMProfiles(hmm, width, 0, width, group.isIgnoreBelowBackground(), group.isUseInfoLetterHeight()); @@ -193,19 +193,24 @@ public class InformationThread extends AlignCalcWorker /* * annotation for alignment HMM consensus if present */ - SequenceI hmmSeq = alignment.getHmmConsensus(); - ProfilesI profile = alignViewport.getHmmProfiles(); - float m = updateInformationAnnotation(hmmSeq, profile, null, infos); - maxInformation = Math.max(maxInformation, m); + List hmmSeqs = alignment.getHmmSequences(); + if (!hmmSeqs.isEmpty()) + { + ProfilesI profile = alignViewport.getHmmProfiles(); + float m = updateInformationAnnotation(hmmSeqs.get(0), profile, null, + infos); + maxInformation = Math.max(maxInformation, m); + } /* * annotation for group HMM consensus if present */ for (SequenceGroup group : alignment.getGroups()) { - hmmSeq = group.getHmmConsensus(); + hmmSeqs = group.getHmmSequences(); ProfilesI profiles = group.getHmmProfiles(); - m = updateInformationAnnotation(hmmSeq, profiles, group, infos); + float m = updateInformationAnnotation(hmmSeqs.get(0), profiles, group, + infos); maxInformation = Math.max(maxInformation, m); } diff --git a/src/jalview/ws/params/simple/LogarithmicParameter.java b/src/jalview/ws/params/simple/LogarithmicParameter.java index 91ed03a..5f57d54 100644 --- a/src/jalview/ws/params/simple/LogarithmicParameter.java +++ b/src/jalview/ws/params/simple/LogarithmicParameter.java @@ -4,17 +4,23 @@ import jalview.ws.params.ParameterI; import jalview.ws.params.ValueConstrainI; /** + * A model for a numeric-valued parameter which should be displayed using a + * logarithmic scale * * @author TZVanaalten * */ public class LogarithmicParameter extends Option implements ParameterI { - Double defval; + public static final double LOGSLIDERSCALE = 1000000D; - Double min, max; + final double defval; - Double base; + final double min; + + final double max; + + final double base; @Override public ValueConstrainI getValidValue() @@ -31,27 +37,13 @@ public class LogarithmicParameter extends Option implements ParameterI @Override public Number getMin() { - if (min < max) - { - return min; - } - else - { - return null; - } + return min < max ? min : null; } @Override public Number getMax() { - if (min < max) - { - return max; - } - else - { - return null; - } + return min < max ? max : null; } }; } @@ -61,30 +53,31 @@ public class LogarithmicParameter extends Option implements ParameterI super(parm); max = parm.max; min = parm.min; + defval = 0D; base = parm.base; } public LogarithmicParameter(String name, String description, - boolean required, Double defValue, Double min, Double max, - Double base) + boolean required, double defValue, double min, double max, + double base) { super(name, description, required, String.valueOf(defValue), null, null, null); defval = defValue; - this.min = min * 1000000; - this.max = max * 1000000; + this.min = min;// * LOGSLIDERSCALE; + this.max = max;// * LOGSLIDERSCALE; this.base = base; } public LogarithmicParameter(String name, String description, - boolean required, Double defValue, Double value, Double min, - Double max, Double base) + boolean required, double defValue, double value, double min, + double max, double base) { super(name, description, required, String.valueOf(defValue), String.valueOf(value), null, null); defval = defValue; - this.min = min * 1000000; - this.max = max * 1000000; + this.min = min;// * LOGSLIDERSCALE; + this.max = max;// * LOGSLIDERSCALE; this.base = base; } @@ -94,7 +87,7 @@ public class LogarithmicParameter extends Option implements ParameterI return new LogarithmicParameter(this); } - public Double getBase() + public double getBase() { return base; } diff --git a/test/jalview/hmmer/HMMERTest.java b/test/jalview/hmmer/HMMERTest.java index 8f96d04..e3b7067 100644 --- a/test/jalview/hmmer/HMMERTest.java +++ b/test/jalview/hmmer/HMMERTest.java @@ -1,6 +1,7 @@ package jalview.hmmer; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -19,6 +20,7 @@ import jalview.ws.params.simple.Option; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; +import java.util.List; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -60,15 +62,15 @@ public class HMMERTest { throws MalformedURLException, IOException { /* - * run hmmbuild - note the side-effect of selecting the HMM - * sequence that gets added to the alignment + * run hmmbuild */ testHMMBuild(); - HiddenMarkovModel hmm = frame.getSelectedHMM(); - assertNotNull(hmm); + List hmms = frame.getViewport().getAlignment() + .getHmmSequences(); + assertFalse(hmms.isEmpty()); /* - * now run hmmalign - with respect to the select HMM profile + * now run hmmalign - by default with respect to the added HMM profile */ testHMMAlign(); } @@ -100,7 +102,7 @@ public class HMMERTest { public void testHMMAlign() { - HMMAlign thread = new HMMAlign(frame, + HmmerCommand thread = new HMMAlign(frame, new ArrayList()); thread.run(); @@ -118,8 +120,8 @@ public class HMMERTest { assertNotNull(original); AlignmentI realigned = alignFrames[1].getViewport().getAlignment(); assertNotNull(realigned); - assertNotNull(original.getHmmConsensus()); - assertNotNull(realigned.getHmmConsensus()); + assertFalse(original.getHmmSequences().isEmpty()); + assertFalse(realigned.getHmmSequences().isEmpty()); SequenceI ferCapan = original.findName("FER_CAPAN"); assertTrue(ferCapan.getSequenceAsString().startsWith("MA------SVSAT")); diff --git a/test/jalview/schemes/HmmerGlobalBackgroundTest.java b/test/jalview/schemes/HmmerGlobalBackgroundTest.java index 13bf47b..1cdee91 100644 --- a/test/jalview/schemes/HmmerGlobalBackgroundTest.java +++ b/test/jalview/schemes/HmmerGlobalBackgroundTest.java @@ -24,7 +24,6 @@ public class HmmerGlobalBackgroundTest { SequenceI hmmSeq = file.getSeqsAsArray()[0]; AlignmentI al = new Alignment(new SequenceI[] { hmmSeq }); - al.setHmmConsensus(hmmSeq); ColourSchemeI scheme = new HmmerGlobalBackground(al); /* diff --git a/test/jalview/schemes/HmmerLocalBackgroundTest.java b/test/jalview/schemes/HmmerLocalBackgroundTest.java index 7467ab2..5f2bb8f 100644 --- a/test/jalview/schemes/HmmerLocalBackgroundTest.java +++ b/test/jalview/schemes/HmmerLocalBackgroundTest.java @@ -37,7 +37,6 @@ public class HmmerLocalBackgroundTest { AnnotatedCollectionI ac = new Alignment( new SequenceI[] { hmmSeq, seq1, seq2 }); - ac.setHmmConsensus(hmmSeq); ColourSchemeI scheme = new HmmerLocalBackground(ac); /* diff --git a/utils/i18nAnt.xml b/utils/i18nAnt.xml index 01973d2..ab53613 100755 --- a/utils/i18nAnt.xml +++ b/utils/i18nAnt.xml @@ -36,7 +36,7 @@ - + -- 1.7.10.2