Exemple #1
0
def get_mapping(tree1, tree2, pos, times):
    recomb, coal = arghmm.find_recomb_coal(tree2, tree1, pos=pos)
    states1 = list(arghmm.iter_coal_states(tree1, times))
    states2 = list(arghmm.iter_coal_states(tree2, times))
    
    for i, (node1, time1) in enumerate(states1):
        j = arghmm.get_deterministic_transition(
            (node1, time1), states2, times, tree2, tree1,
            recomb[0], times.index(recomb[1]),
            coal[0], times.index(coal[1]))
        node2, time2 = states2[j]
        yield (node1, time1), (node2, time2)
Exemple #2
0
    def test_nlineages(self):
        """
        Test lineage counting
        """
        k = 4
        n = 1e4
        rho = 1.5e-8 * 1
        length = 1000
        arg = arglib.sample_arg(k, n, rho, start=0, end=length)

        times = arghmm.get_time_points(ntimes=6)
        arghmm.discretize_arg(arg, times)
        tree = arg.get_marginal_tree(0)

        nlineages, nrecombs, ncoals = arghmm.get_nlineages_recomb_coal(
            tree, times)

        treelib.draw_tree_names(tree.get_tree(), scale=4e-3)

        print list(arghmm.iter_coal_states(tree, times))
        print nlineages
        self.assert_(nlineages == sorted(nlineages, reverse=True))

        print nlineages
        print nrecombs
        print ncoals
Exemple #3
0
    def test_states(self):
        """
        Test state enumeration
        """
        k = 2
        n = 1e4
        rho = 1.5e-8 * 100
        length = 1000

        for i in xrange(20):
            arg = arglib.sample_arg(k, n, rho, start=0, end=length)

            times = arghmm.get_time_points(10)
            arghmm.discretize_arg(arg, times)
            tree = arg.get_marginal_tree(0)

            states = list(arghmm.iter_coal_states(tree, times))

            treelib.draw_tree_names(tree.get_tree(), scale=4e-4,
                                    minlen=6, maxlen=6)
            print states
Exemple #4
0
    def test_states(self):
        """
        Test state enumeration
        """
        k = 2
        n = 1e4
        rho = 1.5e-8 * 100
        length = 1000

        for i in range(20):
            arg = arglib.sample_arg(k, n, rho, start=0, end=length)

            times = arghmm.get_time_points(10)
            arghmm.discretize_arg(arg, times)
            tree = arg.get_marginal_tree(0)

            states = list(arghmm.iter_coal_states(tree, times))

            treelib.draw_tree_names(tree.get_tree(),
                                    scale=4e-4,
                                    minlen=6,
                                    maxlen=6)
            print(states)