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