Commit 1bc64e01 by Yoann Dufresne

### scored unitig extraction ok

parent e7f0a973
 ... @@ -91,6 +91,7 @@ def filter_singeltons(graph): ... @@ -91,6 +91,7 @@ def filter_singeltons(graph): """ Compute the unambiguous paths in a d2g. The d2g must not contain singletons. """ Compute the unambiguous paths in a d2g. The d2g must not contain singletons. The unitigs are sorted by increasing penalty first and decreasing size second. @param d2g a d2g graph @param d2g a d2g graph @return a list of unitigs @return a list of unitigs """ """ ... @@ -117,6 +118,9 @@ def compute_unitigs(d2g): ... @@ -117,6 +118,9 @@ def compute_unitigs(d2g): for node in unitig: for node in unitig: used_nodes[node.idx] = True used_nodes[node.idx] = True # Sort the unitigs unitigs.sort(key=lambda x: (x.normalized_penalty(), -len(x))) return unitigs return unitigs ... @@ -127,7 +131,8 @@ def compute_unitigs(d2g): ... @@ -127,7 +131,8 @@ def compute_unitigs(d2g): @return The constructed unitig @return The constructed unitig """ """ def compute_unitig_from(d2g, node): def compute_unitig_from(d2g, node): unitig = Unitig(udgs=[node]) unitig = Unitig() unitig.add_udgs([node]) if d2g.degree(str(node.idx)) == 2: if d2g.degree(str(node.idx)) == 2: left, right = d2g.neighbors(str(node.idx)) left, right = d2g.neighbors(str(node.idx)) else: else: ... @@ -142,7 +147,7 @@ def compute_unitig_from(d2g, node): ... @@ -142,7 +147,7 @@ def compute_unitig_from(d2g, node): # Extends second side # Extends second side prev_node = node prev_node = node current_node = d2g.node_by_idx[int(right)] if right != None else None current_node = d2g.node_by_idx[int(right)] if right is not None else None unitig = extend_unitig(unitig, d2g, prev_node, current_node) unitig = extend_unitig(unitig, d2g, prev_node, current_node) return unitig return unitig ... @@ -155,10 +160,8 @@ def compute_unitig_from(d2g, node): ... @@ -155,10 +160,8 @@ def compute_unitig_from(d2g, node): @param current_node Node to add into the unitig and used to select the next node to add. If not set, stop the extension. @param current_node Node to add into the unitig and used to select the next node to add. If not set, stop the extension. @return Return the modified unitig. @return Return the modified unitig. """ """ def extend_unitig(unitig, d2g, prev_node, current_node): def extend_unitig(unitig, d2g, prev_node, current_node): if current_node == None: if current_node is None: return unitig return unitig # Add the node # Add the node ... ...