JAL-2629 moved HMM storage location to placeholder sequence
[jalview.git] / src / jalview / gui / AlignFrame.java
index 74e7652..0c951fa 100644 (file)
@@ -383,6 +383,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       }
     });
     buildColourMenu();
+    buildHMMERMenu();
 
     if (Desktop.desktop != null)
     {
@@ -489,6 +490,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
   }
 
+  private void buildHMMERMenu()
+  {
+    hmmerMenu.removeAll();
+
+    hmmerMenu.add(autoAlignSeqs);
+    hmmerMenu.addSeparator();
+
+    hmmerMenu.add(hmmAlign);
+    hmmerMenu.add(hmmBuild);
+    hmmerMenu.add(hmmSearch);
+    
+  }
+
   /**
    * Change the filename and format for the alignment, and enable the 'reload'
    * button functionality.
@@ -4669,11 +4683,36 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                                                                             // pipeline
             hmmFile.parse();
             HiddenMarkovModel hmm = hmmFile.getHMM();
+            AlignmentAnnotation annotArray[] = getViewport().getAlignment()
+                    .getAlignmentAnnotation();
+
+            AlignmentAnnotation reference = null;
+            for (AlignmentAnnotation annot : annotArray)
+            {
+              if (annot.label.contains("Reference"))
+              {
+                reference = annot;
+              }
+            }
+
+            if (reference != null)
+            {
+              hmm.mapToReferenceAnnotation(reference);
+            }
+
             AlignmentAnnotation annotation = hmm.createAnnotation(
                     getViewport().getAlignment().getWidth());
             getViewport().getAlignment().addAnnotation(annotation);
+            int length = getViewport().getAlignment().getWidth();
+            Sequence consensus = hmm.getConsensusSequence(length);
+            consensus.setHMM(hmm);
             annotation.setHMM(hmm);
+            SequenceI[] consensusArr = new Sequence[] { consensus };
+            AlignmentI newAlignment = new Alignment(consensusArr);
+            newAlignment.append(getViewport().getAlignment());
+            getViewport().setAlignment(newAlignment);
             isAnnotation = true;
+            alignPanel.repaint();
 
           }
           else if (FileFormat.Jnet.equals(format))