def monophyletic_partition_discordance(tree, taxon_namespace_partition): deprecate.dendropy_deprecation_warning( preamble= "The 'dendropy.reconcile' module has moved to 'dendropy.model.reconcile'.", old_construct= "from dendropy import reconcile\nreconcile.monophyletic_partition_discordance(...)", new_construct= "from dendropy.model import reconcile\nreconcile.monophyletic_partition_discordance(...)", ) return reconcile.monophyletic_partition_discordance( tree, taxon_namespace_partition)
def testGroupedDeepCoalCounting(self): src_trees = [ "((a1,a2)x,b1)y;", "((a1, (a2, a3), b1), (b2,(b3,b4)));", "(((((a1, a2),a3), b1), b2), (b3, ((b4,b5),b6)));", "((b1, (b2, b3), a1), (a2,(a3, a4)));", "(((((b1, b2),b3), a1), a2), (a3, ((a4,a5),a6)));", "((a1,a2),(b1,b2),(c1,c2));", "((a1,a2),(b1,b2,c3),(c1,c2));", "(((a1,a2),(b1,b2),c1),c2);", ] scores = [0, 1, 2, 1, 2, 0, 1, 1] for src_tree, expected in zip(src_trees, scores): tree = dendropy.Tree.get_from_string(src_tree, "NEWICK") groups = dendropy.TaxonNamespacePartition( tree.taxon_namespace, membership_fn=lambda x: x.label[0]) dc = reconcile.monophyletic_partition_discordance(tree, groups) assert dc == expected, \ "deep coalescences by groups: expecting %d, but found %d" % (expected, dc)