Commit 5bb97919 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[cmd] get common graph info: add number of events and genes

parent 7ce33225
...@@ -412,13 +412,25 @@ def queries_2_common_graph(output_dir, model_file, path, ...@@ -412,13 +412,25 @@ def queries_2_common_graph(output_dir, model_file, path,
if make_json or make_csv: if make_json or make_csv:
# Export to json file (similaire à model_graph_info() ...) # Export to json file (similaire à model_graph_info() ...)
# Get 2 lists: 1: frontiers; 2: events
unzipped_solutions = list(zip(*solutions))
# Frontiers # Frontiers
frontiers = set(it.chain(*[sol.split() for sol, _ in solutions])) frontiers = set(it.chain(*[sol.split() for sol in unzipped_solutions[0]]))
# Events
events = set(it.chain(*it.chain(*unzipped_solutions[1])))
# Genes
# brutal but effective as long as the nodes of a model do not have
# the information in hard in one of their attributes
genes = [name for name in frontiers if "_gene" in name]
solutions_info = { solutions_info = {
'modelFile': model_file, 'modelFile': model_file,
'query': query, 'query': query,
'solutions': len(solutions), # nb trajectories/solutions 'solutions': len(solutions), # nb trajectories/solutions
'boundaries': len(frontiers), # frontier places 'boundaries': len(frontiers),
'events': len(events),
'genes': len(genes),
} }
# Advanced metrics # Advanced metrics
get_solutions_graph_data(graph, solutions_info, True) get_solutions_graph_data(graph, solutions_info, True)
...@@ -443,11 +455,14 @@ def queries_2_common_graph(output_dir, model_file, path, ...@@ -443,11 +455,14 @@ def queries_2_common_graph(output_dir, model_file, path,
# Init the CSV file now # Init the CSV file now
import csv import csv
f_d = open(output_dir + 'graphs_summary.csv', 'w') f_d = open(output_dir + 'graphs_summary.csv', 'w')
# Get a subset of solutions_info keys
writer = csv.DictWriter( writer = csv.DictWriter(
f_d, f_d,
[ [
"query", "solutions", "boundaries", "graph_nodes", "graph_edges", "query", "solutions", "boundaries", "events", "genes",
"strongly_connected", "max_degree", "min_degree", "average_degree" "graph_nodes", "graph_edges",
"strongly_connected",
"max_degree", "min_degree", "average_degree",
], ],
extrasaction="ignore", # Ignore unknown fieldnames extrasaction="ignore", # Ignore unknown fieldnames
delimiter=str(';'), delimiter=str(';'),
......
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