+++ /dev/null
-package jalview.ws.slivkaws;
-
-import java.io.IOError;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SequenceI;
-import jalview.io.DataSourceType;
-import jalview.io.JPredFile;
-import jalview.ws.api.JPredServiceI;
-import jalview.ws.api.JobId;
-import jalview.ws.params.ArgumentI;
-import uk.ac.dundee.compbio.slivkaclient.RemoteFile;
-import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
-import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
-
-public class SlivkaJPredServiceInstance extends SlivkaWSInstance
- implements JPredServiceI
-{
-
- private class InputFormatParameter implements ArgumentI
- {
- String value = "";
-
- @Override
- public String getName()
- {
- return "format";
- }
-
- @Override
- public String getValue()
- {
- return value;
- }
-
- @Override
- public void setValue(String selectedItem)
- {
- value = selectedItem;
- }
- }
-
-
- public SlivkaJPredServiceInstance(SlivkaClient client,
- SlivkaService service, String action)
- {
- super(client, service, action);
- style = ServiceClient.JPREDWSCLIENT;
- }
-
- @Override
- public JobId predict(List<SequenceI> sequences, boolean msa) throws Throwable
- {
- // Hack allowing to send both single and msa jobs
- // until msa and single sequence services are separated.
- var arg = new InputFormatParameter();
- arg.setValue(msa ? "fasta" : "seq");
- return super.submit(sequences, null, List.of(arg));
- }
-
- @Override
- public AlignmentI getAlignment(JobId jobId) throws Exception
- {
- Collection<RemoteFile> files;
- try {
- var job = client.getJob(jobId.getJobId());
- files = job.getResults();
- for (RemoteFile f : files) {
- var alignment = readAlignment(f);
- if (alignment != null)
- {
- return alignment;
- }
- }
- }
- catch (IOException e) {
- throw new IOError(e);
- }
- return null;
- }
-
- @Override
- public JPredFile getPrediction(JobId jobId) throws Exception
- {
- Collection<RemoteFile> files = client.getJob(jobId.getJobId()).getResults();
- for (RemoteFile f : files)
- {
- if (f.getLabel().equals("concise"))
- {
- return new JPredFile(f.getContentUrl(), DataSourceType.URL);
- }
- }
- return null;
- }
-}