Commit 3459a8f4 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain

draw_neighborhood

parent 8f9fe3df
...@@ -96,6 +96,7 @@ create_cgraph(Id, Graph) :- ...@@ -96,6 +96,7 @@ create_cgraph(Id, Graph) :-
agattr(Graph, node, shape, ellipse, _), agattr(Graph, node, shape, ellipse, _),
agattr(Graph, edge, arrowhead, 'normal', _), agattr(Graph, edge, arrowhead, 'normal', _),
agattr(Graph, edge, color, 'black', _), agattr(Graph, edge, color, 'black', _),
agattr(Graph, edge, dir, 'forward', _),
\+ ( \+ (
item([parent: Id, kind: vertex, item: VertexName, id: VertexId]), item([parent: Id, kind: vertex, item: VertexName, id: VertexId]),
\+ ( \+ (
...@@ -126,6 +127,10 @@ create_cgraph(Id, Graph) :- ...@@ -126,6 +127,10 @@ create_cgraph(Id, Graph) :-
get_attribute(EdgeId, sign='+') get_attribute(EdgeId, sign='+')
-> ->
agset(GraphvizEdge, color, 'green4') agset(GraphvizEdge, color, 'green4')
;
get_attribute(EdgeId, dir='none')
->
agset(GraphvizEdge, dir, 'none')
; ;
true true
) )
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
% Commands % Commands
list_molecules/0, list_molecules/0,
list_locations/0, list_locations/0,
list_neighborhood/0,
draw_neighborhood/0,
% Public API % Public API
enumerate_molecules/1 enumerate_molecules/1
] ]
...@@ -23,21 +25,38 @@ list_locations :- ...@@ -23,21 +25,38 @@ list_locations :-
biocham_command, biocham_command,
doc('lists all the locations of the current model.'), doc('lists all the locations of the current model.'),
enumerate_all_molecules(L), enumerate_all_molecules(L),
setof( maplist(get_location, L, Locs),
Location, sort([default | Locs], Locations),
M^member(M@Location, L), write_numbered(Locations).
Locations
),
write_numbered([default | Locations]).
list_neighborhood :- list_neighborhood :-
retractall(neighbor(_, _)), biocham_command,
nusmv:enumerate_rules(negative, Rules), doc('lists all neighborhood relationships inferred from the model.'),
add_neighborhood(Rules), compute_neighborhood,
listing(molecules:neighbor/2). listing(molecules:neighbor/2).
draw_neighborhood :-
biocham_command,
doc('draws the graph of all neighborhood relationships inferred from the
model.'),
compute_neighborhood,
new_graph,
set_graph_name(neighborhood_graph),
get_current_graph(GraphId),
forall(
neighbor(X, Y),
(
add_vertex(GraphId, X, XId),
add_vertex(GraphId, Y, YId),
add_edge(GraphId, XId, YId, EdgeId),
set_attribute(EdgeId, dir = 'none')
)
),
draw_graph(GraphId).
:- devdoc('\\section{Public API}'). :- devdoc('\\section{Public API}').
...@@ -76,8 +95,10 @@ add_neighborhood([]). ...@@ -76,8 +95,10 @@ add_neighborhood([]).
add_neighborhood([(A, B, C, D) | L]) :- add_neighborhood([(A, B, C, D) | L]) :-
append([A, B, C, D], E), append([A, B, C, D], E),
maplist(nusmv:reactant_to_name, E, F), maplist(nusmv:reactant_to_name, E, F),
sort(F), maplist(get_location, F, G),
add_neighboor_pairs(F), sort(G, H),
subtract(H, [default], I),
add_neighboor_pairs(I),
add_neighborhood(L). add_neighborhood(L).
...@@ -92,3 +113,15 @@ add_neighboor_pairs(L) :- ...@@ -92,3 +113,15 @@ add_neighboor_pairs(L) :-
Pairs Pairs
), ),
maplist(assertz, Pairs). maplist(assertz, Pairs).
get_location(_@L, L) :-
!.
get_location(_, default).
compute_neighborhood :-
retractall(neighbor(_, _)),
nusmv:enumerate_rules(negative, Rules),
add_neighborhood(Rules).
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