Skip to content

Commit 0865657

Browse files
authored
Merge pull request #94
* - add basico to dependencies * - add simulate action * Merge branch 'develop' into basico-simulate-button
1 parent 5602674 commit 0865657

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ dependencies = [
2525
"python-libsbml",
2626
"matplotlib",
2727
"petab",
28-
"qtawesome"
28+
"qtawesome",
29+
"copasi-basico",
30+
"copasi-petab-importer"
2931
]
3032

3133
[build-system]

src/petab_gui/controllers/mother_controller.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ def setup_actions(self):
339339
# Recent Files
340340
actions["recent_files"] = self.recent_files_manager.tool_bar_menu
341341

342+
# simulate action
343+
actions["simulate"] = QAction(
344+
qta.icon("mdi6.play"), "Simulate", self.view
345+
)
346+
actions["simulate"].triggered.connect(self.simulate)
347+
342348
# Filter widget
343349
filter_widget = QWidget()
344350
filter_layout = QHBoxLayout()
@@ -930,6 +936,34 @@ def _on_simulation_selection_changed(self, selected, deselected):
930936
y_axis_col="simulation"
931937
)
932938

939+
def simulate(self):
940+
"""Simulate the model."""
941+
# obtain petab problem
942+
petab_problem = self.model.current_petab_problem
943+
944+
# import petabsimualtor
945+
from basico.petab import PetabSimulator
946+
import basico
947+
948+
# report current basico / COPASI version
949+
self.logger.log_message(f"Simulate with basico: {basico.__version__}, COPASI: {basico.COPASI.__version__}", color="green")
950+
951+
import tempfile
952+
953+
# create temp directory in temp folder:
954+
with tempfile.TemporaryDirectory() as temp_dir:
955+
# settings is only current solution statistic for now:
956+
settings = {'method' : {'name': basico.PE.CURRENT_SOLUTION}}
957+
# create simulator
958+
simulator = PetabSimulator(petab_problem, settings=settings, working_dir=temp_dir)
959+
960+
# simulate
961+
sim_df = simulator.simulate()
962+
963+
# assign to simulation table
964+
self.simulation_controller.overwrite_df(sim_df)
965+
self.simulation_controller.model.reset_invalid_cells()
966+
933967
def _schedule_plot_update(self):
934968
"""Start the plot schedule timer."""
935969
self._plot_update_timer.start()

src/petab_gui/views/main_view.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def setup_toolbar(self, actions):
180180
tb.addAction(actions["delete_row"])
181181
tb.addAction(actions["add_column"])
182182
tb.addAction(actions["delete_column"])
183+
tb.addAction(actions["simulate"])
183184
tb.addWidget(spacer)
184185
tb.addWidget(actions["filter_widget"])
185186

src/petab_gui/views/task_bar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def __init__(self, parent, actions):
9191
self.menu.addSeparator()
9292
# Reset Model
9393
self.menu.addAction(actions["reset_model"])
94+
self.menu.addAction(actions["simulate"])
9495
self.menu.addSeparator()
9596
# Settings
9697
self.menu.addAction(actions["settings"])

0 commit comments

Comments
 (0)