Commit 94a83157 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Add the test for molecules that are neither rectant nor inhibitor

parent 1655d1d7
......@@ -315,9 +315,12 @@ check_model :-
identifier_kind(ModelId, Molecule, object),
List_Molecule
),
reactions_with_species(List_Molecule, List_Reaction),
(
maplist(test_all_reactions(reactant, test_wf_reactant), List_Molecule),
maplist(test_all_reactions(inhibitor, test_wf_inhibitor), List_Molecule)
forall(
member(Reaction, List_Reaction),
test_wellformed(List_Molecule, Reaction)
)
->
format("The model is wellformed.~n", [])
;
......@@ -1312,6 +1315,27 @@ test_all_reactions(Type, Test, Molecule) :-
).
%! test_wellformed(+List_Molecule, +Reaction)
%
% loop on molecule to determine if they follow the condition of wellformedness
test_wellformed([], _Reaction).
test_wellformed([Molecule|Tail], Expression for Reaction) :-
(
is_reactant(Molecule, Expression for Reaction)
->
test_wf_reactant(Molecule, Expression)
;
is_inhibitor(Molecule, Expression for Reaction)
->
test_wf_inhibitor(Molecule, Expression)
;
test_wf_other(Molecule, Expression)
),
test_wellformed(Tail, Expression for Reaction).
%! test_wf_reactant(+Molecule, +Expression)
%
% Check if the derivative of Expression wrt Molecule is positive somewhere
......@@ -1319,13 +1343,13 @@ test_all_reactions(Type, Test, Molecule) :-
test_wf_reactant(Molecule, Expression) :-
formal_derivation:derivate(Expression, Molecule, Derivative),
(
\+(arithmetic_rules:always_negative(Derivative))
\+(arithmetic_rules:always_negative(Derivative)),
!
;
format("Due to: ~w while checking ~w;~n", [Derivative, Molecule]),
format("Fail for wellformedness of ~w with ~w as reactant.~n", [Expression, Molecule]),
fail
).
%! test_wf_inhibitor(+Molecule, +Expression)
%
% Check if the derivative of Expression wrt Molecule is negative somewhere
......@@ -1333,9 +1357,22 @@ test_wf_reactant(Molecule, Expression) :-
test_wf_inhibitor(Molecule, Expression) :-
formal_derivation:derivate(Expression, Molecule, Derivative),
(
\+(arithmetic_rules:always_positive(Derivative))
\+(arithmetic_rules:always_positive(Derivative)),
!
;
format("Fail for wellformedness of ~w with ~w as inhibitor.~n", [Expression, Molecule]),
fail
).
%! test_wf_other(+Molecule, +Expression)
test_wf_other(Molecule, Expression) :-
formal_derivation:derivate(Expression, Molecule, Derivative),
(
is_null(Derivative),
!
;
format("Due to: ~w while checking ~w;~n", [Derivative, Molecule]),
format("Fail for wellformedness of ~w with ~w as not present.~n", [Expression, Molecule]),
fail
).
......
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