Commit 1655d1d7 authored by Hemery Mathieu's avatar Hemery Mathieu
Browse files

Add comments and tests for the subroutines of check_model

parent e6553e0d
......@@ -73,7 +73,10 @@ Coder: T. Martinez
get_model/2,
load_all/2,
parametrize_initial_concentration/0,
parametrize_reaction/0
parametrize_reaction/0,
test_wf_reactant/2,
test_wf_inhibitor/2,
test_strictness/2
]
).
......@@ -313,15 +316,15 @@ check_model :-
List_Molecule
),
(
maplist(test_all_reactions(reactions_with_reactant, test_wf_reactant), List_Molecule),
maplist(test_all_reactions(reactions_with_inhibitor, test_wf_inhibitor), List_Molecule)
maplist(test_all_reactions(reactant, test_wf_reactant), List_Molecule),
maplist(test_all_reactions(inhibitor, test_wf_inhibitor), List_Molecule)
->
format("The model is wellformed.~n", [])
;
format("The model is NOT wellformed.~n", [])
),
(
maplist(test_all_reactions(reactions_with_catalyst, test_strictness), List_Molecule)
maplist(test_all_reactions(catalyst, test_strictness), List_Molecule)
->
format("The model is strict.~n", [])
;
......@@ -1293,7 +1296,13 @@ introduce_param(Func, Func2) :-
introduce_param(O,O).
test_all_reactions(Apply, Test, Molecule) :-
%! test_all_reactions(+Type, +Test, +Molecule)
%
% apply test to all the reactions where Molecule is present as Type (catalyst, etc.)
% Type is concatenate with 'reactions_with_', cf reaction_rules.pl
test_all_reactions(Type, Test, Molecule) :-
atomic_concat('reactions_with_', Type, Apply),
Constructor =.. [Apply, [Molecule], List_Reactions],
call(Constructor),
forall(
......@@ -1303,6 +1312,10 @@ test_all_reactions(Apply, Test, Molecule) :-
).
%! test_wf_reactant(+Molecule, +Expression)
%
% Check if the derivative of Expression wrt Molecule is positive somewhere
test_wf_reactant(Molecule, Expression) :-
formal_derivation:derivate(Expression, Molecule, Derivative),
(
......@@ -1312,6 +1325,11 @@ test_wf_reactant(Molecule, Expression) :-
fail
).
%! test_wf_inhibitor(+Molecule, +Expression)
%
% Check if the derivative of Expression wrt Molecule is negative somewhere
test_wf_inhibitor(Molecule, Expression) :-
formal_derivation:derivate(Expression, Molecule, Derivative),
(
......@@ -1321,6 +1339,11 @@ test_wf_inhibitor(Molecule, Expression) :-
fail
).
%! test_strictness(+Molecule, +Expression)
%
% Check if Expression is null when Molecule is absent
test_strictness(Molecule, Expression) :-
substitute([Molecule], [0], Expression, Output),
(
......
......@@ -39,5 +39,16 @@ test(
list_model
).
test('test_wf_reactant', []):-
with_output_to(atom(_), (
test_wf_reactant(a, a*2),
\+(test_wf_reactant(m, -m))
)).
test('test_strictness', []):-
with_output_to(atom(_), (
test_strictness(a, a*b+a^2.5/c),
\+(test_strictness(mapk, j0*mk/(1+(mapk/j1)^j2)/(j1+mk)))
)).
:- end_tests(models).
Supports Markdown
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