Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / jalview / workers / StrucConsensusThread.js
index 4010f84..12e93fc 100644 (file)
-Clazz.declarePackage ("jalview.workers");\r
-Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency", "java.lang.Thread"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.strucConsensus = null;\r
-this.hStrucConsensus = null;\r
-this.nseq = -1;\r
-Clazz.instantialize (this, arguments);\r
-}, jalview.workers, "StrucConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);\r
-Clazz.overrideMethod (c$, "getNewWorker", \r
-function () {\r
-return  new jalview.workers.StrucConsensusThread (this.alignViewport, this.ap);\r
-});\r
-Clazz.overrideMethod (c$, "run", \r
-function () {\r
-try {\r
-if (this.calcMan.isPending (this)) {\r
-return;\r
-}this.calcMan.notifyStart (this);\r
-while (!this.calcMan.notifyWorking (this)) {\r
-try {\r
-if (this.ap != null) {\r
-}Thread.sleep (200);\r
-} catch (ex) {\r
-if (Clazz.exceptionOf (ex, Exception)) {\r
-ex.printStackTrace ();\r
-} else {\r
-throw ex;\r
-}\r
-}\r
-}\r
-if (this.alignViewport.isClosed ()) {\r
-this.abortAndDestroy ();\r
-return;\r
-}var alignment = this.alignViewport.getAlignment ();\r
-var aWidth = -1;\r
-if (alignment == null || (aWidth = alignment.getWidth ()) < 0) {\r
-this.calcMan.workerComplete (this);\r
-return;\r
-}this.strucConsensus = this.alignViewport.getAlignmentStrucConsensusAnnotation ();\r
-this.hStrucConsensus = this.alignViewport.getRnaStructureConsensusHash ();\r
-this.strucConsensus.annotations = null;\r
-this.strucConsensus.annotations =  new Array (aWidth);\r
-this.hStrucConsensus =  new Array (aWidth);\r
-var aa = this.alignViewport.getAlignment ().getAlignmentAnnotation ();\r
-var rnaStruc = null;\r
-for (var i = 0; i < aa.length; i++) {\r
-if (aa[i].getRNAStruc () != null && aa[i].isValidStruc ()) {\r
-rnaStruc = aa[i];\r
-break;\r
-}}\r
-if (rnaStruc == null || !rnaStruc.isValidStruc ()) {\r
-this.calcMan.workerComplete (this);\r
-return;\r
-}try {\r
-var arr = alignment.getSequencesArray ();\r
-this.nseq = arr.length;\r
-jalview.analysis.StructureFrequency.calculate (arr, 0, alignment.getWidth (), this.hStrucConsensus, true, rnaStruc);\r
-} catch (x) {\r
-if (Clazz.exceptionOf (x, ArrayIndexOutOfBoundsException)) {\r
-this.calcMan.workerComplete (this);\r
-return;\r
-} else {\r
-throw x;\r
-}\r
-}\r
-this.alignViewport.setRnaStructureConsensusHash (this.hStrucConsensus);\r
-this.updateResultAnnotation (true);\r
-if (this.alignViewport.getGlobalColourScheme () != null) {\r
-this.alignViewport.getGlobalColourScheme ().setConsensus (this.hStrucConsensus);\r
-}} catch (error) {\r
-if (Clazz.exceptionOf (error, OutOfMemoryError)) {\r
-this.calcMan.workerCannotRun (this);\r
-this.ap.raiseOOMWarning ("calculating RNA structure consensus", error);\r
-} else {\r
-throw error;\r
-}\r
-} finally {\r
-this.calcMan.workerComplete (this);\r
-if (this.ap != null) {\r
-this.ap.paintAlignment (true);\r
-}}\r
-});\r
-Clazz.overrideMethod (c$, "updateAnnotation", \r
-function () {\r
-this.updateResultAnnotation (false);\r
-});\r
-Clazz.defineMethod (c$, "updateResultAnnotation", \r
-function (immediate) {\r
-if (immediate || !this.calcMan.isWorking (this) && this.strucConsensus != null && this.hStrucConsensus != null) {\r
-jalview.analysis.StructureFrequency.completeConsensus (this.strucConsensus, this.hStrucConsensus, 0, this.hStrucConsensus.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), this.nseq);\r
-}}, "~B");\r
-Clazz.overrideMethod (c$, "run1", \r
-function (state) {\r
-}, "~N");\r
-});\r
+Clazz.declarePackage ("jalview.workers");
+Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.rnaStruc = null;
+this.strucConsensus = null;
+this.hStrucConsensus = null;
+this.nseq = -1;
+this.aa = null;
+this.arr = null;
+Clazz.instantialize (this, arguments);
+}, jalview.workers, "StrucConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI);
+Clazz.overrideMethod (c$, "getNewWorker", 
+function () {
+return  new jalview.workers.StrucConsensusThread (this.alignViewport, this.ap);
+});
+Clazz.overrideMethod (c$, "run1", 
+function (state) {
+if (this.alignViewport.isClosed ()) {
+this.abortAndDestroy ();
+return;
+}while (!Thread.interrupted ()) {
+try {
+switch (state) {
+case 0:
+if (this.calcMan.isPending (this)) return;
+this.calcMan.notifyStart (this);
+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.strucConsensus = this.alignViewport.getAlignmentStrucConsensusAnnotation ();
+this.hStrucConsensus = this.alignViewport.getRnaStructureConsensusHash ();
+this.strucConsensus.annotations = null;
+this.strucConsensus.annotations =  new Array (this.aWidth);
+this.hStrucConsensus =  new Array (this.aWidth);
+this.aa = this.alignViewport.getAlignment ().getAlignmentAnnotation ();
+for (var i = 0; i < this.aa.length; i++) {
+if (this.aa[i].getRNAStruc () != null && this.aa[i].isValidStruc ()) {
+this.rnaStruc = this.aa[i];
+break;
+}}
+if (this.rnaStruc == null || !this.rnaStruc.isValidStruc ()) {
+this.calcMan.workerComplete (this);
+return;
+}this.arr = this.alignment.getSequencesArray ();
+this.nseq = this.arr.length;
+state = 4;
+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 {
+jalview.analysis.StructureFrequency.calculate (this.arr, 0, this.alignment.getWidth (), this.hStrucConsensus, true, this.rnaStruc);
+if (this.sleepAndReturn (0, state)) return;
+}break;
+case 2:
+this.alignViewport.setRnaStructureConsensusHash (this.hStrucConsensus);
+this.updateResultAnnotation (true);
+if (this.alignViewport.getGlobalColourScheme () != null) {
+this.alignViewport.getGlobalColourScheme ().setConsensus (this.hStrucConsensus);
+}this.notifyDone ();
+return;
+}
+} catch (e$$) {
+if (Clazz.exceptionOf (e$$, OutOfMemoryError)) {
+var error = e$$;
+{
+this.calcMan.workerCannotRun (this);
+this.ap.raiseOOMWarning ("calculating RNA structure consensus", error);
+}
+} else {
+var e = e$$;
+{
+System.out.println ("Error in ConsensusThread: " + e);
+e.printStackTrace ();
+this.calcMan.workerComplete (this);
+}
+}
+}
+}
+}, "~N");
+Clazz.overrideMethod (c$, "updateAnnotation", 
+function () {
+this.updateResultAnnotation (false);
+});
+Clazz.defineMethod (c$, "updateResultAnnotation", 
+function (immediate) {
+if (immediate || !this.calcMan.isWorking (this) && this.strucConsensus != null && this.hStrucConsensus != null) {
+jalview.analysis.StructureFrequency.completeConsensus (this.strucConsensus, this.hStrucConsensus, 0, this.hStrucConsensus.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), this.nseq);
+}}, "~B");
+});