X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fworkers%2FStrucConsensusThread.js;h=7908c3f36b6bb878b489e2afce54dcd15ac2290d;hp=4010f84a002518c99ce3d0a32a69d3d6aefa43b8;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/site/j2s/jalview/workers/StrucConsensusThread.js b/site/j2s/jalview/workers/StrucConsensusThread.js index 4010f84..7908c3f 100644 --- a/site/j2s/jalview/workers/StrucConsensusThread.js +++ b/site/j2s/jalview/workers/StrucConsensusThread.js @@ -1,85 +1,107 @@ Clazz.declarePackage ("jalview.workers"); -Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency", "java.lang.Thread"], function () { +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$, "run", -function () { -try { -if (this.calcMan.isPending (this)) { +Clazz.overrideMethod (c$, "run1", +function (state) { +if (this.alignViewport.isClosed ()) { +this.abortAndDestroy (); return; -}this.calcMan.notifyStart (this); -while (!this.calcMan.notifyWorking (this)) { +}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) { -}Thread.sleep (200); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); +this.ap.paintAlignment (false); +}try { +if (this.sleepAndReturn (200, state)) return; +} catch (e) { +if (Clazz.exceptionOf (e, InterruptedException)) { +state = 2; +break; } else { -throw ex; +throw e; } } } if (this.alignViewport.isClosed ()) { this.abortAndDestroy (); -return; -}var alignment = this.alignViewport.getAlignment (); -var aWidth = -1; -if (alignment == null || (aWidth = alignment.getWidth ()) < 0) { -this.calcMan.workerComplete (this); -return; +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 (aWidth); -this.hStrucConsensus = new Array (aWidth); -var aa = this.alignViewport.getAlignment ().getAlignmentAnnotation (); -var rnaStruc = null; -for (var i = 0; i < aa.length; i++) { -if (aa[i].getRNAStruc () != null && aa[i].isValidStruc ()) { -rnaStruc = aa[i]; +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 (rnaStruc == null || !rnaStruc.isValidStruc ()) { -this.calcMan.workerComplete (this); -return; -}try { -var arr = alignment.getSequencesArray (); -this.nseq = arr.length; -jalview.analysis.StructureFrequency.calculate (arr, 0, alignment.getWidth (), this.hStrucConsensus, true, rnaStruc); -} catch (x) { -if (Clazz.exceptionOf (x, ArrayIndexOutOfBoundsException)) { +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 { -throw x; -} -} +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); -}} catch (error) { -if (Clazz.exceptionOf (error, OutOfMemoryError)) { +}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 { -throw error; } -} finally { +} else { +var e = e$$; +{ +System.out.println ("Error in ConsensusThread: " + e); +e.printStackTrace (); this.calcMan.workerComplete (this); -if (this.ap != null) { -this.ap.paintAlignment (true); -}} -}); +} +} +} +} +}, "~N"); Clazz.overrideMethod (c$, "updateAnnotation", function () { this.updateResultAnnotation (false); @@ -89,7 +111,4 @@ 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"); -Clazz.overrideMethod (c$, "run1", -function (state) { -}, "~N"); });