def gene_tree(
            self,
            scale_to=None,
            population_size=1,
            trim_names=True,
    ):
        """ Using the current tree object as a species tree, generate a gene
        tree using the constrained Kingman coalescent process from dendropy. The
        species tree should probably be a valid, ultrametric tree, generated by
        some pure birth, birth-death or coalescent process, but no checks are
        made. Optional kwargs are: -- scale_to, which is a floating point value
        to scale the total tree tip-to-root length to, -- population_size, which
        is a floating point value which all branch lengths will be divided by to
        convert them to coalescent units, and -- trim_names, boolean, defaults
        to true, trims off the number which dendropy appends to the sequence
        name """

        tree = self.template or self.yule()

        for leaf in tree._tree.leaf_node_iter():
            leaf.num_genes = 1

        dfr = tree._tree.seed_node.distance_from_root()
        dft = tree._tree.seed_node.distance_from_tip()
        tree_height = dfr + dft

        if scale_to:
            population_size = tree_height / scale_to

        for edge in tree._tree.preorder_edge_iter():
            edge.pop_size = population_size

        gene_tree = dpy.simulate.treesim.constrained_kingman_tree(tree._tree)[0]

        if trim_names:
            for leaf in gene_tree.leaf_node_iter():
                leaf.taxon.label = leaf.taxon.label.replace('\'', '').split('_')[0]

        # Dendropy changed its API
        return {'gene_tree': tree.__class__(gene_tree.as_string('newick', suppress_rooting=True).strip(';\n') + ';'),
                'species_tree': tree}
Using the current tree object as a species tree, generate a gene
        tree using the constrained Kingman coalescent process from dendropy. The
        species tree should probably be a valid, ultrametric tree, generated by
        some pure birth, birth-death or coalescent process, but no checks are
        made. Optional kwargs are: -- scale_to, which is a floating point value
        to scale the total tree tip-to-root length to, -- population_size, which
        is a floating point value which all branch lengths will be divided by to
        convert them to coalescent units, and -- trim_names, boolean, defaults
        to true, trims off the number which dendropy appends to the sequence
        name