Commit f1d92ae9 authored by FAGES Francois's avatar FAGES Francois
Browse files

trace reecritures rate indpendence

parent 0716ebff
......@@ -19,7 +19,7 @@
% Test the 3 graphical conditions (and not yet well-formedness) for rate independence.
test_rate_independence :-
biocham_command,
doc('Test graphical sufficient conditions for rate independence of the current model for all output species (assuming well-formed kinetics).'),
doc('Tests graphical sufficient conditions for rate independence of the current model for all output species (assuming well-formed kinetics).'),
reaction_graph,
get_current_graph(Id),
(
......@@ -27,12 +27,12 @@ test_rate_independence :-
is_synthesis_free,
is_loop_free(Id)
->
write('Current model is rate independent.\n')
writeln('The model is rate independent.')
;
write('Cannot establish rate independence from graphical conditions.\n'),
write('Undecided, sufficient condition for rate independence not verified: model '),
nb_getval(rate_dependence_reason, Failed),
Failed =.. [Stage, Place],
format("Model is not ~w-free (on ~w).~n", [Stage, Place])
format("not ~w-free (on ~w).~n", [Stage, Place])
).
......@@ -67,8 +67,7 @@ rate_independence_reduction(Inputs, Outputs):-
write('outputs: '), writeln(Outputs),
simplify(Inputs, Outputs),
!,
writeln('Reduced'),
list_model.
writeln('There is no more reduction preserving rate independence.').
rate_independence_reduction_inputs_sinks:-
biocham_command,
......@@ -169,23 +168,26 @@ dfs_no_loop(GraphId, Vertex) :-
% Elimination of trivial reactions and isolated species with no outgoing fork
simplify(Inputs, Outputs):-
\+ trivial_reaction,
\+ same_reaction,
enumerate_molecules(L),
subtract(L, Inputs, L1),
subtract(L1, Outputs, Molecules),
\+ simplify(Molecules).
reduce(Molecules).
simplify(Inputs, Outputs):-
writeln('--------- iterate ---------'), list_model,
simplify(Inputs, Outputs).
reduce(Molecules):-
list_model,
\+ trivial_reaction,
\+ same_reaction,
\+ (member(M, Molecules), eliminate(M)).
reduce(Molecules):-
reduce(Molecules).
% Elimination of trivial reactions with products=reactants
trivial_reaction:-
item([kind:reaction, id: Id, item: Reaction]),
reaction(Reaction, _Kinetics, Reactants, _Inhibitors, Reactants),
write('trivial reaction: '), writeln(Reaction),
write('--> removing trivial reaction '), writeln(Reaction),
delete_item(Id).
% Elimination of doublon reactions with same reactants and products
......@@ -197,24 +199,16 @@ same_reaction:-
item([kind:reaction, id: Id2, item: Reaction2]),
Id\=Id2,
reaction(Reaction2, _, Reactants, _, Products),
write('double reaction: '), writeln(Reaction2),
write('--> removing double reaction '), writeln(Reaction2),
delete_item(Id2).
% Merge of reactions on molecules with no outgoing fork or in trivial loops
simplify(Molecules):-
member(M, Molecules),
simpl(M),
!.
% Elimination of reaction catalyst M not produced in other reaction
% +
% Elimination of species M isolated in reactions alpha_i => beta_i + M and M + gamma => delta
% if forall i alpha_i\cap\gamma=\emptyset and \alpha_i \= \delta
% by merging reactions resulting in alpha_i + gamma => beta_i + delta
simpl(M):-
eliminate(M):-
reactions_with_reactant([M], [Reaction1]),
reactions_with_product([M], Reactions),
delete(Reactions, Reaction1, Reactions2),
......@@ -222,12 +216,13 @@ simpl(M):-
(
Reactions=[Reaction1] % M catalyst not produced elsewhere
->
write('Isolated catalyst: '), write(M), write(' in '), writeln(Reaction1),
delete_reaction(Reaction1),
reaction(Reaction1, Kinetics1, Reactants1, Inhibitors1, Products1),
member((C*M), Reactants1),
member((D*M), Products1),
C=D, % asking now for same stoichiometry (just a catalyst, no synthesis, no degradation)
write('--> eliminating catalyst '), write(M), write(' isolated in reaction: '), writeln(Reaction1),
delete_reaction(Reaction1),
delete(Reactants1, (C*M), Reac1),
member((D*M), Products1),
delete(Products1, (D*M), Prod1),
(
C<D
......@@ -254,7 +249,7 @@ write('Isolated catalyst: '), write(M), write(' in '), writeln(Reaction1),
)
),
write('Isolated species: '), write(M), write(' in '), writeln(Reaction1),
write('--> eliminating '), writeln(M), write(' product of '), writeln(Reactions), write(' reactant of '), writeln(Reaction1),
delete_reaction(Reaction1),
forall(
......@@ -270,7 +265,7 @@ write('Isolated species: '), write(M), write(' in '), writeln(Reaction1),
% Elimination of M in 2 loops alpha 1<=>3 M (4<)=>2 gamma rewritten alpha (<)=> gamma
% GENERALIZED TO alpha 1<=>3 beta+M (4<)=>2 gamma in alpha<=>gamma ELIMINATING M ISOLATED AND KEEPING REACTIONS WITH BETA
simpl(M):-
eliminate(M):-
reactions_with_reactant([M], [Reaction1, Reaction2]), % M isolated
reactions_with_product([M], [Reaction3 | Reactions]),
(
......@@ -350,7 +345,9 @@ simpl(M):-
delete_reaction(Reaction4)
)
),
write('Isolated species in loops: '), write(M), write(' in '), writeln(Reaction1), writeln(Reaction2), writeln(Reaction3), writeln(Reaction4),
write('--> Eliminating '), writeln(M),
write(' product of loop '), write(Reaction1), write(' and '),writeln(Reaction2),
write(' reactant of '), write(Reaction3), write(' '), writeln(Reaction4),
delete_reaction(Reaction1),
delete_reaction(Reaction2),
......
prolog("writeln(' ')").
prolog('writeln("%%%%%%%% WRONG ANSWER %%%%%%%%%")').
prolog("writeln(' ')").
prolog("writeln(' ')").
clear_model.
d=>a.
a=>b.
b=>2*d.
a=>c.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER NO AAAARGH NON CONFLUENCE OF RESULT / REACTION ORDERING AS SHOWN BELOW:")').
prolog("writeln(' ')").
clear_model.
a=>c.
a=>b.
b=>2*d.
d=>a.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER NO ")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO ")').
prolog("writeln(' ')").
prolog('writeln("%%%%%%%% DIVERGING SYLVAIN %%%%%%%%%")').
prolog("writeln(' ')").
prolog("writeln(' ')").
clear_model.
a=>b.
b=> a+c.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES DIV ")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES DIV ")').
prolog("writeln(' ')").
clear_model.
a=>b.
b=> a+c.
d=> a.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES DIV ")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES DIV ")').
prolog("writeln(' ')").
clear_model.
a=>c.
a=>b.
b=>2*a.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES DIV ")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES DIV ")').
prolog("writeln(' ')").
clear_model.
a=>c.
a=>b.
b=>2*d.
d=>a.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES DIV ")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES DIV ")').
prolog('writeln("============")').
prolog("writeln(' ')").
prolog('writeln("%%%%%%%% UNDECIDED %%%%%%%%%")').
prolog("writeln(' ')").
prolog("writeln(' ')").
clear_model.
a => x+c.
b => y+c.
x+y => z.
c+z => r.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: max = sum-min")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: max = sum-min")').
prolog("writeln(' ')").
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
e=>c+f.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite loop leakage with and-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: composite loop leakage with and-fork")').
prolog("writeln(' ')").
prolog('writeln("%%%%%%% CORRECT ANSWER %%%%%%%%")').
prolog("writeln(' ')").
prolog("writeln(' ')").
clear_model.
2*a => a+b.
a+b => 2*a.
a+b => 2*b.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER NO: subtle multiple steady states ")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: subtle multiple steady states ")').
prolog("writeln(' ')").
clear_model.
MA(k1) for a+b => b.
MA(k2) for b+c=>d.
list_model.
test_rate_independence_inputs_sinks. % no
prolog('writeln("ANSWER NO: for on input a")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: for on input a")').
prolog("writeln(' ')").
clear_model.
MA(k1) for a+b => b.
MA(k2) for b+c=>d.
list_model.
test_rate_independence({b,c}, {d}). % no
prolog('writeln("ANSWER YES: declared irrelevant input")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: declared irrelevant input")').
prolog("writeln(' ')").
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite loop leakage with or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: composite loop leakage with or-fork")').
prolog("writeln(' ')").
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
e=>c+d.
e=>f+g.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: composite double loop leakage with composite or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: composite double loop leakage with composite or-fork")').
prolog("writeln(' ')").
clear_model.
a => b.
b => c.
c => b + d.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: loop leakage with and-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: loop leakage with and-fork")').
prolog("writeln(' ')").
clear_model.
input=>a.
a => b.
b => c.
c => a + d.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: loop leakage with and-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: loop leakage with and-fork")').
prolog("writeln(' ')").
clear_model.
a => b.
b => c.
b => d.
c => a.
c => e.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER NO: loop double leakage with or-forks")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: loop double leakage with or-forks")').
prolog("writeln(' ')").
clear_model.
a => b.
b => c+d.
c => a+e.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER NO: loop double leakage with and-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: loop double leakage with and-fork")').
prolog("writeln(' ')").
clear_model.
a => b.
b => c+d.
c => a.
c => e.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER NO: loop double leakage with and-or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: loop double leakage with and-or-fork")').
prolog("writeln(' ')").
clear_model.
a => b.
b => a.
b => c.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: short loop leakage with or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: short loop leakage with or-fork")').
prolog("writeln(' ')").
clear_model.
a => b.
b => c.
c => a.
c => d.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: loop leakage with or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: loop leakage with or-fork")').
prolog("writeln(' ')").
clear_model.
a+b=>c+d.
c+d=>e.
e=>c+f.
list_model.
test_rate_independence_inputs_sinks.
prolog('writeln("ANSWER YES: partial loop leakage with or-fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: partial loop leakage with or-fork")').
prolog("writeln(' ')").
clear_model.
a=>b+c.
b=>d.
c=>d.
list_model.
test_rate_independence_inputs_sinks. % yes
prolog('writeln("ANSWER YES: closing and-fork with or-join")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: closing and-fork with or-join")').
prolog("writeln(' ')").
clear_model.
a=>b+c.
b+c=>d.
list_model.
test_rate_independence_inputs_sinks. % yes
prolog('writeln("ANSWER YES: closing and-fork with and-join")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: closing and-fork with and-join")').
prolog("writeln(' ')").
clear_model.
a=>b.
a=>c.
b=>d.
c=>d.
list_model.
test_rate_independence_inputs_sinks. % yes
prolog('writeln("ANSWER YES: closing or-fork with or-join")'). prolog('writeln("============")').
prolog('writeln("ANSWER YES: closing or-fork with or-join")').
prolog("writeln(' ')").
clear_model.
a=>b.
a=>c.
b+c=>d.
list_model.
test_rate_independence_inputs_sinks. % yes
prolog('writeln("ANSWER NO: closing or-fork with and-join")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: closing or-fork with and-join")').
prolog("writeln(' ')").
clear_model.
MA(k1) for A => B.
MA(k2) for A + B => C.
list_model.
test_rate_independence_inputs_sinks. % no
prolog('writeln("ANSWER NO: closing or-fork with and-join")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: closing or-fork with and-join")').
prolog("writeln(' ')").
clear_model.
MA(1) for A=>B.
MA(2) for B=>C.
MA(5) for B=>D.
MA(6) for D=>B.
list_model.
test_rate_independence_inputs_sinks. % no
prolog('writeln("ANSWER NO: parasite loop and fork")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: parasite loop and fork")').
prolog("writeln(' ')").
clear_model.
input=>a.
MA(k1) for a => b.
MA(k2) for b => a.
MA(k3) for b => c.
MA(k4) for c => b.
list_model.
test_rate_independence_inputs_sinks. % no
prolog('writeln("ANSWER NO: output in loop equilibriuem")'). prolog('writeln("============")').
prolog('writeln("ANSWER NO: output in loop equilibrium")').
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