Browse Source

final, buggy..

nzimme 2 years ago
parent
commit
85d52b80ca
1 changed files with 11 additions and 8 deletions
  1. 11 8
      debruijn/debruijn.py

+ 11 - 8
debruijn/debruijn.py View File

@@ -286,14 +286,17 @@ def simplify_bubbles(graph):
286 286
         graph, nx.DiGraph: a bubble-less de bruijn graph
287 287
     """
288 288
     fork_nodes = []# empty list containing nodes with 2 or more ancestors
289
-
290
-    for node in graph:
291
-        if graph.in_degree(node) >= 2: # if 2 or more ancestor add node
292
-            pred = [n for n in graph.predecessors(node)] 
293
-            ancestor = algorithms.lowest_common_ancestor(graph,pred[0], pred[1])
294
-            graph = solve_bubble(graph, ancestor, node)
295
-
296
-
289
+    f=1
290
+    while f == 1: 
291
+        for node in graph:
292
+            if graph.in_degree(node) >= 2: # if 2 or more ancestor add node
293
+                pred = [n for n in graph.predecessors(node)] 
294
+                if len(pred) > 2:
295
+                    f = 1
296
+                else:
297
+                    f = 0
298
+                ancestor = algorithms.lowest_common_ancestor(graph,pred[0], pred[1])
299
+                graph = solve_bubble(graph, ancestor, node)
297 300
 
298 301
     return graph
299 302