JAL-2629 multiple HMMs can now be dropped onto an alignment
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 91caebc..b3ccb45 100644 (file)
@@ -37,6 +37,8 @@ import jalview.datamodel.CigarArray;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.HiddenSequences;
+import jalview.datamodel.ProfileI;
+import jalview.datamodel.Profiles;
 import jalview.datamodel.ProfilesI;
 import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.Sequence;
@@ -702,20 +704,17 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   protected AlignmentAnnotation[] groupConservation;
 
-  protected AlignmentAnnotation[] groupInformation;
+  protected List<AlignmentAnnotation> groupInformation = new ArrayList<>();
 
-  protected AlignmentAnnotation information;
-
-  /**
-   * results of alignment information analysis for visible portion of view
-   */
-  protected ProfilesI hinformation = null;
+  protected List<AlignmentAnnotation> information = new ArrayList<>();
 
   /**
    * results of alignment consensus analysis for visible portion of view
    */
   protected ProfilesI hconsensus = null;
 
+  protected List<ProfilesI> hinformation = new ArrayList<>();
+
   /**
    * results of cDNA complement consensus visible portion of view
    */
@@ -766,18 +765,30 @@ public abstract class AlignmentViewport implements AlignViewportI,
   }
 
   @Override
-  public ProfilesI setSequenceInformationHash()
+  public void setSequenceInformationHashes(List<ProfilesI> info)
   {
-    return hinformation;
+    hinformation = info;
+  }
+
+  @Override
+  public void setSequenceInformationHash(ProfilesI info, int index)
+  {
+    hinformation.set(index, info);
   }
 
   @Override
-  public ProfilesI getSequenceInformationHash()
+  public List<ProfilesI> getSequenceInformationHashes()
   {
     return hinformation;
   }
 
   @Override
+  public ProfilesI getSequenceInformationHash(int index)
+  {
+    return hinformation.get(index);
+  }
+
+  @Override
   public Hashtable[] getComplementConsensusHash()
   {
     return hcomplementConsensus;
@@ -815,12 +826,19 @@ public abstract class AlignmentViewport implements AlignViewportI,
   }
 
   @Override
-  public AlignmentAnnotation getAlignmentInformationAnnotation()
+  public List<AlignmentAnnotation> getInformationAnnotations()
   {
     return information;
   }
 
   @Override
+  public AlignmentAnnotation getInformationAnnotation(int index)
+  {
+    return information.get(index);
+  }
+
+
+  @Override
   public AlignmentAnnotation getAlignmentGapAnnotation()
   {
     return gapcounts;
@@ -916,10 +934,6 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   public void updateInformation(final AlignmentViewPanel ap)
   {
-    if (information == null)
-    {
-      return;
-    }
     if (calculator
             .getRegisteredWorkersOfClass(InformationThread.class) == null)
     {
@@ -985,7 +999,6 @@ public abstract class AlignmentViewport implements AlignViewportI,
      * defensively null out references to large objects in case
      * this object is not garbage collected (as if!)
      */
-    information = null;
     consensus = null;
     complementConsensus = null;
     strucConsensus = null;
@@ -1959,9 +1972,15 @@ public abstract class AlignmentViewport implements AlignViewportI,
     {
       updateStrucConsensus(ap);
     }
-    if (information != null)
+    updateInformation(ap);
+
+    Map<Integer, SequenceI> hmmSequences;
+    hmmSequences = alignment.getHMMConsensusSequences(false);
+
+    for (Map.Entry<Integer, SequenceI> entry : hmmSequences.entrySet())
     {
-      updateInformation(ap);
+      SequenceI seq = entry.getValue();
+      seq.updateHMMMapping();
     }
 
     // Reset endRes of groups if beyond alignment width
@@ -1999,7 +2018,6 @@ public abstract class AlignmentViewport implements AlignViewportI,
       rs.alignmentChanged(alignment, hiddenRepSequences);
 
       rs.setConsensus(hconsensus);
-      rs.setInformation(hinformation);
       if (rs.conservationApplied())
       {
         rs.setConservation(Conservation.calculateConservation("All",
@@ -2100,7 +2118,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   public void initInformation(SequenceI hmmSequence)
   {
-    information = new AlignmentAnnotation("Information",
+    AlignmentAnnotation information;
+    information = new AlignmentAnnotation(hmmSequence.getName(),
             MessageManager.getString("label.information_description"),
             new Annotation[1], 0f, 6.52f, AlignmentAnnotation.BAR_GRAPH);
     information.hasText = true;
@@ -2108,6 +2127,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
     information.hasText = true;
     information.autoCalculated = false;
     information.sequenceRef = hmmSequence;
+    this.information.add(information);
+    hinformation.add(new Profiles(new ProfileI[1]));
     alignment.addAnnotation(information);
   }