Example #1
0
 def test_overlaps_with(self):
     # no overlap
     feature = helpers.DummyFeature(5, 10)
     assert isinstance(feature, Feature)  # just to be sure it works the way we want
     other = helpers.DummyFeature(100, 110)
     assert not feature.overlaps_with(other) and not other.overlaps_with(feature)
     # completely within
     other = helpers.DummyFeature(0, 20)
     assert feature.overlaps_with(other) and other.overlaps_with(feature)
     # partially within
     other = helpers.DummyFeature(0, 8)
     assert feature.overlaps_with(other) and other.overlaps_with(feature)
     # borders touching
     other = helpers.DummyFeature(0, 5)
     assert not (feature.overlaps_with(other) or other.overlaps_with(feature))
Example #2
0
 def test_is_contained_by(self):
     # same location is considered to be contained
     feature = helpers.DummyFeature(5, 10)
     assert feature.is_contained_by(feature)
     for strand in (-1, 1):
         # no overlap
         other = helpers.DummyFeature(15, 25, strand)
         assert not feature.is_contained_by(other)
         assert not other.is_contained_by(feature)
         # b is contained
         other = helpers.DummyFeature(6, 9, strand)
         assert not feature.is_contained_by(other)
         assert other.is_contained_by(feature)
         # only partial overlap
         other = helpers.DummyFeature(6, 19, strand)
         assert not feature.is_contained_by(other)
         assert not other.is_contained_by(feature)
         other = helpers.DummyFeature(1, 7, strand)
         assert not feature.is_contained_by(other)
         assert not other.is_contained_by(feature)
         # edge cases
         other = helpers.DummyFeature(5, 7, strand)
         assert not feature.is_contained_by(other)
         assert other.is_contained_by(feature)
         other = helpers.DummyFeature(7, 10, strand)
         assert not feature.is_contained_by(other)
         assert other.is_contained_by(feature)