def construct_network(comb):
    left, right = comb
    h_left = cluster_hard(left)
    h_right = cluster_hard(right)
    clusters = {cl for cl in itertools.chain(h_left, h_right)}
    g = construct(clusters)
    return g
 def test_seven(self):
     edges = [("['1', u'4', u'6']", u'3'),
              ("['1', u'4', u'6']", u'2'),
              ('1h', '1'),
              (u'3', '1h'),
              (u'3', u'6'),
              (u'2', '1h'),
              (u'2', u'4') ]
     G = nx.DiGraph()
     G.add_edges_from(edges)
     gold = ['1', '4', '6', '1,4,6', '1,4', '1,6', ]
     self.assertItemsEqual(cluster_hard(G), gold)
 def test_five(self):
     edges = [
         ((1, 2, 3, 4), (4, )),
         ((4, ), (3, )),
         ((1, 2,), (1, )),
         ((1, 2,), (2, )),
         ((1, 2, 3, 4), (1, 2, )),
         ]
     G = nx.DiGraph()
     G.add_edges_from(edges)
     gold = "1 2 3 1,2 1,2,3".split()
     self.assertItemsEqual(cluster_hard(G), gold)
Beispiel #4
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())
Beispiel #5
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)
 def test_four(self):
     clusters = [(1, 2, 3)]
     G = construct(clusters)
     gold = "1 2 3 1,2,3".split()
     self.assertItemsEqual(cluster_hard(G), gold)
 def test_three(self):
     clusters = [(1, 2), (3, 4)]
     G = construct(clusters)
     gold = "1 2 3 4  1,2,3,4  1,2 3,4".split()
     self.assertItemsEqual(cluster_hard(G), gold)
 def test_one(self):
     clusters = [(1, 2)]
     G = construct(clusters)
     gold = "1 2 1,2".split()
     self.assertItemsEqual(cluster_hard(G), gold)
 def test_empty(self):
     G = nx.DiGraph()
     gold = set()
     self.assertItemsEqual(cluster_hard(G), gold)