Example #1
0
 def test_four(self):
     text = ("(0,((((((((1,((2,3),4)),(5,6)),(((7,(8,9)),10),"
             "((11,((((12,13),(14,15)),16),17)),((18,19),(20,21))))),"
             "(22,23)),(((24,25),26),((27,28),(29,((30,31),((((32,33),"
             "(34,(35,(36,37)))),(38,(39,((40,41),42)))),43)))))),44),45),46));")
     enewick_graph = enewick_to_digraph(text)
     self.assertEqual(len(enewick_graph.nodes()), 93)
     enewick_phylo = enewick_to_phylonet(text)
     self.assertEqual(len(enewick_phylo.nodes()), 93)
Example #2
0
    def test_three(self):
        text = "((4, 5#1)2, (#1, 6)3);"
        enewick_graph = enewick_to_digraph(text)
        self.assertEqual(len(enewick_graph.nodes()), 6)
        enewick_graph = calc_hybrid(enewick_graph)
        leafs = get_leaf_nodes(enewick_graph)
        gold_leafs = ['1', '4', '6', ]
        self.assertItemsEqual(leafs, gold_leafs)

        clusters = ["1,2", "2,3"]
        gold = construct(clusters)
        g = enewick_to_phylonet(text)
        GM = GraphMatcher(g, gold)
        self.assertTrue(GM.is_isomorphic())
Example #3
0
    def test_two(self):
        text = "((4, 5#1)2, (#1, 6)3);"
        enewick_graph = enewick_to_digraph(text)
        self.assertEqual(len(enewick_graph.nodes()), 6)

        enewick_phylo = enewick_to_phylonet(text)
        gold_hard = "1,4 1,4,6 1,6 4 6".split()
        hard = cluster_hard(enewick_graph)
        self.assertItemsEqual(hard, gold_hard)
        self.assertEqual(len(enewick_phylo.nodes()), 7)

        clusters = [(1, 2), (2, 3),]
        gold = construct(clusters)
        GM = GraphMatcher(enewick_phylo, gold)
        self.assertTrue(GM.is_isomorphic())
Example #4
0
 def test_one(self):
     text = "((MOUSE,(HUMAN,RAT)),CIOIN);"
     enewick_graph = enewick_to_digraph(text)
     self.assertEqual(len(enewick_graph.nodes()), 7)
     enewick_graph = enewick_to_phylonet(text)
     self.assertEqual(len(enewick_graph.nodes()), 7)
     clusters = [(1, 2, 3), (2, 3), (4,)]
     gold = construct(clusters)
     GM = GraphMatcher(enewick_graph, gold)
     self.assertTrue(GM.is_isomorphic())
     gold_hard = [
          'CIOIN,HUMAN,MOUSE,RAT',
          'CIOIN', 'HUMAN', 'MOUSE', 'RAT',
          'HUMAN,MOUSE,RAT',
          'HUMAN,RAT',
         ]
     hard = cluster_hard(enewick_graph)
     self.assertEqual(len(hard), 7)
     self.assertItemsEqual(hard, gold_hard)