JAL-1933 basic hack to get gap counts shown as an annotation row.
[jalview.git] / src / jalview / workers / ConsensusThread.java
index debe45d..5c55d48 100644 (file)
@@ -50,7 +50,8 @@ public class ConsensusThread extends AlignCalcWorker
     try
     {
       AlignmentAnnotation consensus = getConsensusAnnotation();
-      if (consensus == null || calcMan.isPending(this))
+      AlignmentAnnotation gap = getGapAnnotation();
+      if ((consensus == null && gap == null) || calcMan.isPending(this))
       {
         calcMan.workerComplete(this);
         return;
@@ -117,6 +118,10 @@ public class ConsensusThread extends AlignCalcWorker
   {
     AlignmentAnnotation consensus = getConsensusAnnotation();
     consensus.annotations = new Annotation[aWidth];
+    AlignmentAnnotation gap = getGapAnnotation();
+    if (gap!=null) {
+      gap.annotations = new Annotation[aWidth];
+    }
   }
 
   /**
@@ -166,6 +171,16 @@ public class ConsensusThread extends AlignCalcWorker
   }
 
   /**
+   * Get the Gap annotation for the alignment
+   * 
+   * @return
+   */
+  protected AlignmentAnnotation getGapAnnotation()
+  {
+    return alignViewport.getAlignmentGapAnnotation();
+  }
+
+  /**
    * update the consensus annotation from the sequence profile data using
    * current visualization settings.
    */
@@ -183,6 +198,11 @@ public class ConsensusThread extends AlignCalcWorker
             && hconsensus != null)
     {
       deriveConsensus(consensus, hconsensus);
+      AlignmentAnnotation gap = getGapAnnotation();
+      if (gap != null)
+      {
+        deriveGap(gap, hconsensus);
+      }
     }
   }
 
@@ -206,6 +226,25 @@ public class ConsensusThread extends AlignCalcWorker
             alignViewport.isIgnoreGapsConsensus(),
             alignViewport.isShowSequenceLogo(), nseq);
   }
+    /**
+     * Convert the computed consensus data into a gap annotation row for
+     * display.
+     * 
+     * @param gapAnnotation
+     *          the annotation to be populated
+     * @param hconsensus
+     *          the computed consensus data
+     */
+    protected void deriveGap(AlignmentAnnotation gapAnnotation,
+            ProfilesI hconsensus)
+    {
+
+      long nseq = getSequences().length;
+      AAFrequency.completeGapAnnot(gapAnnotation, hconsensus,
+            hconsensus.getStartColumn(), hconsensus.getEndColumn() + 1,
+            nseq);
+
+  }
 
   /**
    * Get the consensus data stored on the viewport.