From 820c75d483648a2208039a00580bdc257b22e5f6 Mon Sep 17 00:00:00 2001 From: Mungo Carstairs Date: Mon, 9 Apr 2018 17:07:09 +0100 Subject: [PATCH] JAL-2629 more error checking --- src/jalview/datamodel/HiddenMarkovModel.java | 5 ++++- src/jalview/hmmer/HMMBuild.java | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/jalview/datamodel/HiddenMarkovModel.java b/src/jalview/datamodel/HiddenMarkovModel.java index a4270cd..dd27fa6 100644 --- a/src/jalview/datamodel/HiddenMarkovModel.java +++ b/src/jalview/datamodel/HiddenMarkovModel.java @@ -606,7 +606,10 @@ public class HiddenMarkovModel public void setNodes(List nodeList) { nodes = nodeList; - buildConsensusSequence(); + if (nodes.size() > 1) + { + buildConsensusSequence(); + } } } diff --git a/src/jalview/hmmer/HMMBuild.java b/src/jalview/hmmer/HMMBuild.java index d95be48..c596cec 100644 --- a/src/jalview/hmmer/HMMBuild.java +++ b/src/jalview/hmmer/HMMBuild.java @@ -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; -- 1.7.10.2