X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fworkers%2FConsensusThread.java;fp=src%2Fjalview%2Fworkers%2FConsensusThread.java;h=284f1a164b28c03ca351b6214fe2cd9704cc43d3;hb=d5bcc3830eab04e6db816e1c2ad8fce1dc189612;hp=0c7e69ad84c3f3b89313c3592f412c5008ba81e4;hpb=3ebdd4e28382e38a181aae1eed71549f603f9025;p=jalview.git diff --git a/src/jalview/workers/ConsensusThread.java b/src/jalview/workers/ConsensusThread.java index 0c7e69a..284f1a1 100644 --- a/src/jalview/workers/ConsensusThread.java +++ b/src/jalview/workers/ConsensusThread.java @@ -50,7 +50,8 @@ 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; @@ -117,6 +118,11 @@ public class ConsensusThread extends AlignCalcWorker { AlignmentAnnotation consensus = getConsensusAnnotation(); consensus.annotations = new Annotation[aWidth]; + AlignmentAnnotation gap = getGapAnnotation(); + if (gap != null) + { + gap.annotations = new Annotation[aWidth]; + } } /** @@ -127,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); @@ -165,6 +171,16 @@ public class ConsensusThread extends AlignCalcWorker } /** + * 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. */ @@ -182,6 +198,11 @@ public class ConsensusThread extends AlignCalcWorker && hconsensus != null) { deriveConsensus(consensus, hconsensus); + AlignmentAnnotation gap = getGapAnnotation(); + if (gap != null) + { + deriveGap(gap, hconsensus); + } } } @@ -200,13 +221,29 @@ 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, + hconsensus.getStartColumn(), hconsensus.getEndColumn() + 1, + nseq); + } + + /** * Get the consensus data stored on the viewport. * * @return