From: gmungoc Date: Tue, 6 Sep 2016 14:31:42 +0000 (+0100) Subject: JAL-2106 DBRefEntry.isPrimary() renamed isPrimaryCandidate() X-Git-Tag: Release_2_10_0~47^2~4^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6c43dd36929855a7907380ffb36b4df249d4a557;p=jalview.git JAL-2106 DBRefEntry.isPrimary() renamed isPrimaryCandidate() --- diff --git a/src/jalview/api/DBRefEntryI.java b/src/jalview/api/DBRefEntryI.java index a4ec575..52ee381 100644 --- a/src/jalview/api/DBRefEntryI.java +++ b/src/jalview/api/DBRefEntryI.java @@ -72,7 +72,10 @@ public interface DBRefEntryI public boolean updateFrom(DBRefEntryI otherEntry); /** - * Method to distinguish between direct and indirect database references.
+ * Answers true if the ref looks like a primary (direct) database reference.
+ * The only way a dbref's mappings can be fully verified is via the local + * sequence frame, so rather than use isPrimaryCandidate directly, please use + * SequenceI.getPrimaryDbRefs().
* Primary references indicate the local sequence data directly corresponds * with the database record. All other references are secondary. Direct * references indicate that part or all of the local sequence data can be @@ -82,13 +85,10 @@ public interface DBRefEntryI * This method is also sufficient to distinguish direct DBRefEntry mappings * from other relationships - e.g. coding relationships (imply a 1:3/3:1 * mapping), but not transcript relationships, which imply a (possibly - * non-contiguous) 1:1 mapping.
- * The only way a dbref's mappings can be fully verified is via the local - * sequence frame, so rather than use isPrimary directly, please use - * SequenceI.getPrimaryDbRefs(). + * non-contiguous) 1:1 mapping. * * @return true if this reference provides a primary accession for the * associated sequence object */ - public boolean isPrimary(); + public boolean isPrimaryCandidate(); } diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java index 143a4d2..ec6dcf8 100755 --- a/src/jalview/datamodel/DBRefEntry.java +++ b/src/jalview/datamodel/DBRefEntry.java @@ -282,7 +282,7 @@ public class DBRefEntry implements DBRefEntryI } @Override - public boolean isPrimary() + public boolean isPrimaryCandidate() { /* * if a map is present, unless it is 1:1 and has no SequenceI mate, it cannot be a primary reference. @@ -298,7 +298,7 @@ public class DBRefEntry implements DBRefEntryI { return false; } - // check map is really 1:1, between identical single ranges + // check map is between identical single contiguous ranges List fromRanges = map.getMap().getFromRanges(); List toRanges = map.getMap().getToRanges(); if (fromRanges.size() != 1 || toRanges.size() != 1) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index b50e5af..5886ae0 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1431,7 +1431,7 @@ public class Sequence extends ASequence implements SequenceI DBRefEntry[] tmp = new DBRefEntry[1]; for (DBRefEntry ref : dbrefs) { - if (!ref.isPrimary()) + if (!ref.isPrimaryCandidate()) { continue; } diff --git a/src/jalview/ws/sifts/SiftsClient.java b/src/jalview/ws/sifts/SiftsClient.java index e08b8cb..f20954e 100644 --- a/src/jalview/ws/sifts/SiftsClient.java +++ b/src/jalview/ws/sifts/SiftsClient.java @@ -338,11 +338,10 @@ public class SiftsClient implements SiftsClientI { continue; } + String canonicalSource = DBRefUtils.getCanonicalName(dbRef + .getSource()); if (isValidDBRefEntry(dbRef) - && dbRef.isPrimary() - && (DBRefUtils.getCanonicalName(dbRef.getSource()) - .equalsIgnoreCase(DBRefSource.UNIPROT) || DBRefUtils - .getCanonicalName(dbRef.getSource()) + && (canonicalSource.equalsIgnoreCase(DBRefSource.UNIPROT) || canonicalSource .equalsIgnoreCase(DBRefSource.PDB))) { return dbRef; diff --git a/test/jalview/datamodel/DBRefEntryTest.java b/test/jalview/datamodel/DBRefEntryTest.java index ee0bd41..7b1ab57 100644 --- a/test/jalview/datamodel/DBRefEntryTest.java +++ b/test/jalview/datamodel/DBRefEntryTest.java @@ -140,80 +140,80 @@ public class DBRefEntryTest } @Test(groups = { "Functional" }) - public void testIsPrimary() + public void testIsPrimaryCandidate() { DBRefEntry dbr = new DBRefEntry(DBRefSource.UNIPROT, "", "Q12345"); - assertTrue(dbr.isPrimary()); + assertTrue(dbr.isPrimaryCandidate()); /* * 1:1 mapping - ok */ dbr.setMap(new Mapping(null, new int[] { 1, 3 }, new int[] { 1, 3 }, 1, 1)); - assertTrue(dbr.isPrimary()); + 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.isPrimary()); + 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.isPrimary()); + 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.isPrimary()); + assertFalse(dbr.isPrimaryCandidate()); dbr.setMap(null); - assertTrue(dbr.isPrimary()); + assertTrue(dbr.isPrimaryCandidate()); /* * Version string is prefixed with another dbref source string (fail) */ dbr.setVersion(DBRefSource.EMBL + ":0"); - assertFalse(dbr.isPrimary()); + assertFalse(dbr.isPrimaryCandidate()); /* * Version string is alphanumeric */ dbr.setVersion("0.1.b"); - assertTrue(dbr.isPrimary()); + assertTrue(dbr.isPrimaryCandidate()); /* * null version string can't be primary ref */ dbr.setVersion(null); - assertFalse(dbr.isPrimary()); + assertFalse(dbr.isPrimaryCandidate()); dbr.setVersion(""); - assertTrue(dbr.isPrimary()); + 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.isPrimary()); + assertFalse(dbr.isPrimaryCandidate()); /* * 1:3 mapping (fail) */ dbr.setMap(new Mapping(null, new int[] { 1, 3 }, new int[] { 1, 3 }, 1, 3)); - assertFalse(dbr.isPrimary()); + 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.isPrimary()); + assertFalse(dbr.isPrimaryCandidate()); } } diff --git a/test/jalview/ext/ensembl/EnsemblXrefTest.java b/test/jalview/ext/ensembl/EnsemblXrefTest.java index 4dc8ab2..df1c1ad 100644 --- a/test/jalview/ext/ensembl/EnsemblXrefTest.java +++ b/test/jalview/ext/ensembl/EnsemblXrefTest.java @@ -44,12 +44,12 @@ public class EnsemblXrefTest assertEquals(2, dbrefs.size()); assertEquals("CCDS", dbrefs.get(0).getSource()); assertEquals("CCDS5863", dbrefs.get(0).getAccessionId()); - assertFalse(dbrefs.get(0).isPrimary()); + assertFalse(dbrefs.get(0).isPrimaryCandidate()); assertEquals(dbName + ":" + dbVers, dbrefs.get(0).getVersion()); // Uniprot name should get converted to Jalview canonical form assertEquals("UNIPROT", dbrefs.get(1).getSource()); assertEquals("P15056", dbrefs.get(1).getAccessionId()); assertEquals(dbName + ":" + dbVers, dbrefs.get(1).getVersion()); - assertFalse(dbrefs.get(1).isPrimary()); + assertFalse(dbrefs.get(1).isPrimaryCandidate()); } }