JAL-1807 test
[jalviewjs.git] / bin / jalview / workers / ConservationThread.js
1 Clazz.declarePackage ("jalview.workers");
2 Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.ConservationThread", ["jalview.analysis.Conservation", "jalview.schemes.ResidueProperties", "java.util.ArrayList"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.ConsPercGaps = 25;
5 this.cons = null;
6 this.conservation = null;
7 this.quality = null;
8 Clazz.instantialize (this, arguments);
9 }, jalview.workers, "ConservationThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);
10 Clazz.overrideMethod (c$, "getNewWorker", 
11 function () {
12 return  new jalview.workers.ConservationThread (this.alignViewport, this.ap);
13 });
14 Clazz.makeConstructor (c$, 
15 function (alignViewport, alignPanel) {
16 Clazz.superConstructor (this, jalview.workers.ConservationThread, [alignViewport, alignPanel]);
17 this.ConsPercGaps = alignViewport.getConsPercGaps ();
18 }, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel");
19 Clazz.overrideMethod (c$, "run1", 
20 function (state) {
21 while (!Thread.interrupted ()) {
22 try {
23 switch (state) {
24 case 0:
25 if (this.calcMan.isPending (this)) return;
26 this.calcMan.notifyStart (this);
27 state = 3;
28 break;
29 case 3:
30 while (!this.calcMan.notifyWorking (this)) {
31 if (this.ap != null) {
32 this.ap.paintAlignment (false);
33 }try {
34 if (this.sleepAndReturn (200, state)) return;
35 } catch (e) {
36 if (Clazz.exceptionOf (e, InterruptedException)) {
37 state = 2;
38 break;
39 } else {
40 throw e;
41 }
42 }
43 }
44 if (this.alignViewport.isClosed ()) {
45 this.abortAndDestroy ();
46 state = 2;
47 break;
48 }var ourAnnot =  new java.util.ArrayList ();
49 this.alignment = this.alignViewport.getAlignment ();
50 this.conservation = this.alignViewport.getAlignmentConservationAnnotation ();
51 this.quality = this.alignViewport.getAlignmentQualityAnnot ();
52 ourAnnot.add (this.conservation);
53 ourAnnot.add (this.quality);
54 this.ourAnnots = ourAnnot;
55 this.ConsPercGaps = this.alignViewport.getConsPercGaps ();
56 if (this.alignment == null || (this.aWidth = this.alignment.getWidth ()) < 0) {
57 this.calcMan.workerComplete (this);
58 return;
59 }state = 4;
60 break;
61 case 4:
62 this.iFirst = this.iLast;
63 this.nPer = this.aWidth + 1;
64 this.iLast = Math.min (this.iLast + this.nPer, this.aWidth);
65 if (this.iLast == this.iFirst) {
66 state = 2;
67 } else {
68 this.computeConsensus ();
69 if (this.sleepAndReturn (0, state)) return;
70 }break;
71 case 2:
72 this.updateResultAnnotation (true);
73 this.notifyDone ();
74 return;
75 }
76 } catch (e$$) {
77 if (Clazz.exceptionOf (e$$, OutOfMemoryError)) {
78 var error = e$$;
79 {
80 this.calcMan.workerCannotRun (this);
81 this.ap.raiseOOMWarning ("calculating conservation", error);
82 }
83 } else {
84 var e = e$$;
85 {
86 System.out.println ("Error in ConsensusThread: " + e);
87 e.printStackTrace ();
88 this.calcMan.workerComplete (this);
89 }
90 }
91 }
92 }
93 }, "~N");
94 Clazz.defineMethod (c$, "computeConsensus", 
95 ($fz = function () {
96 this.cons = jalview.analysis.Conservation.calculateConservation ("All", jalview.schemes.ResidueProperties.propHash, 3, this.alignment.getSequences (), 0, this.aWidth - 1, false, this.ConsPercGaps, this.quality != null);
97 }, $fz.isPrivate = true, $fz));
98 Clazz.defineMethod (c$, "updateResultAnnotation", 
99 ($fz = function (b) {
100 if (b || !this.calcMan.isWorking (this) && this.cons != null && this.conservation != null && this.quality != null) {
101 this.alignViewport.setConservation (this.cons);
102 this.cons.completeAnnotations (this.conservation, this.quality, 0, this.aWidth);
103 }}, $fz.isPrivate = true, $fz), "~B");
104 Clazz.overrideMethod (c$, "updateAnnotation", 
105 function () {
106 this.updateResultAnnotation (false);
107 });
108 });