Commit 555912a7 authored by Thierry Martinez's avatar Thierry Martinez

Rules are now reactions

parent 29ceb236
......@@ -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
).
......
......@@ -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).
......@@ -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).
......
......@@ -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).
......
......@@ -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).
......
......@@ -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').
......
:- 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)
;
......
:- 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).
:- 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).
......@@ -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
......
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