Пример #1
0
def test_file_collapse():
    lines = fileinput.input("tests/treefiles/basic.trees")
    trees = list(NewickParser().consume(lines))
    collapsed = Collapse(filename="tests/argfiles/collapse.txt").consume(trees)
    # These groups are monophyletic in the first 5 of the 6 basic trees, so...
    for n, t in enumerate(collapsed):
        assert len(t.get_leaves()) == (2 if n < 5 else 6)
Пример #2
0
def test_collapse():
    lines = fileinput.input("tests/treefiles/basic.trees")
    trees = list(NewickParser().consume(lines))
    collapsed = Collapse({"left":("A","B","C"), "right":("D","E","F")}).consume(trees)
    # These groups are monophyletic in the first 5 of the 6 basic trees, so...
    for n, t in enumerate(collapsed):
        assert len(t.get_leaves()) == (2 if n < 5 else 6)
Пример #3
0
def test_attribute_collapse(basictrees):
    annotated = Annotate(
        filename="tests/argfiles/annotation.csv", key="taxon").consume(basictrees)
    # f1 in the annotations applied above corresponds to the same left/right
    # split as the other tests above
    collapsed = Collapse(attribute="f1").consume(annotated)
    # These groups are monophyletic in the first 5 of the 6 basic trees, so...
    for n, t in enumerate(collapsed):
        assert len(t.get_leaves()) == (2 if n < 5 else 6)
Пример #4
0
def test_attribute_collapse():
    lines = fileinput.input("tests/treefiles/basic.trees")
    trees = list(NewickParser().consume(lines))
    annotated = Annotate("tests/argfiles/annotation.csv", "taxon").consume(trees)
    # f1 in the annotations applied above corresponds to the same left/right
    # split as the other tests above
    collapsed = Collapse(attribute="f1").consume(annotated)
    # These groups are monophyletic in the first 5 of the 6 basic trees, so...
    for n, t in enumerate(collapsed):
        assert len(t.get_leaves()) == (2 if n < 5 else 6)
Пример #5
0
def test_init():
    collapse = Collapse.init_from_args("--translate tests/argfiles/collapse.txt")
    assert collapse.filename == "tests/argfiles/collapse.txt"

    collapse = Collapse.init_from_args("--attribute collapsibility")
    assert collapse.attribute == "collapsibility"
Пример #6
0
def test_attribute_non_collapse():
    lines = fileinput.input("tests/treefiles/basic.trees")
    trees = list(NewickParser().consume(lines))
    collapsed = Collapse(attribute="foo").consume(trees)
    for t1, t2 in zip(trees, collapsed):
        assert t1.write() == t2.write()
Пример #7
0
def test_non_collapse():
    lines = fileinput.input("tests/treefiles/basic.trees")
    trees = list(NewickParser().consume(lines))
    collapsed = Collapse({"non-existent":("X","Y","Z")}).consume(trees)
    for t1, t2 in zip(trees, collapsed):
        assert t1.write() == t2.write()
Пример #8
0
def test_bad_init_no_args():
    Collapse()
Пример #9
0
def test_init(argfilepath):
    collapse = Collapse.init_from_args("--translate {0}".format(argfilepath('collapse.txt')))
    assert collapse.opts.filename == argfilepath('collapse.txt')

    collapse = Collapse.init_from_args("--attribute collapsibility")
    assert collapse.opts.attribute == "collapsibility"
Пример #10
0
def test_attribute_non_collapse(basictrees):
    trees = list(basictrees)
    collapsed = Collapse(attribute="foo").consume(trees)
    for t1, t2 in zip(trees, collapsed):
        assert t1.write() == t2.write()
Пример #11
0
def test_non_collapse(basictrees):
    trees = list(basictrees)
    collapsed = Collapse({"non-existent":("X","Y","Z")}).consume(trees)
    for t1, t2 in zip(trees, collapsed):
        assert t1.write() == t2.write()
Пример #12
0
def test_file_collapse(basictrees, argfilepath):
    collapsed = Collapse(filename=argfilepath("collapse.txt")).consume(basictrees)
    # These groups are monophyletic in the first 5 of the 6 basic trees, so...
    for n, t in enumerate(collapsed):
        assert len(t.get_leaves()) == (2 if n < 5 else 6)
Пример #13
0
def test_collapse(basictrees):
    collapsed = Collapse(
        clades={"left":("A","B","C"), "right":("D","E","F")}).consume(basictrees)
    # These groups are monophyletic in the first 5 of the 6 basic trees, so...
    for n, t in enumerate(collapsed):
        assert len(t.get_leaves()) == (2 if n < 5 else 6)
Пример #14
0
def test_bad_init_no_args():
    with pytest.raises(ValueError):
        Collapse()