aspartik.b3.utils.tree

def trees_to_newick(
    names: list[str],
    trace_path: str,
    dest: str | pathlib.Path | TextIO,
    *,
    tree_key: str = 'tree'
)

def trees_to_newick(
    names: list[str],
    trace_path: str,
    dest: str | Path | TextIO,
    *,
    tree_key: str = "tree",
):
    import polars as pl

    dest = _to_io(dest)

    tree = Tree(names, RNG(4))
    df = pl.read_ipc(trace_path)

    for bytes in df["tree"]:
        tree.load(bytes)
        dest.write(tree.to_newick())
        dest.write("\n")

    dest.flush()
#