JAL-2526 first draft of findIndex/findPosition with SequenceCursor
[jalview.git] / src / jalview / datamodel / DBRefEntry.java
index e2ee195..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,6 +298,18 @@ public class DBRefEntry implements DBRefEntryI
       {
         return false;
       }
+      // 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;
+      }
     }
     if (version == null)
     {