Пример #1
0
 def runTest(self, ntax=10):
     """TruncatedCoalescentTreeTest -- tree generation without checking [TODO: checks]"""
     species_tree = self.get_species_tree(ntax)
     gene_trees = []
     while len(gene_trees) < 20:
         gene_trees.append(
             coalescent.constrained_kingman_tree(species_tree)[0])
Пример #2
0
    def generate_gene_tree(self, species_name, samples_per_pop=10):
        """
        Given:
            ``species_name`` : string identifying species/taxon
            ``samples_per_pop`` : number of samples (genes) per population
        Returns:
            DendroPy tree, with branch lengths in generations
        """
        if self.pop_tree is None:
            self.generate_pop_tree(species_name, samples_per_pop=10)
        for idx, leaf in enumerate(self.pop_tree.leaf_iter()):
            if idx == 1:
                # ancestral population = num_desc_pops * desc population
                leaf.parent_node.edge.pop_size = self.num_desc_pops * self.desc_pop_size
            leaf.edge.pop_size = self.desc_pop_size
            leaf.num_genes = samples_per_pop
        self.gene_tree, self.pop_tree = coalescent.constrained_kingman_tree(
            self.pop_tree,
            gene_node_label_fn=lambda x, y: "%sX%d" % (x, y),
            rng=self.rng)

        self.mutation_tree = copy.deepcopy(self.gene_tree)
        for edge in self.mutation_tree.preorder_edge_iter():
            edge.length = edge.length * self.mutrate_per_site_per_generation
        return self.gene_tree
Пример #3
0
    def generate_gene_tree(self, species_name, samples_per_pop=10):
        """
        Given:
            ``species_name`` : string identifying species/taxon
            ``samples_per_pop`` : number of samples (genes) per population
        Returns:
            DendroPy tree, with branch lengths in generations
        """
        if self.pop_tree is None:
            self.generate_pop_tree(species_name, samples_per_pop=10)
        for idx, leaf in enumerate(self.pop_tree.leaf_iter()):
            if idx == 1:
                # ancestral population = num_desc_pops * desc population
                leaf.parent_node.edge.pop_size = self.num_desc_pops * self.desc_pop_size
            leaf.edge.pop_size = self.desc_pop_size
            leaf.num_genes = samples_per_pop
        self.gene_tree, self.pop_tree = coalescent.constrained_kingman_tree(self.pop_tree,
                                                          gene_node_label_fn=lambda x,y: "%sX%d" % (x,y),
                                                          rng=self.rng)

        self.mutation_tree = copy.deepcopy(self.gene_tree)
        for edge in self.mutation_tree.preorder_edge_iter():
            edge.length = edge.length * self.mutrate_per_site_per_generation
        return self.gene_tree
Пример #4
0
 def runTest(self, ntax=10):
     """TruncatedCoalescentTreeTest -- tree generation without checking [TODO: checks]"""
     species_tree = self.get_species_tree(ntax)
     gene_trees = []
     while len(gene_trees) < 20:
         gene_trees.append(coalescent.constrained_kingman_tree(species_tree)[0])