JAL-1807
[jalview.git] / site / j2s / 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.lang.Thread", "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 this.alWidth = 0;
9 Clazz.instantialize (this, arguments);
10 }, jalview.workers, "ConservationThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);
11 Clazz.makeConstructor (c$, 
12 function (alignViewport, alignPanel) {
13 Clazz.superConstructor (this, jalview.workers.ConservationThread, [alignViewport, alignPanel]);
14 this.ConsPercGaps = alignViewport.getConsPercGaps ();
15 }, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel");
16 Clazz.overrideMethod (c$, "run", 
17 function () {
18 try {
19 this.calcMan.notifyStart (this);
20 while (!this.calcMan.notifyWorking (this)) {
21 try {
22 if (this.ap != null) {
23 }Thread.sleep (200);
24 } catch (ex) {
25 if (Clazz.exceptionOf (ex, Exception)) {
26 ex.printStackTrace ();
27 } else {
28 throw ex;
29 }
30 }
31 }
32 if (this.alignViewport.isClosed ()) {
33 this.abortAndDestroy ();
34 return;
35 }var ourAnnot =  new java.util.ArrayList ();
36 var alignment = this.alignViewport.getAlignment ();
37 this.conservation = this.alignViewport.getAlignmentConservationAnnotation ();
38 this.quality = this.alignViewport.getAlignmentQualityAnnot ();
39 ourAnnot.add (this.conservation);
40 ourAnnot.add (this.quality);
41 this.ourAnnots = ourAnnot;
42 this.ConsPercGaps = this.alignViewport.getConsPercGaps ();
43 if (alignment == null || (this.alWidth = alignment.getWidth ()) < 0) {
44 this.calcMan.workerComplete (this);
45 return;
46 }try {
47 this.cons = jalview.analysis.Conservation.calculateConservation ("All", jalview.schemes.ResidueProperties.propHash, 3, alignment.getSequences (), 0, this.alWidth - 1, false, this.ConsPercGaps, this.quality != null);
48 } catch (x) {
49 if (Clazz.exceptionOf (x, IndexOutOfBoundsException)) {
50 this.calcMan.workerComplete (this);
51 return;
52 } else {
53 throw x;
54 }
55 }
56 this.updateResultAnnotation (true);
57 } catch (error) {
58 if (Clazz.exceptionOf (error, OutOfMemoryError)) {
59 this.ap.raiseOOMWarning ("calculating conservation", error);
60 this.calcMan.workerCannotRun (this);
61 } else {
62 throw error;
63 }
64 }
65 this.calcMan.workerComplete (this);
66 if (this.ap != null) {
67 this.ap.paintAlignment (true);
68 }});
69 Clazz.defineMethod (c$, "updateResultAnnotation", 
70  function (b) {
71 if (b || !this.calcMan.isWorking (this) && this.cons != null && this.conservation != null && this.quality != null) {
72 this.alignViewport.setConservation (this.cons);
73 this.cons.completeAnnotations (this.conservation, this.quality, 0, this.alWidth);
74 }}, "~B");
75 Clazz.overrideMethod (c$, "updateAnnotation", 
76 function () {
77 this.updateResultAnnotation (false);
78 });
79 });