Exemple #1
0
def test_viterbi_100():
    data = msp.simulate(sample_size=100,
                        length=1e8,
                        mutation_rate=1.4e-8,
                        recombination_rate=1e-9)
    xs = xsmc.XSMC(data, 0, list(range(1, 100)))
    N0 = xs.theta / (4 * 1e-8)
    map_path = xs.viterbi()
Exemple #2
0
def test_multithreaded(big_data):
    from concurrent.futures import ThreadPoolExecutor

    xs = [
        xsmc.XSMC(big_data, 2 * i, [2 * i + 1])
        for i in range(big_data.get_sample_size() // 2)
    ]
    with ThreadPoolExecutor() as p:
        futs = [p.submit(x.sample, k=100, seed=i) for i, x in enumerate(xs)]
        res = [f.result() for f in futs]
Exemple #3
0
def test_memory_leak(tiny_data):
    import logging

    # import tracemalloc
    # tracemalloc.start()
    # logger = logging.getLogger('xsmc')
    # logger.info('tracing')
    # start = tracemalloc.take_snapshot()
    for _ in range(4):
        focal = 0
        panel = list(range(1, 2))
        x = xsmc.XSMC(tiny_data, focal, panel, rho_over_theta=1.0, w=100, robust=True)
        s = x.sample(k=100, seed=1)
Exemple #4
0
def test_bug():
    data = msp.simulate(
        sample_size=40,
        recombination_rate=1.4e-8,
        mutation_rate=1.4e-8,
        length=1e5,
        Ne=1e4,
        demographic_events=[],
        random_seed=1,
    )
    L = data.get_sequence_length()
    focal = 0
    panel = list(range(1, 19))
    xs = [xsmc.XSMC(data, focal, panel, rho_over_theta=1.0, w=100, robust=True)]
    with ThreadPoolExecutor() as p:
        futs = [p.submit(x.sample, k=1, seed=1) for i, x in enumerate(xs)]
        paths = [f.result() for f in futs]
Exemple #5
0
def test_viterbi(ts):
    xsmc.XSMC(ts, 0, [1, 2]).viterbi()
Exemple #6
0
def test_sample_paths_2(ts):
    xsmc.XSMC(ts, 0, [1, 2]).sample(k=100)
Exemple #7
0
def test_theta_equals_0(big_data):
    with pytest.raises(ValueError):
        p = xsmc.XSMC(big_data, 0, [1, 2, 3], theta=0.0, rho_over_theta=0.0).sample(
            k=5, seed=1
        )
Exemple #8
0
def test_multiple_panel(data):
    p = xsmc.XSMC(data, 0, [1, 2, 3], theta=1, rho_over_theta=1.0).sample(k=1, seed=1)