From ce36ce68c3ec8d050f70163833e28f58e26bde89 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 4 Jul 2016 15:27:21 +0100 Subject: [PATCH] Revert "JAL-2110 use shared alignment dataset when copying alignment for split frame" This reverts commit f931c557266d95b3f4ab5b64bd108123c90e85ab. --- src/jalview/analysis/AlignmentUtils.java | 25 ++++++++++++++++++++---- src/jalview/gui/AlignFrame.java | 6 +----- test/jalview/analysis/AlignmentUtilsTests.java | 12 +++--------- test/jalview/datamodel/SequenceTest.java | 11 ----------- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 033f7e5..9150d62 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -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) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 15b1fb4..b310ab9 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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()); diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 9394385..d704ec6 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -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 cdsMappings = cds.getDataset().getCodonFrames(); + /* + * 6 mappings, 2*(DNA->CDS), 2*(DNA->Pep), 2*(CDS->Pep) + */ assertEquals(6, cdsMappings.size()); /* diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index eb32e5d..5c5c5c3 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -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() { -- 1.7.10.2