From 679e63aab1a22d128bf429a07514eb15f8b288e1 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 2 Dec 2016 15:05:59 +0000 Subject: [PATCH] JAL-1933 gap value as description; minor formatting --- src/jalview/analysis/AAFrequency.java | 23 +++++++--------- src/jalview/viewmodel/AlignmentViewport.java | 35 ++++++++++++------------ src/jalview/workers/ConsensusThread.java | 38 ++++++++++++-------------- 3 files changed, 45 insertions(+), 51 deletions(-) diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index e682e2c..0e055e4 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -20,6 +20,10 @@ */ 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 list, - int start, int end) + public static final ProfilesI calculate(List 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(); diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 560ff59..da05a09 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -20,6 +20,17 @@ */ 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() { diff --git a/src/jalview/workers/ConsensusThread.java b/src/jalview/workers/ConsensusThread.java index 5c55d48..1cce3ff 100644 --- a/src/jalview/workers/ConsensusThread.java +++ b/src/jalview/workers/ConsensusThread.java @@ -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); - } /** -- 1.7.10.2