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())
{
it.remove();
}
+ else if (featureEndColumn > toColumn && sf.isContactFeature())
+ {
+ /*
+ * remove an enclosing feature if it is a contact feature
+ */
+ it.remove();
+ }
}
}
}
null);
sq.addSequenceFeature(sf0);
// add feature on BCD
- SequenceFeature sf1 = new SequenceFeature("Cath", "desc", 9, 11, 2f,
+ SequenceFeature sfBCD = new SequenceFeature("Cath", "desc", 9, 11, 2f,
null);
- sq.addSequenceFeature(sf1);
+ sq.addSequenceFeature(sfBCD);
// add feature on DE
- SequenceFeature sf2 = new SequenceFeature("Cath", "desc", 11, 12, 2f,
+ SequenceFeature sfDE = new SequenceFeature("Cath", "desc", 11, 12, 2f,
null);
- sq.addSequenceFeature(sf2);
+ sq.addSequenceFeature(sfDE);
// add contact feature at [B, H]
- SequenceFeature sf3 = new SequenceFeature("Disulphide bond", "desc", 9,
- 15, 2f,
- null);
- sq.addSequenceFeature(sf3);
+ SequenceFeature sfContactBH = new SequenceFeature("Disulphide bond",
+ "desc", 9, 15, 2f, null);
+ sq.addSequenceFeature(sfContactBH);
// add contact feature at [F, G]
- SequenceFeature sf4 = new SequenceFeature("Disulfide Bond", "desc", 13,
- 14, 2f,
- null);
- sq.addSequenceFeature(sf4);
+ SequenceFeature sfContactFG = new SequenceFeature("Disulfide Bond",
+ "desc", 13, 14, 2f, null);
+ sq.addSequenceFeature(sfContactFG);
// no features in columns 1-2 (-A)
List<SequenceFeature> found = sq.findFeatures(1, 2);
// columns 1-6 (-ABC--) includes BCD and B/H feature but not DE
found = sq.findFeatures(1, 6);
assertEquals(2, found.size());
- assertTrue(found.contains(sf1));
- assertTrue(found.contains(sf3));
+ assertTrue(found.contains(sfBCD));
+ assertTrue(found.contains(sfContactBH));
// columns 5-6 (--) includes (enclosing) BCD but not (contact) B/H feature
found = sq.findFeatures(5, 6);
assertEquals(1, found.size());
- assertTrue(found.contains(sf1));
+ assertTrue(found.contains(sfBCD));
// columns 7-10 (DEF-) includes BCD, DE, F/G but not B/H feature
found = sq.findFeatures(7, 10);
assertEquals(3, found.size());
- assertTrue(found.contains(sf1));
- assertTrue(found.contains(sf2));
- assertTrue(found.contains(sf4));
+ assertTrue(found.contains(sfBCD));
+ assertTrue(found.contains(sfDE));
+ assertTrue(found.contains(sfContactFG));
+
+ // columns 10-11 (--) should find nothing
+ found = sq.findFeatures(10, 11);
+ assertEquals(0, found.size());
}
@Test(groups = { "Functional" })