Example #1
0
 def foo_test_mc_trees(self):
     print 'testing mc trees:'
     k = 4
     for i in range(4, 4 + k):
         print 'N:', i
         all_bifurcating_trees = splitalg.get_bifurcating_trees(i)
         all_quartets = splitalg.get_quartets(i)
         # get multifurcating trees using the nine rules
         mc_trees_ben = set(get_mc_trees_ben(i))
         print 'number of mc trees using the nine rules:', len(mc_trees_ben)
         tree_set_sets_ben = set(
             frozenset(mc_tree_to_trees(tree, all_bifurcating_trees))
             for tree in mc_trees_ben)
         print 'number of unique bifurcating tree sets generated by these mc trees:', len(
             tree_set_sets_ben)
         # get multifurcating trees using a naive method
         mc_trees = set(get_mc_trees(i))
         print 'number of mc trees using a naive search:', len(mc_trees)
         tree_set_sets = set(
             frozenset(mc_tree_to_trees(tree, all_bifurcating_trees))
             for tree in mc_trees)
         print 'number of unique bifurcating tree sets generated by these mc trees:', len(
             tree_set_sets)
         # compare subsets
         symmetric_difference = mc_trees_ben ^ mc_trees
         print 'number of trees in the symmetric difference set:', len(
             symmetric_difference)
         if mc_trees_ben - mc_trees:
             print 'an mc tree using the rules but not the naive:'
             print(mc_trees_ben - mc_trees).pop()
         if mc_trees - mc_trees_ben:
             print 'an mc tree using the naive but not the rules:'
             print(mc_trees - mc_trees_ben).pop()
         # Look for a naive mc tree that generates a set of bifurcating trees that
         # is not representable by a multiconnected tree constructed from the rules.
         weird_naive_mc_trees = set()
         for mc_tree in mc_trees:
             if frozenset(mc_tree_to_trees(
                     mc_tree,
                     all_bifurcating_trees)) not in tree_set_sets_ben:
                 weird_naive_mc_trees.add(mc_tree)
         if weird_naive_mc_trees:
             weird_tree = weird_naive_mc_trees.pop()
             print 'a naive mc tree that represents a set of trees not representable by any real mc tree:'
             print weird_tree
             mytrees = set(all_bifurcating_trees)
             for split in weird_tree:
                 mytrees = get_compatible_trees(split, mytrees)
             print len(mytrees), 'trees compatible with the weird tree:'
             for tree in mytrees:
                 print tree
             # find the quartets implied by the trees
             quartets = get_splits_implied_by_trees(mytrees, all_quartets)
             print len(
                 quartets
             ), 'quartets implied by the set of bifurcating trees:'
             for q in quartets:
                 print q
         print
Example #2
0
 def foo_test_mc_trees(self):
     print 'testing mc trees:'
     k = 4
     for i in range(4, 4+k):
         print 'N:', i
         all_bifurcating_trees = splitalg.get_bifurcating_trees(i)
         all_quartets = splitalg.get_quartets(i)
         # get multifurcating trees using the nine rules
         mc_trees_ben = set(get_mc_trees_ben(i))
         print 'number of mc trees using the nine rules:', len(mc_trees_ben)
         tree_set_sets_ben = set(frozenset(mc_tree_to_trees(tree, all_bifurcating_trees)) for tree in mc_trees_ben)
         print 'number of unique bifurcating tree sets generated by these mc trees:', len(tree_set_sets_ben)
         # get multifurcating trees using a naive method
         mc_trees = set(get_mc_trees(i))
         print 'number of mc trees using a naive search:', len(mc_trees)
         tree_set_sets = set(frozenset(mc_tree_to_trees(tree, all_bifurcating_trees)) for tree in mc_trees)
         print 'number of unique bifurcating tree sets generated by these mc trees:', len(tree_set_sets)
         # compare subsets
         symmetric_difference = mc_trees_ben ^ mc_trees
         print 'number of trees in the symmetric difference set:', len(symmetric_difference)
         if mc_trees_ben - mc_trees:
             print 'an mc tree using the rules but not the naive:'
             print (mc_trees_ben - mc_trees).pop()
         if mc_trees - mc_trees_ben:
             print 'an mc tree using the naive but not the rules:'
             print (mc_trees - mc_trees_ben).pop()
         # Look for a naive mc tree that generates a set of bifurcating trees that
         # is not representable by a multiconnected tree constructed from the rules.
         weird_naive_mc_trees = set()
         for mc_tree in mc_trees:
             if frozenset(mc_tree_to_trees(mc_tree, all_bifurcating_trees)) not in tree_set_sets_ben:
                 weird_naive_mc_trees.add(mc_tree)
         if weird_naive_mc_trees:
             weird_tree = weird_naive_mc_trees.pop()
             print 'a naive mc tree that represents a set of trees not representable by any real mc tree:'
             print weird_tree
             mytrees = set(all_bifurcating_trees)
             for split in weird_tree:
                 mytrees = get_compatible_trees(split, mytrees)
             print len(mytrees), 'trees compatible with the weird tree:'
             for tree in mytrees:
                 print tree
             # find the quartets implied by the trees
             quartets = get_splits_implied_by_trees(mytrees, all_quartets)
             print len(quartets), 'quartets implied by the set of bifurcating trees:'
             for q in quartets:
                 print q
         print
Example #3
0
 def __init__(self, N):
     self.N = N
     self.all_quartets = list(splitalg.get_quartets(N))
     self.all_splits = list(splitalg.get_informative_partial_splits(N))
Example #4
0
 def __init__(self, N):
     self.N = N
     self.all_quartets = list(splitalg.get_quartets(N))
     self.all_splits = list(splitalg.get_informative_partial_splits(N))