Beispiel #1
0
def test_find_overlaps():
    r1 = Range(start=np.array([1, 4, 8]), end=np.array([2, 7, 10]))
    q1 = Range(start=np.array([3]), end=np.array([5]))
    fo = FindOverlaps(subject=r1)
    assert fo.index == NCList(None, [NCList(0), NCList(1), NCList(2)])
    for x in fo.query(query=q1):
        pass
    overlapped = list(fo.query(query=q1))
    assert len(overlapped) == 1
    assert overlapped == [Range(start=np.array([4]), end=np.array([7]))]
Beispiel #2
0
def test_search_in_builded_nc_list():
    #      0       0->1  0->0  0     1     1      1
    #      0       1     2     3     4     5      6
    a = [False, True, True, False, True, True, False]
    nc = NCList(None, [
        NCList(0),
        NCList(1, [NCList(4), NCList(5), NCList(6)]),
        NCList(2),
        NCList(3)
    ])
    assert list(nc.find_overlap_index(lambda i: a[i])) == [1, 2, 4, 5]
Beispiel #3
0
def test_building_nclist_on_sorted_data(interval_arrays1):
    s, e, idx = interval_arrays1
    ncb = NCListBuilder(Intervals(s, e))
    ncb.index = idx
    assert (ncb._construct_nclist_from_sorted_index() == NCList(
        None, [NCList(4, [NCList(0), NCList(1)]),
               NCList(3, [NCList(2)])]))
Beispiel #4
0
def test_nc_list_child_interfaces():
    assert NCList(None).childs() == 0
Beispiel #5
0
def test_counting_nc_list_on_modification_and_creation():
    ncl = NCList(None)
    ncl.append(NCList(1))
    assert len(ncl.childs) == 1
    assert len(ncl) == 1
    assert len(NCList(None, [NCList(1, [NCList(2)])])) == 2
Beispiel #6
0
def test_nc_list_equality():
    assert NCList(1) == NCList(1)
    assert NCList(1) != NCList(2)
    assert NCList(1, [NCList(2)]) != NCList(1, [NCList(3)])
    assert NCList(1, [NCList(2, [NCList(3)])]) != NCList(
        1, [NCList(2, [NCList(4)])])
Beispiel #7
0
def test_nonempty_nclist():
    ncl = NCList(None, [NCList(1), NCList(2), NCList(3)])
    assert list(ncl) == [1, 2, 3]
Beispiel #8
0
def test_empty_nclist():
    NCList(0)
Beispiel #9
0
def test_nclist_repr():
    assert NCList(None, []).__repr__() == 'NCList(None)'
    assert (NCList(
        None,
        [NCList(0, [NCList(1), NCList(2)])
         ]).__repr__() == 'NCList(None, [NCList(0, [NCList(1), NCList(2)])])')