Exemplo n.º 1
0
def reconciliation_discordance(gene_tree, species_tree):
    deprecate.dendropy_deprecation_warning(
            preamble="The 'dendropy.reconcile' module has moved to 'dendropy.model.reconcile'.",
            old_construct="from dendropy import reconcile\nreconcile.reconciliation_discordance(...)",
            new_construct="from dendropy.model import reconcile\nreconcile.reconciliation_discordance(...)",
            )
    return reconcile.reconciliation_discordance(gene_tree, species_tree)
Exemplo n.º 2
0
def reconciliation_discordance(gene_tree, species_tree):
    deprecate.dendropy_deprecation_warning(
        preamble=
        "The 'dendropy.reconcile' module has moved to 'dendropy.model.reconcile'.",
        old_construct=
        "from dendropy import reconcile\nreconcile.reconciliation_discordance(...)",
        new_construct=
        "from dendropy.model import reconcile\nreconcile.reconciliation_discordance(...)",
    )
    return reconcile.reconciliation_discordance(gene_tree, species_tree)
Exemplo n.º 3
0
    def testFittedDeepCoalCounting(self):

        taxa = dendropy.TaxonNamespace()

        gene_trees = dendropy.TreeList.get_from_string("""
            [&R] (A,(B,(C,D))); [&R] ((A,C),(B,D)); [&R] (C,(A,(B,D)));
            """,
                                                       "newick",
                                                       taxon_namespace=taxa)

        species_trees = dendropy.TreeList.get_from_string("""
            [&R] (A,(B,(C,D)));
            [&R] (A,(C,(B,D)));
            [&R] (A,(D,(C,B)));
            [&R] (B,(A,(C,D)));
            [&R] (B,(C,(A,D)));
            [&R] (B,(D,(C,A)));
            [&R] (C,(A,(B,D)));
            [&R] (C,(B,(A,D)));
            [&R] (C,(D,(B,A)));
            [&R] (D,(A,(B,C)));
            [&R] (D,(B,(A,C)));
            [&R] (D,(C,(B,A)));
            [&R] ((A,B),(C,D));
            [&R] ((A,C),(B,D));
            [&R] ((A,D),(C,B));
            """,
                                                          "NEWICK",
                                                          taxon_namespace=taxa)

        # expected results, for each gene tree / species tree pairing, with
        # cycling through species trees for each gene tree
        expected_deep_coalescences = [
            0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1,
            2, 2, 2, 1, 2, 2, 0, 2, 2, 1, 2, 3, 3, 3, 0, 1, 1, 3, 3, 3, 2, 1, 2
        ]
        assert len(
            expected_deep_coalescences) == len(gene_trees) * len(species_trees)

        for t in gene_trees + species_trees:
            t.update_bipartitions()
        idx = 0
        _LOG.info("Species\t\tGene\t\tDC\t\tExp.DC\t\tDiff")
        for gt in gene_trees:
            gt.update_bipartitions()
            for st in species_trees:
                st.update_bipartitions()
                dc = reconcile.reconciliation_discordance(gt, st)
                _LOG.info("%s\t\t%s\t\t%s\t\t%s\t\t%s" %
                          (st._as_newick_string(), gt._as_newick_string(), dc,
                           expected_deep_coalescences[idx],
                           dc - expected_deep_coalescences[idx]))
                assert dc == expected_deep_coalescences[idx]
                idx += 1
    def testFittedDeepCoalCounting(self):

        taxa = dendropy.TaxonNamespace()

        gene_trees = dendropy.TreeList.get_from_string(
            """
            [&R] (A,(B,(C,D))); [&R] ((A,C),(B,D)); [&R] (C,(A,(B,D)));
            """,
            "newick",
            taxon_namespace=taxa,
        )

        species_trees = dendropy.TreeList.get_from_string(
            """
            [&R] (A,(B,(C,D)));
            [&R] (A,(C,(B,D)));
            [&R] (A,(D,(C,B)));
            [&R] (B,(A,(C,D)));
            [&R] (B,(C,(A,D)));
            [&R] (B,(D,(C,A)));
            [&R] (C,(A,(B,D)));
            [&R] (C,(B,(A,D)));
            [&R] (C,(D,(B,A)));
            [&R] (D,(A,(B,C)));
            [&R] (D,(B,(A,C)));
            [&R] (D,(C,(B,A)));
            [&R] ((A,B),(C,D));
            [&R] ((A,C),(B,D));
            [&R] ((A,D),(C,B));
            """,
            "NEWICK",
            taxon_namespace=taxa,
        )

        # expected results, for each gene tree / species tree pairing, with
        # cycling through species trees for each gene tree
        expected_deep_coalescences = [
            0,
            1,
            1,
            1,
            2,
            2,
            3,
            3,
            3,
            3,
            3,
            3,
            1,
            2,
            2,
            2,
            1,
            2,
            2,
            2,
            1,
            1,
            2,
            2,
            2,
            1,
            2,
            2,
            0,
            2,
            2,
            1,
            2,
            3,
            3,
            3,
            0,
            1,
            1,
            3,
            3,
            3,
            2,
            1,
            2,
        ]
        assert len(expected_deep_coalescences) == len(gene_trees) * len(species_trees)

        for t in gene_trees + species_trees:
            t.update_bipartitions()
        idx = 0
        _LOG.info("Species\t\tGene\t\tDC\t\tExp.DC\t\tDiff")
        for gt in gene_trees:
            gt.update_bipartitions()
            for st in species_trees:
                st.update_bipartitions()
                dc = reconcile.reconciliation_discordance(gt, st)
                _LOG.info(
                    "%s\t\t%s\t\t%s\t\t%s\t\t%s"
                    % (
                        st._as_newick_string(),
                        gt._as_newick_string(),
                        dc,
                        expected_deep_coalescences[idx],
                        dc - expected_deep_coalescences[idx],
                    )
                )
                assert dc == expected_deep_coalescences[idx]
                idx += 1