JAL-728 offer choice of substitution matrix for Quality calculation
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 5f84a5d..7d152ce 100644 (file)
@@ -51,6 +51,7 @@ import jalview.structure.VamsasSource;
 import jalview.util.Comparison;
 import jalview.util.MapList;
 import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
 import jalview.viewmodel.styles.ViewStyle;
 import jalview.workers.AlignCalcManager;
 import jalview.workers.ComplementConsensusThread;
@@ -674,6 +675,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   protected AlignmentAnnotation complementConsensus;
 
+  protected AlignmentAnnotation gapcounts;
+
   protected AlignmentAnnotation strucConsensus;
 
   protected AlignmentAnnotation conservation;
@@ -776,6 +779,12 @@ public abstract class AlignmentViewport implements AlignViewportI,
   }
 
   @Override
+  public AlignmentAnnotation getAlignmentGapAnnotation()
+  {
+    return gapcounts;
+  }
+
+  @Override
   public AlignmentAnnotation getComplementConsensusAnnotation()
   {
     return complementConsensus;
@@ -815,7 +824,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
   public void updateConsensus(final AlignmentViewPanel ap)
   {
     // see note in mantis : issue number 8585
-    if (consensus == null || !autoCalculateConsensus)
+    if ((consensus == null || gapcounts == null) || !autoCalculateConsensus)
     {
       return;
     }
@@ -1851,7 +1860,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
       {
         rs.setConservation(Conservation.calculateConservation("All",
                 alignment.getSequences(), 0, alignment.getWidth(), false,
-                getConsPercGaps(), false));
+                getConsPercGaps(), false, null));
       }
     }
 
@@ -1885,6 +1894,11 @@ public abstract class AlignmentViewport implements AlignViewportI,
       consensus = new AlignmentAnnotation("Consensus", "PID",
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       initConsensus(consensus);
+      gapcounts = new AlignmentAnnotation("Occupancy",
+              "Number of aligned positions",
+              new Annotation[1], 0f, alignment.getHeight(),
+              AlignmentAnnotation.BAR_GRAPH);
+      initGapCounts(gapcounts);
 
       initComplementConsensus();
     }
@@ -1937,6 +1951,20 @@ public abstract class AlignmentViewport implements AlignViewportI,
     }
   }
 
+  // these should be extracted from the view model - style and settings for
+  // derived annotation
+  private void initGapCounts(AlignmentAnnotation counts)
+  {
+    counts.hasText = false;
+    counts.autoCalculated = true;
+    counts.graph = AlignmentAnnotation.BAR_GRAPH;
+
+    if (showConsensus)
+    {
+      alignment.addAnnotation(counts);
+    }
+  }
+
   private void initConservation()
   {
     if (showConservation)
@@ -1961,8 +1989,9 @@ public abstract class AlignmentViewport implements AlignViewportI,
       if (quality == null)
       {
         quality = new AlignmentAnnotation("Quality",
-                "Alignment Quality based on Blosum62 scores",
-                new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
+                MessageManager.formatMessage("label.quality_label",
+                        "Blosum62"), new Annotation[1], 0f, 11f,
+                AlignmentAnnotation.BAR_GRAPH);
         quality.hasText = true;
         quality.autoCalculated = true;
         alignment.addAnnotation(quality);
@@ -2760,7 +2789,6 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   private boolean selectionIsDefinedGroup = false;
 
-
   @Override
   public boolean isSelectionDefinedGroup()
   {