}
/**
+ * 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
AlignmentAnnotation getAlignmentConsensusAnnotation();
/**
+ * get the container for alignment gap annotation
+ *
+ * @return
+ */
+ AlignmentAnnotation getAlignmentGapAnnotation();
+
+ /**
* get the container for cDNA complement consensus annotation
*
* @return
protected AlignmentAnnotation complementConsensus;
+ protected AlignmentAnnotation gapcounts;
+
protected AlignmentAnnotation strucConsensus;
protected AlignmentAnnotation conservation;
}
@Override
+ public AlignmentAnnotation getAlignmentGapAnnotation()
+ {
+ return gapcounts;
+ }
+
+ @Override
public AlignmentAnnotation getComplementConsensusAnnotation()
{
return complementConsensus;
public void updateConsensus(final AlignmentViewPanel ap)
{
// see note in mantis : issue number 8585
- if (consensus == null || !autoCalculateConsensus)
+ if ((consensus == null || gapcounts == null) || !autoCalculateConsensus)
{
return;
}
consensus = new AlignmentAnnotation("Consensus", "PID",
new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
initConsensus(consensus);
+ gapcounts = new AlignmentAnnotation("Gaps", "Number of Gaps",
+ new Annotation[1], 0f, alignment.getHeight(),
+ AlignmentAnnotation.LINE_GRAPH);
+ initGapCounts(gapcounts);
initComplementConsensus();
}
}
}
+ // these should be extracted from the view model - style and settings for
+ // derived annotation
+ private void initGapCounts(AlignmentAnnotation gapcounts)
+ {
+ gapcounts.hasText = false;
+ gapcounts.autoCalculated = true;
+ gapcounts.graph = AlignmentAnnotation.BAR_GRAPH;
+
+ if (showConsensus)
+ {
+ alignment.addAnnotation(gapcounts);
+ }
+ }
+
private void initConservation()
{
if (showConservation)
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;
{
AlignmentAnnotation consensus = getConsensusAnnotation();
consensus.annotations = new Annotation[aWidth];
+ AlignmentAnnotation gap = getGapAnnotation();
+ if (gap!=null) {
+ gap.annotations = new Annotation[aWidth];
+ }
}
/**
}
/**
+ * 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.
*/
&& hconsensus != null)
{
deriveConsensus(consensus, hconsensus);
+ AlignmentAnnotation gap = getGapAnnotation();
+ if (gap != null)
+ {
+ deriveGap(gap, hconsensus);
+ }
}
}
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.