X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FDBRefEntryTest.java;fp=test%2Fjalview%2Fdatamodel%2FDBRefEntryTest.java;h=87e7082bcbb18989f25162d4c735d90e92727988;hb=7d67fb613ec026dc9a265e351e7fab542e3f1d61;hp=ae6dcdafa92140adc317b9c11b85360b5626e78c;hpb=02e38bb826828ab2991584cf4b737c0138cb6c44;p=jalview.git diff --git a/test/jalview/datamodel/DBRefEntryTest.java b/test/jalview/datamodel/DBRefEntryTest.java index ae6dcda..87e7082 100644 --- a/test/jalview/datamodel/DBRefEntryTest.java +++ b/test/jalview/datamodel/DBRefEntryTest.java @@ -81,7 +81,7 @@ public class DBRefEntryTest assertTrue(ref1.updateFrom(ref2)); assertEquals("UNIPROT", ref1.getSource()); // unchanged assertEquals("V71633", ref1.getAccessionId()); // unchanged - + /* * ref1 has no mapping, acquires mapping from ref2 */ @@ -138,4 +138,82 @@ public class DBRefEntryTest assertFalse(ref1.updateFrom(ref2)); assertEquals("10", ref1.getVersion()); } + + @Test(groups = { "Functional" }) + public void testIsPrimaryCandidate() + { + DBRefEntry dbr = new DBRefEntry(DBRefSource.UNIPROT, "", "Q12345"); + assertTrue(dbr.isPrimaryCandidate()); + + /* + * 1:1 mapping - ok + */ + dbr.setMap(new Mapping(null, new int[] { 1, 3 }, new int[] { 1, 3 }, 1, + 1)); + assertTrue(dbr.isPrimaryCandidate()); + + /* + * 1:1 mapping of identical split ranges - not ok + */ + dbr.setMap(new Mapping(null, new int[] { 1, 3, 6, 9 }, new int[] { 1, + 3, 6, 9 }, 1, 1)); + assertFalse(dbr.isPrimaryCandidate()); + + /* + * 1:1 mapping of different ranges - not ok + */ + dbr.setMap(new Mapping(null, new int[] { 1, 4 }, new int[] { 2, 5 }, 1, + 1)); + assertFalse(dbr.isPrimaryCandidate()); + + /* + * 1:1 mapping of 'isoform' ranges - not ok + */ + dbr.setMap(new Mapping(null, new int[] { 1, 2, 6, 9 }, new int[] { 1, + 3, 7, 9 }, 1, 1)); + assertFalse(dbr.isPrimaryCandidate()); + dbr.setMap(null); + assertTrue(dbr.isPrimaryCandidate()); + + /* + * Version string is prefixed with another dbref source string (fail) + */ + dbr.setVersion(DBRefSource.EMBL + ":0"); + assertFalse(dbr.isPrimaryCandidate()); + + /* + * Version string is alphanumeric + */ + dbr.setVersion("0.1.b"); + assertTrue(dbr.isPrimaryCandidate()); + + /* + * null version string can't be primary ref + */ + dbr.setVersion(null); + assertFalse(dbr.isPrimaryCandidate()); + dbr.setVersion(""); + assertTrue(dbr.isPrimaryCandidate()); + + /* + * 1:1 mapping and sequenceRef (fail) + */ + dbr.setMap(new Mapping(new Sequence("foo", "ASDF"), new int[] { 1, 3 }, + new int[] { 1, 3 }, 1, 1)); + assertFalse(dbr.isPrimaryCandidate()); + + /* + * 1:3 mapping (fail) + */ + dbr.setMap(new Mapping(null, new int[] { 1, 3 }, new int[] { 1, 3 }, 1, + 3)); + assertFalse(dbr.isPrimaryCandidate()); + + /* + * 2:2 mapping with shift (expected fail, but maybe use case for a pass) + */ + dbr.setMap(new Mapping(null, new int[] { 1, 4 }, new int[] { 1, 4 }, 2, + 2)); + assertFalse(dbr.isPrimaryCandidate()); + } }