From 202513865e673d976497e53d7254b2539cefac85 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 15 Jan 2021 19:21:47 +0100 Subject: [PATCH] JAL-3690 Fixed slivka wsmenu categories. --- .../slivkaws/SlivkaAnnotationServiceInstance.java | 10 +-- .../ws/slivkaws/SlivkaMsaServiceInstance.java | 5 +- src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java | 81 ++++++++++++-------- src/jalview/ws/slivkaws/SlivkaWSInstance.java | 2 +- 4 files changed, 56 insertions(+), 42 deletions(-) diff --git a/src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java b/src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java index cc5c1e4..f11eb1c 100644 --- a/src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java +++ b/src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import compbio.data.msa.Category; import uk.ac.dundee.compbio.slivkaclient.RemoteFile; import uk.ac.dundee.compbio.slivkaclient.SlivkaClient; import uk.ac.dundee.compbio.slivkaclient.SlivkaService; @@ -29,13 +30,12 @@ import uk.ac.dundee.compbio.slivkaclient.SlivkaService; public class SlivkaAnnotationServiceInstance extends SlivkaWSInstance implements SequenceAnnotationServiceI { public SlivkaAnnotationServiceInstance(SlivkaClient client, - SlivkaService service, boolean conservation) + SlivkaService service, String category) { - super(client, service, !conservation ? "Protein sequence analysis" - : "Alignment Conservation"); - if (conservation) + super(client, service, category); + if (category == Category.CATEGORY_CONSERVATION) { - setAlignAnalysisUI(new AlignAnalysisUIText(getName(), + setAlignAnalysisUI(new AlignAnalysisUIText(category, SlivkaAnnotationServiceInstance.class, "Slivka.AACons", false, true, true, true, true, 2, MessageManager.getString("label.aacon_calculations"), diff --git a/src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java b/src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java index a65e93e..9a33b04 100644 --- a/src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java +++ b/src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java @@ -16,14 +16,15 @@ import java.io.IOException; import java.rmi.ServerError; import java.util.List; +import compbio.data.msa.Category; import uk.ac.dundee.compbio.slivkaclient.RemoteFile; import uk.ac.dundee.compbio.slivkaclient.SlivkaClient; import uk.ac.dundee.compbio.slivkaclient.SlivkaService; public class SlivkaMsaServiceInstance extends SlivkaWSInstance implements MultipleSequenceAlignmentI { - SlivkaMsaServiceInstance(SlivkaClient client, SlivkaService service) { - super(client, service, "Sequence Alignment"); + SlivkaMsaServiceInstance(SlivkaClient client, SlivkaService service, String category) { + super(client, service, category); style = ServiceClient.MSAWSCLIENT; } diff --git a/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java b/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java index cd296c6..e849f97 100644 --- a/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java +++ b/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java @@ -17,6 +17,8 @@ import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; + +import compbio.data.msa.Category; import uk.ac.dundee.compbio.slivkaclient.SlivkaClient; import uk.ac.dundee.compbio.slivkaclient.SlivkaService; @@ -65,7 +67,9 @@ public class SlivkaWSDiscoverer implements WSDiscovererI } } - private final ExecutorService executor = Executors.newSingleThreadExecutor(); + private final ExecutorService executor = Executors + .newSingleThreadExecutor(); + private Vector> discoveryTasks = new Vector<>(); public CompletableFuture startDiscoverer() @@ -87,48 +91,57 @@ public class SlivkaWSDiscoverer implements WSDiscovererI for (String url : getServiceUrls()) { - Cache.log.info(url); - SlivkaClient client; - client = new SlivkaClient(url); + SlivkaClient client = new SlivkaClient(url); + + List services; try { - for (SlivkaService service : client.getServices()) + services = client.getServices(); + } catch (IOException e) + { + e.printStackTrace(); + continue; + } + for (SlivkaService service : services) + { + SlivkaWSInstance newInstance = null; + for (String classifier : service.classifiers) { - SlivkaWSInstance newinstance = null; - for (String classifier : service.classifiers) + String[] path = classifier.split("\\s*::\\s*"); + if (path.length >= 3 && path[0].toLowerCase().equals("operation") + && path[1].toLowerCase().equals("analysis")) { - if (classifier.contains("Multiple sequence alignment")) - { - newinstance = new SlivkaMsaServiceInstance(client, service); - } - if (classifier.contains("Protein sequence analysis") - && newinstance == null) + switch (path[path.length - 1].toLowerCase()) { - newinstance = new SlivkaAnnotationServiceInstance(client, - service, false); - } - if (classifier - .contains("Sequence alignment analysis (conservation)")) - { - newinstance = new SlivkaAnnotationServiceInstance(client, - service, true); + case "sequence alignment analysis (conservation)": + newInstance = new SlivkaAnnotationServiceInstance(client, + service, Category.CATEGORY_CONSERVATION); + break; + case "protein sequence analysis": + newInstance = new SlivkaAnnotationServiceInstance(client, + service, Category.CATEGORY_DISORDER); + break; + case "protein secondary structure prediction": + newInstance = new SlivkaAnnotationServiceInstance(client, + service, "Secondary Structure Prediction"); + break; + case "multiple sequence alignment": + newInstance = new SlivkaMsaServiceInstance(client, service, + Category.CATEGORY_ALIGNMENT); + break; } } - if (newinstance != null) - { - instances.add(newinstance); - } + if (newInstance != null) + break; } - } catch (IOException e) - { - e.printStackTrace(); - continue; + if (newInstance != null) + instances.add(newInstance); } } services = instances; - notifyServiceListeners(instances); Cache.log.info("Slivka services reloading finished"); + notifyServiceListeners(instances); return instances; } @@ -178,11 +191,11 @@ public class SlivkaWSDiscoverer implements WSDiscovererI } catch (MalformedURLException e) { Cache.log.warn("Problem whilst trying to make a URL from '" - + ((url != null) ? url : "") + "'"); + + ((url != null) ? url : "") + "'"); Cache.log.warn( - "This was probably due to a malformed comma separated list" - + " in the " + SLIVKA_HOST_URLS - + " entry of $(HOME)/.jalview_properties)"); + "This was probably due to a malformed comma separated list" + + " in the " + SLIVKA_HOST_URLS + + " entry of $(HOME)/.jalview_properties)"); Cache.log.debug("Exception was ", e); } } diff --git a/src/jalview/ws/slivkaws/SlivkaWSInstance.java b/src/jalview/ws/slivkaws/SlivkaWSInstance.java index 978d775..54039ce 100644 --- a/src/jalview/ws/slivkaws/SlivkaWSInstance.java +++ b/src/jalview/ws/slivkaws/SlivkaWSInstance.java @@ -64,7 +64,7 @@ public abstract class SlivkaWSInstance extends ServiceWithParameters public SlivkaWSInstance(SlivkaClient client, SlivkaService service, String action) { - super(service.getName(), action, service.getLabel(), "Slivka", client.getUrl().toString()); + super(action, action, service.getLabel(), "Slivka", client.getUrl().toString()); this.client = client; this.service = service; } -- 1.7.10.2