JAL-3748 recover complement alignment from complement alignmentView rather than let...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 16 Sep 2020 16:45:12 +0000 (17:45 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 16 Sep 2020 16:45:12 +0000 (17:45 +0100)
src/jalview/ws/jws2/MsaWSThread.java

index db6e03f..89cf024 100644 (file)
@@ -974,13 +974,24 @@ class MsaWSThread extends AWS2Thread implements WSClientI
     {
       al.setDataset(dataset);
     }
-
     propagateDatasetMappings(al);
+    Alignment complement=null;
+    if (input.hasComplementView())
+    {
+      Object[] newcompl = input
+              .getComplementView()
+              .getAlignmentAndHiddenColumns(getRequestingAlignFrame()
+                      .getViewport().getCodingComplement().getGapCharacter());
+      complement = new Alignment((SequenceI[])newcompl[0]);
+      complement.setHiddenColumns((HiddenColumns) newcompl[1]);
+      complement.setDataset(dataset);
+      complement.alignAs(al);
+    }
     // JBNote- TODO: warn user if a block is input rather than aligned data ?
 
     if (newFrame)
     {
-      displayInNewFrame(al, alorders, hidden);
+      displayInNewFrame(al, alorders, hidden, complement);
 
     }
     else
@@ -998,10 +1009,11 @@ class MsaWSThread extends AWS2Thread implements WSClientI
    * 
    * @param al
    * @param alorders
+   * @param complement2 
    * @param columnselection
    */
   protected void displayInNewFrame(AlignmentI al,
-          List<AlignmentOrder> alorders, HiddenColumns hidden)
+          List<AlignmentOrder> alorders, HiddenColumns hidden, AlignmentI complement)
   {
     AlignFrame af = new AlignFrame(al, hidden, AlignFrame.DEFAULT_WIDTH,
             AlignFrame.DEFAULT_HEIGHT);
@@ -1021,26 +1033,18 @@ class MsaWSThread extends AWS2Thread implements WSClientI
      * SplitFrame with the other pane similarly aligned.
      */
     AlignFrame requestedBy = getRequestingAlignFrame();
-    if (requestedBy != null && requestedBy.getSplitViewContainer() != null
+    if (complement!=null && requestedBy != null && requestedBy.getSplitViewContainer() != null
             && requestedBy.getSplitViewContainer()
                     .getComplement(requestedBy) != null)
     {
-      AlignmentI complement = requestedBy.getSplitViewContainer()
-              .getComplement(requestedBy);
       String complementTitle = requestedBy.getSplitViewContainer()
               .getComplementTitle(requestedBy);
       // becomes null if the alignment window was closed before the alignment
       // job finished.
-      AlignmentI copyComplement = new Alignment(complement);
-      // todo should this be done by copy constructor?
-      copyComplement.setGapCharacter(complement.getGapCharacter());
-      // share the same dataset (and the mappings it holds)
-      copyComplement.setDataset(complement.getDataset());
-      copyComplement.alignAs(al);
-      if (copyComplement.getHeight() > 0)
+      if (complement.getHeight() > 0)
       {
         af.setTitle(alTitle);
-        AlignFrame af2 = new AlignFrame(copyComplement,
+        AlignFrame af2 = new AlignFrame(complement,
                 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
         af2.setTitle(complementTitle);
         String linkedTitle = MessageManager