From 4660937a02602e6986e7c0753699b22afa26347e Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 4 Oct 2016 13:50:02 +0100 Subject: [PATCH] JAL-2232 added test that failed before last fix, passes after it --- test/jalview/datamodel/AlignmentTest.java | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index 7ad9436..fcf724a 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -1042,4 +1042,67 @@ public class AlignmentTest assertEquals(23, startEnd[1]); } + /** + * Tests that dbrefs with mappings to sequence get updated if the sequence + * acquires a dataset sequence + */ + @Test(groups = "Functional") + public void testCreateDataset_updateDbrefMappings() + { + SequenceI pep = new Sequence("pep", "ASD"); + SequenceI dna = new Sequence("dna", "aaaGCCTCGGATggg"); + SequenceI cds = new Sequence("cds", "GCCTCGGAT"); + + // add dbref from dna to peptide + DBRefEntry dbr = new DBRefEntry("UNIPROT", "", "pep"); + dbr.setMap(new Mapping(pep, new MapList(new int[] { 4, 15 }, new int[] { + 1, 4 }, 3, 1))); + dna.addDBRef(dbr); + + // add dbref from dna to peptide + DBRefEntry dbr2 = new DBRefEntry("UNIPROT", "", "pep"); + dbr2.setMap(new Mapping(pep, new MapList(new int[] { 1, 12 }, new int[] + { 1, 4 }, 3, 1))); + cds.addDBRef(dbr2); + + // add dbref from peptide to dna + DBRefEntry dbr3 = new DBRefEntry("EMBL", "", "dna"); + dbr3.setMap(new Mapping(dna, new MapList(new int[] { 1, 4 }, new int[] { + 4, 15 }, 1, 3))); + pep.addDBRef(dbr3); + + // add dbref from peptide to cds + DBRefEntry dbr4 = new DBRefEntry("EMBLCDS", "", "cds"); + dbr4.setMap(new Mapping(cds, new MapList(new int[] { 1, 4 }, new int[] { + 1, 12 }, 1, 3))); + pep.addDBRef(dbr4); + + AlignmentI protein = new Alignment(new SequenceI[] { pep }); + + /* + * create the alignment dataset + */ + ((Alignment) protein).createDatasetAlignment(); + + AlignmentI ds = protein.getDataset(); + + // should be 3 sequences in dataset + assertEquals(3, ds.getHeight()); + assertTrue(ds.getSequences().contains(pep.getDatasetSequence())); + assertTrue(ds.getSequences().contains(dna)); + assertTrue(ds.getSequences().contains(cds)); + + /* + * verify peptide.cdsdbref.peptidedbref is now mapped to peptide dataset + */ + DBRefEntry[] dbRefs = pep.getDBRefs(); + assertEquals(2, dbRefs.length); + assertSame(dna, dbRefs[0].map.to); + assertSame(cds, dbRefs[1].map.to); + assertEquals(1, dna.getDBRefs().length); + assertSame(pep.getDatasetSequence(), dna.getDBRefs()[0].map.to); + assertEquals(1, cds.getDBRefs().length); + assertSame(pep.getDatasetSequence(), cds.getDBRefs()[0].map.to); + } + } -- 1.7.10.2