JAL-2490 performant findFeaturesAtRes
[jalview.git] / src / jalview / datamodel / SequenceFeature.java
index c330df9..719cf52 100755 (executable)
@@ -178,6 +178,24 @@ public class SequenceFeature implements FeatureLocationI
   }
 
   /**
+   * A copy constructor that allows the begin and end positions and group to be
+   * modified
+   * 
+   * @param sf
+   * @param newBegin
+   * @param newEnd
+   * @param newGroup
+   */
+  public SequenceFeature(SequenceFeature sf, int newBegin, int newEnd,
+          String newGroup)
+  {
+    this(sf);
+    begin = newBegin;
+    end = newEnd;
+    featureGroup = newGroup;
+  }
+
+  /**
    * Two features are considered equal if they have the same type, group,
    * description, start, end, phase, strand, and (if present) 'Name', ID' and
    * 'Parent' attributes.
@@ -344,7 +362,10 @@ public class SequenceFeature implements FeatureLocationI
       links = new Vector<String>();
     }
 
-    links.insertElementAt(labelLink, 0);
+    if (!links.contains(labelLink))
+    {
+      links.insertElementAt(labelLink, 0);
+    }
   }
 
   public float getScore()
@@ -553,4 +574,14 @@ public class SequenceFeature implements FeatureLocationI
     }
     return false;
   }
+
+  /**
+   * Answers true if the sequence has zero start and end position
+   * 
+   * @return
+   */
+  public boolean isNonPositional()
+  {
+    return begin == 0 && end == 0;
+  }
 }