Commit 8473d581 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Add a pruning step on reaction before modifier handling

parent 223cbaaf
......@@ -35,7 +35,7 @@ correct_model :-
(
remove_null_kinetic(Reaction),!
;
split_bidirectional_reaction(Reaction),!
split_bidirectional_reaction(List_Molecule, Reaction),!
;
reverse_reaction(Reaction),!
;
......@@ -61,16 +61,17 @@ remove_null_kinetic(Expression for Reaction) :-
delete_reaction(Expression for Reaction)
).
%! split_bidirectional_reaction(+Reaction)
%! split_bidirectional_reaction(+List_Mol, +Reaction)
%
% Split a bidirection reaction in two
split_bidirectional_reaction(Expression for Reactant => Product) :-
split_bidirectional_reaction(List_Mol, Expression for Reactant => Product) :-
(
ode:substitute_functions(Expression, Expr),
distribute(Expr, DistExpr),
DistExpr = Up - Down,
% test if it is effectively a bidir. reaction
member(P, List_Mol),
models:formal_product(P, Reactant => Product),
present_in_kinetics(P, Down)
->
......@@ -106,12 +107,15 @@ reverse_reaction(Expression for Reactant => Product) :-
correct_modifiers(List_Molecule, Expression_raw for Reaction) :-
ode:substitute_functions(Expression_raw, Expression),
detect_modifiers(List_Molecule, Expression, Catalysts, Inhibitors),
% purify reaction
findall(M, (member(M, List_Molecule), models:formal_catalyst(M, Reaction)), LC),
remove_all_catalysts(LC, Reaction, Purified_Reaction),
(
append(Catalysts, Inhibitors, [])
->
true
;
add_catalysts(Catalysts, Reaction, ReactionTempo),
% append(Catalysts, Inhibitors, [])
%->
%true
%;
add_catalysts(Catalysts, Purified_Reaction, ReactionTempo),
add_inhibitors(Inhibitors, ReactionTempo, NewReaction),
delete_reaction(Expression_raw for Reaction),
add_reaction(Expression_raw for NewReaction)
......@@ -245,3 +249,29 @@ remove_molecule(P*Molecule+Other, Molecule, Result) :- !,
remove_molecule(Species+Other, Molecule, Without+Other) :-
remove_molecule(Species, Molecule, Without).
%! remove_all_catalysts(+List_Catalyst, +Reaction, -NewReaction)
%
%
remove_all_catalysts([], Reaction, Reaction).
remove_all_catalysts([Head|Tail], R/I=>P, RR/I=>PP) :-
remove_all_catalysts(Tail, R/I=>P, RT/I=>PT),
remove_catalyst(RT, PT, Head, RR, PP).
remove_all_catalysts([Head|Tail], R=>P, RR=>PP) :-
remove_all_catalysts(Tail, R=>P, RT=>PT),
remove_catalyst(RT, PT, Head, RR, PP).
remove_catalyst(Reac, Prod, Cat, NReac, NProd) :-
(
remove_molecule(Reac, Cat, TReac),
remove_molecule(Prod, Cat, TProd)
->
remove_catalyst(TReac, TProd, Cat, NReac, NProd)
;
NReac = Reac,
NProd = Prod
).
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