Example #1
0
def test_gap():
    # Test when r2 is contained in r1
    r = Region(1, 100, context=Context(100, True, start_index=1))
    r2 = Region(10, 90, context=Context(100, True, start_index=1))
    g = r.get_gap(r2)
    assert g is None

    # Test when r2 is contained in r1; test on end
    r = Region(1, 100, context=Context(100, True, start_index=1))
    r2 = Region(10, 100, context=Context(100, True, start_index=1))
    g = r.get_gap(r2)
    assert g is None

    # Test when r2 is contained in r1; test on start
    r = Region(1, 100, context=Context(100, True, start_index=1))
    r2 = Region(1, 10, context=Context(100, True, start_index=1))
    g = r.get_gap(r2)
    assert g is None

    r = Region(25, 90, context=Context(100, True, start_index=1))
    r2 = Region(1, 10, context=Context(100, True, start_index=1))

    # Test outer gap
    g = r.get_gap(r2)
    assert r.get_gap_span(r2) == g.length
    assert r.get_gap_span(r2) == 10

    # Test inner gap
    g = r2.get_gap(r)
    assert r2.get_gap_span(r) == g.length
    assert g.length == 14

    # Test overlap
    r = Region(1, 10, context=Context(100, True, start_index=1))
    r2 = Region(5, 15, context=Context(100, True, start_index=1))
    g = r.get_gap(r2)
    assert g is None

    r = Region(1, 10, context=Context(100, True, start_index=1))
    r2 = Region(10, 15, context=Context(100, True, start_index=1))
    g = r.get_gap(r2)
    assert g is None
Example #2
0
def test_gap_span():
    r = Region(1, 100, context=Context(100, True, start_index=1))
    r2 = Region(10, 90, context=Context(100, True, start_index=1))
    assert r.get_gap_span(r2) is None

    r = Region(1, 10, context=Context(100, True, start_index=1))
    r2 = Region(10, 90, context=Context(100, True, start_index=1))
    assert r.get_gap_span(r2) == -1

    r = Region(1, 10, context=Context(100, True, start_index=1))
    r2 = Region(11, 90, context=Context(100, True, start_index=1))
    assert r.get_gap_span(r2) == 0

    r = Region(1, 10, context=Context(100, True, start_index=1))
    r2 = Region(8, 90, context=Context(100, True, start_index=1))
    assert r.get_gap_span(r2) == -3

    r = Region(1, 10, context=Context(100, True, start_index=1))
    r2 = Region(15, 90, context=Context(100, True, start_index=1))
    assert r.get_gap_span(r2) == 4