JAL-2629 more error checking
authorMungo Carstairs <gmungoc@gmail.com>
Mon, 9 Apr 2018 16:07:09 +0000 (17:07 +0100)
committerMungo Carstairs <gmungoc@gmail.com>
Mon, 9 Apr 2018 16:07:09 +0000 (17:07 +0100)
src/jalview/datamodel/HiddenMarkovModel.java
src/jalview/hmmer/HMMBuild.java

index a4270cd..dd27fa6 100644 (file)
@@ -606,7 +606,10 @@ public class HiddenMarkovModel
   public void setNodes(List<HMMNode> nodeList)
   {
     nodes = nodeList;
-    buildConsensusSequence();
+    if (nodes.size() > 1)
+    {
+      buildConsensusSequence();
+    }
   }
 }
 
index d95be48..c596cec 100644 (file)
@@ -12,6 +12,7 @@ import jalview.gui.JvOptionPane;
 import jalview.io.DataSourceType;
 import jalview.io.FileParse;
 import jalview.io.HMMFile;
+import jalview.util.FileUtils;
 import jalview.util.MessageManager;
 import jalview.ws.params.ArgumentI;
 
@@ -147,8 +148,8 @@ public class HMMBuild extends HmmerCommand
     File alignmentFile = null;
     try
     {
-      hmmFile = createTempFile("hmm", ".hmm");
-      alignmentFile = createTempFile("output", ".sto");
+      hmmFile = FileUtils.createTempFile("hmm", ".hmm");
+      alignmentFile = FileUtils.createTempFile("output", ".sto");
 
       if (ac instanceof Alignment)
       {
@@ -330,10 +331,22 @@ public class HMMBuild extends HmmerCommand
   private void importData(File hmmFile, AnnotatedCollectionI ac)
           throws IOException
   {
+    if (hmmFile.length() == 0L)
+    {
+      Cache.log.error("Error: hmmbuild produced empty hmm file");
+      return;
+    }
+
     HMMFile file = new HMMFile(
             new FileParse(hmmFile.getAbsolutePath(), DataSourceType.FILE));
     SequenceI hmmSeq = file.getHMM().getConsensusSequence();
 
+    if (hmmSeq == null)
+    {
+      // hmmbuild failure not detected earlier
+      return;
+    }
+
     if (ac instanceof SequenceGroup)
     {
       SequenceGroup grp = (SequenceGroup) ac;