From 298994d0fc548fe5d88ff4ff3b0ee077a4f76c93 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 13 Oct 2021 15:30:56 +0200 Subject: [PATCH] JAL-3878 Add getCalcName to AlignCalcWorkerI. getCalcName() can be used to identify services that run the calculator. when an alternative calculator (different host or parameters) is created the old ones sharing the name can be stopped. --- src/jalview/api/AlignCalcWorkerI.java | 18 +++++++++++++++--- src/jalview/workers/ColumnCounterSetWorker.java | 6 ++++++ src/jalview/workers/ComplementConsensusThread.java | 6 ++++++ src/jalview/workers/ConsensusThread.java | 6 ++++++ src/jalview/workers/ConservationThread.java | 6 ++++++ src/jalview/workers/InformationThread.java | 6 ++++++ src/jalview/workers/StrucConsensusThread.java | 6 ++++++ .../ws/jws2/SeqAnnotationServiceCalcWorker.java | 8 +++++++- test/jalview/workers/AlignCaclManager2Test.java | 11 +++++++++-- 9 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/jalview/api/AlignCalcWorkerI.java b/src/jalview/api/AlignCalcWorkerI.java index b51b94e..19df53f 100644 --- a/src/jalview/api/AlignCalcWorkerI.java +++ b/src/jalview/api/AlignCalcWorkerI.java @@ -31,6 +31,17 @@ import jalview.datamodel.AlignmentAnnotation; public interface AlignCalcWorkerI { /** + * Returns the name of this calculation used to identify the service running + * this worker. + * + * @return calculator name + */ + public default String getCalcName() + { + return null; + } + + /** * Answers true if this worker updates the given annotation (regardless of its * current state) * @@ -50,13 +61,14 @@ public interface AlignCalcWorkerI * Removes any annotation(s) managed by this worker from the alignment */ void removeAnnotation(); - + /** * The main calculation happens here - * @throws Throwable + * + * @throws Throwable */ public void run() throws Throwable; - + /** * Answers true if the worker should be deleted entirely when its annotation * is deleted from the display, or false if it should continue to run. Some diff --git a/src/jalview/workers/ColumnCounterSetWorker.java b/src/jalview/workers/ColumnCounterSetWorker.java index a711f2b..6054ad5 100644 --- a/src/jalview/workers/ColumnCounterSetWorker.java +++ b/src/jalview/workers/ColumnCounterSetWorker.java @@ -62,6 +62,12 @@ class ColumnCounterSetWorker extends AlignCalcWorker calcMan.registerWorker(this); } + @Override + public String getCalcName() + { + return "Column Counter Set"; + } + /** * method called under control of AlignCalcManager to recompute the annotation * when the alignment changes diff --git a/src/jalview/workers/ComplementConsensusThread.java b/src/jalview/workers/ComplementConsensusThread.java index aca8ed0..49877e9 100644 --- a/src/jalview/workers/ComplementConsensusThread.java +++ b/src/jalview/workers/ComplementConsensusThread.java @@ -46,6 +46,12 @@ public class ComplementConsensusThread extends ConsensusThread } @Override + public String getCalcName() + { + return "Complement Consensus"; + } + + @Override protected AlignmentAnnotation getConsensusAnnotation() { return alignViewport.getComplementConsensusAnnotation(); diff --git a/src/jalview/workers/ConsensusThread.java b/src/jalview/workers/ConsensusThread.java index b97c4c5..dc3bf06 100644 --- a/src/jalview/workers/ConsensusThread.java +++ b/src/jalview/workers/ConsensusThread.java @@ -39,6 +39,12 @@ public class ConsensusThread extends AlignCalcWorker } @Override + public String getCalcName() + { + return "Consensus"; + } + + @Override public void run() { AlignmentAnnotation consensus = getConsensusAnnotation(); diff --git a/src/jalview/workers/ConservationThread.java b/src/jalview/workers/ConservationThread.java index 3752841..a78037c 100644 --- a/src/jalview/workers/ConservationThread.java +++ b/src/jalview/workers/ConservationThread.java @@ -49,6 +49,12 @@ public class ConservationThread extends AlignCalcWorker int alWidth; @Override + public String getCalcName() + { + return "Conservation"; + } + + @Override public void run() { if ((alignViewport == null) || (calcMan == null) diff --git a/src/jalview/workers/InformationThread.java b/src/jalview/workers/InformationThread.java index c8084b9..dae4ef2 100644 --- a/src/jalview/workers/InformationThread.java +++ b/src/jalview/workers/InformationThread.java @@ -37,6 +37,12 @@ public class InformationThread extends AlignCalcWorker super(alignViewport, alignPanel); } + @Override + public String getCalcName() + { + return "Information"; + } + /** * Recomputes Information annotations for any HMM consensus sequences (for * alignment and/or groups) diff --git a/src/jalview/workers/StrucConsensusThread.java b/src/jalview/workers/StrucConsensusThread.java index 3cb6114..a53f344 100644 --- a/src/jalview/workers/StrucConsensusThread.java +++ b/src/jalview/workers/StrucConsensusThread.java @@ -45,6 +45,12 @@ public class StrucConsensusThread extends AlignCalcWorker private long nseq = -1; @Override + public String getCalcName() + { + return "Struc Consensus"; + } + + @Override public void run() { if (alignViewport.isClosed()) diff --git a/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java b/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java index aafbbab..36a737e 100644 --- a/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java +++ b/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java @@ -229,7 +229,13 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker JobStateSummary job = null; WebserviceInfo info = null; List seqs = null; - + + @Override + public String getCalcName() + { + return service.getName(); + } + @Override public void startUp() throws Throwable { if (alignViewport.isClosed()) diff --git a/test/jalview/workers/AlignCaclManager2Test.java b/test/jalview/workers/AlignCaclManager2Test.java index 343ad14..5a22631 100644 --- a/test/jalview/workers/AlignCaclManager2Test.java +++ b/test/jalview/workers/AlignCaclManager2Test.java @@ -320,8 +320,9 @@ class AlignCalcWorkerMock implements AlignCalcWorkerI var result = getLastResult(); return (result instanceof Throwable) ? (Throwable) result : null; } - - public int getCallCount() { + + public int getCallCount() + { return callCount; } @@ -331,6 +332,12 @@ class AlignCalcWorkerMock implements AlignCalcWorkerI } @Override + public String getCalcName() + { + return "Mock"; + } + + @Override public boolean involves(AlignmentAnnotation annot) { if (annotation == null) -- 1.7.10.2