From 69792203615f9cce5e384dab9b34dd2b90a958b5 Mon Sep 17 00:00:00 2001 From: TZVanaalten Date: Thu, 24 Aug 2017 15:08:02 +0100 Subject: [PATCH] JAL-2629 hmmsearch no longer throws an error if no sequences are found --- resources/lang/Messages.properties | 1 + src/jalview/hmmer/HMMSearchThread.java | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 38e29ed..f9aef72 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1329,6 +1329,7 @@ label.invalid_hmmer_folder = The folder that you selected does not contain the n warn.no_selected_hmm = Please select a hidden Markov model sequence. label.select_hmm = Select HMM warn.no_sequence_data = No sequence data found. +label.no_sequences_found = No matching sequences were found. 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. diff --git a/src/jalview/hmmer/HMMSearchThread.java b/src/jalview/hmmer/HMMSearchThread.java index b67ef6f..d6c0c29 100644 --- a/src/jalview/hmmer/HMMSearchThread.java +++ b/src/jalview/hmmer/HMMSearchThread.java @@ -2,7 +2,6 @@ package jalview.hmmer; import jalview.bin.Cache; import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenMarkovModel; import jalview.datamodel.SequenceI; @@ -17,7 +16,9 @@ import jalview.viewmodel.seqfeatures.FeatureRendererSettings; import jalview.ws.params.ArgumentI; import jalview.ws.params.simple.BooleanOption; +import java.io.BufferedReader; import java.io.File; +import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; @@ -265,6 +266,14 @@ public class HMMSearchThread implements Runnable */ private void importData() throws IOException, InterruptedException { + BufferedReader br = new BufferedReader( + new FileReader(inputAlignmentTemp)); + if (br.readLine() == null) + { + JOptionPane.showMessageDialog(af, + MessageManager.getString("label.no_sequences_found")); + return; + } StockholmFile file = new StockholmFile(new FileParse( inputAlignmentTemp.getAbsolutePath(), DataSourceType.FILE)); seqs = file.getSeqsAsArray(); @@ -280,16 +289,6 @@ public class HMMSearchThread implements Runnable { hmmAndSeqs = new SequenceI[seqs.length + 1]; } - - AlignmentAnnotation[] list = hmmSeq.getAnnotation(); - for (AlignmentAnnotation annot : list) - { - if ("HMM".equals(annot.getCalcId())) - { - hmmSeq.removeAlignmentAnnotation(annot); - } - } - hmmSeq.setHasInfo(false); hmmAndSeqs[0] = hmmSeq; if (numberOfSequences != null && seqs.length > numberOfSequences) -- 1.7.10.2