X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FDBRefEntry.java;h=bc8d0cf1d1723e423b1d1d62608ce1a62d2bb6fa;hb=2eea4e73351d902cd88923d863e9780fa57a0ee7;hp=11e77d85a138ec545ddbd37c4287ce30ccdb0e7f;hpb=9a0e53e18ba1280658e1424c5e08b90e7beeebde;p=jalview.git diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java index 11e77d8..bc8d0cf 100755 --- a/src/jalview/datamodel/DBRefEntry.java +++ b/src/jalview/datamodel/DBRefEntry.java @@ -23,10 +23,15 @@ package jalview.datamodel; import jalview.api.DBRefEntryI; import java.util.Arrays; +import java.util.List; public class DBRefEntry implements DBRefEntryI { - String source = "", version = "", accessionId = ""; + String source = ""; + + String version = ""; + + String accessionId = ""; /** * maps from associated sequence to the database sequence's coordinate system @@ -67,10 +72,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 +93,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 +107,8 @@ public class DBRefEntry implements DBRefEntryI * @@ -140,8 +145,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 +164,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 +200,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 +285,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 +301,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; }