def test_recomb(self): """ Investigate the fact that some recombinations are not visible """ k = 3 n = 1e4 rho = 1.5e-8 * 20 mu = 2.5e-8 length = 1000 arg = arglib.sample_arg(k, n, rho, start=0, end=length) times = arghmm.get_time_points(10) arghmm.discretize_arg(arg, times) arg.set_ancestral() arg.prune() recombs = arglib.get_recomb_pos(arg) # find recombs by walking recombs2 = [] i = 0 while True: tree = arg.get_marginal_tree(i - .5) recomb = arghmm.find_tree_next_recomb(tree, i + 1, tree=True) if recomb: recombs2.append(recomb.pos) i = recomb.pos else: break # these are suppose to differ because some recombination occur # in the hole of ancestral sequence intervals print recombs print recombs2 arglib.write_arg("tmp/b.arg", arg)
def test_recomb(self): """ Investigate the fact that some recombinations are not visible """ k = 3 n = 1e4 rho = 1.5e-8 * 20 mu = 2.5e-8 length = 1000 arg = arglib.sample_arg(k, n, rho, start=0, end=length) times = arghmm.get_time_points(10) arghmm.discretize_arg(arg, times) arg.set_ancestral() arg.prune() recombs = arglib.get_recomb_pos(arg) # find recombs by walking recombs2 = [] i = 0 while True: tree = arg.get_marginal_tree(i-.5) recomb = arghmm.find_tree_next_recomb(tree, i+1, tree=True) if recomb: recombs2.append(recomb.pos) i = recomb.pos else: break # these are suppose to differ because some recombination occur # in the hole of ancestral sequence intervals print recombs print recombs2 arglib.write_arg("tmp/b.arg", arg)
#arg2.set_ancestral() #arg2.prune() # load model mu = 2.5e-8 rho = 1.5e-8 new_name = "n4" model = arghmm.ArgHmm(arg2, seqs, new_name=new_name, times=times, rho=rho, mu=mu) pos = 9910 tree = arg2.get_marginal_tree(pos-.5) last_tree = arg2.get_marginal_tree(pos-1-.5) recomb = arghmm.find_tree_next_recomb(arg2, pos - 1) states1 = model.states[pos-1] states2 = model.states[pos] model.check_local_tree(pos) mat = arghmm.calc_transition_probs_switch( tree, last_tree, recomb.name, states1, states2, model.nlineages, model.times, model.time_steps, model.popsizes, model.rho) #pos2 = 7000 #n = model.get_num_states(pos2) #mat2 = [[model.prob_transition(pos2-1, i, pos2, j) # for j in range(n)] for i in range(n)]
# load model mu = 2.5e-8 rho = 1.5e-8 new_name = "n4" model = arghmm.ArgHmm(arg2, seqs, new_name=new_name, times=times, rho=rho, mu=mu) pos = 9910 tree = arg2.get_marginal_tree(pos - .5) last_tree = arg2.get_marginal_tree(pos - 1 - .5) recomb = arghmm.find_tree_next_recomb(arg2, pos - 1) states1 = model.states[pos - 1] states2 = model.states[pos] model.check_local_tree(pos) mat = arghmm.calc_transition_probs_switch(tree, last_tree, recomb.name, states1, states2, model.nlineages, model.times, model.time_steps, model.popsizes, model.rho) #pos2 = 7000 #n = model.get_num_states(pos2) #mat2 = [[model.prob_transition(pos2-1, i, pos2, j) # for j in range(n)] for i in range(n)]