/*
* 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, non-contact features
+ * remove any that are not enclosing features
*/
if (endPos > this.end || Comparison.isGap(sequence[fromColumn - 1])
|| Comparison.isGap(sequence[toColumn - 1]))
SequenceFeature sf = it.next();
int featureStartColumn = findIndex(sf.getBegin());
int featureEndColumn = findIndex(sf.getEnd());
- boolean noOverlap = featureStartColumn > toColumn
- || featureEndColumn < fromColumn;
-
- /*
- * reject an 'enclosing' feature if it is actually a contact feature
- */
- if (sf.isContactFeature() && featureStartColumn < fromColumn
- && featureEndColumn > toColumn)
- {
- noOverlap = true;
- }
- if (noOverlap)
+ if (featureStartColumn > toColumn
+ || featureEndColumn < fromColumn)
{
it.remove();
}
/**
* Returns a (possibly empty) list of features, optionally restricted to
* specified types, which overlap the given (inclusive) sequence position
- * range
+ * range. Contact features are included if either start or end (or both) lie
+ * within the range. Non-contact features which span the range are also
+ * included.
*
* @param from
* @param to
assertTrue(found.contains(sf1));
assertTrue(found.contains(sf2));
assertTrue(found.contains(sf4));
+
+ // columns 9-12 (F--G) includes F/G (once only) but not B/H feature
+ found = sq.findFeatures(9, 12);
+ assertEquals(1, found.size());
+ assertTrue(found.contains(sf4));
+
+ // column 4 (C) includes enclosing BCD but not B/H feature
+ found = sq.findFeatures(4, 4);
+ assertEquals(1, found.size());
+ assertTrue(found.contains(sf1));
}
@Test(groups = { "Functional" })