Esempio n. 1
0
def test_init():
    rename = Rename.init_from_args("--file tests/argfiles/rename.txt")
    assert rename.remove == False

    rename = Rename.init_from_args(
        "--file tests/argfiles/rename.txt --remove-missing")
    assert rename.remove == True
Esempio n. 2
0
def test_rename_from_file(basictrees):
    renamed = Rename(filename="tests/argfiles/rename.txt", from_="old", to_="new").consume(basictrees)
    for t in renamed:
        leaves = t.get_leaf_names()
        assert "A" not in leaves
        assert "X" in leaves
        assert all((x in leaves for x in ("B", "C", "D", "E", "F")))
Esempio n. 3
0
def test_rename(basictrees):
    renamed = Rename(rename={"A":"X"}).consume(basictrees)
    for t in renamed:
        leaves = t.get_leaf_names()
        assert "A" not in leaves
        assert "X" in leaves
        assert all((x in leaves for x in ("B", "C", "D", "E", "F")))
Esempio n. 4
0
def test_rename_from_file():
    lines = fileinput.input("tests/treefiles/basic.trees")
    trees = NewickParser().consume(lines)
    renamed = Rename(filename="tests/argfiles/rename.txt").consume(trees)
    for t in renamed:
        leaves = t.get_leaf_names()
        assert "A" not in leaves
        assert "X" in leaves
        assert all((x in leaves for x in ("B", "C", "D", "E", "F")))
Esempio n. 5
0
def test_rename_with_remove(basictrees):
    renamed = Rename(rename={
        "A":"X",
        "B":"Y",
        "C":"Z" }, remove=True).consume(basictrees)
    for t in renamed:
        leaves = t.get_leaf_names()
        assert all((x in leaves for x in ("X", "Y", "Z")))
        assert not any((x in leaves for x in ("A", "B", "C", "D", "E", "F")))
Esempio n. 6
0
def test_rename_with_remove():
    lines = fileinput.input("tests/treefiles/basic.trees")
    trees = NewickParser().consume(lines)
    renamed = Rename({
        "A": "X",
        "B": "Y",
        "C": "Z"
    }, remove=True).consume(trees)
    for t in renamed:
        leaves = t.get_leaf_names()
        assert all((x in leaves for x in ("X", "Y", "Z")))
        assert not any((x in leaves for x in ("A", "B", "C", "D", "E", "F")))
Esempio n. 7
0
def test_bad_init_no_args():
    Rename()
Esempio n. 8
0
def test_init(argfilepath):
    rename = Rename.init_from_args("--file {0} --from old --to new".format(argfilepath("rename.txt")))
    assert rename.opts.remove == False

    rename = Rename.init_from_args("--file {0} --from old --to new --remove-missing".format(argfilepath("rename.txt")))
    assert rename.opts.remove == True
Esempio n. 9
0
def test_bad_init_no_args():
    with pytest.raises(ValueError):
        Rename()