diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e96266..786e4f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: - name: Install Python uses: actions/setup-python@v3 with: - python-version: '3.9' + python-version: '3.11' - name: Setup pip cache uses: actions/cache@v3 diff --git a/Dockerfile b/Dockerfile index e8cf636..ef67fea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base OS -FROM python:3.9-slim-buster +FROM python:3.11-slim-bookworm ARG VERSION="0.1.22" ARG SIMULATOR_VERSION="0.11.25" @@ -45,9 +45,11 @@ RUN apt-get update -y \ # Copy code for command-line interface into image and install it COPY . /root/Biosimulators_AMICI -RUN pip install /root/Biosimulators_AMICI \ +RUN pip install pip==23.0.1 +RUN pip install sympy /root/Biosimulators_AMICI \ && rm -rf /root/Biosimulators_AMICI -RUN pip install amici==${SIMULATOR_VERSION} +#RUN pip install sympy /root/Biosimulators_AMICI amici==${SIMULATOR_VERSION} \ +# && rm -rf /root/Biosimulators_AMICI ENV VERBOSE=0 \ MPLBACKEND=PDF diff --git a/biosimulators_amici/core.py b/biosimulators_amici/core.py index 5689298..bcc17cb 100644 --- a/biosimulators_amici/core.py +++ b/biosimulators_amici/core.py @@ -280,7 +280,7 @@ def import_model_from_sbml(filename, variables): model_dir = tempfile.mkdtemp() model_name = 'biosimulators_amici_model_' + os.path.basename(model_dir) constant_parameters = [param.getId() for param in sbml_model.parameters if param.constant] - observables = {var: {'name': var, 'formula': var} for var in variables} + observables = {variable_id_to_observable_id(var): {'name': var, 'formula': var} for var in variables} sbml_importer.sbml2amici(model_name, model_dir, observables=observables, @@ -456,7 +456,7 @@ def validate_variables(model, variables, variable_target_sbml_id_map): unpredicted_symbols = [] unpredicted_targets = [] - sbml_id_to_obs_index = {id: index for index, id in enumerate(model.getObservableIds())} + obs_id_to_obs_index = {id: index for index, id in enumerate(model.getObservableIds())} for variable in variables: if variable.symbol: @@ -467,7 +467,7 @@ def validate_variables(model, variables, variable_target_sbml_id_map): else: sbml_id = variable_target_sbml_id_map.get(variable.target, None) - i_obs = sbml_id_to_obs_index.get(sbml_id, None) + i_obs = obs_id_to_obs_index.get(variable_id_to_observable_id(sbml_id), None) if i_obs is None: unpredicted_targets.append(variable.target) else: @@ -566,3 +566,12 @@ def preprocess_sed_task(task, variables, config=None): } }, } + + +def variable_id_to_observable_id(variable_id: str) -> str: + """Convert a variable ID to an observable ID. + + In AMICI, identifiers need to be globally unique. Therefore, we cannot use a species ID as an observable ID. + Let's hope that this alias does not already exist in the model... + """ + return f"___{variable_id}" diff --git a/docs-src/conf.py b/docs-src/conf.py index 23eca24..24dceeb 100644 --- a/docs-src/conf.py +++ b/docs-src/conf.py @@ -42,7 +42,6 @@ 'sphinx.ext.autodoc', 'sphinx.ext.linkcode', 'sphinx.ext.napoleon', - 'sphinxprettysearchresults', ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs-src/requirements.txt b/docs-src/requirements.txt index 41c3485..05a0f7f 100644 --- a/docs-src/requirements.txt +++ b/docs-src/requirements.txt @@ -1,3 +1,2 @@ pydata-sphinx-theme sphinx >= 1.8 -sphinxprettysearchresults diff --git a/tests/test_core_main.py b/tests/test_core_main.py index f0d75ce..0c1862a 100644 --- a/tests/test_core_main.py +++ b/tests/test_core_main.py @@ -251,7 +251,7 @@ def test_exec_sed_task_with_changes(self): model.changes.append(sedml_data_model.ModelAttributeChange( target="/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='{}']".format(variable_id), target_namespaces=self.NAMESPACES, - new_value=None)) + new_value=1.3)) variables.append(sedml_data_model.Variable( id=variable_id, target="/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='{}']".format(variable_id), @@ -287,7 +287,7 @@ def test_exec_sed_task_with_changes(self): for variable_id in variable_ids: numpy.testing.assert_allclose( results3[variable_id], - results[variable_id][-int(sim.number_of_points + 1):], + results[variable_id][-int(sim.number_of_points + 1):], rtol=1e-5, atol=1e-4 ) task.model.changes = [ @@ -673,3 +673,6 @@ def test_exec_sedml_docs_in_combine_archive_with_docker_image(self): archive_filename, out_dir, docker_image, environment=env, pull_docker_image=False) self._assert_combine_archive_outputs(doc, out_dir) + +if __name__ == "__main__": + unittest.main()