1 Clazz.declarePackage ("jalview.workers");
2 Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.strucConsensus = null;
6 this.hStrucConsensus = null;
10 Clazz.instantialize (this, arguments);
11 }, jalview.workers, "StrucConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);
12 Clazz.overrideMethod (c$, "getNewWorker",
14 return new jalview.workers.StrucConsensusThread (this.alignViewport, this.ap);
16 Clazz.overrideMethod (c$, "run1",
18 if (this.alignViewport.isClosed ()) {
19 this.abortAndDestroy ();
21 }while (!Thread.interrupted ()) {
25 if (this.calcMan.isPending (this)) return;
26 this.calcMan.notifyStart (this);
30 while (!this.calcMan.notifyWorking (this)) {
31 if (this.ap != null) {
32 this.ap.paintAlignment (false);
34 if (this.sleepAndReturn (200, state)) return;
36 if (Clazz.exceptionOf (e, InterruptedException)) {
44 if (this.alignViewport.isClosed ()) {
45 this.abortAndDestroy ();
48 }this.alignment = this.alignViewport.getAlignment ();
50 if (this.alignment == null || (this.aWidth = this.alignment.getWidth ()) < 0) {
52 }this.strucConsensus = this.alignViewport.getAlignmentStrucConsensusAnnotation ();
53 this.hStrucConsensus = this.alignViewport.getRnaStructureConsensusHash ();
54 this.strucConsensus.annotations = null;
55 this.strucConsensus.annotations = new Array (this.aWidth);
56 this.hStrucConsensus = new Array (this.aWidth);
57 this.aa = this.alignViewport.getAlignment ().getAlignmentAnnotation ();
58 for (var i = 0; i < this.aa.length; i++) {
59 if (this.aa[i].getRNAStruc () != null && this.aa[i].isValidStruc ()) {
60 this.rnaStruc = this.aa[i];
63 if (this.rnaStruc == null || !this.rnaStruc.isValidStruc ()) {
64 this.calcMan.workerComplete (this);
66 }this.arr = this.alignment.getSequencesArray ();
67 this.nseq = this.arr.length;
71 this.iFirst = this.iLast;
72 this.iLast = Math.min (this.iLast + this.nPer, this.aWidth);
73 if (this.iLast == this.iFirst) {
76 jalview.analysis.StructureFrequency.calculate (this.arr, 0, this.alignment.getWidth (), this.hStrucConsensus, true, this.rnaStruc);
77 if (this.sleepAndReturn (0, state)) return;
80 this.alignViewport.setRnaStructureConsensusHash (this.hStrucConsensus);
81 this.updateResultAnnotation (true);
82 if (this.alignViewport.getGlobalColourScheme () != null) {
83 this.alignViewport.getGlobalColourScheme ().setConsensus (this.hStrucConsensus);
88 if (Clazz.exceptionOf (e$$, OutOfMemoryError)) {
91 this.calcMan.workerCannotRun (this);
92 this.ap.raiseOOMWarning ("calculating RNA structure consensus", error);
97 System.out.println ("Error in ConsensusThread: " + e);
99 this.calcMan.workerComplete (this);
105 Clazz.overrideMethod (c$, "updateAnnotation",
107 this.updateResultAnnotation (false);
109 Clazz.defineMethod (c$, "updateResultAnnotation",
110 function (immediate) {
111 if (immediate || !this.calcMan.isWorking (this) && this.strucConsensus != null && this.hStrucConsensus != null) {
112 jalview.analysis.StructureFrequency.completeConsensus (this.strucConsensus, this.hStrucConsensus, 0, this.hStrucConsensus.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), this.nseq);