コード例 #1
0
    def test_trim_tails_by_freq_forks(self):
        g = DeBruijnGraph()
        for s, t in itertools.combinations([1, 2, 3, 4, 5, 6], 2):
            g.add_edge(s, t)
            print('s => t', s, t)
        g.add_edge(6, 1)
        g.add_node(10)  # singlet
        g.add_edge(7, 6)
        g.add_edge(8, 7)
        g.add_edge(9, 8)
        g.trim_tails_by_freq(2)
        self.assertEqual([1, 2, 3, 4, 5, 6], sorted(g.nodes()))

        g = DeBruijnGraph()
        for s, t in itertools.combinations([1, 2, 3, 4, 5, 6], 2):
            g.add_edge(s, t)
        g.add_node(10)  # singlet
        g.add_edge(6, 1)
        g.add_edge(7, 6)
        g.add_edge(7, 8)
        g.add_edge(8, 7)
        g.add_edge(9, 8)
        g.trim_tails_by_freq(2)
        self.assertEqual([1, 2, 3, 4, 5, 6, 7, 8], sorted(g.nodes()))

        g = DeBruijnGraph()
        for s, t in itertools.combinations([1, 2, 3, 4, 5, 6], 2):
            g.add_edge(s, t)
        g.add_node(10)  # singlet
        g.add_edge(6, 1)
        g.add_edge(7, 6)
        g.add_edge(7, 8)
        g.add_edge(9, 8)
        g.trim_tails_by_freq(2)
        self.assertEqual([1, 2, 3, 4, 5, 6], sorted(g.nodes()))
コード例 #2
0
 def test_add_edge(self):
     g = DeBruijnGraph()
     g.add_edge(1, 2)
     self.assertEqual(1, g.get_edge_freq(1, 2))
     g.add_edge(1, 2)
     self.assertEqual(2, g.get_edge_freq(1, 2))
     g.add_edge(1, 2, 5)
     self.assertEqual(7, g.get_edge_freq(1, 2))
コード例 #3
0
    def test_trim_noncutting_paths_by_freq_degree_stop(self):
        g = DeBruijnGraph()
        for s, t in itertools.combinations([1, 2, 3, 4], 2):
            g.add_edge(s, t, freq=4)
        for s, t in itertools.combinations([5, 6, 7, 8], 2):
            g.add_edge(s, t, freq=4)
        path1 = [5, 9, 10, 11, 12, 1]
        for s, t in zip(path1, path1[1:]):
            g.add_edge(s, t)
        for edge in g.edges():
            print(edge)
        g.trim_noncutting_paths_by_freq(3)
        self.assertEqual(list(range(1, 9)) + path1[1:-1], g.nodes())

        # add an equal weight path to force namesorting
        path2 = [5, 13, 14, 15, 16, 1]
        for s, t in zip(path2, path2[1:]):
            g.add_edge(s, t)

        g.trim_noncutting_paths_by_freq(3)
        self.assertEqual(list(range(1, 9)) + path2[1:-1], g.nodes())

        # add back the original path with a higher (but still low) weight
        for s, t in zip(path1, path1[1:]):
            g.add_edge(s, t, freq=2)

        g.trim_noncutting_paths_by_freq(3)
        self.assertEqual(list(range(1, 9)) + path1[1:-1], g.nodes())

        # add the second path with 1 high weight edge
        path2 = [5, 13, 14, 15, 16, 1]
        for s, t in zip(path2, path2[1:]):
            g.add_edge(s, t)
        g.add_edge(14, 15, freq=6)

        g.trim_noncutting_paths_by_freq(3)
        self.assertEqual(list(range(1, 9)) + path2[1:-1], g.nodes())
コード例 #4
0
ファイル: test_assemble.py プロジェクト: bcgsc/mavis
 def test_add_edge(self):
     g = DeBruijnGraph()
     g.add_edge(1, 2)
     assert g.get_edge_freq(1, 2) == 1
     g.add_edge(1, 2)
     assert g.get_edge_freq(1, 2) == 2
     g.add_edge(1, 2, 5)
     assert g.get_edge_freq(1, 2) == 7