From bde4b760fc2379ada34724bc52fcd570782b2871 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 3 Aug 2023 13:18:01 -0700 Subject: [PATCH 1/4] Fix situation when the output start time is different from the initial time. Do this with presimulation: simulate up to output start time, then simulate again. This fixes runs of biomodels that use the technique, but don't have an evenly-divisible presimulation time. --- biosimulators_tellurium/core.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/biosimulators_tellurium/core.py b/biosimulators_tellurium/core.py index 277156f..b283476 100644 --- a/biosimulators_tellurium/core.py +++ b/biosimulators_tellurium/core.py @@ -263,20 +263,14 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None # simulate if isinstance(sim, UniformTimeCourseSimulation): - number_of_points = (sim.output_end_time - sim.initial_time) / \ - (sim.output_end_time - sim.output_start_time) * sim.number_of_steps + 1 - if abs(number_of_points % 1) > 1e-8: - msg = ( - 'The number of simulation points `{}` must be an integer:' - '\n Initial time: {}' - '\n Output start time: {}' - '\n Output end time: {}' - '\n Number of points: {}' - ).format(number_of_points, sim.initial_time, sim.output_start_time, sim.output_start_time, sim.number_of_points) - raise NotImplementedError(msg) - - number_of_points = round(number_of_points) - results = numpy.array(road_runner.simulate(sim.initial_time, sim.output_end_time, number_of_points).tolist()).transpose() + if sim.initial_time < sim.output_start_time: + number_of_presim_points = (sim.output_end_time - sim.initial_time) / \ + (sim.output_end_time - sim.output_start_time) * sim.number_of_steps + 1 + + number_of_presim_points = round(number_of_presim_points) - sim.number_of_steps + road_runner.simulate(sim.initial_time, sim.output_start_time, number_of_presim_points) + + results = numpy.array(road_runner.simulate(sim.output_start_time, sim.output_end_time, sim.number_of_points).tolist()).transpose() else: road_runner.steadyState() results = road_runner.getSteadyStateValues() From 356c9531b2ad3721ed4f75320110b7f91cbb1ca3 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 3 Aug 2023 13:20:27 -0700 Subject: [PATCH 2/4] Lint fix. --- biosimulators_tellurium/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biosimulators_tellurium/core.py b/biosimulators_tellurium/core.py index b283476..00813c7 100644 --- a/biosimulators_tellurium/core.py +++ b/biosimulators_tellurium/core.py @@ -266,7 +266,7 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None if sim.initial_time < sim.output_start_time: number_of_presim_points = (sim.output_end_time - sim.initial_time) / \ (sim.output_end_time - sim.output_start_time) * sim.number_of_steps + 1 - + number_of_presim_points = round(number_of_presim_points) - sim.number_of_steps road_runner.simulate(sim.initial_time, sim.output_start_time, number_of_presim_points) From e6bdc41099990b1c7fd6b212507d22b96028efad Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 3 Aug 2023 13:39:33 -0700 Subject: [PATCH 3/4] Fix test, actual number of points. --- biosimulators_tellurium/core.py | 2 +- tests/test_core_main.py | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/biosimulators_tellurium/core.py b/biosimulators_tellurium/core.py index 00813c7..fa39e54 100644 --- a/biosimulators_tellurium/core.py +++ b/biosimulators_tellurium/core.py @@ -270,7 +270,7 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None number_of_presim_points = round(number_of_presim_points) - sim.number_of_steps road_runner.simulate(sim.initial_time, sim.output_start_time, number_of_presim_points) - results = numpy.array(road_runner.simulate(sim.output_start_time, sim.output_end_time, sim.number_of_points).tolist()).transpose() + results = numpy.array(road_runner.simulate(sim.output_start_time, sim.output_end_time, sim.number_of_steps+1).tolist()).transpose() else: road_runner.steadyState() results = road_runner.getSteadyStateValues() diff --git a/tests/test_core_main.py b/tests/test_core_main.py index 34d6177..77c7cd9 100644 --- a/tests/test_core_main.py +++ b/tests/test_core_main.py @@ -436,12 +436,6 @@ def test_exec_sed_task_error_handling_with_biosimulators(self): with self.assertRaisesRegex(ValueError, 'targets are not supported'): variable_results, log = core.exec_sed_task(task, variables_2, simulator_config=simulator_config) - task_2 = copy.deepcopy(task) - task_2.simulation.output_start_time = 1.5 - simulator_config.sedml_interpreter = SedmlInterpreter.biosimulators - with self.assertRaises(NotImplementedError): - variable_results, log = core.exec_sed_task(task_2, variables, simulator_config=simulator_config) - def test_exec_sed_task_with_preprocesssed_task(self): # configure simulation task = sedml_data_model.Task( From 036e5168046cbe8a9191a74a1f0d31aa9029cef9 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 3 Aug 2023 13:44:21 -0700 Subject: [PATCH 4/4] Update version number. --- biosimulators_tellurium/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biosimulators_tellurium/_version.py b/biosimulators_tellurium/_version.py index da9d669..88395d2 100644 --- a/biosimulators_tellurium/_version.py +++ b/biosimulators_tellurium/_version.py @@ -1 +1 @@ -__version__ = '0.1.37' +__version__ = '0.1.38'