JAL-2526 first draft of findIndex/findPosition with SequenceCursor
[jalview.git] / src / jalview / datamodel / DBRefEntry.java
index 11e77d8..ec6dcf8 100755 (executable)
@@ -23,6 +23,7 @@ package jalview.datamodel;
 import jalview.api.DBRefEntryI;
 
 import java.util.Arrays;
+import java.util.List;
 
 public class DBRefEntry implements DBRefEntryI
 {
@@ -281,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.  
@@ -297,12 +298,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<int[]> fromRanges = map.getMap().getFromRanges();
+      List<int[]> 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;
       }