X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fworkers%2FConsensusThread.java;h=c98c27d155f0585d33cb996219cd32634e981158;hb=17de9804e86a60c532039b6630d77480f903e9e0;hp=0278a3b20c9995adc4a9e871dddfca33c9b9cff1;hpb=8e1be43e250107a4d86898bd554cf03098fa5957;p=jalview.git diff --git a/src/jalview/workers/ConsensusThread.java b/src/jalview/workers/ConsensusThread.java index 0278a3b..c98c27d 100644 --- a/src/jalview/workers/ConsensusThread.java +++ b/src/jalview/workers/ConsensusThread.java @@ -28,7 +28,7 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; import jalview.datamodel.ProfilesI; import jalview.datamodel.SequenceI; -import jalview.schemes.CollectionColourSchemeI; +import jalview.renderer.ResidueShaderI; public class ConsensusThread extends AlignCalcWorker { @@ -50,19 +50,21 @@ 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) @@ -91,7 +93,7 @@ public class ConsensusThread extends AlignCalcWorker if (ap != null) { - ap.paintAlignment(true); + ap.paintAlignment(true, true); } } catch (OutOfMemoryError error) { @@ -116,7 +118,15 @@ public class ConsensusThread extends AlignCalcWorker protected void eraseConsensus(int aWidth) { AlignmentAnnotation consensus = getConsensusAnnotation(); - consensus.annotations = new Annotation[aWidth]; + if (consensus != null) + { + consensus.annotations = new Annotation[aWidth]; + } + AlignmentAnnotation gap = getGapAnnotation(); + if (gap != null) + { + gap.annotations = new Annotation[aWidth]; + } } /** @@ -127,8 +137,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); @@ -147,7 +157,7 @@ public class ConsensusThread extends AlignCalcWorker */ protected void setColourSchemeConsensus(ProfilesI hconsensus) { - CollectionColourSchemeI cs = alignViewport.getViewportColourScheme(); + ResidueShaderI cs = alignViewport.getResidueShading(); if (cs != null) { cs.setConsensus(hconsensus); @@ -165,6 +175,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 +202,11 @@ public class ConsensusThread extends AlignCalcWorker && hconsensus != null) { deriveConsensus(consensus, hconsensus); + AlignmentAnnotation gap = getGapAnnotation(); + if (gap != null) + { + deriveGap(gap, hconsensus); + } } } @@ -197,16 +222,31 @@ public class ConsensusThread extends AlignCalcWorker protected void deriveConsensus(AlignmentAnnotation consensusAnnotation, ProfilesI hconsensus) { - 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