JAL-2144 TODO - new methods for canonicalisation and comparison of source strings...
[jalview.git] / src / jalview / gui / AlignFrame.java
index b310ab9..891fdd6 100644 (file)
@@ -4734,6 +4734,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
           AlignmentI xrefsAlignment = makeCrossReferencesAlignment(dataset,
                   xrefs);
+          if (!dna)
+          {
+            xrefsAlignment = AlignmentUtils.makeCdsAlignment(
+                    xrefsAlignment.getSequencesArray(), dataset, sel);
+            xrefsAlignment.alignAs(alignment);
+          }
 
           AlignFrame newFrame = new AlignFrame(xrefsAlignment, DEFAULT_WIDTH,
                   DEFAULT_HEIGHT);
@@ -4761,13 +4767,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
            * sequences). If we are DNA, drop introns and update mappings
            */
           AlignmentI copyAlignment = null;
-          final SequenceI[] sequenceSelection = AlignFrame.this.viewport
-                  .getSequenceSelection();
           boolean copyAlignmentIsAligned = false;
           if (dna)
           {
-            copyAlignment = AlignmentUtils.makeCdsAlignment(
-                    sequenceSelection, dataset, xrefsAlignment);
+            copyAlignment = AlignmentUtils.makeCdsAlignment(sel, dataset,
+                    xrefsAlignment.getSequencesArray());
             if (copyAlignment.getHeight() == 0)
             {
               System.err.println("Failed to make CDS alignment");
@@ -4787,8 +4791,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           }
           else
           {
-            copyAlignment = AlignmentUtils.makeCopyAlignment(
-                    sequenceSelection, xrefs.getSequencesArray());
+            copyAlignment = AlignmentUtils.makeCopyAlignment(sel,
+                    xrefs.getSequencesArray(), dataset);
           }
           copyAlignment.setGapCharacter(AlignFrame.this.viewport
                   .getGapCharacter());
@@ -4821,7 +4825,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
              * align cdna to protein - currently only if 
              * fetching and aligning Ensembl transcripts!
              */
-            if (DBRefSource.ENSEMBL.equalsIgnoreCase(source))
+            // TODO: generalise for other sources of locus/transcript/cds data
+            if (dna && DBRefSource.ENSEMBL.equalsIgnoreCase(source))
             {
               copyAlignment.alignAs(xrefsAlignment);
             }
@@ -4880,6 +4885,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
        * Makes an alignment containing the given sequences, and adds them to the
        * given dataset, which is also set as the dataset for the new alignment
        * 
+       * TODO: refactor to DatasetI method
+       * 
        * @param dataset
        * @param seqs
        * @return