From 702cba6bd5a240e026f0fa299553890907326a87 Mon Sep 17 00:00:00 2001 From: Jonathan Karr Date: Wed, 22 Sep 2021 12:45:06 -0400 Subject: [PATCH] feat: added support for max_sim_steps --- biosimulators.json | 197 ++++++++++++++++++++------ biosimulators_bionetgen/data_model.py | 20 +++ requirements.txt | 4 +- tests/test_core_main.py | 26 ++++ tests/test_data_model.py | 11 +- 5 files changed, 210 insertions(+), 48 deletions(-) diff --git a/biosimulators.json b/biosimulators.json index 4c69cfa..bce3976 100644 --- a/biosimulators.json +++ b/biosimulators.json @@ -96,12 +96,11 @@ } ], "references": { - "identifiers": [ - { - "namespace": "pypi", - "id": "bionetgen", - "url": "https://pypi.org/project/bionetgen/" - }, + "identifiers": [{ + "namespace": "pypi", + "id": "bionetgen", + "url": "https://pypi.org/project/bionetgen/" + }, { "namespace": "pypi", "id": "biosimulators-bionetgen", @@ -178,8 +177,7 @@ "version": null, "supportedFeatures": [] }], - "modelChangePatterns": [ - { + "modelChangePatterns": [{ "name": "Change compartments sizes", "types": ["SedAttributeModelChange", "SedComputeAttributeChangeModelChange", "SedSetValueAttributeModelChange"], "target": { @@ -263,6 +261,30 @@ }, "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"] }, + { + "id": "output_step_interval", + "name": "Output step interval", + "type": "integer", + "value": null, + "recommendedRange": null, + "kisaoId": { + "namespace": "KISAO", + "id": "KISAO_0000684" + }, + "availableSoftwareInterfaceTypes": ["desktop application", "command-line application"] + }, + { + "id": "max_sim_steps", + "name": "Maximum simulation steps", + "type": "integer", + "value": null, + "recommendedRange": null, + "kisaoId": { + "namespace": "KISAO", + "id": "KISAO_0000415" + }, + "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"] + }, { "id": "stop_if", "name": "Stop condition", @@ -280,21 +302,26 @@ "namespace": "SIO", "id": "SIO_000418" }], - "outputVariablePatterns": [ - { + "outputVariablePatterns": [{ "name": "time", "symbol": { - "value": "time", - "namespace": "urn:sedml:symbol" - } + "value": "time", + "namespace": "urn:sedml:symbol" + } }, { "name": "species concentrations", - "target": {"value": "species..count", "grammar": "BNGL"} + "target": { + "value": "species..count", + "grammar": "BNGL" + } }, { "name": "molecule concentrations", - "target": {"value": "molecules..count", "grammar": "BNGL"} + "target": { + "value": "molecules..count", + "grammar": "BNGL" + } } ], "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"], @@ -325,8 +352,7 @@ "version": null, "supportedFeatures": [] }], - "modelChangePatterns": [ - { + "modelChangePatterns": [{ "name": "Change compartments sizes", "types": ["SedAttributeModelChange", "SedComputeAttributeChangeModelChange", "SedSetValueAttributeModelChange"], "target": { @@ -398,6 +424,30 @@ }, "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"] }, + { + "id": "output_step_interval", + "name": "Output step interval", + "type": "integer", + "value": null, + "recommendedRange": null, + "kisaoId": { + "namespace": "KISAO", + "id": "KISAO_0000684" + }, + "availableSoftwareInterfaceTypes": ["desktop application", "command-line application"] + }, + { + "id": "max_sim_steps", + "name": "Maximum simulation steps", + "type": "integer", + "value": null, + "recommendedRange": null, + "kisaoId": { + "namespace": "KISAO", + "id": "KISAO_0000415" + }, + "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"] + }, { "id": "stop_if", "name": "Stop condition", @@ -415,21 +465,26 @@ "namespace": "SIO", "id": "SIO_000418" }], - "outputVariablePatterns": [ - { + "outputVariablePatterns": [{ "name": "time", "symbol": { - "value": "time", - "namespace": "urn:sedml:symbol" - } + "value": "time", + "namespace": "urn:sedml:symbol" + } }, { "name": "species counts", - "target": {"value": "species..count", "grammar": "BNGL"} + "target": { + "value": "species..count", + "grammar": "BNGL" + } }, { "name": "molecule counts", - "target": {"value": "molecules..count", "grammar": "BNGL"} + "target": { + "value": "molecules..count", + "grammar": "BNGL" + } } ], "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"], @@ -454,8 +509,7 @@ "version": null, "supportedFeatures": [] }], - "modelChangePatterns": [ - { + "modelChangePatterns": [{ "name": "Change compartments sizes", "types": ["SedAttributeModelChange", "SedComputeAttributeChangeModelChange", "SedSetValueAttributeModelChange"], "target": { @@ -486,7 +540,7 @@ "value": "functions.{ name e.g., `h` or name and arguments e.g., `h(...)` }.expression", "grammar": "BNGL" } - } + } ], "simulationFormats": [{ "namespace": "EDAM", @@ -527,6 +581,30 @@ }, "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"] }, + { + "id": "output_step_interval", + "name": "Output step interval", + "type": "integer", + "value": null, + "recommendedRange": null, + "kisaoId": { + "namespace": "KISAO", + "id": "KISAO_0000684" + }, + "availableSoftwareInterfaceTypes": ["desktop application", "command-line application"] + }, + { + "id": "max_sim_steps", + "name": "Maximum simulation steps", + "type": "integer", + "value": null, + "recommendedRange": null, + "kisaoId": { + "namespace": "KISAO", + "id": "KISAO_0000415" + }, + "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"] + }, { "id": "stop_if", "name": "Stop condition", @@ -544,21 +622,26 @@ "namespace": "SIO", "id": "SIO_000418" }], - "outputVariablePatterns": [ - { + "outputVariablePatterns": [{ "name": "time", "symbol": { - "value": "time", - "namespace": "urn:sedml:symbol" - } + "value": "time", + "namespace": "urn:sedml:symbol" + } }, { "name": "species counts", - "target": {"value": "species..count", "grammar": "BNGL"} + "target": { + "value": "species..count", + "grammar": "BNGL" + } }, { "name": "molecule counts", - "target": {"value": "molecules..count", "grammar": "BNGL"} + "target": { + "value": "molecules..count", + "grammar": "BNGL" + } } ], "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"], @@ -582,8 +665,7 @@ "version": null, "supportedFeatures": [] }], - "modelChangePatterns": [ - { + "modelChangePatterns": [{ "name": "Change compartments sizes", "types": ["SedAttributeModelChange", "SedComputeAttributeChangeModelChange", "SedSetValueAttributeModelChange"], "target": { @@ -655,6 +737,30 @@ }, "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"] }, + { + "id": "output_step_interval", + "name": "Output step interval", + "type": "integer", + "value": null, + "recommendedRange": null, + "kisaoId": { + "namespace": "KISAO", + "id": "KISAO_0000684" + }, + "availableSoftwareInterfaceTypes": ["desktop application", "command-line application"] + }, + { + "id": "max_sim_steps", + "name": "Maximum simulation steps", + "type": "integer", + "value": null, + "recommendedRange": null, + "kisaoId": { + "namespace": "KISAO", + "id": "KISAO_0000415" + }, + "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"] + }, { "id": "stop_if", "name": "Stop condition", @@ -672,21 +778,26 @@ "namespace": "SIO", "id": "SIO_000418" }], - "outputVariablePatterns": [ - { + "outputVariablePatterns": [{ "name": "time", "symbol": { - "value": "time", - "namespace": "urn:sedml:symbol" - } + "value": "time", + "namespace": "urn:sedml:symbol" + } }, { "name": "species counts", - "target": {"value": "species..count", "grammar": "BNGL"} + "target": { + "value": "species..count", + "grammar": "BNGL" + } }, { "name": "molecule counts", - "target": {"value": "molecules..count", "grammar": "BNGL"} + "target": { + "value": "molecules..count", + "grammar": "BNGL" + } } ], "availableSoftwareInterfaceTypes": ["desktop application", "command-line application", "BioSimulators Docker image"], diff --git a/biosimulators_bionetgen/data_model.py b/biosimulators_bionetgen/data_model.py index b6ed5c6..5d695da 100644 --- a/biosimulators_bionetgen/data_model.py +++ b/biosimulators_bionetgen/data_model.py @@ -135,6 +135,11 @@ def is_equal(self, other): 'name': 'relative tolerance', 'type': ValueType.float, }, + 'KISAO_0000415': { + 'id': 'max_sim_steps', + 'name': 'Maximum simulation steps', + 'type': ValueType.integer, + }, 'KISAO_0000525': { 'id': 'stop_if', 'name': 'stop condition', @@ -152,6 +157,11 @@ def is_equal(self, other): 'name': 'random number generator seed', 'type': ValueType.integer, }, + 'KISAO_0000415': { + 'id': 'max_sim_steps', + 'name': 'Maximum simulation steps', + 'type': ValueType.integer, + }, 'KISAO_0000525': { 'id': 'stop_if', 'name': 'stop condition', @@ -169,6 +179,11 @@ def is_equal(self, other): 'name': 'random number generator seed', 'type': ValueType.integer, }, + 'KISAO_0000415': { + 'id': 'max_sim_steps', + 'name': 'Maximum simulation steps', + 'type': ValueType.integer, + }, 'KISAO_0000525': { 'id': 'stop_if', 'name': 'stop condition', @@ -186,6 +201,11 @@ def is_equal(self, other): 'name': 'random number generator seed', 'type': ValueType.integer, }, + 'KISAO_0000415': { + 'id': 'max_sim_steps', + 'name': 'Maximum simulation steps', + 'type': ValueType.integer, + }, 'KISAO_0000525': { 'id': 'stop_if', 'name': 'stop condition', diff --git a/requirements.txt b/requirements.txt index 128e5a2..cd87413 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -biosimulators_utils[bngl,logging] >= 0.1.118 -kisao +biosimulators_utils[bngl,logging] >= 0.1.124 +kisao >= 2.29 pandas diff --git a/tests/test_core_main.py b/tests/test_core_main.py index 8a622ca..ceac293 100644 --- a/tests/test_core_main.py +++ b/tests/test_core_main.py @@ -108,6 +108,32 @@ def test_exec_sed_task_negative_initial_time(self): numpy.testing.assert_allclose(variable_results['var_time'], numpy.linspace(sim.output_start_time, sim.output_end_time, sim.number_of_points + 1)) + def test_exec_sed_task_output_step_interval(self): + doc = self._build_sed_doc() + doc.models[0].source = os.path.join(os.path.dirname(__file__), 'fixtures', 'test.bngl') + sim = doc.simulations[0] + sim.initial_time = 0. + sim.output_start_time = 0. + sim.output_end_time = 0.1 + sim.number_of_points = 10 + sim.algorithm.changes.append( + sedml_data_model.AlgorithmParameterChange(kisao_id='KISAO_0000684', new_value='2'), + ) + sim.algorithm.changes.append( + sedml_data_model.AlgorithmParameterChange(kisao_id='KISAO_0000415', new_value='1000000'), + ) + + variables = [data_gen.variables[0] for data_gen in doc.data_generators] + with mock.patch.dict('os.environ', {'ALGORITHM_SUBSTITUTION_POLICY': 'NONE'}): + with self.assertRaises(NotImplementedError): + exec_sed_task(doc.tasks[0], variables) + + with mock.patch.dict('os.environ', {'ALGORITHM_SUBSTITUTION_POLICY': 'SIMILAR_VARIABLES'}): + results, _ = exec_sed_task(doc.tasks[0], variables) + + numpy.testing.assert_allclose(results['var_time'], + numpy.linspace(sim.output_start_time, sim.output_end_time, sim.number_of_points + 1)) + def test_exec_sedml_docs_in_combine_archive(self): doc, archive_filename = self._build_combine_archive() diff --git a/tests/test_data_model.py b/tests/test_data_model.py index 9e3ac2c..c5595b8 100644 --- a/tests/test_data_model.py +++ b/tests/test_data_model.py @@ -123,9 +123,14 @@ def test_data_model_matches_specifications(self): for alg_specs in specs['algorithms']: alg_props = KISAO_SIMULATION_METHOD_ARGUMENTS_MAP[alg_specs['kisaoId']['id']] - self.assertEqual(set(alg_props['parameters'].keys()), set(param_specs['kisaoId']['id'] for param_specs in alg_specs['parameters'])) + self.assertEqual(set(alg_props['parameters'].keys()), + set(param_specs['kisaoId']['id'] + for param_specs in alg_specs['parameters'] + if "BioSimulators Docker image" in param_specs['availableSoftwareInterfaceTypes'] + )) for param_specs in alg_specs['parameters']: - param_props = alg_props['parameters'][param_specs['kisaoId']['id']] + if "BioSimulators Docker image" in param_specs['availableSoftwareInterfaceTypes']: + param_props = alg_props['parameters'][param_specs['kisaoId']['id']] - self.assertEqual(param_props['type'], param_specs['type']) + self.assertEqual(param_props['type'], param_specs['type'])