Esempio n. 1
0
def _test_multicoal_tree(stree, n, nsamples):
    """test multicoal_tree"""
    tops = {}

    for i in xrange(nsamples):
        tree, recon = coal.sample_multicoal_tree(stree, n,
                                                 namefunc=lambda x: x)
        top = phylo.hash_tree(tree)
        tops.setdefault(top, [0, tree, recon])[0] += 1

    tab = Table(headers=["top", "simple_top", "percent", "prob"])
    for top, (num, tree, recon) in tops.items():
        tree2 = tree.copy()
        treelib.remove_single_children(tree2)

        print phylo.hash_tree(tree2)
        print phylo.hash_tree(stree)

        tab.add(top=top,
                simple_top=phylo.hash_tree(tree2),
                percent=num/float(nsamples),
                prob=exp(coal.prob_multicoal_recon_topology(
                    tree, recon, stree, n)))
    tab.sort(col="prob", reverse=True)

    return tab, tops
Esempio n. 2
0
        pretime=None, premean=None,
        maxdoom=20, nsamples=100,
        add_spec=True))

if 0:
    draw_tree_names(coal_tree, scale=.5e-7, minlen=8)
    draw_tree_names(ex["locus_tree"], scale=.5e-7, minlen=8)
    print exp(dlcoal.prob_multicoal_recon_topology(
        coal_tree, ex["coal_recon"], ex["locus_tree"], n, ex["daughters"]))
    print exp(dlcoal.prob_multicoal_recon_topology2(
        coal_tree, ex["coal_recon"], ex["locus_tree"], n, ex["daughters"]))


if 0:
    draw_tree_names(coal_tree, scale=1e-7)
    print exp(coal.prob_multicoal_recon_topology(
        coal_tree, ex["coal_recon"], ex["locus_tree"], n))
    print exp(coal.prob_multicoal_recon_topology_old(
        coal_tree, ex["coal_recon"], ex["locus_tree"], n))

if 0:
    pd(coal.count_lineages_per_branch(
        coal_tree, ex["coal_recon"], ex["locus_tree"]))




#=============================================================================

show_plots = False
def show_plot():
    if show_plots: