Commit 80a808e5 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain
Browse files

FIX remove_stoichiometry_and_sort does not rely on reaction/2 output order any more

parent 5ab9ee85
......@@ -379,6 +379,10 @@ rules_from_trace([_], _, []).
rules_from_trace([S1, S2 | States], Molecules, [R | Rules]) :-
rules_from_states(S1, S2, Molecules, R),
debug(
revision,
"possible use of reaction ~p between states ~w and ~w", [R, S1, S2]
),
rules_from_trace([S2 | States], Molecules, Rules).
......@@ -434,10 +438,20 @@ del_reaction_backtracking(R) :-
compatible(SInc, SDec, SPres, Reaction) :-
debug(
revision,
"Testing compatibility with SInc: ~w, SDec: ~w and SPres: ~w",
[SInc, SDec, SPres]
),
item([kind: reaction, item: Reaction]),
reaction(Reaction, [reactants: Reactants, products: Products]),
% TODO something with inhibitors
remove_stoichiometry_and_sort(Reactants, Products, UReac, UProd, UCata),
debug(
revision,
"Reaction ~w (~w, ~w) has UReac: ~w, UProd: ~w and UCata: ~w",
[Reaction, Reactants, Products, UReac, UProd, UCata]
),
% products are true at the end
ord_union(SInc, SPres, SAfter),
ord_subset(UProd, SAfter),
......@@ -450,17 +464,14 @@ compatible(SInc, SDec, SPres, Reaction) :-
ord_subset(UCata, SPres).
% Based on reaction/5 implementation, we know catalysts come first
remove_stoichiometry_and_sort([_*M | Reac], [_*M | Prod], UReac, UProd, UUCata) :-
!,
remove_stoichiometry_and_sort(Reac, Prod, UReac, UProd, UCata),
ord_add_element(UCata, M, UUCata).
remove_stoichiometry_and_sort(Reactants, Products, UReac, UProd, []) :-
maplist(remove_stoich, Reactants, Reac),
msort(Reac, UReac),
maplist(remove_stoich, Products, Prod),
msort(Prod, UProd).
remove_stoichiometry_and_sort(Reactants, Products, UReac, UProd, UCata) :-
maplist(remove_stoich, Reactants, UR),
maplist(remove_stoich, Products, UP),
msort(UR, SR),
msort(UP, SP),
ord_subtract(SR, SP, UReac),
ord_subtract(SP, SR, UProd),
ord_intersection(SR, SP, UCata).
remove_stoich(_*X, X).
......
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