X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FDBRefEntry.java;h=98868ce64edbae6634dd50e80337b580a6ed6613;hb=9e926ac4305fd9dff38b6e079e55b4f50664d544;hp=11e77d85a138ec545ddbd37c4287ce30ccdb0e7f;hpb=9a0e53e18ba1280658e1424c5e08b90e7beeebde;p=jalview.git diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java index 11e77d8..98868ce 100755 --- a/src/jalview/datamodel/DBRefEntry.java +++ b/src/jalview/datamodel/DBRefEntry.java @@ -23,10 +23,24 @@ package jalview.datamodel; import jalview.api.DBRefEntryI; import java.util.Arrays; +import java.util.List; public class DBRefEntry implements DBRefEntryI { - String source = "", version = "", accessionId = ""; + /* + * the mapping to chromosome (genome) is held as an instance with + * source = speciesId + * version = assemblyId + * accessionId = "chromosome:" + chromosomeId + * map = mapping from sequence to reference assembly + */ + public static final String CHROMOSOME = "chromosome"; + + String source = ""; + + String version = ""; + + String accessionId = ""; /** * maps from associated sequence to the database sequence's coordinate system @@ -67,10 +81,10 @@ public class DBRefEntry implements DBRefEntryI public DBRefEntry(DBRefEntryI entry) { this((entry.getSource() == null ? "" : new String(entry.getSource())), - (entry.getVersion() == null ? "" : new String( - entry.getVersion())), - (entry.getAccessionId() == null ? "" : new String( - entry.getAccessionId())), + (entry.getVersion() == null ? "" + : new String(entry.getVersion())), + (entry.getAccessionId() == null ? "" + : new String(entry.getAccessionId())), (entry.getMap() == null ? null : new Mapping(entry.getMap()))); } @@ -88,9 +102,8 @@ public class DBRefEntry implements DBRefEntryI { return true; } - if (equalRef(entry) - && ((map == null && entry.map == null) || (map != null - && entry.map != null && map.equals(entry.map)))) + if (equalRef(entry) && ((map == null && entry.map == null) + || (map != null && entry.map != null && map.equals(entry.map)))) { return true; } @@ -103,7 +116,8 @@ public class DBRefEntry implements DBRefEntryI * @@ -140,8 +154,8 @@ public class DBRefEntry implements DBRefEntryI String otherAccession = other.getAccessionId(); if ((accessionId == null && otherAccession != null) || (accessionId != null && otherAccession == null) - || (accessionId != null && !accessionId - .equalsIgnoreCase(otherAccession))) + || (accessionId != null + && !accessionId.equalsIgnoreCase(otherAccession))) { return false; } @@ -159,9 +173,8 @@ public class DBRefEntry implements DBRefEntryI } else { - if (version != null - && (otherVersion == null || !version - .equalsIgnoreCase(otherVersion))) + if (version != null && (otherVersion == null + || !version.equalsIgnoreCase(otherVersion))) { return false; } @@ -196,12 +209,12 @@ public class DBRefEntry implements DBRefEntryI return true; } if (entry != null - && (source != null && entry.getSource() != null && source - .equalsIgnoreCase(entry.getSource())) - && (accessionId != null && entry.getAccessionId() != null && accessionId - .equalsIgnoreCase(entry.getAccessionId())) - && (version != null && entry.getVersion() != null && version - .equalsIgnoreCase(entry.getVersion()))) + && (source != null && entry.getSource() != null + && source.equalsIgnoreCase(entry.getSource())) + && (accessionId != null && entry.getAccessionId() != null + && accessionId.equalsIgnoreCase(entry.getAccessionId())) + && (version != null && entry.getVersion() != null + && version.equalsIgnoreCase(entry.getVersion()))) { return true; } @@ -281,7 +294,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. @@ -297,12 +310,15 @@ public class DBRefEntry implements DBRefEntryI { return false; } - // check map is really 1:1, no shifts allowed. - if (map.getMap().getFromHighest() != map.getMap().getToHighest() - && map.getMap().getFromLowest() != map.getMap().getToLowest() - && !Arrays.equals( - map.getMap().getFromRanges().toArray(new int[0][]), - map.getMap().getToRanges().toArray(new int[0][]))) + // 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) + { + return false; + } + if (fromRanges.get(0)[0] != toRanges.get(0)[0] + || fromRanges.get(0)[1] != toRanges.get(0)[1]) { return false; } @@ -328,4 +344,14 @@ public class DBRefEntry implements DBRefEntryI } return true; } + + /** + * Mappings to chromosome are held with accessionId as "chromosome:id" + * + * @return + */ + public boolean isChromosome() + { + return accessionId != null && accessionId.startsWith(CHROMOSOME + ":"); + } }