import jalview.datamodel.Annotation;
import jalview.datamodel.ProfilesI;
import jalview.datamodel.SequenceI;
-import jalview.schemes.ColourSchemeI;
+import jalview.renderer.ResidueShaderI;
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;
}
while (!calcMan.notifyWorking(this))
{
- // System.err.println("Thread (Consensus"+Thread.currentThread().getName()+") Waiting around.");
+ // System.err.println("Thread
+ // (Consensus"+Thread.currentThread().getName()+") Waiting around.");
try
{
if (ap != null)
{
- ap.paintAlignment(false);
+ ap.paintAlignment(false, false);
}
Thread.sleep(200);
} catch (Exception ex)
if (ap != null)
{
- ap.paintAlignment(true);
+ ap.paintAlignment(true, true);
}
} catch (OutOfMemoryError error)
{
{
AlignmentAnnotation consensus = getConsensusAnnotation();
consensus.annotations = new Annotation[aWidth];
+ AlignmentAnnotation gap = getGapAnnotation();
+ if (gap != null)
+ {
+ gap.annotations = new Annotation[aWidth];
+ }
}
/**
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);
*/
protected void setColourSchemeConsensus(ProfilesI hconsensus)
{
- ColourSchemeI globalColourScheme = alignViewport
- .getGlobalColourScheme();
- if (globalColourScheme != null)
+ ResidueShaderI cs = alignViewport.getResidueShading();
+ if (cs != null)
{
- globalColourScheme.setConsensus(hconsensus);
+ cs.setConsensus(hconsensus);
}
}
}
/**
+ * 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);
+ }
}
}
{
long nseq = getSequences().length;
- AAFrequency.completeConsensus(consensusAnnotation, hconsensus, 0,
- hconsensus.getEndColumn() + 1,
+ AAFrequency.completeConsensus(consensusAnnotation, hconsensus,
+ 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,
+ hconsensus.getStartColumn(), hconsensus.getEndColumn() + 1,
+ nseq);
+ }
+
+ /**
* Get the consensus data stored on the viewport.
*
* @return