--- /dev/null
+package jalview.ws2.client.ebi;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import jalview.bin.Console;
+import jalview.ws.params.ParamManager;
+import jalview.ws2.actions.NullAction;
+import jalview.ws2.actions.api.ActionI;
+import jalview.ws2.api.WebService;
+import jalview.ws2.client.api.AbstractWebServiceDiscoverer;
+import uk.ac.dundee.compbio.hmmerclient.PhmmerClient;
+
+public final class JobDispatcherWSDiscoverer extends AbstractWebServiceDiscoverer
+{
+
+ private static final URL DEFAULT_URL;
+ static
+ {
+ try
+ {
+ DEFAULT_URL = new URL("https://www.ebi.ac.uk/Tools/services/rest/hmmer3_phmmer/");
+ } catch (MalformedURLException e)
+ {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ private static JobDispatcherWSDiscoverer instance = null;
+ private static ParamManager paramManager = null;
+
+ private JobDispatcherWSDiscoverer() {}
+
+ public static JobDispatcherWSDiscoverer getInstance() {
+ if (instance == null)
+ instance = new JobDispatcherWSDiscoverer();
+ return instance;
+ }
+
+ public static void setParamManager(ParamManager manager)
+ {
+ paramManager = manager;
+ }
+
+ @Override
+ public int getStatusForUrl(URL url)
+ {
+ try
+ {
+ return new PhmmerClient(url).testEndpoint() ? STATUS_OK : STATUS_INVALID;
+ } catch (URISyntaxException e)
+ {
+ Console.error(e.getMessage());
+ return STATUS_INVALID;
+ }
+ }
+
+ @Override
+ protected String getUrlsPropertyKey()
+ {
+ return null;
+ }
+
+ @Override
+ protected URL getDefaultUrl()
+ {
+ return DEFAULT_URL;
+ }
+
+ @Override
+ protected List<WebService<?>> fetchServices(URL url) throws IOException
+ {
+ PhmmerClient client;
+ try {
+ client = new PhmmerClient(url);
+ }
+ catch (URISyntaxException e) {
+ throw new MalformedURLException(e.getMessage());
+ }
+ if (!client.testEndpoint())
+ throw new IOException(
+ "unable to reach dispatcher server at " + url);
+ // TODO change once a concrete action is implemented
+ var wsBuilder = WebService.<NullAction> newBuilder();
+ wsBuilder.url(url);
+ wsBuilder.clientName("job dispatcher");
+ wsBuilder.category("Database search");
+ wsBuilder.name("pHMMER");
+ wsBuilder.description("Hmmer3 phmmer is used to search one or more query sequences against a sequence database.");
+ wsBuilder.interactive(false);
+ wsBuilder.paramDatastore(ParamStores.newPhmmerDatastore(url, paramManager));
+ wsBuilder.actionClass(NullAction.class);
+ var webService = wsBuilder.build();
+
+ var actionBuilder = NullAction.newBuilder();
+ actionBuilder.webService(webService);
+ actionBuilder.name("");
+ webService.addAction(actionBuilder.build());
+
+ return List.of(webService);
+ }
+
+}