JAL-2629 fix hmmbuild failing due to RF longer than alignment features/hmmer
authorTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Fri, 1 Sep 2017 15:52:10 +0000 (16:52 +0100)
committerTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Fri, 1 Sep 2017 15:52:10 +0000 (16:52 +0100)
src/jalview/hmmer/HMMBuildThread.java
src/jalview/hmmer/HMMERCommands.java
src/jalview/io/HMMFile.java

index 2fdc97b..346bcbd 100644 (file)
@@ -325,7 +325,6 @@ public class HMMBuildThread implements Runnable
           break;
 
         }
-
       }
     }
 
index 4c1748b..ea795dd 100644 (file)
@@ -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);
index 49d885c..f966f3f 100644 (file)
@@ -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();
+    }
   }
 
   /**