JAL-1601 Propagate representative sequence to the final output alignment
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Mon, 16 Oct 2023 15:41:52 +0000 (17:41 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Mon, 16 Oct 2023 15:41:52 +0000 (17:41 +0200)
src/jalview/ws2/actions/secstructpred/SecStructPredJob.java
src/jalview/ws2/actions/secstructpred/SecStructPredTask.java
src/jalview/ws2/gui/SearchServiceGuiHandler.java

index 506b8a5..2df2f25 100644 (file)
@@ -29,4 +29,9 @@ public class SecStructPredJob extends BaseJob
   {
     return true;
   }
+
+  public int[] getDelMap()
+  {
+    return this.delMap;
+  }
 }
index 1c53904..cf6ef73 100644 (file)
@@ -12,6 +12,7 @@ import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
+import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.SeqCigar;
 import jalview.datamodel.SequenceI;
 import jalview.io.AlignFile;
@@ -26,7 +27,7 @@ import jalview.ws2.api.Credentials;
 import jalview.ws2.api.JobStatus;
 import jalview.ws2.client.api.SecStructPredWebServiceClientI;
 
-public class SecStructPredTask extends BaseTask<BaseJob, AlignmentI>
+public class SecStructPredTask extends BaseTask<SecStructPredJob, AlignmentI>
 {
   private final SecStructPredWebServiceClientI client;
 
@@ -47,7 +48,8 @@ public class SecStructPredTask extends BaseTask<BaseJob, AlignmentI>
   }
 
   @Override
-  protected List<BaseJob> prepareJobs() throws ServiceInputInvalidException
+  protected List<SecStructPredJob> prepareJobs()
+      throws ServiceInputInvalidException
   {
     SeqCigar[] msf = alignmentView.getSequences();
     SequenceI referenceSeq = msf[0].getSeq('-');
@@ -78,7 +80,8 @@ public class SecStructPredTask extends BaseTask<BaseJob, AlignmentI>
   }
 
   @Override
-  protected AlignmentI collectResult(List<BaseJob> jobs) throws IOException
+  protected AlignmentI collectResult(List<SecStructPredJob> jobs)
+      throws IOException
   {
     var job = jobs.get(0); // There shouldn't be more than one job
     var status = job.getStatus();
@@ -90,17 +93,17 @@ public class SecStructPredTask extends BaseTask<BaseJob, AlignmentI>
       return null;
     JPredFile predictionFile = client.getPredictionFile(job.getServerJob());
     AlignFile alignmentFile = client.getAlignmentFile(job.getServerJob());
-    // Object[] alnAndHiddenCols =
-    // alignmentView.getAlignmentAndHiddenColumns(gapChar);
-    // SequenceI[] sequences = (SequenceI[]) alnAndHiddenCols[0];
-    var sequences = alignmentFile.getSeqsAsArray();
-    // HiddenColumns hiddenCols = (HiddenColumns) alnAndHiddenCols[1];
-    var aln = new Alignment(sequences);
-    int firstSeq = 0;
+
+    Object[] alnAndHiddenCols = alignmentView
+        .getAlignmentAndHiddenColumns(gapChar);
+    SequenceI[] sequences = (SequenceI[]) alnAndHiddenCols[0];
+    Alignment aln = new Alignment(sequences);
+    HiddenColumns alhidden = (HiddenColumns) alnAndHiddenCols[1];
     aln.setDataset(currentView.getDataset());
     try
     {
-      JnetAnnotationMaker.add_annotation(predictionFile, aln, firstSeq, false);
+      JnetAnnotationMaker
+          .add_annotation(predictionFile, aln, 0, false, job.getDelMap());
     } catch (Exception e)
     {
       throw new IOException(e);
@@ -115,7 +118,7 @@ public class SecStructPredTask extends BaseTask<BaseJob, AlignmentI>
                 getClass().getSimpleName());
       }
     }
-    aln.setSeqrep(aln.getSequenceAt(firstSeq));
+    aln.setSeqrep(aln.getSequenceAt(0));
     return aln;
   }
 
index 49df466..a57db1d 100644 (file)
@@ -142,6 +142,12 @@ class SearchServiceGuiHandler implements TaskEventListener<AlignmentI>
       alnCpy.setDataset(result.getDataset());
       for (AlignmentAnnotation annotation : result.getAlignmentAnnotation())
         alnCpy.addAnnotation(new AlignmentAnnotation(annotation));
+      if (result.hasSeqrep())
+      {
+        int idx = result.findIndex(result.getSeqrep());
+        if (idx >= 0)
+          alnCpy.setSeqrep(alnCpy.getSequenceAt(idx));
+      }
       displayResultsNewFrame(alnCpy);
     });
     SwingUtilities.invokeLater(infoPanel::setResultsReady);