From 6020cbd82050cf011f1c8b8017be189b28a85945 Mon Sep 17 00:00:00 2001 From: "Frank T. Bergmann" Date: Tue, 13 May 2025 13:36:53 +0200 Subject: [PATCH 1/2] - add basico to dependencies using explicit dependencies, since PEtab select seems incompatible with libroadRunner --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c3bd56c..cd02beb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,9 @@ dependencies = [ "python-libsbml", "matplotlib", "petab", - "qtawesome" + "qtawesome", + "copasi-basico", + "copasi-petab-importer" ] [build-system] From 2681becd14d68a1912f26526a1d736a9d3fb2ed3 Mon Sep 17 00:00:00 2001 From: "Frank T. Bergmann" Date: Tue, 13 May 2025 13:37:13 +0200 Subject: [PATCH 2/2] - add simulate action --- .../controllers/mother_controller.py | 34 +++++++++++++++++++ src/petab_gui/views/main_view.py | 1 + src/petab_gui/views/task_bar.py | 1 + 3 files changed, 36 insertions(+) diff --git a/src/petab_gui/controllers/mother_controller.py b/src/petab_gui/controllers/mother_controller.py index 75d8c39..96971e6 100644 --- a/src/petab_gui/controllers/mother_controller.py +++ b/src/petab_gui/controllers/mother_controller.py @@ -333,6 +333,12 @@ def setup_actions(self): # Recent Files actions["recent_files"] = self.recent_files_manager.tool_bar_menu + # simulate action + actions["simulate"] = QAction( + qta.icon("mdi6.play"), "Simulate", self.view + ) + actions["simulate"].triggered.connect(self.simulate) + # Filter widget filter_widget = QWidget() filter_layout = QHBoxLayout() @@ -919,3 +925,31 @@ def _on_simulation_selection_changed(self, selected, deselected): proxy=self.simulation_controller.proxy_model, y_axis_col="simulation" ) + + def simulate(self): + """Simulate the model.""" + # obtain petab problem + petab_problem = self.model.current_petab_problem + + # import petabsimualtor + from basico.petab import PetabSimulator + import basico + + # report current basico / COPASI version + self.logger.log_message(f"Simulate with basico: {basico.__version__}, COPASI: {basico.COPASI.__version__}", color="green") + + import tempfile + + # create temp directory in temp folder: + with tempfile.TemporaryDirectory() as temp_dir: + # settings is only current solution statistic for now: + settings = {'method' : {'name': basico.PE.CURRENT_SOLUTION}} + # create simulator + simulator = PetabSimulator(petab_problem, settings=settings, working_dir=temp_dir) + + # simulate + sim_df = simulator.simulate() + + # assign to simulation table + self.simulation_controller.overwrite_df(sim_df) + self.simulation_controller.model.reset_invalid_cells() diff --git a/src/petab_gui/views/main_view.py b/src/petab_gui/views/main_view.py index 8c5da4a..54206e1 100644 --- a/src/petab_gui/views/main_view.py +++ b/src/petab_gui/views/main_view.py @@ -180,6 +180,7 @@ def setup_toolbar(self, actions): tb.addAction(actions["delete_row"]) tb.addAction(actions["add_column"]) tb.addAction(actions["delete_column"]) + tb.addAction(actions["simulate"]) tb.addWidget(spacer) tb.addWidget(actions["filter_widget"]) diff --git a/src/petab_gui/views/task_bar.py b/src/petab_gui/views/task_bar.py index 8d910b8..1145ed5 100644 --- a/src/petab_gui/views/task_bar.py +++ b/src/petab_gui/views/task_bar.py @@ -91,6 +91,7 @@ def __init__(self, parent, actions): self.menu.addSeparator() # Reset Model self.menu.addAction(actions["reset_model"]) + self.menu.addAction(actions["simulate"]) self.menu.addSeparator() # Settings self.menu.addAction(actions["settings"])