From d595e9cf7672de6d60165b536bc3def4b31f2352 Mon Sep 17 00:00:00 2001 From: TZVanaalten Date: Thu, 24 Aug 2017 16:49:34 +0100 Subject: [PATCH] JAL-2629 add adjustable parameters to hmmbuild --- resources/lang/Messages.properties | 21 +++++---- src/jalview/datamodel/HiddenMarkovModel.java | 2 +- src/jalview/datamodel/SequenceGroup.java | 2 +- src/jalview/gui/AlignFrame.java | 6 +-- src/jalview/gui/AnnotationLabels.java | 4 +- src/jalview/hmmer/HMMBuildThread.java | 62 +++++++++++++++++++------- src/jalview/hmmer/HMMERCommands.java | 2 - src/jalview/hmmer/HMMERParamStore.java | 38 +++++++++++++++- src/jalview/renderer/AnnotationRenderer.java | 4 +- src/jalview/viewmodel/AlignmentViewport.java | 14 ++++++ 10 files changed, 118 insertions(+), 37 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index f9aef72..574ac72 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1354,16 +1354,21 @@ label.seq_e_value = Sequence E-value Cutoff label.seq_score = Sequence Score Threshold label.dom_e_value = Domain E-value Cutoff label.dom_score = Domain Score Threshold -label.number_of_results_desc = The maximum number of results that hmmsearch will return. -label.auto_align_seqs_desc = If true, all fetched sequences will be aligned to the hidden Markov model with which the search was performed. -label.use_accessions_desc = If true, the accession number of each sequence is returned, rather than that sequences name. -label.seq_e_value_desc = The E-value cutoff for returned sequences. -label.seq_score_desc = The score threshold for returned sequences. -label.dom_e_value_desc = The E-value cutoff for returned domains. -label.dom_score_desc = The score threshold for returned domains. +label.number_of_results_desc = The maximum number of results that hmmsearch will return +label.auto_align_seqs_desc = If true, all fetched sequences will be aligned to the hidden Markov model with which the search was performed +label.use_accessions_desc = If true, the accession number of each sequence is returned, rather than that sequences name +label.seq_e_value_desc = The E-value cutoff for returned sequences +label.seq_score_desc = The score threshold for returned sequences +label.dom_e_value_desc = The E-value cutoff for returned domains +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. \ No newline at end of file +label.database_for_hmmsearch = The database hmmsearch will search through +label.use_reference = Use Reference Annotation +label.use_reference_desc = If true, hmmbuild will keep all columns defined as a reference position by the reference annotation +label.hmm_name = HMM Name +label.hmm_name_desc = The name given to the HMM. +warn.no_reference_annotation = No reference annotation found \ No newline at end of file diff --git a/src/jalview/datamodel/HiddenMarkovModel.java b/src/jalview/datamodel/HiddenMarkovModel.java index 086f5cd..2f58d3f 100644 --- a/src/jalview/datamodel/HiddenMarkovModel.java +++ b/src/jalview/datamodel/HiddenMarkovModel.java @@ -988,7 +988,7 @@ public class HiddenMarkovModel } - Sequence seq = new Sequence(getName() + "_HMM", sequence, start, + Sequence seq = new Sequence(getName(), sequence, start, end); return seq; } diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 7d124da..854b39d 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -1187,7 +1187,7 @@ public class SequenceGroup implements AnnotatedCollectionI information.hasText = true; information.autoCalculated = false; information.groupRef = this; - information.label = getName() + "_HMM"; + information.label = getName(); information.description = "Information content, measured in bits"; information.calcId = "HMM"; } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 38e9423..043fd3d 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1045,7 +1045,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } WsParamSetI set = new HMMERPreset(); List args = new ArrayList<>(); - ParamDatastoreI store = new HMMERParamStore("hmmalign"); + ParamDatastoreI store = new HMMERParamStore("hmmbuild"); WsJobParameters params = new WsJobParameters(new JFrame(), store, set, args); if (params.showRunDialog()) @@ -5898,9 +5898,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { this.selectedHMMSequence = selectedHMM; hmmAlign.setText(MessageManager.getString("label.hmmalign") + " to " - + selectedHMM.getHMM().getName() + "_HMM"); + + selectedHMM.getHMM().getName()); hmmSearch.setText(MessageManager.getString("label.hmmsearch") + " with " - + selectedHMM.getHMM().getName() + "_HMM"); + + selectedHMM.getHMM().getName()); } @Override diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index f494a01..f1d8d7c 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -423,7 +423,7 @@ public class AnnotationLabels extends JPanel { final String label = aa[selectedRow].label; if (!(aa[selectedRow].autoCalculated) - && !(label.indexOf("_HMM") > -1)) + && !("HMM".equals(aa[selectedRow].getCalcId()))) { if (aa[selectedRow].graph == AlignmentAnnotation.NO_GRAPH) { @@ -604,7 +604,7 @@ public class AnnotationLabels extends JPanel consclipbrd.addActionListener(this); pop.add(consclipbrd); } - else if (label.indexOf("_HMM") > -1) // TODO create labels + else if ("HMM".equals(aa[selectedRow].getCalcId())) // TODO create labels // in message resource // for these { diff --git a/src/jalview/hmmer/HMMBuildThread.java b/src/jalview/hmmer/HMMBuildThread.java index eb9fc2a..4260c34 100644 --- a/src/jalview/hmmer/HMMBuildThread.java +++ b/src/jalview/hmmer/HMMBuildThread.java @@ -152,11 +152,6 @@ public class HMMBuildThread implements Runnable boolean ran = runCommand(); if (!ran) { - if (af != null) - { - JvOptionPane.showInternalMessageDialog(af, - MessageManager.getString("warn.hmmbuild_failed")); - } return; } } catch (IOException | InterruptedException e) @@ -205,30 +200,63 @@ public class HMMBuildThread implements Runnable { if (!file.canExecute()) { + if (af != null) + { + JvOptionPane.showInternalMessageDialog(af, + MessageManager.getString("warn.hmmbuild_failed")); + } return false; } } } - String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.NAME; - if (forGroup) + String command = cmds.HMMERFOLDER + cmds.HMMBUILD + cmds.SPACE; + String name = null; + + if (params != null) { - command += group.getName(); + for (ArgumentI arg : params) + { + String argName = arg.getName(); + switch (argName) + { + case "HMM Name": + name = arg.getValue(); + break; + case "Use Reference Annotation": + command += "--hand "; + if (!af.getViewport().hasReferenceAnnotation()) + { + JvOptionPane.showInternalMessageDialog(af, MessageManager + .getString("warn.no_reference_annotation")); + return false; + } + break; + + } + + } } - else + + if (name == null || name == "" || name == " ") { - String name = null; - if (af != null) + if (forGroup) { - // name = af.getTitle(); - name = "replace"; + name = group.getName(); } - if (name == null || name == "" || name == " " || name == " ") + else { - name = "Alignment"; + if (af != null) + { + name = af.getTitle(); + } + if (name == null || name == "" || name == " " || name == " ") + { + name = "Alignment"; + } } - command += name; } - command += cmds.SPACE; + + command += "-n " + name + cmds.SPACE; if (!alignment.isNucleotide()) { command += cmds.FORCEAMINO; // TODO check for rna diff --git a/src/jalview/hmmer/HMMERCommands.java b/src/jalview/hmmer/HMMERCommands.java index 6b81b65..ba4c57b 100644 --- a/src/jalview/hmmer/HMMERCommands.java +++ b/src/jalview/hmmer/HMMERCommands.java @@ -39,8 +39,6 @@ public class HMMERCommands public String OUTPUTALIGNMENT; - public final String NAME = "-n "; - public final String SPACE = " "; public final String ALLCOL = "--allcol "; diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java index a4bf8e4..b512ce1 100644 --- a/src/jalview/hmmer/HMMERParamStore.java +++ b/src/jalview/hmmer/HMMERParamStore.java @@ -6,11 +6,13 @@ import jalview.gui.Preferences; import jalview.util.MessageManager; import jalview.ws.params.ArgumentI; import jalview.ws.params.ParamDatastoreI; +import jalview.ws.params.ValueConstrainI; import jalview.ws.params.WsParamSetI; import jalview.ws.params.simple.BooleanOption; import jalview.ws.params.simple.IntegerParameter; import jalview.ws.params.simple.LogarithmicParameter; import jalview.ws.params.simple.Option; +import jalview.ws.params.simple.StringParameter; import java.io.IOException; import java.util.ArrayList; @@ -60,7 +62,7 @@ public class HMMERParamStore implements ParamDatastoreI } if ("hmmbuild".equals(name)) { - + getHMMBuildParams(args); } return args; @@ -137,6 +139,7 @@ public class HMMERParamStore implements ParamDatastoreI */ } + private void getHMMAlignParams(List args) { args.add(new BooleanOption( @@ -146,6 +149,39 @@ public class HMMERParamStore implements ParamDatastoreI false, false, true, null)); } + private void getHMMBuildParams(List args) + { + args.add(new StringParameter(MessageManager.getString("label.hmm_name"), + MessageManager.getString("label.hmm_name_desc"), true, "")); + args.add(new BooleanOption( + MessageManager.getString("label.use_reference"), + MessageManager.getString("label.use_reference_desc"), true, + true, true, null)); + } + + private class StringValueConstrain implements ValueConstrainI + { + + @Override + public ValueType getType() + { + return ValueType.String; + } + + @Override + public Number getMax() + { + return null; + } + + @Override + public Number getMin() + { + return null; + } + + } + @Override public boolean presetExists(String name) { diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index d37eac1..6099a85 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -372,7 +372,7 @@ public class AnnotationRenderer // properties/rendering attributes as a global 'alignment group' which holds // all vis settings for the alignment as a whole rather than a subset // - if (aa.label.contains("_HMM")) + if ("HMM".equals(aa.getCalcId())) { HiddenMarkovModel hmm = aa.sequenceRef.getHMM(); return AAFrequency.extractHMMProfile(hmm, column, @@ -523,7 +523,7 @@ public class AnnotationRenderer renderProfile = av_renderProfile; normaliseProfile = av_normaliseProfile; } - else if (row.label.contains("_HMM")) + else if ("HMM".equals(row.getCalcId())) { renderHistogram = av_renderInformationHistogram; renderProfile = av_renderHMMProfile; diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index eeea831..ad12035 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -3122,4 +3122,18 @@ public abstract class AlignmentViewport + ((ignoreGapsInConsensusCalculation) ? " without gaps" : "")); return sq; } + + public boolean hasReferenceAnnotation() + { + AlignmentAnnotation[] annots = this.alignment.getAlignmentAnnotation(); + for (AlignmentAnnotation annot : annots) + { + if ("RF".equals(annot.getCalcId())) + { + return true; + } + } + return false; + } + } -- 1.7.10.2