diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0614f4..30917edb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,14 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Added support for for sbml models to select parameters and species used in the inference +- Added support for evaluating sbml models at multiple time points + +### Changed + +- Switched from using parameter names to using parameter ids in the sbml model ## [0.4.0] @@ -26,6 +34,7 @@ All notable changes to this project will be documented in this file. - Added a new example model, a 2d heat conduction equation - Added a function to model to specify more complex parameter domains + ### Changed - Removed old functions from corona model diff --git a/docs/source/examples/sbml_example.rst b/docs/source/examples/sbml_example.rst index ae71b496..b9ed0058 100644 --- a/docs/source/examples/sbml_example.rst +++ b/docs/source/examples/sbml_example.rst @@ -22,12 +22,14 @@ Here's a code snippet to load your own sbml model and to do the parameter infere central_param = np.array([1.0, 1.0]) # initial guess, evaluation must have nonzero density param_limits = np.array([[0.0, 2.0], [0.0, 2.0]]) - param_names = ['k1', 'k2'] + param_ids = ['k1', 'k2'] + timepoints = np.array([1.0]) - model = SBMLModel('model.xml', + model = SBMLModel(sbml_file='model.xml', central_param=central_param, param_limits=param_limits, - param_names=param_names) + timepoints=timepoints, + param_ids=param_ids) inference(model, 'data.csv') The attribute :py:attr:`~eulerpi.core.model.SBMLModel.param_names` contains the names of the parameters in the sbml model, for which the inference should be performed. diff --git a/eulerpi/core/model.py b/eulerpi/core/model.py index 3a8b8552..4f7ff0ba 100644 --- a/eulerpi/core/model.py +++ b/eulerpi/core/model.py @@ -324,9 +324,9 @@ def data_dim(self): def __init__( self, sbml_file: str, - timepoints: list, central_param: np.ndarray, param_limits: np.ndarray, + timepoints: list, param_ids: Optional[list] = None, state_ids: Optional[list] = None, skip_creation: bool = False, diff --git a/eulerpi/examples/sbml/sbml_caffeine_model.py b/eulerpi/examples/sbml/sbml_caffeine_model.py index bceb1ce3..2b4251ba 100644 --- a/eulerpi/examples/sbml/sbml_caffeine_model.py +++ b/eulerpi/examples/sbml/sbml_caffeine_model.py @@ -24,9 +24,9 @@ def __init__( super().__init__( sbml_file, - timepoints, central_param, param_limits, + timepoints, param_ids, **kwargs, ) diff --git a/eulerpi/examples/sbml/sbml_menten_model.py b/eulerpi/examples/sbml/sbml_menten_model.py index 967e0761..e7567e62 100644 --- a/eulerpi/examples/sbml/sbml_menten_model.py +++ b/eulerpi/examples/sbml/sbml_menten_model.py @@ -24,17 +24,17 @@ def __init__( sbml_file = importlib.resources.path( "eulerpi.examples.sbml", "sbml_menten_model.xml" ) - timepoints = np.array([0.5, 1.0, 2.0]) + timepoints = np.array([0.5, 1.0]) param_ids = ["Km", "kcat"] state_ids = ["s1"] super().__init__( sbml_file, - timepoints, central_param, param_limits, + timepoints, param_ids, - state_ids=state_ids, + state_ids, **kwargs, ) diff --git a/tests/test_examples.py b/tests/test_examples.py index 2824fdc8..69033030 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -73,7 +73,20 @@ def get_example_name(example): @pytest.mark.parametrize("example", Examples(), ids=get_example_name) def test_model_requirements(example): - """Test the requirements of the inference for the example models.""" + """Perform a simple sanity check on the model. It tests the following: + - The model has a positive parameter dimension + - The model has a positive data dimension + - The model has a valid combination of parameter and data dimension + - The central parameter has the correct shape + - The parameter limits have the correct shape + - The model can be instantiated + - The model forward pass can be calculated + - The model jacobi matrix can be calculated + - The return values of the forward pass and the jacobi matrix have the correct shape + + Args: + example: Tuple of the form (module_location, className, dataFileName) or (module_location, className) + """ # extract example parameters from tuple try: