Revert "JAL-2110 use shared alignment dataset when copying alignment for split frame"
[jalview.git] / src / jalview / analysis / AlignmentUtils.java
index 033f7e5..9150d62 100644 (file)
@@ -2211,15 +2211,32 @@ public class AlignmentUtils
    * 
    * @param seqs
    * @param xrefs
-   * @param dataset
-   *          alignment dataset shared by the new copy
    * @return
    */
   public static AlignmentI makeCopyAlignment(SequenceI[] seqs,
-          SequenceI[] xrefs, AlignmentI dataset)
+          SequenceI[] xrefs)
   {
     AlignmentI copy = new Alignment(new Alignment(seqs));
-    copy.setDataset(dataset);
+
+    /*
+     * add mappings between sequences to the new alignment
+     */
+    AlignedCodonFrame mappings = new AlignedCodonFrame();
+    copy.addCodonFrame(mappings);
+    for (int i = 0; i < copy.getHeight(); i++)
+    {
+      SequenceI from = seqs[i];
+      SequenceI to = copy.getSequenceAt(i);
+      if (to.getDatasetSequence() != null)
+      {
+        to = to.getDatasetSequence();
+      }
+      int start = from.getStart();
+      int end = from.getEnd();
+      MapList map = new MapList(new int[] { start, end }, new int[] {
+          start, end }, 1, 1);
+      mappings.addMap(to, from, map);
+    }
 
     SequenceIdMatcher matcher = new SequenceIdMatcher(seqs);
     if (xrefs != null)