Commit 44261c77 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

evaluate coverage variables

parent f75e2095
......@@ -216,7 +216,7 @@ def path_to_jumps(path):
return chuncks
def print_d2_summary(connected_components, longest_path, covered_vars={}, light_print=False):
def print_d2_summary(connected_components, longest_path, coverage_vars=(0, 0), light_print=False):
print("--- Global summary ---")
print(f"Number of connected components: {len(connected_components)}")
print(f"Total number of nodes: {sum([len(x) for x in connected_components])}")
......@@ -234,16 +234,10 @@ def print_d2_summary(connected_components, longest_path, covered_vars={}, light_
print(f"Size of the longest path: {len(longest_path)}")
print("Jumps in central nodes:")
print(path_to_jumps(longest_path))
print(f"Number of optimization variable coverage: {len(covered_vars)}")
nb_true = 0
falses = []
for idx, val in covered_vars.items():
if val:
nb_true += 1
else:
falses.append(idx)
print(f"Coverage: {nb_true}/{len(covered_vars)}")
print(f"Uncovered_values:\n{falses}")
print(f"Number of usable coverage variables: {len(coverage_vars[1])}")
print(f"Coverage: {len(coverage_vars[0])}/{len(coverage_vars[1])}")
print(f"Missing coverage variables:\n{coverage_vars[1]-coverage_vars[0]}")
def compute_next_nodes(d2_component):
......@@ -342,40 +336,20 @@ def recursive_longest_path(current_node, current_molecule, next_nodes, longest_p
return longest_paths[current_node][current_molecule]
def compute_covered_variables(optimization_file, path):
vars = None
var_assignments = {}
# Read optimization variables
with open(optimization_file) as of:
header = of.readline()
header = [int(x) for x in header.split(" ")]
nb_nodes = header[0]
nb_vars = header[1]
vars = {x:False for x in range(nb_vars)}
# nb_true = 0
# for x in vars.values():
# if x: nb_true += 1
# print(nb_true)
# exit()
for idx, line in enumerate(of):
# Stop at the end of nodes
if idx >= nb_nodes:
break
def compute_covered_variables(graph, path):
path_nodes = set()
for mol, node_name in path:
path_nodes.add(node_name)
parsed = [int(x) for x in line.split(' ')]
var_assignments[parsed[0]] = parsed[1:]
print(var_assignments[0])
# Read the path to cover the variables
for node in path:
node_idx = int(node[1].split(" ")[0])
for var_idx in var_assignments[node_idx]:
vars[var_idx] = True
used_vars = set()
total_vars = set()
for node, data in graph.nodes(data=True):
vars = data["barcode_edges"].split(" ")
total_vars.update(vars)
if node in path_nodes:
used_vars.update(vars)
return vars
return used_vars, total_vars
# returns True iff there exist x in mol1 such that there exists y in mol2 and |x-y| <= some_value
def nearby_udg_molecules(mols1, mols2):
......@@ -496,10 +470,8 @@ def main():
component = graph.subgraph(components[0])
longest_path = compute_longest_increasing_paths(component)
covered_vars = {}
if args.optimization_file and len(args.optimization_file) > 0:
covered_vars = compute_covered_variables(args.optimization_file, longest_path)
print_d2_summary(components, longest_path, covered_vars=covered_vars, light_print=args.light_print)
vars = compute_covered_variables(graph, longest_path)
print_d2_summary(components, longest_path, coverage_vars=vars, light_print=args.light_print)
# added by Rayan
# example:
......
Supports Markdown
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