Exemplo n.º 1
0
def test_filter_annotations1():

    annotations = [
        Annotation(start=1, end=10, bitscore=20),
        Annotation(start=5, end=10, bitscore=30),
        Annotation(start=9, end=15, bitscore=10),
        Annotation(start=16, end=20, bitscore=30),
        Annotation(start=16, end=20, bitscore=20),
        Annotation(start=21, end=30, bitscore=40),
    ]
    choose_func = None

    assert filter_annotations(annotations, choose_func=choose_func) == \
        set(
            [
                annotations[1],
                annotations[2],
                annotations[3],
                annotations[5],
            ]
        )
Exemplo n.º 2
0
def test_filter_attr_num_ge_fail2():
    a = Annotation()
    assert not filter_attr_num(a, 'bitscore', 15, True)
Exemplo n.º 3
0
    a = Annotation(bitscore=10)
    assert filter_attr_num(a, 'bitscore', 10, False)


def test_filter_attr_num_le_fail1():
    a = Annotation(bitscore=10)
    assert not filter_attr_num(a, 'bitscore', 5, False)


def test_filter_attr_num_le_fail2():
    a = Annotation()
    assert not filter_attr_num(a, 'bitscore', 5, False)


@pytest.mark.parametrize("annotation,attr,value,greater,result", [
    (Annotation(bitscore=11), 'bitscore', 10, True, True),
    (Annotation(bitscore=10), 'bitscore', 10, True, False),
    (Annotation(bitscore=None), 'bitscore', 10, True, False),
    (Annotation(bitscore=11), 'bitscore', 10, False, False),
    (Annotation(bitscore=9), 'bitscore', 10, False, True),
])
def test_filter_attr_num_s(annotation, attr, value, greater, result):
    assert filter_attr_num_s(annotation, attr, value, greater) == result


def test_filter_attr_str_eq_ok1():
    a = Annotation(ec='1.1.1.1')
    assert filter_attr_str(a, 'ec', '1.1.1.1', True)


def test_filter_attr_str_eq_fail1():
Exemplo n.º 4
0
def test_choose_annotation_contained1():
    # same size, better score
    a = Annotation(start=1, end=10, bitscore=10)
    b = Annotation(start=1, end=10, bitscore=15)
    assert choose_annotation(a, b) == a
Exemplo n.º 5
0
def test_choose_annotation_none2():
    # overlap lower than the limits
    a = Annotation(start=1, end=10, bitscore=10)
    b = Annotation(start=9, end=12, bitscore=10)
    assert choose_annotation(a, b, overlap=2) is None
Exemplo n.º 6
0
def test_choose_annotation_overlap2():
    # overlapping, same score, choose longer
    a = Annotation(start=1, end=11, bitscore=10)
    b = Annotation(start=5, end=11, bitscore=10)
    assert choose_annotation(a, b, overlap=4) == b
Exemplo n.º 7
0
def test_filter_attr_str_in_ok1():
    a = Annotation(ec='1.1.1.1')
    assert filter_attr_str(a, 'ec', '1.1.1.1', False)
Exemplo n.º 8
0
def test_choose_annotation_overlap1():
    # overlapping, better score
    a = Annotation(start=1, end=10, bitscore=10)
    b = Annotation(start=5, end=11, bitscore=15)
    assert choose_annotation(a, b, overlap=4) == a
Exemplo n.º 9
0
def test_filter_len_le_fail1():
    a = Annotation(start=1, end=10)
    assert not filter_len(a, 5, False)
Exemplo n.º 10
0
def test_filter_len_ge_fail1():
    a = Annotation(start=1, end=3)
    assert not filter_len(a, 5, True)
Exemplo n.º 11
0
def test_filter_len_le_ok2():
    # lower
    a = Annotation(start=1, end=3)
    assert filter_len(a, 5, False)
Exemplo n.º 12
0
def test_filter_len_ge_ok2():
    # greater
    a = Annotation(start=1, end=3)
    assert filter_len(a, 2, True)
Exemplo n.º 13
0
def test_filter_len_le_ok1():
    # equal
    a = Annotation(start=1, end=2)
    assert filter_len(a, 2, False)
Exemplo n.º 14
0
def test_filter_base_fail2():
    a = Annotation(seq_id='seq1')
    assert not filter_base(a, 'seqid', 'seq1')
Exemplo n.º 15
0
def test_filter_attr_num_le_ok2():
    a = Annotation(bitscore=10)
    assert filter_attr_num(a, 'bitscore', 10, False)
Exemplo n.º 16
0
def test_filter_attr_num_le_fail2():
    a = Annotation()
    assert not filter_attr_num(a, 'bitscore', 5, False)
Exemplo n.º 17
0
def test_filter_base_num_ge_ok2():
    a = Annotation(bitscore=10)
    assert filter_base_num(a, 'bitscore', 10, True)
Exemplo n.º 18
0
def test_filter_attr_str_eq_fail2():
    a = Annotation(ec='1.1.1.1')
    assert not filter_attr_str(a, 'ec', '1.1.1', True)
Exemplo n.º 19
0
def test_filter_base_num_ge_fail1():
    a = Annotation(bitscore=10)
    assert not filter_base_num(a, 'bitscore', 15, True)
Exemplo n.º 20
0
def test_filter_attr_str_in_fail2():
    a = Annotation(ec='1.1.1.1')
    assert not filter_attr_str(a, 'ec', '1.1.1.2', False)
Exemplo n.º 21
0
def test_choose_annotation_contained2():
    # same score, longer
    a = Annotation(start=1, end=10, bitscore=10)
    b = Annotation(start=5, end=10, bitscore=10)
    assert choose_annotation(a, b) == b
Exemplo n.º 22
0
def test_choose_annotation_none1():
    # no overlap
    a = Annotation(start=1, end=10, bitscore=10)
    b = Annotation(start=11, end=12, bitscore=10)
    assert choose_annotation(a, b, overlap=4) is None
Exemplo n.º 23
0
def test_filter_base_num_le_ok1():
    a = Annotation(bitscore=10)
    assert filter_base_num(a, 'bitscore', 15, False)
Exemplo n.º 24
0
def test_filter_base_num_le_fail1():
    a = Annotation(bitscore=10)
    assert not filter_base_num(a, 'bitscore', 5, False)
Exemplo n.º 25
0
def test_filter_attr_num_ge_ok1():
    a = Annotation(bitscore=10)
    assert filter_attr_num(a, 'bitscore', 5, True)
Exemplo n.º 26
0
def test_filter_base_ok1():
    a = Annotation(seq_id='seq1')
    assert filter_base(a, 'seq_id', 'seq1')
Exemplo n.º 27
0
def annotations():
    return [
        Annotation(seq_id='1', start=0, end=100, strand='+', uid='u1'),
        Annotation(seq_id='1', start=10, end=100, strand='-', uid='u2'),
        Annotation(seq_id='2', start=0, end=100, strand='+', uid='u3'),
    ]