1 Clazz.declarePackage ("jalview.workers");
2 Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency", "java.lang.Thread"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.strucConsensus = null;
5 this.hStrucConsensus = null;
7 Clazz.instantialize (this, arguments);
8 }, jalview.workers, "StrucConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);
9 Clazz.overrideMethod (c$, "run",
12 if (this.calcMan.isPending (this)) {
14 }this.calcMan.notifyStart (this);
15 while (!this.calcMan.notifyWorking (this)) {
17 if (this.ap != null) {
20 if (Clazz.exceptionOf (ex, Exception)) {
21 ex.printStackTrace ();
27 if (this.alignViewport.isClosed ()) {
28 this.abortAndDestroy ();
30 }var alignment = this.alignViewport.getAlignment ();
32 if (alignment == null || (aWidth = alignment.getWidth ()) < 0) {
33 this.calcMan.workerComplete (this);
35 }this.strucConsensus = this.alignViewport.getAlignmentStrucConsensusAnnotation ();
36 this.hStrucConsensus = this.alignViewport.getRnaStructureConsensusHash ();
37 this.strucConsensus.annotations = null;
38 this.strucConsensus.annotations = new Array (aWidth);
39 this.hStrucConsensus = new Array (aWidth);
40 var aa = this.alignViewport.getAlignment ().getAlignmentAnnotation ();
42 for (var i = 0; i < aa.length; i++) {
43 if (aa[i].getRNAStruc () != null && aa[i].isValidStruc ()) {
47 if (rnaStruc == null || !rnaStruc.isValidStruc ()) {
48 this.calcMan.workerComplete (this);
51 var arr = alignment.getSequencesArray ();
52 this.nseq = arr.length;
53 jalview.analysis.StructureFrequency.calculate (arr, 0, alignment.getWidth (), this.hStrucConsensus, true, rnaStruc);
55 if (Clazz.exceptionOf (x, ArrayIndexOutOfBoundsException)) {
56 this.calcMan.workerComplete (this);
62 this.alignViewport.setRnaStructureConsensusHash (this.hStrucConsensus);
63 this.updateResultAnnotation (true);
64 if (this.alignViewport.getGlobalColourScheme () != null) {
65 this.alignViewport.getGlobalColourScheme ().setConsensus (this.hStrucConsensus);
67 if (Clazz.exceptionOf (error, OutOfMemoryError)) {
68 this.calcMan.workerCannotRun (this);
69 this.ap.raiseOOMWarning ("calculating RNA structure consensus", error);
74 this.calcMan.workerComplete (this);
75 if (this.ap != null) {
76 this.ap.paintAlignment (true);
79 Clazz.overrideMethod (c$, "updateAnnotation",
81 this.updateResultAnnotation (false);
83 Clazz.defineMethod (c$, "updateResultAnnotation",
84 function (immediate) {
85 if (immediate || !this.calcMan.isWorking (this) && this.strucConsensus != null && this.hStrucConsensus != null) {
86 jalview.analysis.StructureFrequency.completeConsensus (this.strucConsensus, this.hStrucConsensus, 0, this.hStrucConsensus.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), this.nseq);