1 Clazz.declarePackage ("jalview.workers");
\r
2 Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency", "java.lang.Thread"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.strucConsensus = null;
\r
5 this.hStrucConsensus = null;
\r
7 Clazz.instantialize (this, arguments);
\r
8 }, jalview.workers, "StrucConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);
\r
9 Clazz.overrideMethod (c$, "getNewWorker",
\r
11 return new jalview.workers.StrucConsensusThread (this.alignViewport, this.ap);
\r
13 Clazz.overrideMethod (c$, "run",
\r
16 if (this.calcMan.isPending (this)) {
\r
18 }this.calcMan.notifyStart (this);
\r
19 while (!this.calcMan.notifyWorking (this)) {
\r
21 if (this.ap != null) {
\r
22 }Thread.sleep (200);
\r
24 if (Clazz.exceptionOf (ex, Exception)) {
\r
25 ex.printStackTrace ();
\r
31 if (this.alignViewport.isClosed ()) {
\r
32 this.abortAndDestroy ();
\r
34 }var alignment = this.alignViewport.getAlignment ();
\r
36 if (alignment == null || (aWidth = alignment.getWidth ()) < 0) {
\r
37 this.calcMan.workerComplete (this);
\r
39 }this.strucConsensus = this.alignViewport.getAlignmentStrucConsensusAnnotation ();
\r
40 this.hStrucConsensus = this.alignViewport.getRnaStructureConsensusHash ();
\r
41 this.strucConsensus.annotations = null;
\r
42 this.strucConsensus.annotations = new Array (aWidth);
\r
43 this.hStrucConsensus = new Array (aWidth);
\r
44 var aa = this.alignViewport.getAlignment ().getAlignmentAnnotation ();
\r
45 var rnaStruc = null;
\r
46 for (var i = 0; i < aa.length; i++) {
\r
47 if (aa[i].getRNAStruc () != null && aa[i].isValidStruc ()) {
\r
51 if (rnaStruc == null || !rnaStruc.isValidStruc ()) {
\r
52 this.calcMan.workerComplete (this);
\r
55 var arr = alignment.getSequencesArray ();
\r
56 this.nseq = arr.length;
\r
57 jalview.analysis.StructureFrequency.calculate (arr, 0, alignment.getWidth (), this.hStrucConsensus, true, rnaStruc);
\r
59 if (Clazz.exceptionOf (x, ArrayIndexOutOfBoundsException)) {
\r
60 this.calcMan.workerComplete (this);
\r
66 this.alignViewport.setRnaStructureConsensusHash (this.hStrucConsensus);
\r
67 this.updateResultAnnotation (true);
\r
68 if (this.alignViewport.getGlobalColourScheme () != null) {
\r
69 this.alignViewport.getGlobalColourScheme ().setConsensus (this.hStrucConsensus);
\r
71 if (Clazz.exceptionOf (error, OutOfMemoryError)) {
\r
72 this.calcMan.workerCannotRun (this);
\r
73 this.ap.raiseOOMWarning ("calculating RNA structure consensus", error);
\r
78 this.calcMan.workerComplete (this);
\r
79 if (this.ap != null) {
\r
80 this.ap.paintAlignment (true);
\r
83 Clazz.overrideMethod (c$, "updateAnnotation",
\r
85 this.updateResultAnnotation (false);
\r
87 Clazz.defineMethod (c$, "updateResultAnnotation",
\r
88 function (immediate) {
\r
89 if (immediate || !this.calcMan.isWorking (this) && this.strucConsensus != null && this.hStrucConsensus != null) {
\r
90 jalview.analysis.StructureFrequency.completeConsensus (this.strucConsensus, this.hStrucConsensus, 0, this.hStrucConsensus.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), this.nseq);
\r
92 Clazz.overrideMethod (c$, "run1",
\r