JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / jalview / workers / ConsensusThread.js
index 3f62035..089a18e 100644 (file)
-Clazz.declarePackage ("jalview.workers");\r
-Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.ConsensusThread", ["jalview.analysis.AAFrequency"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.hconsensus = null;\r
-this.aseqs = null;\r
-Clazz.instantialize (this, arguments);\r
-}, jalview.workers, "ConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);\r
-Clazz.overrideMethod (c$, "getNewWorker", \r
-function () {\r
-return  new jalview.workers.ConsensusThread (this.alignViewport, this.ap);\r
-});\r
-Clazz.overrideMethod (c$, "run1", \r
-function (state) {\r
-while (!Thread.interrupted ()) {\r
-if (this.alignViewport.isClosed ()) {\r
-this.abortAndDestroy ();\r
-return;\r
-}try {\r
-switch (state) {\r
-case 0:\r
-if (this.calcMan.isPending (this)) return;\r
-this.calcMan.notifyStart (this);\r
-var consensus = this.getConsensusAnnotation ();\r
-if (consensus == null || this.calcMan.isPending (this)) {\r
-this.calcMan.workerComplete (this);\r
-return;\r
-}state = 3;\r
-break;\r
-case 3:\r
-while (!this.calcMan.notifyWorking (this)) {\r
-if (this.ap != null) {\r
-this.ap.paintAlignment (false);\r
-}try {\r
-if (this.sleepAndReturn (200, state)) return;\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, InterruptedException)) {\r
-state = 2;\r
-break;\r
-} else {\r
-throw e;\r
-}\r
-}\r
-}\r
-if (this.alignViewport.isClosed ()) {\r
-this.abortAndDestroy ();\r
-state = 2;\r
-break;\r
-}this.alignment = this.alignViewport.getAlignment ();\r
-this.aWidth = -1;\r
-if (this.alignment == null || (this.aWidth = this.alignment.getWidth ()) < 0) {\r
-state = 2;\r
-}this.eraseConsensus (this.aWidth);\r
-state = (this.initializeCalc () ? 4 : 2);\r
-break;\r
-case 4:\r
-this.iFirst = this.iLast;\r
-this.iLast = Math.min (this.iLast + this.nPer, this.aWidth);\r
-if (this.iLast == this.iFirst) {\r
-state = 2;\r
-} else {\r
-this.computeConsensus ();\r
-if (this.sleepAndReturn (0, state)) return;\r
-}break;\r
-case 2:\r
-this.finalizeCalc ();\r
-this.updateAlignment ();\r
-this.notifyDone ();\r
-return;\r
-}\r
-} catch (e$$) {\r
-if (Clazz.exceptionOf (e$$, OutOfMemoryError)) {\r
-var error = e$$;\r
-{\r
-this.calcMan.workerCannotRun (this);\r
-this.ap.raiseOOMWarning ("calculating consensus", error);\r
-}\r
-} else {\r
-var e = e$$;\r
-{\r
-System.out.println ("Error in ConsensusThread: " + e);\r
-e.printStackTrace ();\r
-this.calcMan.workerComplete (this);\r
-}\r
-}\r
-}\r
-}\r
-}, "~N");\r
-Clazz.defineMethod (c$, "initializeCalc", \r
-function () {\r
-this.iLast = 0;\r
-this.hconsensus =  new Array (this.aWidth);\r
-this.aseqs = this.getSequences ();\r
-return true;\r
-});\r
-Clazz.defineMethod (c$, "computeConsensus", \r
-function () {\r
-this.started = System.currentTimeMillis ();\r
-jalview.analysis.AAFrequency.calculate (this.aseqs, this.iFirst, this.iLast, this.hconsensus, true);\r
-if (System.currentTimeMillis () - this.started < 500) this.nPer *= 2;\r
-});\r
-Clazz.defineMethod (c$, "finalizeCalc", \r
-function () {\r
-this.alignViewport.setSequenceConsensusHash (this.hconsensus);\r
-});\r
-Clazz.defineMethod (c$, "updateAlignment", \r
-function () {\r
-this.setColourSchemeConsensus (this.hconsensus);\r
-this.updateResultAnnotation (true);\r
-});\r
-Clazz.defineMethod (c$, "eraseConsensus", \r
-function (aWidth) {\r
-var consensus = this.getConsensusAnnotation ();\r
-consensus.annotations =  new Array (aWidth);\r
-}, "~N");\r
-Clazz.defineMethod (c$, "getSequences", \r
-function () {\r
-return this.alignViewport.getAlignment ().getSequencesArray ();\r
-});\r
-Clazz.defineMethod (c$, "setColourSchemeConsensus", \r
-function (hconsensus) {\r
-var globalColourScheme = this.alignViewport.getGlobalColourScheme ();\r
-if (globalColourScheme != null) {\r
-globalColourScheme.setConsensus (hconsensus);\r
-}}, "~A");\r
-Clazz.defineMethod (c$, "getConsensusAnnotation", \r
-function () {\r
-return this.alignViewport.getAlignmentConsensusAnnotation ();\r
-});\r
-Clazz.overrideMethod (c$, "updateAnnotation", \r
-function () {\r
-this.updateResultAnnotation (false);\r
-});\r
-Clazz.defineMethod (c$, "updateResultAnnotation", \r
-function (immediate) {\r
-var consensus = this.getConsensusAnnotation ();\r
-var hconsensus = this.getViewportConsensus ();\r
-if (immediate || !this.calcMan.isWorking (this) && consensus != null && hconsensus != null) {\r
-this.deriveConsensus (consensus, hconsensus);\r
-}}, "~B");\r
-Clazz.defineMethod (c$, "deriveConsensus", \r
-function (consensusAnnotation, consensusData) {\r
-var nseq = this.getSequences ().length;\r
-jalview.analysis.AAFrequency.completeConsensus (consensusAnnotation, consensusData, 0, consensusData.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), nseq);\r
-}, "jalview.datamodel.AlignmentAnnotation,~A");\r
-Clazz.defineMethod (c$, "getViewportConsensus", \r
-function () {\r
-return this.alignViewport.getSequenceConsensusHash ();\r
-});\r
-});\r
+Clazz.declarePackage ("jalview.workers");
+Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.ConsensusThread", ["jalview.analysis.AAFrequency"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.hconsensus = null;
+this.aseqs = null;
+Clazz.instantialize (this, arguments);
+}, jalview.workers, "ConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);
+Clazz.overrideMethod (c$, "getNewWorker", 
+function () {
+return  new jalview.workers.ConsensusThread (this.alignViewport, this.ap);
+});
+Clazz.overrideMethod (c$, "run1", 
+function (state) {
+while (!Thread.interrupted ()) {
+if (this.alignViewport.isClosed ()) {
+this.abortAndDestroy ();
+return;
+}try {
+switch (state) {
+case 0:
+if (this.calcMan.isPending (this)) return;
+this.calcMan.notifyStart (this);
+var consensus = this.getConsensusAnnotation ();
+if (consensus == null || this.calcMan.isPending (this)) {
+this.calcMan.workerComplete (this);
+return;
+}state = 3;
+break;
+case 3:
+while (!this.calcMan.notifyWorking (this)) {
+if (this.ap != null) {
+this.ap.paintAlignment (false);
+}try {
+if (this.sleepAndReturn (200, state)) return;
+} catch (e) {
+if (Clazz.exceptionOf (e, InterruptedException)) {
+state = 2;
+break;
+} else {
+throw e;
+}
+}
+}
+if (this.alignViewport.isClosed ()) {
+this.abortAndDestroy ();
+state = 2;
+break;
+}this.alignment = this.alignViewport.getAlignment ();
+this.aWidth = -1;
+if (this.alignment == null || (this.aWidth = this.alignment.getWidth ()) < 0) {
+state = 2;
+}this.eraseConsensus (this.aWidth);
+state = (this.initializeCalc () ? 4 : 2);
+break;
+case 4:
+this.iFirst = this.iLast;
+this.iLast = Math.min (this.iLast + this.nPer, this.aWidth);
+if (this.iLast == this.iFirst) {
+state = 2;
+} else {
+this.computeConsensus ();
+if (this.sleepAndReturn (0, state)) return;
+}break;
+case 2:
+this.finalizeCalc ();
+this.updateAlignment ();
+this.notifyDone ();
+return;
+}
+} catch (e$$) {
+if (Clazz.exceptionOf (e$$, OutOfMemoryError)) {
+var error = e$$;
+{
+this.calcMan.workerCannotRun (this);
+this.ap.raiseOOMWarning ("calculating consensus", error);
+}
+} else {
+var e = e$$;
+{
+System.out.println ("Error in ConsensusThread: " + e);
+e.printStackTrace ();
+this.calcMan.workerComplete (this);
+}
+}
+}
+}
+}, "~N");
+Clazz.defineMethod (c$, "initializeCalc", 
+function () {
+this.iLast = 0;
+this.hconsensus =  new Array (this.aWidth);
+this.aseqs = this.getSequences ();
+return true;
+});
+Clazz.defineMethod (c$, "computeConsensus", 
+function () {
+this.started = System.currentTimeMillis ();
+jalview.analysis.AAFrequency.calculate (this.aseqs, this.iFirst, this.iLast, this.hconsensus, true);
+if (System.currentTimeMillis () - this.started < 500) this.nPer *= 2;
+});
+Clazz.defineMethod (c$, "finalizeCalc", 
+function () {
+this.alignViewport.setSequenceConsensusHash (this.hconsensus);
+});
+Clazz.defineMethod (c$, "updateAlignment", 
+function () {
+this.setColourSchemeConsensus (this.hconsensus);
+this.updateResultAnnotation (true);
+});
+Clazz.defineMethod (c$, "eraseConsensus", 
+function (aWidth) {
+var consensus = this.getConsensusAnnotation ();
+consensus.annotations =  new Array (aWidth);
+}, "~N");
+Clazz.defineMethod (c$, "getSequences", 
+function () {
+return this.alignViewport.getAlignment ().getSequencesArray ();
+});
+Clazz.defineMethod (c$, "setColourSchemeConsensus", 
+function (hconsensus) {
+var globalColourScheme = this.alignViewport.getGlobalColourScheme ();
+if (globalColourScheme != null) {
+globalColourScheme.setConsensus (hconsensus);
+}}, "~A");
+Clazz.defineMethod (c$, "getConsensusAnnotation", 
+function () {
+return this.alignViewport.getAlignmentConsensusAnnotation ();
+});
+Clazz.overrideMethod (c$, "updateAnnotation", 
+function () {
+this.updateResultAnnotation (false);
+});
+Clazz.defineMethod (c$, "updateResultAnnotation", 
+function (immediate) {
+var consensus = this.getConsensusAnnotation ();
+var hconsensus = this.getViewportConsensus ();
+if (immediate || !this.calcMan.isWorking (this) && consensus != null && hconsensus != null) {
+this.deriveConsensus (consensus, hconsensus);
+}}, "~B");
+Clazz.defineMethod (c$, "deriveConsensus", 
+function (consensusAnnotation, consensusData) {
+var nseq = this.getSequences ().length;
+jalview.analysis.AAFrequency.completeConsensus (consensusAnnotation, consensusData, 0, consensusData.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), nseq);
+}, "jalview.datamodel.AlignmentAnnotation,~A");
+Clazz.defineMethod (c$, "getViewportConsensus", 
+function () {
+return this.alignViewport.getSequenceConsensusHash ();
+});
+});