JAL-1933 basic hack to get gap counts shown as an annotation row.
[jalview.git] / src / jalview / analysis / AAFrequency.java
index 17874e6..b5dab6f 100755 (executable)
@@ -289,6 +289,55 @@ public class AAFrequency
   }
 
   /**
+   * Derive the gap count annotation row.
+   * 
+   * @param consensus
+   *          the annotation row to add annotations to
+   * @param profiles
+   *          the source consensus data
+   * @param startCol
+   *          start column (inclusive)
+   * @param endCol
+   *          end column (exclusive)
+   */
+  public static void completeGapAnnot(AlignmentAnnotation consensus,
+          ProfilesI profiles, int startCol, int endCol, long nseq)
+  {
+    // long now = System.currentTimeMillis();
+    if (consensus == null || consensus.annotations == null
+            || consensus.annotations.length < endCol)
+    {
+      /*
+       * called with a bad alignment annotation row 
+       * wait for it to be initialised properly
+       */
+      return;
+    }
+
+    for (int i = startCol; i < endCol; i++)
+    {
+      ProfileI profile = profiles.get(i);
+      if (profile == null)
+      {
+        /*
+         * happens if sequences calculated over were 
+         * shorter than alignment width
+         */
+        consensus.annotations[i] = null;
+        return;
+      }
+
+      final int gapped = profile.getGapped();
+
+      String description = "" + gapped;
+
+      consensus.annotations[i] = new Annotation(gapped);
+    }
+    // long elapsed = System.currentTimeMillis() - now;
+    // System.out.println(-elapsed);
+  }
+
+  /**
    * Returns a tooltip showing either
    * <ul>
    * <li>the full profile (percentages of all residues present), if