Commit b15e9b3c authored by Rayan Chikhi's avatar Rayan Chikhi
Browse files

robustness fixes

parent c3537900
......@@ -85,6 +85,12 @@ def is_coherent_path(central_nodes,path_len):
assert(len(mols_in_central_nodes) == path_len+1)
return is_there_path_acc(mols_in_central_nodes)
def get_barcode(x):
if 'udg' in graph.nodes[x]:
return graph.nodes[x]['udg'].split()[0]
else:
return graph.nodes[x]['label']
""" the main function that tests for accuracy of random paths """
graph = None
def evaluate_accuracy_paths(path_len,max_paths_per_node=100):
......@@ -101,7 +107,7 @@ def evaluate_accuracy_paths(path_len,max_paths_per_node=100):
seen_paths.add(tuple(sorted(path)))
assert(len(path) == path_len+1)
#print("path",path)
central_nodes = [graph.nodes[x]['udg'].split()[0] for x in path]
central_nodes = [get_barcode(x) for x in path]
assert(len(central_nodes) == path_len+1)
#print(path,central_nodes)
if is_coherent_path(central_nodes,path_len):
......@@ -131,7 +137,7 @@ def evaluate_sensitivity_paths(path_len,overlap_length=7000):
from collections import defaultdict
molecules_to_nodes = defaultdict(list)
for node in graph.nodes():
central_node = graph.nodes[node]['udg'].split()[0]
central_node = get_barcode(node)
mols = central_node_to_molecules(central_node)
all_molecules |= set(mols)
for mol in mols:
......
......@@ -184,7 +184,10 @@ def str_to_udg_lists(s):
def parse_dg_name(gr, name):
udg = nx.get_node_attributes(gr, 'udg')[name]
central, h1, h2 = str_to_udg_lists(udg)
res = str_to_udg_lists(udg)
if len(res) != 3:
print("parsing problem:",res)
central, h1, h2 = res
idx = name
score = nx.get_node_attributes(gr, 'score')[name]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment