JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / site / j2s / jalview / workers / StrucConsensusThread.js
index 4010f84..7908c3f 100644 (file)
 Clazz.declarePackage ("jalview.workers");\r
 Clazz.declarePackage ("jalview.workers");\r
-Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency", "java.lang.Thread"], function () {\r
+Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency"], function () {\r
 c$ = Clazz.decorateAsClass (function () {\r
 c$ = Clazz.decorateAsClass (function () {\r
+this.rnaStruc = null;\r
 this.strucConsensus = null;\r
 this.hStrucConsensus = null;\r
 this.nseq = -1;\r
 this.strucConsensus = null;\r
 this.hStrucConsensus = null;\r
 this.nseq = -1;\r
+this.aa = null;\r
+this.arr = null;\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.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
+Clazz.overrideMethod (c$, "run1", \r
+function (state) {\r
+if (this.alignViewport.isClosed ()) {\r
+this.abortAndDestroy ();\r
 return;\r
 return;\r
-}this.calcMan.notifyStart (this);\r
-while (!this.calcMan.notifyWorking (this)) {\r
+}while (!Thread.interrupted ()) {\r
 try {\r
 try {\r
+switch (state) {\r
+case 0:\r
+if (this.calcMan.isPending (this)) return;\r
+this.calcMan.notifyStart (this);\r
+state = 3;\r
+break;\r
+case 3:\r
+while (!this.calcMan.notifyWorking (this)) {\r
 if (this.ap != null) {\r
 if (this.ap != null) {\r
-}Thread.sleep (200);\r
-} catch (ex) {\r
-if (Clazz.exceptionOf (ex, Exception)) {\r
-ex.printStackTrace ();\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
 } else {\r
-throw ex;\r
+throw e;\r
 }\r
 }\r
 }\r
 if (this.alignViewport.isClosed ()) {\r
 this.abortAndDestroy ();\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
+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.strucConsensus = this.alignViewport.getAlignmentStrucConsensusAnnotation ();\r
 this.hStrucConsensus = this.alignViewport.getRnaStructureConsensusHash ();\r
 this.strucConsensus.annotations = null;\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
+this.strucConsensus.annotations =  new Array (this.aWidth);\r
+this.hStrucConsensus =  new Array (this.aWidth);\r
+this.aa = this.alignViewport.getAlignment ().getAlignmentAnnotation ();\r
+for (var i = 0; i < this.aa.length; i++) {\r
+if (this.aa[i].getRNAStruc () != null && this.aa[i].isValidStruc ()) {\r
+this.rnaStruc = this.aa[i];\r
 break;\r
 }}\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
+if (this.rnaStruc == null || !this.rnaStruc.isValidStruc ()) {\r
 this.calcMan.workerComplete (this);\r
 return;\r
 this.calcMan.workerComplete (this);\r
 return;\r
+}this.arr = this.alignment.getSequencesArray ();\r
+this.nseq = this.arr.length;\r
+state = 4;\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
 } else {\r
-throw x;\r
-}\r
-}\r
+jalview.analysis.StructureFrequency.calculate (this.arr, 0, this.alignment.getWidth (), this.hStrucConsensus, true, this.rnaStruc);\r
+if (this.sleepAndReturn (0, state)) return;\r
+}break;\r
+case 2:\r
 this.alignViewport.setRnaStructureConsensusHash (this.hStrucConsensus);\r
 this.updateResultAnnotation (true);\r
 if (this.alignViewport.getGlobalColourScheme () != null) {\r
 this.alignViewport.getGlobalColourScheme ().setConsensus (this.hStrucConsensus);\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.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 RNA structure consensus", error);\r
 this.calcMan.workerCannotRun (this);\r
 this.ap.raiseOOMWarning ("calculating RNA structure consensus", error);\r
-} else {\r
-throw error;\r
 }\r
 }\r
-} finally {\r
+} else {\r
+var e = e$$;\r
+{\r
+System.out.println ("Error in ConsensusThread: " + e);\r
+e.printStackTrace ();\r
 this.calcMan.workerComplete (this);\r
 this.calcMan.workerComplete (this);\r
-if (this.ap != null) {\r
-this.ap.paintAlignment (true);\r
-}}\r
-});\r
+}\r
+}\r
+}\r
+}\r
+}, "~N");\r
 Clazz.overrideMethod (c$, "updateAnnotation", \r
 function () {\r
 this.updateResultAnnotation (false);\r
 Clazz.overrideMethod (c$, "updateAnnotation", \r
 function () {\r
 this.updateResultAnnotation (false);\r
@@ -89,7 +111,4 @@ function (immediate) {
 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
 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
 });\r