From 555912a7948d85d83229bdf04b8d20c62eb8205f Mon Sep 17 00:00:00 2001 From: Thierry Martinez Date: Fri, 16 Oct 2015 12:49:12 +0200 Subject: [PATCH] Rules are now reactions --- aliases.pl | 2 +- aliases.plt | 6 +-- conservation_laws.pl | 4 +- initial_state.plt | 4 +- models.plt | 6 +-- nusmv.plt | 4 +- rule_editor.pl => reaction_editor.pl | 59 ++++++++++++++-------------- reaction_editor.plt | 18 +++++++++ rule_editor.plt | 18 --------- toc.org | 6 +-- 10 files changed, 64 insertions(+), 63 deletions(-) rename rule_editor.pl => reaction_editor.pl (81%) create mode 100644 reaction_editor.plt delete mode 100644 rule_editor.plt diff --git a/aliases.pl b/aliases.pl index d5dd6c56..fddbd50b 100644 --- a/aliases.pl +++ b/aliases.pl @@ -30,7 +30,7 @@ add_equivalence_class_list(EquivalenceClassList) :- ; list_to_equals(EquivalenceClassList, EquivalenceClass), add_item(alias, EquivalenceClassList, alias(EquivalenceClass)), - simplify_all_rules + simplify_all_reactions ). diff --git a/aliases.plt b/aliases.plt index 3a852a23..47ee22e6 100644 --- a/aliases.plt +++ b/aliases.plt @@ -2,10 +2,10 @@ :- begin_tests(aliases). -test('alias', [true(Rules == [2 * a => c])]) :- +test('alias', [true(Reactions == [2 * a => c])]) :- clear_model, - add_rule(a + b => c), + add_reaction(a + b => c), command(alias(a = b)), - all_items([model: current_model, kind: rule], Rules). + all_items([model: current_model, kind: reaction], Reactions). :- end_tests(aliases). diff --git a/conservation_laws.pl b/conservation_laws.pl index cf7e0aa4..31ba2c8e 100644 --- a/conservation_laws.pl +++ b/conservation_laws.pl @@ -30,7 +30,7 @@ add_conservation(Conservation) :- these checks are not complete, even a failure will be accepted with a warning.' ), - rule_editor:solution_to_list(Conservation, C), + solution_to_list(Conservation, C), add_item(conservation, C). @@ -38,7 +38,7 @@ delete_conservation(Conservation) :- biocham_command, type(Conservation, solution), doc('removes the given mass conservation law.'), - rule_editor:solution_to_list(Conservation, C), + solution_to_list(Conservation, C), find_item([model: current_model, id: Id, type: conservation, item: C]), delete_item(Id). diff --git a/initial_state.plt b/initial_state.plt index ccfcec87..6795e29b 100644 --- a/initial_state.plt +++ b/initial_state.plt @@ -33,7 +33,7 @@ test( [true(InitialState == [present(a), absent(b)])] ) :- clear_model, - add_rule(a => b), + add_reaction(a => b), command(present(a)), make_absent_not_present, all_items([model: current_model, kind: initial_state], InitialState). @@ -43,7 +43,7 @@ test( [true(InitialState == [absent(a), present(b)])] ) :- clear_model, - add_rule(a => b), + add_reaction(a => b), command(absent(a)), make_present_not_absent, all_items([model: current_model, kind: initial_state], InitialState). diff --git a/models.plt b/models.plt index a3092b58..96caa068 100644 --- a/models.plt +++ b/models.plt @@ -3,13 +3,13 @@ :- begin_tests(models). -test('new_model', [true(Rules == [])]) :- +test('new_model', [true(Reactions == [])]) :- new_model, single_model(Id0), - add_rule(a => b), + add_reaction(a => b), new_model, single_model(Id1), - all_items([model: current_model, kind: rule], Rules), + all_items([model: current_model, kind: reaction], Reactions), delete_item(Id0), delete_item(Id1). diff --git a/nusmv.plt b/nusmv.plt index 7a1fba21..bb2eabcb 100644 --- a/nusmv.plt +++ b/nusmv.plt @@ -4,8 +4,8 @@ test('nusmv') :- clear_model, - add_rule(a => b), - add_rule(a + b => c), + add_reaction(a => b), + add_reaction(a + b => c), command(present(a)), command(absent(c)), export_nusmv('unittest'). diff --git a/rule_editor.pl b/reaction_editor.pl similarity index 81% rename from rule_editor.pl rename to reaction_editor.pl index d311839f..309585d2 100644 --- a/rule_editor.pl +++ b/reaction_editor.pl @@ -1,40 +1,41 @@ :- module( - rule_editor, + reaction_editor, [ - add_rule/1, - list_rules/0, - rule/4, - simplify_all_rules/0, - enumerate_molecules/1 + add_reaction/1, + list_reactions/0, + reaction/4, + simplify_all_reactions/0, + enumerate_molecules/1, + solution_to_list/2 ] ). -add_rule(Reaction) :- +add_reaction(Reaction) :- biocham_command, type(Reaction, reaction), - doc('adds reaction rules to the current set of rules.'), - simplify_rule(Reaction, SimplifiedReaction), - add_item(rule, SimplifiedReaction). + doc('adds reaction rules to the current set of reactions.'), + simplify_reaction(Reaction, SimplifiedReaction), + add_item(reaction, SimplifiedReaction). -list_rules :- +list_reactions :- biocham_command, - doc('lists the current set of rules.'), - list_items([model: current_model, kind: rule]). + doc('lists the current set of reactions.'), + list_items([model: current_model, kind: reaction]). -simplify_all_rules :- +simplify_all_reactions :- \+ ( - item([model: current_model, kind: rule, id: Id, item: Rule]), + item([model: current_model, kind: reaction, id: Id, item: Reaction]), \+ ( delete_item(Id), - simplify_rule(Rule, SimplifiedRule), - add_item(rule, SimplifiedRule) + simplify_reaction(Reaction, SimplifiedReaction), + add_item(reaction, SimplifiedReaction) ) ). -rule(Item, Kinetics, Reactants, Products, Reversible) :- +reaction(Item, Kinetics, Reactants, Products, Reversible) :- ( Item = (Kinetics for Body) -> @@ -68,8 +69,8 @@ rule(Item, Kinetics, Reactants, Products, Reversible) :- append(CatalystMolecules, LeftMolecules, Reactants), append(CatalystMolecules, RightMolecules, Products). -rule(Item, Kinetics, Reactants, Products) :- - rule(Item, PairKinetics, LeftMolecules, RightMolecules, Reversible), +reaction(Item, Kinetics, Reactants, Products) :- + reaction(Item, PairKinetics, LeftMolecules, RightMolecules, Reversible), ( Reversible = yes -> @@ -139,16 +140,16 @@ coefficient_object(1 * Object, Object) :- coefficient_object(CoefficientObject, CoefficientObject). -simplify_rule(Rule, SimplifiedRule) :- - rule(Rule, Kinetics, LeftMolecules, RightMolecules, Reversible), +simplify_reaction(Reaction, SimplifiedReaction) :- + reaction(Reaction, Kinetics, LeftMolecules, RightMolecules, Reversible), simplify_kinetics(Kinetics, KineticsSimplified), simplify_solution(LeftMolecules, LeftMoleculesSimplified), simplify_solution(RightMolecules, RightMoleculesSimplified), simplify_catalyst( LeftMoleculesSimplified, RightMoleculesSimplified, Left, Catalyst, Right ), - build_rule( - KineticsSimplified, Left, Catalyst, Right, Reversible, SimplifiedRule + build_reaction( + KineticsSimplified, Left, Catalyst, Right, Reversible, SimplifiedReaction ). @@ -225,13 +226,13 @@ simplify_catalyst([Head | Tail], Right, NewLeft, Catalyst, NewRight) :- ). -build_rule(Kinetics, Left, Catalyst, Right, Reversible, Rule) :- +build_reaction(Kinetics, Left, Catalyst, Right, Reversible, Reaction) :- ( Kinetics = 'MA'(1) -> - Rule = Body + Reaction = Body ; - Rule = (Kinetics for Body) + Reaction = (Kinetics for Body) ), list_to_solution(Left, LeftSolution), list_to_solution(Catalyst, CatalystSolution), @@ -266,8 +267,8 @@ enumerate_molecules(Molecules) :- enumerate_molecule(Molecule) :- - item([model: current_model, kind: rule, item: Item]), - rule(Item, _Kinetics, Reactants, Products, _Reversible), + item([model: current_model, kind: reaction, item: Item]), + reaction(Item, _Kinetics, Reactants, Products, _Reversible), ( member(_ * Molecule, Reactants) ; diff --git a/reaction_editor.plt b/reaction_editor.plt new file mode 100644 index 00000000..c3d32135 --- /dev/null +++ b/reaction_editor.plt @@ -0,0 +1,18 @@ +:- use_module(library(plunit)). + + +:- begin_tests(reaction_editor). + + +test('compound', [true(Reactions == [2 * a + 2 * b => 2 * 'a-b'])]) :- + clear_model, + command(add_reaction(2 * a + 2 * b => 2 * a-b)), + all_items([model: current_model, kind: reaction], Reactions). + +test('catalyst', [true(Reactions == [2 * b <=[ a + c ]=> b])]) :- + clear_model, + add_reaction(a + b + c <=[ b ]=> a + c), + all_items([model: current_model, kind: reaction], Reactions). + + +:- end_tests(reaction_editor). diff --git a/rule_editor.plt b/rule_editor.plt deleted file mode 100644 index 6cd572c9..00000000 --- a/rule_editor.plt +++ /dev/null @@ -1,18 +0,0 @@ -:- use_module(library(plunit)). - - -:- begin_tests(rule_editor). - - -test('compound', [true(Rules == [2 * a + 2 * b => 2 * 'a-b'])]) :- - clear_model, - command(add_rule(2 * a + 2 * b => 2 * a-b)), - all_items([model: current_model, kind: rule], Rules). - -test('catalyst', [true(Rules == [2 * b <=[ a + c ]=> b])]) :- - clear_model, - add_rule(a + b + c <=[ b ]=> a + c), - all_items([model: current_model, kind: rule], Rules). - - -:- end_tests(rule_editor). diff --git a/toc.org b/toc.org index 8b975a7c..98192120 100644 --- a/toc.org +++ b/toc.org @@ -32,9 +32,9 @@ *** Graphics files *** Other files - nusmv.pl -** Listing and editing rules and events -*** Rules -- rule_editor.pl +** Listing and editing reactions and events +*** Reactions +- reaction_editor.pl - ode.pl *** Events - events.pl -- GitLab