Commit d710aa9b authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain

present_species_up option for drawing graphs

parent d768a8f9
......@@ -99,6 +99,8 @@ create_cgraph(Id, Graph) :-
agattr(Graph, edge, arrowhead, 'normal', _),
agattr(Graph, edge, color, 'black', _),
agattr(Graph, edge, dir, 'forward', _),
agsubg(Graph, 'source', true, Source),
agattr(Source, graph, rank, 'min', _),
\+ (
item([parent: Id, kind: vertex, item: VertexName, id: VertexId]),
\+ (
......@@ -107,6 +109,10 @@ create_cgraph(Id, Graph) :-
get_attribute(VertexId, kind = transition)
->
agset(Node, shape, box)
;
get_attribute(VertexId, source = true)
->
agsubnode(Source, Node, true)
;
true
)
......
......@@ -137,7 +137,8 @@ influence_graph(GraphId) :-
set_attribute(EdgeId, sign = Sign)
)
)
).
),
reaction_graphs:present_up(GraphId).
influence_hypergraph(GraphId) :-
......@@ -183,7 +184,8 @@ influence_hypergraph(GraphId) :-
place(GraphId, Output, OutputId),
add_edge(GraphId, TransitionId, OutputId, _)
)
).
),
reaction_graphs:present_up(GraphId).
:- devdoc('\\section{Private predicates}').
......
......@@ -153,7 +153,37 @@ pl_agnode(
PL_check(node = agnode(graph, name, create_flag));
PL_check(PL_unify_pointer(node_term, node));
PL_succeed;
}
static foreign_t
pl_agsubg(
term_t graph_term, term_t name_term, term_t create_flag_term,
term_t subgraph_term
) {
Agraph_t *graph;
char *name;
int create_flag;
Agraph_t *subgraph;
PL_check(PL_get_graph(graph_term, &graph));
PL_check(PL_get_atom_chars(name_term, &name));
PL_check(PL_get_bool(create_flag_term, &create_flag));
PL_check(subgraph = agsubg(graph, name, create_flag));
PL_check(PL_unify_pointer(subgraph_term, subgraph));
PL_succeed;
}
static foreign_t
pl_agsubnode(
term_t graph_term, term_t node_term, term_t create_flag_term
) {
Agraph_t *graph;
Agnode_t *node;
int create_flag;
PL_check(PL_get_graph(graph_term, &graph));
PL_check(PL_get_node(node_term, &node));
PL_check(PL_get_bool(create_flag_term, &create_flag));
PL_check(agsubnode(graph, node, create_flag));
PL_succeed;
}
static foreign_t
......@@ -246,6 +276,8 @@ PL_extension graphviz_predicates[] = {
{ "agedge", 6, (pl_function_t) pl_agedge, 0 },
{ "agget", 3, (pl_function_t) pl_agget, 0 },
{ "agnode", 4, (pl_function_t) pl_agnode, 0 },
{ "agsubg", 4, (pl_function_t) pl_agsubg, 0 },
{ "agsubnode", 3, (pl_function_t) pl_agsubnode, 0 },
{ "agopen", 3, (pl_function_t) pl_agopen, 0 },
{ "agread", 2, (pl_function_t) pl_agread, 0 },
{ "agset", 3, (pl_function_t) pl_agset, 0 },
......
......@@ -50,7 +50,14 @@ draw_reactions :-
reaction_graph :-
biocham_command,
doc('Builds the reaction graph of the current model.'),
option(present_species_up, yesno, _PresentUp, 'Put species that are present
at the top of the graph when drawing it.'),
doc('Builds the reaction graph of the current model.
\\begin{example}'),
biocham(option(present_species_up: yes)),
biocham(draw_reactions),
doc('\\end{example}'),
biocham_silent(option(present_species_up: no)),
delete_items([kind: graph, key: reaction_graph]),
new_graph,
set_graph_name(reaction_graph),
......@@ -58,6 +65,9 @@ reaction_graph :-
reaction_graph(GraphId).
:- initial('option(present_species_up: no)').
rule_graph :-
biocham_command,
doc('
......@@ -162,6 +172,27 @@ reaction_graph(GraphId) :-
)
)
)
),
present_up(GraphId).
present_up(GraphId) :-
(
get_option(present_species_up, PresentUp),
PresentUp == yes
->
enumerate_molecules(M),
forall(
(
member(Species, M),
place(GraphId, Species, SpeciesId),
get_initial_concentration(Species, C),
C > 0
),
set_attribute(SpeciesId, source = true)
)
;
true
).
......
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