JAL-2629 hmmsearch no longer throws an error if no sequences are found
authorTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Thu, 24 Aug 2017 14:08:02 +0000 (15:08 +0100)
committerTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Fri, 25 Aug 2017 16:21:03 +0000 (17:21 +0100)
resources/lang/Messages.properties
src/jalview/hmmer/HMMSearchThread.java

index 38e29ed..f9aef72 100644 (file)
@@ -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.
index b67ef6f..d6c0c29 100644 (file)
@@ -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)