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

enjoy

parent bf97f8b5
......@@ -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.'),
doc('Test 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,7 +27,7 @@ test_rate_independence :-
is_synthesis_free,
is_loop_free(Id)
->
write('Current model is rate independent if its kinetics are well-formed.\n')
write('Current model is rate independent.\n')
;
write('Cannot establish rate independence from graphical conditions.\n'),
nb_getval(rate_dependence_reason, Failed),
......@@ -38,26 +38,27 @@ test_rate_independence :-
% to generalize to influence models too
test_rate_independence_sources_sinks :-
biocham_command,
doc('Test graphical sufficient conditions for rate independence of the current model for the computation of graph sink species from graph source species.'),
source_species(Inputs),
sink_species(Outputs),
write('sources: '), writeln(Inputs),
write('sinks: '), writeln(Outputs),
test_rate_independence(Inputs, Outputs).
% Test rate independence for given inputs and outputs by performing rate-independence preserving reduction
test_rate_independence(Inputs, Outputs):-
biocham_command,
type(Inputs, {object}),
type(Outputs, {object}),
doc('Checks whether the current reaction model is rate independent
for computing the given set of molecular species \\argument{Outputs} from \\argument{Inputs}.
doc('Test graphical sufficient conditions for rate independence of the current model (assuming well-formed kinetics)
for the computation of molecular species in \\argument{Outputs} from species in \\argument{Inputs}.
Warning: this command destroys the current model by applying the \\command{rate_independence_reduction}.'),
rate_independence_reduction(Inputs, Outputs),
test_rate_independence.
test_rate_independence_sources_sinks :-
biocham_command,
doc('Test graphical sufficient conditions for rate independence of the current model for the computation of graph sink species from graph source species (assuming well-formed kinetics).'),
source_species(Inputs),
sink_species(Outputs),
write('sources: '), writeln(Inputs),
write('sinks: '), writeln(Outputs),
test_rate_independence(Inputs, Outputs).
% Performs a model reduction which preserves the rate independence property for given inputs and outputs
rate_independence_reduction(Inputs, Outputs):-
biocham_command,
......@@ -66,6 +67,7 @@ rate_independence_reduction(Inputs, Outputs):-
doc('Reduces the current reaction model while preserving rate independence for computing \\argument{Outputs} species from \\argument{Inputs} species.'),
simplify(Inputs, Outputs),
!,
writeln('Reduced model:'),
list_model.
rate_independence_reduction_sources_sinks:-
......@@ -165,14 +167,14 @@ dfs_no_loop(GraphId, Vertex) :-
% Compression of species with no outgoing fork and trivial loops
% Elimination of species with no outgoing fork and trivial loops
simplify(Inputs, Outputs):-
\+ trivial_reaction,
\+ same_reaction,
enumerate_molecules(L),
subtract(L, Inputs, L1),
subtract(L1, Outputs, Molecules),
\+ simplify(Molecules),
\+ trivial_reaction,
\+ same_reaction.
\+ simplify(Molecules).
simplify(Inputs, Outputs):-
simplify(Inputs, Outputs).
......@@ -202,20 +204,19 @@ simplify(Molecules):-
simpl(M),
!.
% Elimination of species M if no outgoing fork rewritten by merging reactions
% alpha_i => beta_i + M and M + gamma => delta rewritten alpha_i + gamma => beta_i + delta
% Elimination of species M if no outgoing fork
% rewritten by merging reactions
% alpha_i => beta_i + M and M + gamma => delta is rewritten alpha_i + gamma => beta_i + delta
simpl(M):-
reactions_with_reactant([M], [Reaction1]),
reactions_with_product([M], Reactions),
subtract(Reactions, [Reaction1], Reactions2),
Reactions2\=[],
!,
delete_reaction(Reaction1),
member(Reaction2, Reactions2),
delete_reaction(Reaction2),
add_merge_reactions(M, Reaction1, Reaction2).
% Todo: accept reversible reactions with syntax <=>
......@@ -282,6 +283,6 @@ add_merge_reactions(M, Reaction1, Reaction2):-
append(Reac1, Reac2, Reac),
append(Prod1, Prod2, Prod),
append(Inhib1, Inhib2, Inhib),
add_reaction(Kin1*Kin2,Reac,Inhib,Prod,false).
\ No newline at end of file
clear_model.
a => x+c.
b => y+c.
x+y => z.
c+z => r.
list_model.
test_rate_independence_sources_sinks.
clear_model.
a => b.
b => c.
c => b + d.
list_model.
test_rate_independence_sources_sinks.
clear_model.
a => b.
b => c.
c => b.
c => d.
list_model.
test_rate_independence_sources_sinks.
clear_model.
a+b=>b.
b+c=>_.
list_model.
test_rate_independence_sources_sinks.
clear_model.
a+b=>c+d.
c+d=>a+b.
c+d=>e.
e=>c+d.
e=>f+g.
list_model.
test_rate_independence_sources_sinks.
clear_model.
a => b.
b => a.
b => c.
list_model.
test_rate_independence_sources_sinks.
clear_model.
a=>b.
a=>c.
b=>d.
c=>d.
list_model.
test_rate_independence_sources_sinks.
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