JAL-1933 gap value as description; minor formatting
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 2 Dec 2016 15:05:59 +0000 (15:05 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 2 Dec 2016 15:05:59 +0000 (15:05 +0000)
src/jalview/analysis/AAFrequency.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/workers/ConsensusThread.java

index e682e2c..0e055e4 100755 (executable)
  */
 package jalview.analysis;
 
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.List;
+
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
@@ -37,10 +41,6 @@ import jalview.util.Format;
 import jalview.util.MappingUtils;
 import jalview.util.QuickSort;
 
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.List;
-
 /**
  * Takes in a vector or array of sequences and column start and column end and
  * returns a new Hashtable[] of size maxSeqLength, if Hashtable not supplied.
@@ -67,8 +67,8 @@ public class AAFrequency
     }
   }
 
-  public static final ProfilesI calculate(List<SequenceI> list,
-          int start, int end)
+  public static final ProfilesI calculate(List<SequenceI> list, int start,
+          int end)
   {
     return calculate(list, start, end, false);
   }
@@ -303,7 +303,6 @@ public class AAFrequency
   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)
     {
@@ -331,12 +330,11 @@ public class AAFrequency
 
       final int gapped = profile.getGapped();
 
-      String description = "" + gapped;
+      String description = String.valueOf(gapped);
 
-      consensus.annotations[i] = new Annotation(gapped);
+      consensus.annotations[i] = new Annotation("", description, '0',
+              gapped);
     }
-    // long elapsed = System.currentTimeMillis() - now;
-    // System.out.println(-elapsed);
   }
 
   /**
@@ -408,8 +406,7 @@ public class AAFrequency
    *          calculations
    * @return
    */
-  public static int[] extractProfile(ProfileI profile,
-          boolean ignoreGaps)
+  public static int[] extractProfile(ProfileI profile, boolean ignoreGaps)
   {
     int[] rtnval = new int[64];
     ResidueCount counts = profile.getCounts();
index 560ff59..da05a09 100644 (file)
  */
 package jalview.viewmodel;
 
+import java.awt.Color;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.analysis.Conservation;
 import jalview.api.AlignCalcManagerI;
@@ -57,17 +68,6 @@ import jalview.workers.ComplementConsensusThread;
 import jalview.workers.ConsensusThread;
 import jalview.workers.StrucConsensusThread;
 
-import java.awt.Color;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
 /**
  * base class holding visualization and analysis attributes and common logic for
  * an active alignment view displayed in the GUI
@@ -1913,7 +1913,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
       initConsensus(consensus);
       gapcounts = new AlignmentAnnotation("Gaps", "Number of Gaps",
               new Annotation[1], 0f, alignment.getHeight(),
-              AlignmentAnnotation.LINE_GRAPH);
+              AlignmentAnnotation.BAR_GRAPH);
       initGapCounts(gapcounts);
 
       initComplementConsensus();
@@ -1969,15 +1969,15 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   // these should be extracted from the view model - style and settings for
   // derived annotation
-  private void initGapCounts(AlignmentAnnotation gapcounts)
+  private void initGapCounts(AlignmentAnnotation counts)
   {
-    gapcounts.hasText = false;
-    gapcounts.autoCalculated = true;
-    gapcounts.graph = AlignmentAnnotation.BAR_GRAPH;
+    counts.hasText = false;
+    counts.autoCalculated = true;
+    counts.graph = AlignmentAnnotation.BAR_GRAPH;
 
     if (showConsensus)
     {
-      alignment.addAnnotation(gapcounts);
+      alignment.addAnnotation(counts);
     }
   }
 
@@ -2851,7 +2851,6 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   private boolean selectionIsDefinedGroup = false;
 
-
   @Override
   public boolean isSelectionDefinedGroup()
   {
index 5c55d48..1cce3ff 100644 (file)
@@ -119,7 +119,8 @@ public class ConsensusThread extends AlignCalcWorker
     AlignmentAnnotation consensus = getConsensusAnnotation();
     consensus.annotations = new Annotation[aWidth];
     AlignmentAnnotation gap = getGapAnnotation();
-    if (gap!=null) {
+    if (gap != null)
+    {
       gap.annotations = new Annotation[aWidth];
     }
   }
@@ -132,8 +133,8 @@ public class ConsensusThread extends AlignCalcWorker
 
     SequenceI[] aseqs = getSequences();
     int width = alignment.getWidth();
-    ProfilesI hconsensus = AAFrequency.calculate(aseqs, width, 0,
-            width, true);
+    ProfilesI hconsensus = AAFrequency.calculate(aseqs, width, 0, width,
+            true);
 
     alignViewport.setSequenceConsensusHash(hconsensus);
     setColourSchemeConsensus(hconsensus);
@@ -221,29 +222,26 @@ public class ConsensusThread extends AlignCalcWorker
 
     long nseq = getSequences().length;
     AAFrequency.completeConsensus(consensusAnnotation, hconsensus,
-            hconsensus.getStartColumn(),
-            hconsensus.getEndColumn() + 1,
+            hconsensus.getStartColumn(), hconsensus.getEndColumn() + 1,
             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,
+  /**
+   * 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);
-
   }
 
   /**