JAL-2046 add/delete SequenceFeature operate on dataset if one is defined
[jalview.git] / src / jalview / datamodel / Sequence.java
index 5bfdb04..a61f093 100755 (executable)
@@ -312,7 +312,11 @@ public class Sequence extends ASequence implements SequenceI
   @Override
   public synchronized void addSequenceFeature(SequenceFeature sf)
   {
-    // TODO add to dataset sequence instead if there is one?
+    if (sequenceFeatures==null && datasetSequence != null)
+    {
+      datasetSequence.addSequenceFeature(sf);
+      return;
+    }
     if (sequenceFeatures == null)
     {
       sequenceFeatures = new SequenceFeature[0];
@@ -338,6 +342,9 @@ public class Sequence extends ASequence implements SequenceI
   {
     if (sequenceFeatures == null)
     {
+      if (datasetSequence!=null) {
+         datasetSequence.deleteFeature(sf);
+      }
       return;
     }