Revert "JAL-2110 use shared alignment dataset when copying alignment for split frame"
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 4 Jul 2016 14:27:21 +0000 (15:27 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 4 Jul 2016 14:27:21 +0000 (15:27 +0100)
This reverts commit f931c557266d95b3f4ab5b64bd108123c90e85ab.

src/jalview/analysis/AlignmentUtils.java
src/jalview/gui/AlignFrame.java
test/jalview/analysis/AlignmentUtilsTests.java
test/jalview/datamodel/SequenceTest.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)
index 15b1fb4..b310ab9 100644 (file)
@@ -4787,12 +4787,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           }
           else
           {
-            /*
-             * copy peptide sequences, and add in any alternate products
-             * of their located coding xrefs
-             */
             copyAlignment = AlignmentUtils.makeCopyAlignment(
-                    sequenceSelection, xrefs.getSequencesArray(), dataset);
+                    sequenceSelection, xrefs.getSequencesArray());
           }
           copyAlignment.setGapCharacter(AlignFrame.this.viewport
                   .getGapCharacter());
index 9394385..d704ec6 100644 (file)
@@ -1015,19 +1015,13 @@ public class AlignmentUtilsTests
             .contains(cds.getSequenceAt(1).getDatasetSequence()));
 
     /*
-     * verify cds has dbref with mapping to protein and vice versa
-     */
-    DBRefEntry[] cdsDbrefs = cds.getSequenceAt(0).getDBRefs();
-    // assertNotNull(cdsDbrefs);
-    // assertEquals(1, cdsDbrefs.length);
-    // assertNotNull(cdsDbrefs[0].getMap());
-
-    /*
      * Verify mappings from CDS to peptide, cDNA to CDS, and cDNA to peptide
      * the mappings are on the shared alignment dataset
-     * 6 mappings, 2*(DNA->CDS), 2*(DNA->Pep), 2*(CDS->Pep) 
      */
     List<AlignedCodonFrame> cdsMappings = cds.getDataset().getCodonFrames();
+    /*
+     * 6 mappings, 2*(DNA->CDS), 2*(DNA->Pep), 2*(CDS->Pep) 
+     */
     assertEquals(6, cdsMappings.size());
 
     /*
index eb32e5d..5c5c5c3 100644 (file)
@@ -78,18 +78,7 @@ public class SequenceTest
     // change sequence, should trigger an update of cached result
     sq.setSequence("ASDFASDFADSF");
     assertTrue(sq.isProtein());
-
-    /*
-     * in situ change of sequence doesn't change hashcode :-O
-     * (sequence should not expose internal implementation)
-     */
-    for (int i = 0; i < sq.getSequence().length; i++)
-    {
-      sq.getSequence()[i] = "acgtu".charAt(i % 5);
-    }
-    assertTrue(sq.isProtein()); // but it isn't
   }
-
   @Test(groups = { "Functional" })
   public void testGetAnnotation()
   {