From cda264e0a9bb29a1c401974c10a39827407072bb Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 9 May 2018 16:57:00 +0100 Subject: [PATCH] JAL-2714 HMMSearch cutoff by E-Value, Score or None --- resources/lang/Messages.properties | 11 +- src/jalview/bin/Jalview.java | 2 +- src/jalview/gui/OptsAndParamsPage.java | 21 ++-- src/jalview/hmmer/HMMERParamStore.java | 69 +++++++------ src/jalview/hmmer/HMMSearch.java | 109 +++++++++++++++----- .../ws/params/simple/LogarithmicParameter.java | 15 +-- src/jalview/ws/params/simple/Parameter.java | 51 --------- .../ws/params/simple/StringChoiceParameter.java | 18 ++++ src/jalview/ws/params/simple/StringParameter.java | 72 ++++--------- 9 files changed, 179 insertions(+), 189 deletions(-) delete mode 100644 src/jalview/ws/params/simple/Parameter.java diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index c5ab140..db3dbf8 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1382,6 +1382,7 @@ label.hmmer = HMMER label.trim_termini = Trim Non-Matching Termini label.trim_termini_desc = If true, non-matching regions on either end of the resulting alignment are removed. label.no_of_sequences = Number of sequences returned +label.reporting_cutoff = Reporting Cut-off label.freq_alignment = Use alignment background frequencies label.freq_uniprot = Use Uniprot background frequencies label.hmmalign_options = hmmalign options @@ -1392,17 +1393,17 @@ label.invalid_folder = Invalid Folder label.number_of_results = Number of Results to Return label.auto_align_seqs = Automatically Align Fetched Sequences label.use_accessions = Return Accessions -label.seq_e_value = Sequence E-value Cutoff +label.seq_evalue = Sequence E-value Cut-off label.seq_score = Sequence Score Threshold -label.dom_e_value = Domain E-value Cutoff +label.dom_evalue = Domain E-value Cut-off label.dom_score = Domain Score Threshold label.number_of_results_desc = The maximum number of hmmsearch results to display 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 sequence's name 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.seq_score_desc = The score threshold for returned sequences (hmmsearch -T) +label.dom_e_value_desc = The E-value cutoff for returned domains (hmmsearch --domE) +label.dom_score_desc = The score threshold for returned domains (hmmsearch --domT) label.add_database = Add Database label.this_alignment = This alignment warn.invalid_format = This is not a valid database file format. The current supported formats are Fasta, Stockholm and Pfam. diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index f911675..e66b7ae 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -303,7 +303,7 @@ public class Jalview { System.err.println( "Quaqua LaF not available. Using VAqua(4)."); - UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel"); + // UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel"); } catch (Throwable e) { System.err.println( diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index 34af13d..39b8ed5 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -101,7 +101,7 @@ public class OptsAndParamsPage public class OptionBox extends JPanel implements MouseListener, ActionListener { - JCheckBox enabled = new JCheckBox(); + JCheckBox enabled; final URL finfo; @@ -113,14 +113,13 @@ public class OptsAndParamsPage OptionI option; - JLabel optlabel = new JLabel(); - - JComboBox val = new JComboBox<>(); + JComboBox val; public OptionBox(OptionI opt) { option = opt; setLayout(new FlowLayout(FlowLayout.LEFT)); + enabled = new JCheckBox(); enabled.setSelected(opt.isRequired()); // TODO: lock required options enabled.setFont(new Font("Verdana", Font.PLAIN, 11)); enabled.setText(""); @@ -149,6 +148,9 @@ public class OptsAndParamsPage } } add(enabled); + + // todo combo or radio buttons? + val = new JComboBox<>(); for (String str : opt.getPossibleValues()) { val.addItem(str); @@ -366,7 +368,8 @@ public class OptsAndParamsPage * ensure slider has an integer range corresponding to * the min-max range of the parameter */ - if (validator.getMin() != null && !isIntegerParameter + if (validator.getMin() != null && validator.getMax() != null + // && !isIntegerParameter && !isStringParameter) { double min = validator.getMin().doubleValue(); @@ -380,10 +383,10 @@ public class OptsAndParamsPage // todo scaleMin, scaleMax could also be final fields } } - else - { - isChoiceParameter = parameter.getPossibleValues() != null; - } + + List possibleValues = parameter.getPossibleValues(); + isChoiceParameter = possibleValues != null + && possibleValues.size() > 1; if (compact) { diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java index 6f1f51f..b609f69 100644 --- a/src/jalview/hmmer/HMMERParamStore.java +++ b/src/jalview/hmmer/HMMERParamStore.java @@ -9,6 +9,7 @@ import jalview.ws.params.ArgumentI; import jalview.ws.params.ParamDatastoreI; import jalview.ws.params.WsParamSetI; import jalview.ws.params.simple.BooleanOption; +import jalview.ws.params.simple.DoubleParameter; import jalview.ws.params.simple.IntegerParameter; import jalview.ws.params.simple.LogarithmicParameter; import jalview.ws.params.simple.Option; @@ -16,6 +17,7 @@ import jalview.ws.params.simple.StringParameter; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Scanner; @@ -96,17 +98,16 @@ public final class HMMERParamStore implements ParamDatastoreI */ private void getHMMSearchParams(List args) { + /* + * 'Options' + */ addChoiceOfHmm(args); - args.add(new IntegerParameter( - MessageManager.getString("label.number_of_results"), - MessageManager.getString("label.number_of_results_desc"), true, - 100, 0, 100000)); String names = Cache.getProperty(Preferences.HMMSEARCH_DBS); if (names != null && !names.isEmpty()) { List databases = new ArrayList<>(); - databases.add(MessageManager.getString("label.this_alignment")); + databases.add(MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY)); Scanner nameScanner = new Scanner(names); if (nameScanner.hasNext()) @@ -126,45 +127,55 @@ public final class HMMERParamStore implements ParamDatastoreI } } nameScanner.close(); - args.add(new Option(MessageManager.getString("label.database"), + args.add(new Option(MessageManager.getString(HMMSearch.DATABASE_KEY), MessageManager.getString("label.database_for_hmmsearch"), - true, MessageManager.getString("label.this_alignment"), - MessageManager.getString("label.this_alignment"), databases, - null)); + true, MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY), + MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY), + databases, null)); } args.add(new BooleanOption( - MessageManager.getString("label.auto_align_seqs"), + MessageManager.getString(HMMSearch.AUTO_ALIGN_SEQS_KEY), MessageManager.getString("label.auto_align_seqs_desc"), false, false, true, null)); args.add(new BooleanOption( - MessageManager.getString("label.use_accessions"), + MessageManager.getString(HMMSearch.USE_ACCESSIONS_KEY), MessageManager.getString("label.use_accessions_desc"), false, false, true, null)); args.add(new BooleanOption( - MessageManager.getString("label.trim_termini"), + MessageManager.getString(HMMSearch.TRIM_TERMINI_KEY), MessageManager.getString("label.trim_termini_desc"), false, false, true, null)); + + /* + * 'Parameters' + */ + args.add(new IntegerParameter( + MessageManager.getString(HMMSearch.NUMBER_OF_RESULTS_KEY), + MessageManager.getString("label.number_of_results_desc"), true, + 100, 0, 100000)); + args.add(new StringParameter( + MessageManager.getString(HMMSearch.REPORTING_CUTOFF_KEY), null, + true, HMMSearch.CUTOFF_NONE, HMMSearch.CUTOFF_NONE, + Arrays.asList(HMMSearch.CUTOFF_NONE, HMMSearch.CUTOFF_EVALUE, + HMMSearch.CUTOFF_SCORE))); args.add(new LogarithmicParameter( - MessageManager.getString("label.seq_e_value"), + MessageManager.getString(HMMSearch.SEQ_EVALUE_KEY), MessageManager.getString("label.seq_e_value_desc"), false, 1D, - 1E-38, 10D, 10D)); - /* - args.add(new DoubleParameter( - MessageManager.getString("label.seq_score"), - MessageManager.getString("label.seq_score_desc"), false, - 0d, 0d, 10000d)); - */ + 1E-38, 10D)); args.add(new LogarithmicParameter( - MessageManager.getString("label.dom_e_value"), + MessageManager.getString(HMMSearch.DOM_EVALUE_KEY), MessageManager.getString("label.dom_e_value_desc"), false, 1D, - 1E-38, 10D, 10D)); - /* - args.add(new DoubleParameter( - MessageManager.getString("label.dom_score"), - MessageManager.getString("label.dom_score_desc"), false, 0d, - 0d, - 10000d)); - */ + 1E-38, 10D)); + args.add( + new DoubleParameter( + MessageManager.getString(HMMSearch.SEQ_SCORE_KEY), + MessageManager.getString("label.seq_score_desc"), false, + 0d, 0d, 1000d)); + args.add( + new DoubleParameter( + MessageManager.getString(HMMSearch.DOM_SCORE_KEY), + MessageManager.getString("label.dom_score_desc"), false, + 0d, 0d, 1000d)); } /** diff --git a/src/jalview/hmmer/HMMSearch.java b/src/jalview/hmmer/HMMSearch.java index d4c9656..efc34ae 100644 --- a/src/jalview/hmmer/HMMSearch.java +++ b/src/jalview/hmmer/HMMSearch.java @@ -31,10 +31,39 @@ 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"; + /* + * constants for i18n lookup of passed parameter names + */ + static final String DATABASE_KEY = "label.database"; + + static final String THIS_ALIGNMENT_KEY = "label.this_alignment"; + + static final String USE_ACCESSIONS_KEY = "label.use_accessions"; + + static final String AUTO_ALIGN_SEQS_KEY = "label.auto_align_seqs"; + + static final String NUMBER_OF_RESULTS_KEY = "label.number_of_results"; + + static final String TRIM_TERMINI_KEY = "label.trim_termini"; + + static final String REPORTING_CUTOFF_KEY = "label.reporting_cutoff"; + + static final String CUTOFF_NONE = "None"; + + static final String CUTOFF_SCORE = "Score"; + + static final String CUTOFF_EVALUE = "E-Value"; + + static final String SEQ_EVALUE_KEY = "label.seq_evalue"; + + static final String DOM_EVALUE_KEY = "label.dom_evalue"; + + static final String SEQ_SCORE_KEY = "label.seq_score"; + + static final String DOM_SCORE_KEY = "label.dom_score"; + boolean realign = false; boolean trim = false; @@ -138,57 +167,72 @@ public class HMMSearch extends HmmerCommand String dbPath = ""; File databaseFile = null; + boolean useEvalueCutoff = false; + boolean useScoreCutoff = false; + String seqEvalueCutoff = null; + String domEvalueCutoff = null; + String seqScoreCutoff = null; + String domScoreCutoff = null; + if (params != null) { for (ArgumentI arg : params) { String name = arg.getName(); - if (MessageManager.getString("label.number_of_results") + if (MessageManager.getString(NUMBER_OF_RESULTS_KEY) .equals(name)) { seqsToReturn = Integer.parseInt(arg.getValue()); } - else if (MessageManager.getString("label.auto_align_seqs") + else if (MessageManager.getString(AUTO_ALIGN_SEQS_KEY) .equals(name)) { realign = true; // TODO: not used } - else if (MessageManager.getString("label.use_accessions") + else if (MessageManager.getString(USE_ACCESSIONS_KEY) .equals(name)) { args.add("--acc"); } - else if (MessageManager.getString("label.seq_e_value").equals(name)) + else if (MessageManager.getString(REPORTING_CUTOFF_KEY) + .equals(name)) + { + if (CUTOFF_EVALUE.equals(arg.getValue())) + { + useEvalueCutoff = true; + } + else if (CUTOFF_SCORE.equals(arg.getValue())) + { + useScoreCutoff = true; + } + } + else if (MessageManager.getString(SEQ_EVALUE_KEY).equals(name)) { - args.add("-E"); - args.add(arg.getValue()); + seqEvalueCutoff = arg.getValue(); } - else if (MessageManager.getString("label.seq_score").equals(name)) + else if (MessageManager.getString(SEQ_SCORE_KEY).equals(name)) { - args.add("-incT"); - args.add(arg.getValue()); + seqScoreCutoff = arg.getValue(); } - else if (MessageManager.getString("label.dom_e_value") + else if (MessageManager.getString(DOM_EVALUE_KEY) .equals(name)) { - args.add("--domE"); - args.add(arg.getValue()); + domEvalueCutoff = arg.getValue(); } - else if (MessageManager.getString("label.dom_score").equals(name)) + else if (MessageManager.getString(DOM_SCORE_KEY).equals(name)) { - args.add("--incdomT"); - args.add(arg.getValue()); + domScoreCutoff = arg.getValue(); } - else if (MessageManager.getString("label.trim_termini") + else if (MessageManager.getString(TRIM_TERMINI_KEY) .equals(name)) { trim = true; } - else if (MessageManager.getString("label.database").equals(name)) + else if (MessageManager.getString(DATABASE_KEY).equals(name)) { dbFound = true; dbPath = arg.getValue(); - if (!MessageManager.getString("label.this_alignment") + if (!MessageManager.getString(THIS_ALIGNMENT_KEY) .equals(dbPath)) { databaseFile = new File(dbPath); @@ -197,7 +241,22 @@ public class HMMSearch extends HmmerCommand } } - if (!dbFound || MessageManager.getString("label.this_alignment") + if (useEvalueCutoff) + { + args.add("-E"); + args.add(seqEvalueCutoff); + args.add("--domE"); + args.add(domEvalueCutoff); + } + else if (useScoreCutoff) + { + args.add("-T"); + args.add(seqScoreCutoff); + args.add("--domT"); + args.add(domScoreCutoff); + } + + if (!dbFound || MessageManager.getString(THIS_ALIGNMENT_KEY) .equals(dbPath)) { /* @@ -214,12 +273,6 @@ public class HMMSearch extends HmmerCommand copy.deleteSequence(hmmSeq); } exportStockholm(copy.getSequencesArray(), databaseFile, null); - // StockholmFile stoFile = new StockholmFile(copy); - // stoFile.setSeqs(copy.getSequencesArray()); - // String alignmentString = stoFile.print(); - // PrintWriter writer = new PrintWriter(databaseFile); - // writer.print(alignmentString); - // writer.close(); } args.add(getFilePath(hmmFile)); @@ -273,7 +326,7 @@ public class HMMSearch extends HmmerCommand if (trim) { alignArgs.add(new BooleanOption( - MessageManager.getString("label.trim_termini"), + MessageManager.getString(TRIM_TERMINI_KEY), MessageManager.getString("label.trim_termini_desc"), true, true, true, null)); } diff --git a/src/jalview/ws/params/simple/LogarithmicParameter.java b/src/jalview/ws/params/simple/LogarithmicParameter.java index 01744e7..af80181 100644 --- a/src/jalview/ws/params/simple/LogarithmicParameter.java +++ b/src/jalview/ws/params/simple/LogarithmicParameter.java @@ -17,8 +17,6 @@ public class LogarithmicParameter extends Option implements ParameterI final double max; - final double base; // todo is this even needed? - @Override public ValueConstrainI getValidValue() { @@ -51,31 +49,27 @@ public class LogarithmicParameter extends Option implements ParameterI 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) { super(name, description, required, String.valueOf(defValue), null, null, null); defval = defValue; this.min = min; this.max = max; - this.base = base; } public LogarithmicParameter(String name, String description, boolean required, Double defValue, double value, double min, - double max, double base) + double max) { super(name, description, required, String.valueOf(defValue), String.valueOf(value), null, null); defval = defValue; this.min = min; this.max = max; - this.base = base; } @Override @@ -83,9 +77,4 @@ public class LogarithmicParameter extends Option implements ParameterI { return new LogarithmicParameter(this); } - - public double getBase() - { - return base; - } } diff --git a/src/jalview/ws/params/simple/Parameter.java b/src/jalview/ws/params/simple/Parameter.java deleted file mode 100644 index e2c81a6..0000000 --- a/src/jalview/ws/params/simple/Parameter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.ws.params.simple; - -import jalview.ws.params.OptionI; -import jalview.ws.params.ParameterI; -import jalview.ws.params.ValueConstrainI; - -public abstract class Parameter extends Option - implements OptionI, ParameterI -{ - ValueConstrainI validator; - - @Override - public ValueConstrainI getValidValue() - { - return validator; - } - - public Parameter(Parameter parm) - { - super(parm); - } - - public Parameter(ValueConstrainI validator) - { - super(); - this.validator = validator; - } - - @Override - public abstract Parameter copy(); -} diff --git a/src/jalview/ws/params/simple/StringChoiceParameter.java b/src/jalview/ws/params/simple/StringChoiceParameter.java index d613d58..254eb80 100644 --- a/src/jalview/ws/params/simple/StringChoiceParameter.java +++ b/src/jalview/ws/params/simple/StringChoiceParameter.java @@ -20,7 +20,25 @@ */ package jalview.ws.params.simple; +import java.util.List; + +/** + * A parameter with options intended to be rendered as radio buttons + */ public class StringChoiceParameter extends Option { + /** + * Constructor + * + * @param name + * @param description + * @param options + * @param def + */ + public StringChoiceParameter(String name, String description, + List options, String def) + { + super(name, description, true, def, def, options, null); + } } diff --git a/src/jalview/ws/params/simple/StringParameter.java b/src/jalview/ws/params/simple/StringParameter.java index 1d6a37e..b61836a 100644 --- a/src/jalview/ws/params/simple/StringParameter.java +++ b/src/jalview/ws/params/simple/StringParameter.java @@ -3,65 +3,13 @@ package jalview.ws.params.simple; import jalview.ws.params.ParameterI; import jalview.ws.params.ValueConstrainI; -import java.net.URL; -import java.util.List; +import java.util.Collection; public class StringParameter extends Option implements ParameterI { - - @Override - public URL getFurtherDetails() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isRequired() - { - // TODO Auto-generated method stub - return false; - } - - @Override - public String getDescription() - { - // TODO Auto-generated method stub - return description; - } - - @Override - public List getPossibleValues() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getName() - { - // TODO Auto-generated method stub - return name; - } - - @Override - public String getValue() - { - // TODO Auto-generated method stub - return value; - } - - @Override - public void setValue(String selectedItem) - { - value = selectedItem; - - } - @Override public ValueConstrainI getValidValue() { - // TODO Auto-generated method stub return new StringValueConstrain(); } @@ -115,4 +63,22 @@ public class StringParameter extends Option implements ParameterI String.valueOf(value), null, null); this.defvalue = defValue; } + + /** + * Constructor for a parameter with a list of possible values + * + * @param name2 + * @param description2 + * @param isrequired + * @param defValue + * @param value + * @param possibleVals + */ + public StringParameter(String name2, String description2, + boolean isrequired, String defValue, String value, + Collection possibleVals) + { + super(name2, description2, isrequired, defValue, value, possibleVals, + null); + } } -- 1.7.10.2