X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fworkers%2FConsensusThread.js;h=089a18e2f77c982b0c2aa5904fce6df8b12d359b;hp=3f62035da13c6a9437a479e96b2da3d567e389f8;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/workers/ConsensusThread.js b/site/j2s/jalview/workers/ConsensusThread.js index 3f62035..089a18e 100644 --- a/site/j2s/jalview/workers/ConsensusThread.js +++ b/site/j2s/jalview/workers/ConsensusThread.js @@ -1,149 +1,149 @@ -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 (); -}); -}); +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 (); +}); +});