JAL-1601 Move job class as inner task class
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 18 Oct 2023 11:39:37 +0000 (13:39 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 18 Oct 2023 11:48:25 +0000 (13:48 +0200)
src/jalview/ws2/actions/secstructpred/SecStructPredJob.java [deleted file]
src/jalview/ws2/actions/secstructpred/SecStructPredTask.java

diff --git a/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java b/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java
deleted file mode 100644 (file)
index 2df2f25..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package jalview.ws2.actions.secstructpred;
-
-import java.util.List;
-import java.util.Map;
-
-import jalview.analysis.SeqsetUtils.SequenceInfo;
-import jalview.datamodel.SequenceI;
-import jalview.ws2.actions.BaseJob;
-
-public class SecStructPredJob extends BaseJob
-{
-  private final int[] delMap;
-
-  private final SequenceI refSeq;
-
-  final Map<String, SequenceInfo> seqNames;
-
-  SecStructPredJob(List<SequenceI> sequences, SequenceI refSeq, int[] delMap,
-      Map<String, SequenceInfo> seqNames)
-  {
-    super(sequences);
-    this.refSeq = refSeq;
-    this.delMap = delMap;
-    this.seqNames = seqNames;
-  }
-
-  @Override
-  public boolean isInputValid()
-  {
-    return true;
-  }
-
-  public int[] getDelMap()
-  {
-    return this.delMap;
-  }
-}
index b0a924c..fb904a8 100644 (file)
@@ -3,9 +3,11 @@ package jalview.ws2.actions.secstructpred;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import jalview.analysis.AlignmentAnnotationUtils;
 import jalview.analysis.SeqsetUtils;
+import jalview.analysis.SeqsetUtils.SequenceInfo;
 import jalview.api.AlignViewportI;
 import jalview.bin.Console;
 import jalview.datamodel.Alignment;
@@ -18,7 +20,6 @@ import jalview.datamodel.SequenceI;
 import jalview.io.AlignFile;
 import jalview.io.JPredFile;
 import jalview.io.JnetAnnotationMaker;
-import jalview.util.Comparison;
 import jalview.ws.params.ArgumentI;
 import jalview.ws2.actions.BaseJob;
 import jalview.ws2.actions.BaseTask;
@@ -27,7 +28,8 @@ import jalview.ws2.api.Credentials;
 import jalview.ws2.api.JobStatus;
 import jalview.ws2.client.api.SecStructPredWebServiceClientI;
 
-public class SecStructPredTask extends BaseTask<SecStructPredJob, AlignmentI>
+public class SecStructPredTask
+        extends BaseTask<SecStructPredTask.SecStructPredJob, AlignmentI>
 {
   private final SecStructPredWebServiceClientI client;
 
@@ -37,8 +39,9 @@ public class SecStructPredTask extends BaseTask<SecStructPredJob, AlignmentI>
 
   private final char gapChar;
 
-  SecStructPredTask(SecStructPredWebServiceClientI client, List<ArgumentI> args,
-      Credentials credentials, AlignViewportI viewport)
+  SecStructPredTask(SecStructPredWebServiceClientI client,
+          List<ArgumentI> args, Credentials credentials,
+          AlignViewportI viewport)
   {
     super(client, args, credentials);
     this.client = client;
@@ -49,11 +52,12 @@ public class SecStructPredTask extends BaseTask<SecStructPredJob, AlignmentI>
 
   @Override
   protected List<SecStructPredJob> prepareJobs()
-      throws ServiceInputInvalidException
+          throws ServiceInputInvalidException
   {
     SeqCigar[] msf = alignmentView.getSequences();
     SequenceI referenceSeq = msf[0].getSeq('-');
-    int[] delMap = alignmentView.getVisibleContigMapFor(referenceSeq.gapMap());
+    int[] delMap = alignmentView
+            .getVisibleContigMapFor(referenceSeq.gapMap());
 
     // TODO: assume MSA for now
     SequenceI[] sequences = new SequenceI[msf.length];
@@ -65,7 +69,7 @@ public class SecStructPredTask extends BaseTask<SecStructPredJob, AlignmentI>
       sequences[i].setSequence(alignmentView.getASequenceString('-', i));
     var sequencesList = filterEmptySequences(sequences);
     var job = new SecStructPredJob(sequencesList, referenceSeq, delMap,
-        sequenceInfo);
+            sequenceInfo);
     job.setStatus(JobStatus.READY);
     return List.of(job);
   }
@@ -81,28 +85,27 @@ public class SecStructPredTask extends BaseTask<SecStructPredJob, AlignmentI>
 
   @Override
   protected AlignmentI collectResult(List<SecStructPredJob> jobs)
-      throws IOException
+          throws IOException
   {
     var job = jobs.get(0); // There shouldn't be more than one job
     var status = job.getStatus();
-    Console
-        .info(String
-            .format("sec str pred job \"%s\" finished with status %s",
-                job.getServerJob().getJobId(), status));
+    Console.info(
+            String.format("sec str pred job \"%s\" finished with status %s",
+                    job.getServerJob().getJobId(), status));
     if (status != JobStatus.COMPLETED)
       return null;
     JPredFile predictionFile = client.getPredictionFile(job.getServerJob());
     AlignFile alignmentFile = client.getAlignmentFile(job.getServerJob());
 
     Object[] alnAndHiddenCols = alignmentView
-        .getAlignmentAndHiddenColumns(gapChar);
+            .getAlignmentAndHiddenColumns(gapChar);
     Alignment aln = new Alignment((SequenceI[]) alnAndHiddenCols[0]);
     aln.setDataset(currentView.getDataset());
     aln.setHiddenColumns((HiddenColumns) alnAndHiddenCols[1]);
     try
     {
-      JnetAnnotationMaker
-          .add_annotation(predictionFile, aln, 0, false, job.getDelMap());
+      JnetAnnotationMaker.add_annotation(predictionFile, aln, 0, false,
+              job.getDelMap());
     } catch (Exception e)
     {
       throw new IOException(e);
@@ -112,13 +115,41 @@ public class SecStructPredTask extends BaseTask<SecStructPredJob, AlignmentI>
     {
       if (alnAnnot.sequenceRef != null)
       {
-        AlignmentAnnotationUtils
-            .replaceAnnotationOnAlignmentWith(alnAnnot, alnAnnot.label,
-                getClass().getSimpleName());
+        AlignmentAnnotationUtils.replaceAnnotationOnAlignmentWith(alnAnnot,
+                alnAnnot.label, getClass().getSimpleName());
       }
     }
     aln.setSeqrep(aln.getSequenceAt(0));
     return aln;
   }
 
+  public static class SecStructPredJob extends BaseJob
+  {
+    private final int[] delMap;
+
+    private final SequenceI refSeq;
+
+    final Map<String, SequenceInfo> seqNames;
+
+    SecStructPredJob(List<SequenceI> sequences, SequenceI refSeq,
+            int[] delMap, Map<String, SequenceInfo> seqNames)
+    {
+      super(sequences);
+      this.refSeq = refSeq;
+      this.delMap = delMap;
+      this.seqNames = seqNames;
+    }
+
+    @Override
+    public boolean isInputValid()
+    {
+      return true;
+    }
+
+    public int[] getDelMap()
+    {
+      return this.delMap;
+    }
+  }
+
 }