+package jalview.ws2.actions.hmmer;
+
+import static jalview.util.Comparison.GapChars;
+
+import java.io.IOException;
+import java.util.List;
+
+import jalview.analysis.AlignSeq;
+import jalview.bin.Console;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.Sequence;
+import jalview.ws.params.ArgumentI;
+import jalview.ws2.actions.AbstractPollableTask;
+import jalview.ws2.actions.BaseJob;
+import jalview.ws2.actions.ServiceInputInvalidException;
+import jalview.ws2.actions.api.TaskEventListener;
+import jalview.ws2.api.Credentials;
+import jalview.ws2.api.JobStatus;
+import jalview.ws2.client.api.AlignmentWebServiceClientI;
+
+class PhmmerTask extends AbstractPollableTask<BaseJob, AlignmentI>
+{
+ private final AlignmentWebServiceClientI client;
+ private final AlignmentView view;
+
+ PhmmerTask(AlignmentWebServiceClientI client, List<ArgumentI> args,
+ Credentials credentials, AlignmentView view,
+ TaskEventListener<AlignmentI> eventListener)
+ {
+ super(client, args, credentials, eventListener);
+ this.client = client;
+ this.view = view;
+ }
+
+ @Override
+ protected List<BaseJob> prepare() throws ServiceInputInvalidException
+ {
+ Console.info("Preparing sequence for phmmer job");
+ var sequence = view.getVisibleAlignment('-').getSequenceAt(0);
+ var seq = new Sequence(sequence.getName(),
+ AlignSeq.extractGaps(GapChars, sequence.getSequenceAsString()));
+ var job = new BaseJob(List.of(seq))
+ {
+ @Override
+ public boolean isInputValid()
+ {
+ return true;
+ }
+ };
+ job.setStatus(JobStatus.READY);
+ return List.of(job);
+ }
+
+ @Override
+ protected AlignmentI done() throws IOException
+ {
+ var job = getSubJobs().get(0);
+ var jobId = job.getServerJob().getJobId();
+ var status = job.getStatus();
+ Console.info(String.format("phmmer finished job \"%s\" with status %s",
+ jobId, status));
+ return client.getAlignment(job.getServerJob());
+ }
+
+}