From: gmungoc Date: Wed, 6 Jul 2016 11:47:04 +0000 (+0100) Subject: JAL-2110 add 'mapFromId' to Mapping (for e.g. EMBL CDS protein_id) X-Git-Tag: Release_2_10_0~140^2~5^2~16 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5133de48f4251fa73eedcda66d6e2f2c25ff876b;p=jalview.git JAL-2110 add 'mapFromId' to Mapping (for e.g. EMBL CDS protein_id) --- diff --git a/src/jalview/datamodel/Mapping.java b/src/jalview/datamodel/Mapping.java index b4489e2..a0a050f 100644 --- a/src/jalview/datamodel/Mapping.java +++ b/src/jalview/datamodel/Mapping.java @@ -274,18 +274,23 @@ public class Mapping } - /** + /* * Contains the start-end pairs mapping from the associated sequence to the * sequence in the database coordinate system. It also takes care of step * difference between coordinate systems. */ MapList map = null; - /** + /* * The sequence that map maps the associated sequence to (if any). */ SequenceI to = null; + /* + * optional sequence id for the 'from' ranges + */ + private String mappedFromId; + public Mapping(MapList map) { super(); @@ -333,6 +338,7 @@ public class Mapping map = new MapList(map2.map); } to = map2.to; + mappedFromId = map2.mappedFromId; } } @@ -742,4 +748,22 @@ public class Mapping : this.to.getName()); } + /** + * Returns the identifier for the 'from' range sequence, or null if not set + * + * @return + */ + public String getMappedFromId() + { + return mappedFromId; + } + + /** + * Sets the identifier for the 'from' range sequence + */ + public void setMappedFromId(String mappedFromId) + { + this.mappedFromId = mappedFromId; + } + } diff --git a/test/jalview/datamodel/MappingTest.java b/test/jalview/datamodel/MappingTest.java index 3131ad7..b326d90 100644 --- a/test/jalview/datamodel/MappingTest.java +++ b/test/jalview/datamodel/MappingTest.java @@ -21,6 +21,7 @@ package jalview.datamodel; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertSame; import jalview.util.MapList; @@ -75,4 +76,18 @@ public class MappingTest m = new Mapping(seq, fk); assertEquals("[ [1, 6] [8, 13] ] 3:1 to [ [4, 7] ] Seq1", m.toString()); } + + @Test(groups = { "Functional" }) + public void testCopyConstructor() + { + MapList ml = new MapList(new int[] { 1, 6, 8, 13 }, new int[] { 4, 7 }, + 3, 1); + SequenceI seq = new Sequence("seq1", "agtacg"); + Mapping m = new Mapping(seq, ml); + m.setMappedFromId("abc"); + Mapping copy = new Mapping(m); + assertEquals("abc", copy.getMappedFromId()); + assertEquals(ml, copy.getMap()); + assertSame(seq, copy.getTo()); + } }