JAL-4366 allow a 3di alignment to be loaded and shown as a split frame with existing...
[jalview.git] / src / jalview / gui / AlignViewport.java
index ef9e575..d56764b 100644 (file)
@@ -830,18 +830,31 @@ public class AlignViewport extends AlignmentViewport
     AlignmentI thisAlignment = newWindowOrSplitPane
             ? new Alignment(getAlignment())
             : getAlignment();
-    AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
-    final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
-
-    /*
-     * Map sequences. At least one should get mapped as we have already passed
-     * the test for 'mappability'. Any mappings made will be added to the
-     * protein alignment. Note creating dataset sequences on the new alignment
-     * is a pre-requisite for building mappings.
-     */
+    
+    // always create dataset for imported alignment before doing anything else..
     al.setDataset(null);
-    AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
+    
+    if (!al.isNucleotide() && !thisAlignment.isNucleotide())
+    {
+      // link AA to 3di or other kind of 'alternative' 1:1 mapping alignment
+      AlignmentUtils.map3diPeptideToProteinAligment(thisAlignment,al);
 
+    }
+    else
+    {
+      // link CODON triplets to Protein
+      AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
+      final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
+
+      /*
+       * Map sequences. At least one should get mapped as we have already passed
+       * the test for 'mappability'. Any mappings made will be added to the
+       * protein alignment. Note creating dataset sequences on the new alignment
+       * is a pre-requisite for building mappings.
+       */
+      AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
+    }
+    
     /*
      * Create the AlignFrame for the added alignment. If it is protein, mappings
      * are registered with StructureSelectionManager as a side-effect.
@@ -876,7 +889,7 @@ public class AlignViewport extends AlignmentViewport
     if (newWindowOrSplitPane)
     {
       al.alignAs(thisAlignment);
-      protein = openSplitFrame(newAlignFrame, thisAlignment);
+      AlignmentI mapped = openSplitFrame(newAlignFrame, thisAlignment);
     }
   }
 
@@ -997,7 +1010,7 @@ public class AlignViewport extends AlignmentViewport
    */
   protected boolean noReferencesTo(AlignedCodonFrame acf)
   {
-    AlignFrame[] frames = Desktop.getAlignFrames();
+    AlignFrame[] frames = Desktop.getDesktopAlignFrames();
     if (frames == null)
     {
       return true;