From: Mateusz Warowny Date: Fri, 13 Oct 2023 12:37:12 +0000 (+0200) Subject: JAL-1601 Implement JPred4 WS client and discoverer X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f2ae581a7c93c7c92a574d6c92ee7e0d9fb7b775;p=jalview.git JAL-1601 Implement JPred4 WS client and discoverer --- diff --git a/j11lib/jpred-client-1.0-SNAPSHOT.jar b/j11lib/jpred-client-1.0-SNAPSHOT.jar index 826f028..0e7aacf 100644 Binary files a/j11lib/jpred-client-1.0-SNAPSHOT.jar and b/j11lib/jpred-client-1.0-SNAPSHOT.jar differ diff --git a/src/jalview/ws2/client/jpred4/JPred4WSClient.java b/src/jalview/ws2/client/jpred4/JPred4WSClient.java index 36cc6c2..db1a6e4 100644 --- a/src/jalview/ws2/client/jpred4/JPred4WSClient.java +++ b/src/jalview/ws2/client/jpred4/JPred4WSClient.java @@ -23,8 +23,14 @@ public class JPred4WSClient implements SecStructPredWebServiceClientI { final JPredClient client; - JPred4WSClient(JPredClient client) + private final JPredRequest.Mode mode; + + private final JPredRequest.Format format; + + JPred4WSClient(JPredClient client, boolean msaMode) { + this.mode = msaMode ? JPredRequest.Mode.MSA : JPredRequest.Mode.SINGLE; + this.format = msaMode ? JPredRequest.Format.FASTA : JPredRequest.Format.SEQ; this.client = client; } @@ -44,13 +50,16 @@ public class JPred4WSClient implements SecStructPredWebServiceClientI public WebServiceJobHandle submit(List sequences, List args, Credentials credentials) throws IOException { - var input = FileFormat.Fasta - .getWriter(null) - .print(sequences.toArray(SequenceI[]::new), false); + var input = mode == JPredRequest.Mode.MSA + ? FileFormat.Fasta + .getWriter(null) + .print(sequences.toArray(SequenceI[]::new), false) + : sequences.get(0).getSequenceAsString(); + JPredRequest request = JPredRequest .newBuilder() - .mode(JPredRequest.Mode.MSA) - .format(JPredRequest.Format.FASTA) + .mode(mode) + .format(format) .input(input) .build(); var jobId = client.submit(request); @@ -63,6 +72,8 @@ public class JPred4WSClient implements SecStructPredWebServiceClientI var status = client.getStatus(job.getJobId()); switch (status) { + case PENDING: + return JobStatus.QUEUED; case RUNNING: return JobStatus.RUNNING; case FINISHED: @@ -96,16 +107,16 @@ public class JPred4WSClient implements SecStructPredWebServiceClientI public void cancel(WebServiceJobHandle job) throws IOException, UnsupportedOperationException { - + } - + @Override public AlignFile getAlignmentFile(WebServiceJobHandle job) throws IOException { var url = client.getResultURL(job.getJobId(), ResultTypes.PSIBLAST_ALIGN); return new FastaFile(url.toString(), DataSourceType.URL); } - + @Override public JPredFile getPredictionFile(WebServiceJobHandle job) throws IOException { diff --git a/src/jalview/ws2/client/jpred4/JPred4WSDiscoverer.java b/src/jalview/ws2/client/jpred4/JPred4WSDiscoverer.java index 99c3f28..6cb1576 100644 --- a/src/jalview/ws2/client/jpred4/JPred4WSDiscoverer.java +++ b/src/jalview/ws2/client/jpred4/JPred4WSDiscoverer.java @@ -86,11 +86,17 @@ public class JPred4WSDiscoverer extends AbstractWebServiceDiscoverer wsBuilder.actionClass(SecStructPredAction.class); var webService = wsBuilder.build(); - var wsClient = new JPred4WSClient(client); - var actionBuilder = SecStructPredAction.newBuilder(wsClient); + var actionBuilder = SecStructPredAction.newBuilder( + new JPred4WSClient(client, false)); actionBuilder.webService(webService); - actionBuilder.name(""); + actionBuilder.name("JPred4"); webService.addAction(actionBuilder.build()); + + var actionBuilderMsa = SecStructPredAction.newBuilder( + new JPred4WSClient(client, true)); + actionBuilderMsa.webService(webService); + actionBuilderMsa.name("JPred4 (MSA)"); + webService.addAction(actionBuilderMsa.build()); return List.of(webService); }