JAL-2505 correct handling of change of feature type
[jalview.git] / src / jalview / datamodel / Sequence.java
index 96a2fa1..a01d185 100755 (executable)
@@ -1821,12 +1821,11 @@ public class Sequence extends ASequence implements SequenceI
             endPos, types);
 
     /*
-     * if the start or end column is gapped, startPos or endPos may be to the 
-     * left or right, and we may have included adjacent or enclosing features;
-     * remove any that are not enclosing features
+     * if end column is gapped, endPos may be to the right, 
+     * and we may have included adjacent or enclosing features;
+     * remove any that are not enclosing, non-contact features
      */
-    if (endPos > this.end || Comparison.isGap(sequence[fromColumn - 1])
-            || Comparison.isGap(sequence[toColumn - 1]))
+    if (endPos > this.end || Comparison.isGap(sequence[toColumn - 1]))
     {
       ListIterator<SequenceFeature> it = result.listIterator();
       while (it.hasNext())
@@ -1847,6 +1846,13 @@ public class Sequence extends ASequence implements SequenceI
           {
             it.remove();
           }
+          else if (featureEndColumn > toColumn && sf.isContactFeature())
+          {
+            /*
+             * remove an enclosing feature if it is a contact feature
+             */
+            it.remove();
+          }
         }
       }
     }