From: TZVanaalten Date: Fri, 1 Sep 2017 15:52:10 +0000 (+0100) Subject: JAL-2629 fix hmmbuild failing due to RF longer than alignment X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4490c246e02057d0e539233c2ef348ca561c8688;p=jalview.git JAL-2629 fix hmmbuild failing due to RF longer than alignment --- diff --git a/src/jalview/hmmer/HMMBuildThread.java b/src/jalview/hmmer/HMMBuildThread.java index 2fdc97b..346bcbd 100644 --- a/src/jalview/hmmer/HMMBuildThread.java +++ b/src/jalview/hmmer/HMMBuildThread.java @@ -325,7 +325,6 @@ public class HMMBuildThread implements Runnable break; } - } } diff --git a/src/jalview/hmmer/HMMERCommands.java b/src/jalview/hmmer/HMMERCommands.java index 4c1748b..ea795dd 100644 --- a/src/jalview/hmmer/HMMERCommands.java +++ b/src/jalview/hmmer/HMMERCommands.java @@ -4,6 +4,7 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; +import jalview.datamodel.Annotation; import jalview.datamodel.HiddenMarkovModel; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; @@ -143,10 +144,24 @@ public class HMMERCommands { if (annot.label.contains("Reference") || "RF".equals(annot.label)) { - newAl.addAnnotation(annot); + AlignmentAnnotation newRF; + if (annot.annotations.length > newAl.getWidth()) + { + Annotation[] rfAnnots = new Annotation[newAl.getWidth()]; + System.arraycopy(annot.annotations, 0, rfAnnots, 0, + rfAnnots.length); + newRF = new AlignmentAnnotation("RF", "Reference Positions", + rfAnnots); + } + else + { + newRF = new AlignmentAnnotation(annot); + } + newAl.addAnnotation(newRF); } } } + StockholmFile file = new StockholmFile(newAl); String output = file.print(seqs, false); PrintWriter writer = new PrintWriter(stoLocation); diff --git a/src/jalview/io/HMMFile.java b/src/jalview/io/HMMFile.java index 49d885c..f966f3f 100644 --- a/src/jalview/io/HMMFile.java +++ b/src/jalview/io/HMMFile.java @@ -133,9 +133,15 @@ public class HMMFile extends AlignFile @Override public void parse() throws IOException { - hmm = new HiddenMarkovModel(); - parseFileProperties(dataIn); - parseModel(dataIn); + try + { + hmm = new HiddenMarkovModel(); + parseFileProperties(dataIn); + parseModel(dataIn); + } catch (Exception e) + { + e.printStackTrace(); + } } /**