From dd2b17330673faf79c5e239afd163668fdb3fe0a Mon Sep 17 00:00:00 2001 From: tva Date: Wed, 10 Jul 2019 13:05:12 +0100 Subject: [PATCH] JAL-2629 fix hmmsearch/jackhmmer being unable to search through DB file --- resources/lang/Messages.properties | 4 +++ src/jalview/hmmer/HMMERParamStore.java | 25 ++++++-------- src/jalview/hmmer/HMMSearch.java | 57 ++++++++++++++++++++++++-------- src/jalview/hmmer/HmmerCommand.java | 8 +++-- src/jalview/hmmer/JackHMMER.java | 30 ++++++++--------- 5 files changed, 75 insertions(+), 49 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 3b22f2e..4ff30d4 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1378,13 +1378,17 @@ warn.command_failed = {0} failed label.invalid_folder = Invalid Folder label.number_of_results = Number of Results to Return label.auto_align_seqs = Automatically Align Fetched Sequences +label.new_returned = new sequences returned label.use_accessions = Return Accessions +label.check_for_new_sequences = Return Number of New Sequences label.seq_evalue = Sequence E-value Cut-off +label.evalue = E-Value label.seq_score = Sequence Score Threshold 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.check_for_new_sequences_desc = Display number of new sequences returned from hmmsearch compared to the previous alignment 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 (hmmsearch -T) diff --git a/src/jalview/hmmer/HMMERParamStore.java b/src/jalview/hmmer/HMMERParamStore.java index f95d738..65dd3b8 100644 --- a/src/jalview/hmmer/HMMERParamStore.java +++ b/src/jalview/hmmer/HMMERParamStore.java @@ -124,6 +124,10 @@ public final class HMMERParamStore implements ParamDatastoreI MessageManager.getString(HMMSearch.TRIM_TERMINI_KEY), MessageManager.getString("label.trim_termini_desc"), false, false, true, null)); + args.add(new BooleanOption( + MessageManager.getString(HMMSearch.RETURN_N_NEW_SEQ), + MessageManager.getString("label.check_for_new_sequences_desc"), + false, false, false, null)); /* * 'Parameters' @@ -135,11 +139,6 @@ public final class HMMERParamStore implements ParamDatastoreI String thisAlignment = MessageManager .getString(HMMSearch.THIS_ALIGNMENT_KEY); String database = MessageManager.getString("label.database"); - args.add(new RadioChoiceParameter( - MessageManager.getString("action.search"), null, - Arrays.asList(thisAlignment, - database), - thisAlignment)); args.add(new FileParameter(database, "", false, "", "")); args.add(new IntegerParameter( MessageManager.getString(HMMSearch.NUMBER_OF_RESULTS_KEY), @@ -153,11 +152,11 @@ public final class HMMERParamStore implements ParamDatastoreI args.add(new LogarithmicParameter( MessageManager.getString(HMMSearch.SEQ_EVALUE_KEY), MessageManager.getString("label.seq_e_value_desc"), false, 1D, - 1E-38, 10D)); + 1E-100, 10D)); args.add(new LogarithmicParameter( MessageManager.getString(HMMSearch.DOM_EVALUE_KEY), MessageManager.getString("label.dom_e_value_desc"), false, 1D, - 1E-38, 10D)); + 1E-100, 10D)); args.add( new DoubleParameter( MessageManager.getString(HMMSearch.SEQ_SCORE_KEY), @@ -186,18 +185,14 @@ public final class HMMERParamStore implements ParamDatastoreI // addChoiceOfDatabase(args); - String thisAlignment = MessageManager - .getString(JackHMMER.THIS_ALIGNMENT_KEY); String database = MessageManager.getString("label.database"); - args.add(new RadioChoiceParameter( - MessageManager.getString("action.search"), null, - Arrays.asList(thisAlignment, database), thisAlignment)); args.add(new FileParameter(database, "", false, "", "")); args.add(new RadioChoiceParameter( MessageManager.getString(JackHMMER.REPORTING_CUTOFF_KEY), null, - Arrays.asList(JackHMMER.CUTOFF_NONE, JackHMMER.CUTOFF_EVALUE, - JackHMMER.CUTOFF_SCORE), - JackHMMER.CUTOFF_EVALUE)); + Arrays.asList(MessageManager.getString(JackHMMER.CUTOFF_NONE), + MessageManager.getString(JackHMMER.CUTOFF_EVALUE), + MessageManager.getString(JackHMMER.CUTOFF_SCORE)), + MessageManager.getString(JackHMMER.CUTOFF_EVALUE))); args.add(new LogarithmicParameter( MessageManager.getString(JackHMMER.SEQ_EVALUE_KEY), MessageManager.getString("label.seq_e_value_desc"), false, 1D, diff --git a/src/jalview/hmmer/HMMSearch.java b/src/jalview/hmmer/HMMSearch.java index f714afc..d2b469f 100644 --- a/src/jalview/hmmer/HMMSearch.java +++ b/src/jalview/hmmer/HMMSearch.java @@ -39,8 +39,12 @@ public class HMMSearch extends HmmerCommand boolean trim = false; + boolean returnNoOfNewSeqs = false; + int seqsToReturn = Integer.MAX_VALUE; + boolean searchAlignment = true; + SequenceI[] seqs; private String databaseName; @@ -168,7 +172,6 @@ public class HMMSearch extends HmmerCommand String seqScoreCutoff = null; String domScoreCutoff = null; databaseName = "Alignment"; - boolean searchAlignment = false; if (params != null) { @@ -180,18 +183,6 @@ public class HMMSearch extends HmmerCommand { seqsToReturn = Integer.parseInt(arg.getValue()); } - else if (MessageManager.getString("action.search").equals(name)) - { - searchAlignment = arg.getValue().equals( - MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY)); - } - else if (MessageManager.getString(DATABASE_KEY).equals(name)) - { - dbPath = arg.getValue(); - int pos = dbPath.lastIndexOf(File.separator); - databaseName = dbPath.substring(pos + 1); - databaseFile = new File(dbPath); - } else if (MessageManager.getString(AUTO_ALIGN_SEQS_KEY) .equals(name)) { @@ -247,6 +238,11 @@ public class HMMSearch extends HmmerCommand databaseName = dbPath.substring(pos + 1); databaseFile = new File(dbPath); } + searchAlignment = false; + } + else if (MessageManager.getString(RETURN_N_NEW_SEQ).equals(name)) + { + returnNoOfNewSeqs = true; } } } @@ -314,7 +310,10 @@ public class HMMSearch extends HmmerCommand inputAlignmentTemp.getAbsolutePath(), DataSourceType.FILE)); seqs = file.getSeqsAsArray(); - recoverSequences(sequencesHash, seqs); + if (searchAlignment) + { + recoverSequences(sequencesHash, seqs); + } // look for PP cons and ref seq in alignment only annotation AlignmentAnnotation modelpos = null, ppcons = null; @@ -365,6 +364,7 @@ public class HMMSearch extends HmmerCommand } } } + if (realign) { realignResults(hmmAndSeqs); @@ -386,8 +386,14 @@ public class HMMSearch extends HmmerCommand + hmmSeq.getName(); Desktop.addInternalFrame(alignFrame, ttl, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + + int nNew = checkForNewSequences(); + JvOptionPane.showMessageDialog(af.alignPanel, nNew + " " + + MessageManager.getString("label.new_returned")); + } + hmmTemp.delete(); inputAlignmentTemp.delete(); searchOutputFile.delete(); @@ -400,6 +406,25 @@ public class HMMSearch extends HmmerCommand } } + private int checkForNewSequences() + { + int nNew = seqs.length; + + for (SequenceI resultSeq : seqs) + { + for (SequenceI aliSeq : alignment.getSequencesArray()) + { + if (resultSeq.getName().equals(aliSeq.getName())) + { + nNew--; + } + } + } + + return nNew; + + } + /** * Realigns the given sequences using hmmalign, to the HMM profile sequence * which is the first in the array, and opens the results in a new frame @@ -428,6 +453,10 @@ public class HMMSearch extends HmmerCommand } HmmerCommand hmmalign = new HMMAlign(frame, alignArgs); hmmalign.run(); + + int nNew = checkForNewSequences(); + JvOptionPane.showMessageDialog(frame.alignPanel, + nNew + " " + MessageManager.getString("label.new_returned")); } /** diff --git a/src/jalview/hmmer/HmmerCommand.java b/src/jalview/hmmer/HmmerCommand.java index 6eb294f..a30c524 100644 --- a/src/jalview/hmmer/HmmerCommand.java +++ b/src/jalview/hmmer/HmmerCommand.java @@ -62,13 +62,15 @@ public abstract class HmmerCommand implements Runnable static final String TRIM_TERMINI_KEY = "label.trim_termini"; + static final String RETURN_N_NEW_SEQ = "label.check_for_new_sequences"; + static final String REPORTING_CUTOFF_KEY = "label.reporting_cutoff"; - static final String CUTOFF_NONE = "None"; + static final String CUTOFF_NONE = "label.default"; - static final String CUTOFF_SCORE = "Score"; + static final String CUTOFF_SCORE = "label.score"; - static final String CUTOFF_EVALUE = "E-Value"; + static final String CUTOFF_EVALUE = "label.evalue"; static final String SEQ_EVALUE_KEY = "label.seq_evalue"; diff --git a/src/jalview/hmmer/JackHMMER.java b/src/jalview/hmmer/JackHMMER.java index e532ab7..4435b14 100644 --- a/src/jalview/hmmer/JackHMMER.java +++ b/src/jalview/hmmer/JackHMMER.java @@ -40,6 +40,8 @@ public class JackHMMER extends HmmerCommand private String databaseName; + boolean searchAlignment = true; + Hashtable sequencesHash; /** @@ -163,7 +165,6 @@ public class JackHMMER extends HmmerCommand String seqScoreCutoff = null; String domScoreCutoff = null; databaseName = "Alignment"; - boolean searchAlignment = false; if (params != null) { @@ -171,26 +172,16 @@ public class JackHMMER extends HmmerCommand { String name = arg.getName(); - if (MessageManager.getString("action.search").equals(name)) - { - searchAlignment = arg.getValue().equals( - MessageManager.getString(JackHMMER.THIS_ALIGNMENT_KEY)); - } - else if (MessageManager.getString(DATABASE_KEY).equals(name)) - { - dbPath = arg.getValue(); - int pos = dbPath.lastIndexOf(File.separator); - databaseName = dbPath.substring(pos + 1); - databaseFile = new File(dbPath); - } - else if (MessageManager.getString(REPORTING_CUTOFF_KEY) + if (MessageManager.getString(REPORTING_CUTOFF_KEY) .equals(name)) { - if (CUTOFF_EVALUE.equals(arg.getValue())) + if (MessageManager.getString(CUTOFF_EVALUE) + .equals(arg.getValue())) { useEvalueCutoff = true; } - else if (CUTOFF_SCORE.equals(arg.getValue())) + else if (MessageManager.getString(CUTOFF_SCORE) + .equals(arg.getValue())) { useScoreCutoff = true; } @@ -221,6 +212,7 @@ public class JackHMMER extends HmmerCommand databaseName = dbPath.substring(pos + 1); databaseFile = new File(dbPath); } + searchAlignment = false; } } } @@ -284,7 +276,10 @@ public class JackHMMER extends HmmerCommand inputAlignmentTemp.getAbsolutePath(), DataSourceType.FILE)); seqs = file.getSeqsAsArray(); - recoverSequences(sequencesHash, seqs); + if (searchAlignment) + { + recoverSequences(sequencesHash, seqs); + } readTable(searchOutputFile); @@ -375,6 +370,7 @@ public class JackHMMER extends HmmerCommand annot.setSequenceRef(seq); seq.addAlignmentAnnotation(annot); + } catch (NumberFormatException e) { System.err.println("Error parsing " + label + " from " + eValue -- 1.7.10.2