Commit 493cc46a authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain

Merge branch 'release/4.5.1'

parents 569495ee 280e652c
......@@ -53,7 +53,8 @@ KERNEL_DIR=$(JUPYTER_DIR)/kernel/biocham_kernel
WORKFLOWS_DIR=$(JUPYTER_DIR)/guinbextension/src/config/workflows
# NOTEBOOKS=$(shell find . -type f -name '*.ipynb' -print)
NOTEBOOKS=library/examples/C2-19-Biochemical-Programming/TD1_lotka_volterra.ipynb library/examples/doctor_in_the_cell/diagnosis.ipynb
NOTEBOOKS=library/examples/C2-19-Biochemical-Programming/TD1_lotka_volterra.ipynb library/examples/C2-19-Biochemical-Programming/TD2_enzyme_kinetics.ipynb library/examples/C2-19-Biochemical-Programming/TD4_genetic_switch.ipynb library/examples/C2-19-Biochemical-Programming/TD5_protein_switch.ipynb library/examples/C2-19-Biochemical-Programming/TD6_oscillators.ipynb library/examples/C2-19-Biochemical-Programming/TD7_switches.ipynb library/examples/C2-19-Biochemical-Programming/TD7_rate_independence.ipynb library/examples/C2-19-Biochemical-Programming/TD8_mapk_signalling.ipynb
REFDIR=nbrefs
all: biocham biocham_debug quick doc/index.html pldoc install_kernel install_gui
......
......@@ -8,7 +8,7 @@
about/0
]).
version('4.4.15').
version('4.5.1').
copyright(
'Copyright (C) 2003-2020 Inria, EPI Lifeware, Saclay-Île de France, France'
......
......@@ -11,6 +11,7 @@
]
).
:- use_module(doc).
:- devdoc('\\section{Commands}').
......
......@@ -6,9 +6,13 @@
additive_normal_form/2,
always_negative/1,
always_positive/1,
determine_sign/2,
normalize_number/2,
is_null/1,
modulo/3
zero_like/1,
modulo/3,
is_numeric/2,
is_numeric/1
]).
% Insert here for separate compilation and linting
......@@ -270,29 +274,41 @@ extract_coefficient(+ CA, C, A) :-
extract_coefficient(CA, C, A),
!.
extract_coefficient(A * B, A, B) :-
number(A),
!.
extract_coefficient(A / B, A, 1 / B) :-
number(A),
!.
extract_coefficient(A * B, B, A) :-
number(B),
!.
extract_coefficient(A / B, BInv, A) :-
number(B),
extract_coefficient(A * B, SubCoeff, Others) :-
extract_coefficient(A, ACoeff, AOthers),
extract_coefficient(B, BCoeff, BOthers),
!,
BInv is 1 / B.
(
AOthers = 1
->
Others = BOthers
;
BOthers = 1
->
Others = AOthers
;
Others = AOthers*BOthers
),
SubCoeff is ACoeff*BCoeff.
extract_coefficient(CA * B, C, A * B) :-
extract_coefficient(CA, C, A),
!.
extract_coefficient(A / B, SubCoeff, Others) :-
extract_coefficient(A, ACoeff, AOthers),
extract_coefficient(B, BCoeff, BOthers),
!,
(
AOthers = 1
->
Others = BOthers
;
BOthers = 1
->
Others = AOthers
;
Others = AOthers/BOthers
),
SubCoeff is ACoeff/BCoeff.
extract_coefficient(A * CB, C, A * B) :-
extract_coefficient(CB, C, B).
extract_coefficient(A, 1, A).
extract_powers(sqrt(Expr), Power, Sub) :-
......@@ -637,6 +653,11 @@ rewrite_additive_normal_form(A * (B * C), D * C) :-
rewrite_additive_normal_form(A * (B * C), B * (A * C)) :-
number(B).
rewrite_additive_normal_form((A * B) / C, D * B) :-
number(A),
number(C),
D is A/C.
rewrite_additive_normal_form((A * B) / C, A * (B / C)) :-
number(A).
......@@ -665,105 +686,132 @@ arithmetic_operation(- _).
arithmetic_operation(_ ^ _).
always_negative(A) :-
rewrite(rewrite_simplify, A, B),
B \= A,
!,
always_negative(B).
always_negative(A) :-
number(A),
!,
A =< 0.
always_negative(- A) :-
always_positive(A).
always_negative(A + B) :-
always_negative(A),
always_negative(B).
always_negative(A - B) :-
always_negative(A),
always_positive(B).
%! always_negative(+Expr)
%! always_positive(+Expr)
%
% Check if Expr is assure to be always negative/positive, fail if it can change sign
% or if it is impossible to decide
always_negative(A * B) :-
always_negative(A),
always_positive(B).
always_negative(Expr) :-
determine_sign(Expr, zero);
determine_sign(Expr, neg).
always_negative(0 * _) :-
!.
always_positive(Expr) :-
determine_sign(Expr, zero);
determine_sign(Expr, pos).
always_negative(A * B) :-
always_positive(A),
always_negative(B).
always_negative(A / B) :-
always_negative(A),
always_positive(B).
%! determine_sign(+Expr, -Sign)
%
% Try to infer the sign of Expr, Sign will be unified to: neg/pos/zero/dnk (do not know)
always_negative(A / B) :-
always_positive(A),
always_negative(B).
% TODO : Verify if it needs rewriting
%always_negative(A) :-
% rewrite(rewrite_simplify, A, B),
% B \= A,
% !,
% always_negative(B).
determine_sign(A, zero) :-
is_null(A),
!.
always_positive(A) :-
rewrite(rewrite_simplify, A, B),
B \= A,
determine_sign(Expr, Sign) :-
is_numeric(Expr, A),
!,
always_positive(B).
(
A = 0
->
Sign = zero
;
A < 0
->
Sign = neg
;
Sign = pos
).
always_positive(A) :-
number(A),
determine_sign(- A, NSign) :-
determine_sign(A, Sign),
!,
A >= 0.
always_positive(A):- % assumed for concentrations, parameters
atom(A),
!.
always_positive(- A) :-
always_negative(A).
(
Sign = pos
->
NSign = neg
;
Sign = neg
->
NSign = pos
;
NSign = Sign
).
always_positive(_A ^ B) :-
number(B),
determine_sign(A + B, Sign) :-
!,
(
modulo(B, 2, 0)
determine_sign(A, SignAB),
determine_sign(B, SignAB)
->
true
Sign = SignAB
;
Sign = dnk
).
always_positive(A ^ _B) :-
always_positive(A).
determine_sign(A - B, Sign) :-
!,
determine_sign(A + (- B), Sign).
always_positive(A + B) :-
always_positive(A),
always_positive(B).
determine_sign(A * B, Sign) :-
!,
determine_sign(A, SignA),
determine_sign(B, SignB),
(
(SignA = zero ; SignB = zero)
->
Sign = zero
;
(SignA = dnk ; SignB = dnk)
->
Sign = dnk
;
SignA = SignB
->
Sign = pos
;
Sign = neg
).
always_positive(A - B) :-
always_positive(A),
always_negative(B).
determine_sign(A / B, Sign) :-
!,
(
is_null(B)
->
throw(error(division_by_zero, arithmetic_rules_determine_sign))
;
true
),
determine_sign(A * B, Sign).
always_positive(0 * _) :-
determine_sign(A, pos) :- % concentrations and parameters are assumed positive
atom(A),
!.
always_positive(A * B) :-
always_negative(A),
always_negative(B).
determine_sign(_A ^ B, pos) :-
is_integer(B, Value),
(
modulo(Value, 2, 0)
->
!,
true
).
always_positive(A * B) :-
always_positive(A),
always_positive(B).
determine_sign(A ^ _B, Sign) :-
determine_sign(A, Sign).
always_positive(A / B) :-
always_positive(A),
always_positive(B).
determine_sign(exp(_A), pos).
always_positive(A / B) :-
always_negative(A),
always_negative(B).
always_positive(exp(_A)).
normalize_number(N, Norm) :-
(
......@@ -796,6 +844,14 @@ is_null_sr(_A^(-_N)) :- !, false.
is_null_sr(A^_N) :- is_null_sr(A).
%! zero_like(+Expr)
%
% A more drastic version of is_null
zero_like(0).
zero_like(0.0).
%! modulo(+A, +B)
%
% compute C is mod(A,B) but fail instead of raising an error when A or B are not integer
......@@ -807,4 +863,48 @@ modulo(A, B, C) :-
fail
).
%! is_numeric(+Expr, -Value)
%! is_numeric(+Expr)
%
% determine if an expression is a simple numeric value (eventualy with parameters)
is_numeric(N) :- is_numeric(N, _V).
is_numeric(N, Value) :-
item([kind:parameter, key:N, item:parameter(N = Value)]),
!.
is_numeric(N, Value) :-
% needed for parameters attached to ode system
get_current_ode_system(Id),
item([parent:Id, kind:parameter, item:par(N = Value)]),
!.
is_numeric(N, N) :-
number(N).
is_numeric(A + B, Vab) :- !,
is_numeric(A, Va),
is_numeric(B, Vb),
Vab is Va+Vb.
is_numeric(A - B, Vab) :- !,
is_numeric(A, Va),
is_numeric(B, Vb),
Vab is Va - Vb.
is_numeric(-(A), Vma) :- !,
is_numeric(A, Va),
Vma is -Va.
is_numeric(A*B, Vab) :- !,
is_numeric(A, Va),
is_numeric(B, Vb),
Vab is Va*Vb.
is_numeric(A^N, Van) :- !,
is_numeric(N, Vn),
is_numeric(A, Va),
Van is Va^Vn.
is_numeric(A/N, Van) :- !,
is_numeric(N, Vn),
is_numeric(A, Va),
Van is Va/Vn.
......@@ -2,6 +2,10 @@
:- begin_tests(arithmetic_rules, [setup((clear_model, reset_options))]).
test('simplify1', []) :-
simplify(a+2*a, 3*a),
simplify(-1*a/b+2*a/b, a/b).
test('distribute1', [true(Out == a * a + a * b + c)]) :-
distribute(a * (a + b) + c, Out).
......@@ -9,6 +13,17 @@ test('distribute2', []) :-
distribute((a+b)^2, a*a+a*b+(b*a+b*b)),
distribute((a+b)^ -2, (a+b)^ -2).
test('determine_sign', []) :-
parameter([k1 = 2, k2 = 3]),
determine_sign((a+1)^2, pos),
determine_sign((a-1)^3, dnk),
determine_sign(-exp(a), neg),
determine_sign(a/(a+1), pos),
determine_sign((2+a)*0, zero),
determine_sign((x-1)^k1, pos),
determine_sign((x-1)^k2, dnk).
test('is_null', []) :-
is_null(a*0*1/2),
\+(is_null(a*b/0)).
......
FROM registry.gitlab.inria.fr/lifeware/biocham:v4.4.15
FROM registry.gitlab.inria.fr/lifeware/biocham:v4.5.1
{
"name": "gui",
"version": "4.4.15",
"version": "4.5.1",
"description": "biocham gui in jupyter notebook",
"main": "src/index.js",
"scripts": {
......@@ -26,21 +26,21 @@
"babel-loader": "^8.0.0",
"classnames": "^2.2.6",
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^0.28.10",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"jest": "^23.6.0",
"jsdoc": "^3.5.5",
"lodash": "^4.17.11",
"react-test-renderer": "^16.6.0",
"redux-devtools-extension": "^2.13.8",
"redux-logger": "^3.0.6",
"style-loader": "^0.20.3",
"ttf-loader": "^1.0.2",
"url-loader": "^1.1.2",
"css-loader": "^0.28.10",
"file-loader": "^1.1.11",
"webpack": "^4.22.0",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.1.1",
"jest": "^23.6.0",
"jsdoc": "^3.5.5",
"lodash": "^4.17.11"
"webpack-cli": "^3.1.1"
},
"dependencies": {
"@material-ui/core": "^3.1.0",
......
......@@ -101,6 +101,7 @@ commands = [
"hybrid_static_simulation",
"import_ode",
"import_reactions_from_graph",
"infer_hidden_molecules",
"influence_graph",
"influence_hypergraph",
"influence_model",
......@@ -184,6 +185,7 @@ commands = [
"place",
"plot",
"polynomial_ODE",
"polynomize_ode",
"present",
"prolog",
"quadratic_reduction_ODE",
......
"""Example magic"""
__version__ = '4.4.15'
__version__ = '4.5.1'
#!/usr/bin/bash
# quadratization
swipl --goal=main --stand_alone=true -DSWIPL_LINKER_FLAGS="-static" -DSWIPL_SHARED_LIB=OFF\
--foreign=save -o quadratization -c biochamlib_quadratization.pl
# ODE2SBML
swipl --goal=main --stand_alone=true -DSWIPL_LINKER_FLAGS="-static" -DSWIPL_SHARED_LIB=OFF\
--foreign=save -o ODE2SBML -c biochamlib_ode2sbml.pl
#!/usr/bin/prolog
/*
* The prolog script to create the stand-alone saved state for conversion of an ODE to an
* SBML file.
* Coder: M. Hemery
*/
% Loading libraries
:- use_module(aliases).
:- use_module(arithmetic_rules).
:- use_module(biocham).
:- use_module(counters).
:- use_module(doc).
:- use_module(filename).
:- use_module(formal_derivation).
:- use_module(functions).
:- use_module(initial_state).
:- use_module(kinetics).
:- use_module(models).
:- use_module(molecules).
:- use_module(namespace).
:- use_module(objects).
:- use_module(ode).
:- use_module(parameters).
:- use_module(reaction_editor).
:- use_module(reaction_rules).
:- use_module(sbml_files).
:- use_module(toplevel).
:- use_module(types).
:- use_module(util).
:- use_module(xpp_parser).
set_my_option(Option, Value) :-
change_item([], option, Option, option(Option: Value)).
% parse_arguments(+Arguments, -Input)
%
% Handle the various option of the standalone:
% -i: input file
parse_arguments([], none).
parse_arguments(['-i', Input| Argv], Input) :-
parse_arguments(Argv, _I).
parse_arguments(['--help'| _Argv], _I, _M, _T) :-
print_help.
% print_help
print_help :-
format("help~n", []),
halt.
% main(+argv)
main(Argv) :-
(Argv = [] -> print_help ; true),
% Handling naming and options
parse_arguments(Argv, Input),
file_name_extension(InputBase, 'ode', Input),
file_name_extension(InputBase, 'sbml', Output),
format("Input: ~w~nOutput: ~w~n", [Input, Output]),
% Initialization (see biocham:initialize)
set_prolog_flag(allow_variable_name_as_functor, true),
set_counter(list_item_counter, 0),
set_counter(item_id, 0),
set_counter(model, 0),
set_counter(molecule_id, 0),
set_counter(parameter_id, 1),
nb_setval(ode_viewer, inline),
nb_setval(current_models, []),
new_model,
set_my_option(import_reactions_with_inhibitors, yes),
% Main procedure
read_xpp(Input),
list_ode,
add_reactions_from_ode_system,
export_sbml(Output).
#!/usr/bin/prolog
/*
* The prolog script to create the stand-alone saved state for quadratization, it reads
* and returns an .ode file.
* Coder: M. Hemery
*/
% Loading libraries
:- use_module(arithmetic_rules).
:- use_module(biocham).
:- use_module(counters).
:- use_module(doc).
:- use_module(kinetics).
:- use_module(models).
:- use_module(namespace).
:- use_module(ode).
:- use_module(quadratic_reduction).
:- use_module(sat).
:- use_module(toplevel).
:- use_module(types).
:- use_module(util).
:- use_module(xpp_parser).
set_my_option(Option, Value) :-
change_item([], option, Option, option(Option: Value)).
% parse_arguments(+Arguments, -Input, -Method, -Timeout)
%
% Handle the various option of the standalone:
% --method: method used to perform the reduction
% --timeout: timeout for sat call
% --help: print help and quit
% -i: input file
parse_arguments([], none, sat_species, 120).
parse_arguments(['--method', Method| Argv], Input, Method, Timeout) :-