Пример #1
0
def main():
    """Simulate gene trees according to gene and lineage variation.
    Modify the site variation by gene by simulating different alpha values.
    also modify the clock for each site partition.
    """
    params = variation.Settings()
    base_tree = variation.relaxed_tree(
        mod.get_file_data("../timetree.nwk")[0], 1, params.lineage_sigma2)

    i = 0
    trees = []
    alphas = []
    while i < 70:
        relaxed_trees = []
        rate = variation.get_rate(params.gene_alpha, params.gene_beta)
        j = 0
        while j < params.n_bins_per_gene:
            relaxed_trees.append(
                variation.relaxed_tree(base_tree, rate, params.lineage_sigma2))
            j += 1
        trees.append(relaxed_trees)

        alphas.append(
            str(variation.get_rate(params.site_alpha, params.site_alpha)))
        i += 1

    out_trees = open("treefiles.nwk", "w")
    for set_of_trees in trees:
        out_trees.write("\t".join(set_of_trees) + "\n")
    out_trees.close()

    out_alpha = open("alphas.txt", "w")
    out_alpha.write("\n".join(alphas))
    out_alpha.close()
def main():
    """Modify the 70 gene trees using simulated rates."""
    base_tree = mod.get_file_data("../timetree.nwk")[0]
    params = variation.Settings()
    i = 0
    while i < 70:
        rate = variation.get_rate(params.gene_alpha, params.gene_beta)
        new_tree = variation.modified_tree(base_tree, rate)
        out = open("treefiles.nwk", "a+")
        out.write(new_tree + "\n")
        out.close()
        i += 1
def main():
    """Write gene trees to a file."""
    base_tree = mod.get_file_data("../timetree.nwk")[0]
    params = variation.Settings()

    rate = 1

    tree = variation.relaxed_tree(base_tree, rate, params.lineage_sigma2)
    out = open("treefiles.nwk", "a+")
    i = 0
    while i < 70:
        out.write(tree + "\n")
        i += 1
    out.close()
def main():
    """Generate gene trees and write to a file."""
    base_tree = mod.get_file_data("../timetree.nwk")[0]
    params = variation.Settings()
    rate = 1

    tree = variation.relaxed_tree(base_tree, rate, params.lineage_sigma2)
    out = open("treefiles.nwk", "a+")
    i = 0
    while i < 70:
        rate = variation.get_rate(params.gene_alpha, params.gene_beta)
        new_tree = variation.modified_tree(tree, rate)
        out.write(new_tree + "\n")
        i += 1
    out.close()
def main():
    """Simulate gene trees according to gene variation.
    Modify the site variation by gene by simulating different alpha values.
    """
    base_tree = mod.get_file_data("../timetree.nwk")[0]
    params = variation.Settings()

    i = 0
    trees = []
    alphas = []
    while i < 70:
        rate = variation.get_rate(params.gene_alpha, params.gene_beta)
        trees.append(variation.modified_tree(base_tree, rate))
        alphas.append(str(variation.get_rate(params.site_alpha, params.site_alpha)))
        i += 1

    out_trees = open("treefiles.nwk", "w")
    out_trees.write("\n".join(trees))
    out_trees.close()

    out_alpha = open("alphas.txt", "w")
    out_alpha.write("\n".join(alphas))
    out_alpha.close()
def main():
    """Simulate gene trees for genes with gene + lineage + sitexlineage variation.

    This will involve a base tree for each bin per gene
    each gene will have these trees for each partition multiplied by
    the gene rate"""

    base_tree = mod.get_file_data("../timetree.nwk")[0]
    params = variation.Settings()

    out = open("treefiles.nwk", "w")
    relaxed_trees = []
    i = 0
    while i < 70:
        j = 0
        rate = variation.get_rate(params.gene_alpha, params.gene_beta)
        while j < params.n_bins_per_gene:
            relaxed_trees.append(
                variation.relaxed_tree(base_tree, rate, params.lineage_sigma2))
            j += 1
        out.write("\t".join(relaxed_trees) + "\n")
        i += 1
    out.close()