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
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
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
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
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
private List<SequenceI> sequences;
- private SequenceI hmmConsensus;
-
protected List<SequenceGroup> groups;
protected char gapCharacter = '-';
}
@Override
- public SequenceI getHmmConsensus()
- {
- return hmmConsensus;
- }
-
- @Override
- public void setHmmConsensus(SequenceI hmmConsensus)
- {
- this.hmmConsensus = hmmConsensus;
- }
-
- @Override
public void setupJPredAlignment()
{
SequenceI repseq = getSequenceAt(0);
}
}
}
+
+ @Override
+ public List<SequenceI> getHmmSequences()
+ {
+ List<SequenceI> result = new ArrayList<>();
+ for (int i = 0; i < sequences.size(); i++)
+ {
+ SequenceI seq = sequences.get(i);
+ if (seq.hasHMMProfile())
+ {
+ result.add(seq);
+ }
+ }
+ return result;
+ }
}
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<SequenceI> getHmmSequences();
}
*/
private SequenceI seqrep;
- /*
- * HMM consensus sequence for group (if any)
- */
- private SequenceI hmmConsensus;
-
private int width = -1;
/*
hmmNormaliseSequenceLogo = state;
}
- @Override
- public SequenceI getHmmConsensus()
- {
- return hmmConsensus;
- }
-
- @Override
- public void setHmmConsensus(SequenceI hmmSeq)
- {
- this.hmmConsensus = hmmSeq;
- }
-
public ProfilesI getConsensusData()
{
return consensusProfiles;
this.hmmProfiles = hmmProfiles;
}
+ @Override
+ public List<SequenceI> getHmmSequences()
+ {
+ List<SequenceI> result = new ArrayList<>();
+ for (int i = 0; i < sequences.size(); i++)
+ {
+ SequenceI seq = sequences.get(i);
+ if (seq.hasHMMProfile())
+ {
+ result.add(seq);
+ }
+ }
+ return result;
+ }
+
}
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;
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;
AlignViewport viewport;
public AlignViewControllerI avc;
- /*
- * The selected HMM for this align frame
- */
- SequenceI selectedHMMSequence;
List<AlignmentPanel> alignPanels = new ArrayList<>();
{
return;
}
- List<ArgumentI> 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<ArgumentI> args = store.getServiceParameters();
+
+ if (!withDefaults)
{
WsParamSetI set = new HMMERPreset();
- ParamDatastoreI store = HMMERParamStore.forBuild(viewport);
WsJobParameters params = new WsJobParameters(store, set, args);
if (params.showRunDialog())
{
{
return;
}
- List<ArgumentI> args = new ArrayList<>();
+
+ /*
+ * get default parameters, and optionally show a dialog
+ * to allow them to be modified
+ */
+ ParamDatastoreI store = HMMERParamStore.forAlign(viewport);
+ List<ArgumentI> args = store.getServiceParameters();
+
if (!withDefaults)
{
WsParamSetI set = new HMMERPreset();
- ParamDatastoreI store = HMMERParamStore.forAlign(viewport);
WsJobParameters params = new WsJobParameters(store, set, args);
if (params.showRunDialog())
{
{
return;
}
- List<ArgumentI> args = new ArrayList<>();
+
+ /*
+ * get default parameters, and (if requested) show
+ * dialog to allow modification
+ */
+ ParamDatastoreI store = HMMERParamStore.forSearch(viewport);
+ List<ArgumentI> args = store.getServiceParameters();
+
if (!withDefaults)
{
WsParamSetI set = new HMMERPreset();
- ParamDatastoreI store = HMMERParamStore.forSearch(viewport);
WsJobParameters params = new WsJobParameters(store, set, args);
if (params.showRunDialog())
{
}
/**
- * 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;
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;
else
{
JOptionPane.showMessageDialog(this,
- MessageManager.getString("warn.not_enough_sequences"));
+ MessageManager.getString("label.not_enough_sequences"));
}
}
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)
{
*/
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;
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;
*/
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<String, OptionBox> optSet = new LinkedHashMap<>();
+
+ Map<String, ParamBox> 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
{
JLabel optlabel = new JLabel();
- JComboBox val = new JComboBox();
+ JComboBox<String> 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());
}
}
add(enabled, BorderLayout.NORTH);
- for (Object str : opt.getPossibleValues())
+ for (String str : opt.getPossibleValues())
{
val.addItem(str);
}
}
+ /**
+ * 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;
boolean choice = false;
- JComboBox choicebox;
+ JComboBox<String> choicebox;
JPanel controlPanel = new JPanel();
{
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();
}
- 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)
{
if (choice)
{
- choicebox = new JComboBox();
+ choicebox = new JComboBox<>();
choicebox.addActionListener(this);
controlPanel.add(choicebox, BorderLayout.CENTER);
}
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)
{
}
}
}
-
- @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);
-
}
}
{
if (init)
{
- List vals = parm.getPossibleValues();
- for (Object val : vals)
+ for (String val : parm.getPossibleValues())
{
choicebox.addItem(val);
}
{
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
}
} 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)
}
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)
// 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)
// 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,
} 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
}
}
- 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);
mnu.show(invoker, x, y);
}
- URL linkImageURL = getClass().getResource("/images/link.gif");
-
- Map<String, OptionBox> optSet = new java.util.LinkedHashMap<>();
-
- Map<String, ParamBox> paramSet = new java.util.LinkedHashMap<>();
-
public Map<String, OptionBox> getOptSet()
{
return optSet;
this.paramSet = paramSet;
}
- OptsParametersContainerI poparent;
-
OptionBox addOption(OptionI opt)
{
OptionBox cb = optSet.get(opt.getName());
});
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)
{
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
*/
@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"),
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;
}
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);
}
boolean ran = runCommand(alignmentFile, hmmFile, ac);
if (!ran)
{
+ JvOptionPane.showInternalMessageDialog(af, MessageManager
+ .formatMessage("warn.command_failed", "hmmbuild"));
return;
}
importData(hmmFile, ac);
*/
void deleteHmmSequences(AnnotatedCollectionI ac)
{
- SequenceI hmmSeq = ac.getHmmConsensus();
- if (hmmSeq != null)
+ List<SequenceI> hmmSeqs = ac.getHmmSequences();
+ for (SequenceI hmmSeq : hmmSeqs)
{
if (ac instanceof SequenceGroup)
{
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);
}
}
}
package jalview.hmmer;
import jalview.bin.Cache;
+import jalview.datamodel.SequenceI;
import jalview.gui.Preferences;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
*/
private void getHMMSearchParams(List<ArgumentI> args)
{
+ addChoiceOfHmm(args);
+
args.add(new IntegerParameter(
MessageManager.getString("label.number_of_results"),
MessageManager.getString("label.number_of_results_desc"), true,
String names = Cache.getProperty(Preferences.HMMSEARCH_DBS);
if (names != null && !names.isEmpty())
{
- Collection<String> databases = new ArrayList<>();
+ List<String> databases = new ArrayList<>();
databases.add(MessageManager.getString("label.this_alignment"));
Scanner nameScanner = new Scanner(names);
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"),
*/
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"),
*/
private void getHMMAlignParams(List<ArgumentI> args)
{
+ addChoiceOfHmm(args);
+
boolean def = Cache.getDefault(Preferences.HMMALIGN_TRIM_TERMINI,
false);
args.add(new BooleanOption(
}
/**
+ * 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<ArgumentI> args)
+ {
+ List<SequenceI> hmms = viewport.getAlignment().getHmmSequences();
+ if (!hmms.isEmpty())
+ {
+ List<String> 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
*
*/
private void getHMMBuildParams(List<ArgumentI> 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(
true, true, null));
}
+ /*
+ * choice of whether to compute HMM for alignment and/or group(s)
+ */
Collection<String> 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"),
package jalview.hmmer;
+import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
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;
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;
@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);
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;
}
{
/*
* 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<SequenceI> hmms = copy.getHmmSequences();
+ for (SequenceI hmmSeq : hmms)
{
- copy.deleteSequence(hmms);
+ copy.deleteSequence(hmmSeq);
}
exportStockholm(copy.getSequencesArray(), databaseFile, null);
// StockholmFile stoFile = new StockholmFile(copy);
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<ArgumentI> alignArgs = new ArrayList<>();
+ String defSeq = hmmSeq.getName();
+ List<String> 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(
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();
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();
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;
+ }
}
*/
alignment.deleteSequence(alignment.getAbsoluteHeight() - 1);
alignment.insertSequenceAt(0, seq);
- alignment.setHmmConsensus(seq);
}
viewport.getAlignPanel().adjustAnnotationHeight();
viewport.updateSequenceIdColours();
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);
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"));
import jalview.util.Comparison;
import java.awt.Color;
+import java.util.List;
import java.util.Map;
/**
private Map<Character, Float> 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<SequenceI> hmmSeqs)
{
- hmmSeq = consensusSeq;
+ hmmSeq = hmmSeqs.isEmpty() ? null : hmmSeqs.get(0);
hmm = hmmSeq == null ? null : hmmSeq.getHMM();
}
@Override
public boolean isApplicableTo(AnnotatedCollectionI ac)
{
- return ac.getHmmConsensus() != null;
+ return !ac.getHmmSequences().isEmpty();
}
protected Map<Character, Float> getFrequencies()
package jalview.schemes;
import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
/**
* An HMM colour scheme that uses global ('Uniprot') background frequencies for
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();
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.ResidueCount;
+import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceI;
import java.util.HashMap;
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);
}
* 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<Character, Float> freqs = new HashMap<>();
* count symbols, excluding any HMM consensus sequences
*/
ResidueCount counts = new ResidueCount();
- List<SequenceI> seqs = sg.getSequences();
+ List<SequenceI> seqs = sc.getSequences();
for (SequenceI seq : seqs)
{
if (!seq.hasHMMProfile())
/*
* alignment HMM profile
*/
- SequenceI seq = alignment.getHmmConsensus();
- if (seq != null)
+ List<SequenceI> 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());
List<SequenceGroup> 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());
/*
* 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<SequenceI> 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);
}
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()
@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;
}
};
}
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;
}
return new LogarithmicParameter(this);
}
- public Double getBase()
+ public double getBase()
{
return base;
}
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;
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;
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<SequenceI> 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();
}
public void testHMMAlign()
{
- HMMAlign thread = new HMMAlign(frame,
+ HmmerCommand thread = new HMMAlign(frame,
new ArrayList<ArgumentI>());
thread.run();
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"));
SequenceI hmmSeq = file.getSeqsAsArray()[0];
AlignmentI al = new Alignment(new SequenceI[] { hmmSeq });
- al.setHmmConsensus(hmmSeq);
ColourSchemeI scheme = new HmmerGlobalBackground(al);
/*
AnnotatedCollectionI ac = new Alignment(
new SequenceI[]
{ hmmSeq, seq1, seq2 });
- ac.setHmmConsensus(hmmSeq);
ColourSchemeI scheme = new HmmerLocalBackground(ac);
/*
<param name="file2" value="${file2}" />
</antcall>
<echo message=" "/>
- <echo message="Missing message labels in Messages.properties compare to ${file2}"/>
+ <echo message="Missing message labels in Messages.properties compared to ${file2}"/>
<antcall target="compareProperties">
<param name="file2" value="resources/lang/Messages.properties"/>
<param name="file1" value="${file2}" />