JAL-1687 ignore case when determining if sequence matches consensus
[jalview.git] / src / jalview / ws / jws2 / MsaWSThread.java
index 60694e3..d0d0a6e 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -451,7 +451,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI
    * @param presorder
    *          boolean
    */
-  MsaWSThread(MsaWS server, String wsUrl, WebserviceInfo wsinfo,
+  private MsaWSThread(MsaWS server, String wsUrl, WebserviceInfo wsinfo,
           jalview.gui.AlignFrame alFrame, AlignmentView alview,
           String wsname, boolean subgaps, boolean presorder)
   {
@@ -991,24 +991,35 @@ class MsaWSThread extends AWS2Thread implements WSClientI
      * If alignment was requested from one half of a SplitFrame, show in a
      * SplitFrame with the other pane similarly aligned.
      */
-    if (this.isFromSplitFrame())
+    AlignFrame requestedBy = getRequestingAlignFrame();
+    if (requestedBy != null && requestedBy.getSplitViewContainer() != null)
     {
-      // TODO will only work for protein, as it holds the codon frame mappings
-      // may need this thread to hold a reference to the requesting AlignFrame
-      AlignmentI complement = al.getAlignedComplement(al.getCodonFrames());
-      AlignFrame af2 = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH,
-              AlignFrame.DEFAULT_HEIGHT);
-      String linkedTitle = MessageManager
-              .getString("label.linked_view_title");
-      JInternalFrame splitFrame = new SplitFrame(al.isNucleotide() ? af
-              : af2, al.isNucleotide() ? af2 : af);
-      Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
-    }
-    else
-    {
-      Desktop.addInternalFrame(af, alTitle, AlignFrame.DEFAULT_WIDTH,
-              AlignFrame.DEFAULT_HEIGHT);
+      AlignmentI complement = requestedBy.getSplitViewContainer()
+              .getComplement(requestedBy);
+      String complementTitle = requestedBy.getSplitViewContainer()
+              .getComplementTitle(requestedBy);
+      AlignmentI copyComplement = new Alignment(complement);
+      copyComplement.alignAs(al);
+      if (copyComplement.getHeight() > 0)
+      {
+        af.setTitle(alTitle);
+        AlignFrame af2 = new AlignFrame(copyComplement,
+                AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+        af2.setTitle(complementTitle);
+        String linkedTitle = MessageManager
+                .getString("label.linked_view_title");
+        JInternalFrame splitFrame = new SplitFrame(al.isNucleotide() ? af
+                : af2, al.isNucleotide() ? af2 : af);
+        Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
+        return;
+      }
     }
+
+    /*
+     * Not from SplitFrame, or failed to created a complementary alignment
+     */
+    Desktop.addInternalFrame(af, alTitle, AlignFrame.DEFAULT_WIDTH,
+            AlignFrame.DEFAULT_HEIGHT);
   }
 
   /**