예제 #1
0
def test_circular_gaps():
    """
        context:   |-------------------------|
        r1:         ----|              |-----
        r2:                  |----|
        r1.get_gap(r2)   |==|
        r2.get_gap(r1)             |==|
    """

    r1 = Region(80, 20, context=Context(100, True, start_index=0))
    r2 = Region(50, 60, context=Context(100, True, start_index=0))

    g1 = r1.get_gap(r2)
    assert g1.start == 21
    assert g1.end == 49

    g2 = r2.get_gap(r1)
    assert g2.start == 61
    assert g2.end == 79
예제 #2
0
def test_self_circular_gap():
    """
        context:   |-------------------------|
        r1:         ----|              |-----
        r1.gap(r1)       |>>>>>>>>>>>>|
    """

    r1 = Region(80, 20, context=Context(100, True, start_index=0))
    g = r1.get_gap(r1)
    assert g.start == 21
    assert g.end == 79
예제 #3
0
def test_region_gap_basic():
    r = Region(20, 50, context=Context(100, False, start_index=0))
    r2 = Region(60, 70, context=Context(100, False, start_index=0))
    g = r.get_gap(r2)
    assert g.lp == 51
    assert g.rp == 59

    r = Region(20, 50, context=Context(100, False, start_index=0))
    r2 = Region(51, 70, context=Context(100, False, start_index=0))
    assert r.get_gap(r2) is None

    r = Region(90, 99, context=Context(100, False, start_index=1))
    r2 = Region(2, 70, context=Context(100, False, start_index=1))
    g = r.get_gap(r2)
    assert g.start == 100
    assert g.end == 1

    r = Region(20, 50, context=Context(100, False, start_index=0))
    r2 = Region(48, 70, context=Context(100, False, start_index=0))
    g = r.get_gap(r2)
    assert g is None
예제 #4
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