def test_emit_internal(self): """ Calculate emission probabilities """ k = 10 n = 1e4 rho = 1.5e-8 * 20 mu = 2.5e-8 * 20 length = int(10e3) / 20 times = arghmm.get_time_points(ntimes=20, maxtime=200000) arg = arghmm.sample_arg_dsmc(k, 2 * n, rho, start=0, end=length, times=times) muts = arghmm.sample_arg_mutations(arg, mu, times) seqs = arghmm.make_alignment(arg, muts) trees, names = arghmm.arg2ctrees(arg, times) seqs2, nseqs, seqlen = arghmm.seqs2cseqs(seqs, names) assert arghmm.arghmm_assert_emit_internal(trees, len(times), times, mu, seqs2, nseqs, seqlen)
def test_emit(self): """ Calculate emission probabilities """ k = 10 n = 1e4 rho = 1.5e-8 * 20 mu = 2.5e-8 * 20 length = int(1e3) / 20 times = arghmm.get_time_points(ntimes=20, maxtime=200000) arg = arghmm.sample_arg_dsmc(k, 2*n, rho, start=0, end=length, times=times) muts = arghmm.sample_arg_mutations(arg, mu, times) seqs = arghmm.make_alignment(arg, muts) new_name = "n%d" % (k-1) arg = arghmm.remove_arg_thread(arg, new_name) trees, names = arghmm.arg2ctrees(arg, times) seqs2, nseqs, seqlen = arghmm.seqs2cseqs(seqs, names + [new_name]) assert arghmm.arghmm_assert_emit(trees, len(times), times, mu, seqs2, nseqs, seqlen)
def test_trans_switch_internal(self): """ Calculate transition probabilities for k=2 Only calculate a single matrix """ k = 10 n = 1e4 rho = 1.5e-8 * 20 mu = 2.5e-8 * 20 length = int(100e3) / 20 times = arghmm.get_time_points(ntimes=20, maxtime=200000) popsizes = [n] * len(times) arg = arghmm.sample_arg_dsmc(k, 2 * n, rho, start=0, end=length, times=times) trees, names = arghmm.arg2ctrees(arg, times) assert arghmm.assert_transition_probs_switch_internal( trees, times, popsizes, rho)
def test_prior_tree(self): k = 10 n = 1e4 popsizes = [n] * 20 length = 10 times = arghmm.get_time_points(ntimes=20, maxtime=1000000) arg = arghmm.sample_arg_dsmc(k, 2*n, 1e-50, start=0, end=length, times=times) trees, names = arghmm.arg2ctrees(arg, times) print arghmm.arghmm_tree_prior_prob(trees, times, len(times), popsizes)
def test_prior_tree(self): k = 10 n = 1e4 popsizes = [n] * 20 length = 10 times = arghmm.get_time_points(ntimes=20, maxtime=1000000) arg = arghmm.sample_arg_dsmc(k, 2 * n, 1e-50, start=0, end=length, times=times) trees, names = arghmm.arg2ctrees(arg, times) print arghmm.arghmm_tree_prior_prob(trees, times, len(times), popsizes)
def test_arg_treelens(self): k = 10 n = 1e4 rho = 1.5e-8 * 20 mu = 2.5e-8 * 20 length = 10000 times = arghmm.get_time_points(ntimes=20, maxtime=200000) arg = arghmm.sample_arg_dsmc(k, 2*n, rho, start=0, end=length, times=times) # convert to C++ and back trees, names = arghmm.arg2ctrees(arg, times) treelens = [0.0] * arghmm.get_local_trees_ntrees(trees) arghmm.get_treelens(trees, times, len(times), treelens) print treelens
def test_arg_treelens(self): k = 10 n = 1e4 rho = 1.5e-8 * 20 mu = 2.5e-8 * 20 length = 10000 times = arghmm.get_time_points(ntimes=20, maxtime=200000) arg = arghmm.sample_arg_dsmc(k, 2 * n, rho, start=0, end=length, times=times) # convert to C++ and back trees, names = arghmm.arg2ctrees(arg, times) treelens = [0.0] * arghmm.get_local_trees_ntrees(trees) arghmm.get_treelens(trees, times, len(times), treelens) print treelens
def test_trans_switch_internal(self): """ Calculate transition probabilities for k=2 Only calculate a single matrix """ k = 10 n = 1e4 rho = 1.5e-8 * 20 mu = 2.5e-8 * 20 length = int(100e3) / 20 times = arghmm.get_time_points(ntimes=20, maxtime=200000) popsizes = [n] * len(times) arg = arghmm.sample_arg_dsmc(k, 2*n, rho, start=0, end=length, times=times) trees, names = arghmm.arg2ctrees(arg, times) assert arghmm.assert_transition_probs_switch_internal( trees, times, popsizes, rho)