Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ dependencies = [
"python-libsbml",
"matplotlib",
"petab",
"qtawesome"
"qtawesome",
"copasi-basico",
"copasi-petab-importer"
]

[build-system]
Expand Down
34 changes: 34 additions & 0 deletions src/petab_gui/controllers/mother_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,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()
Expand Down Expand Up @@ -930,6 +936,34 @@ def _on_simulation_selection_changed(self, selected, deselected):
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()

def _schedule_plot_update(self):
"""Start the plot schedule timer."""
self._plot_update_timer.start()
1 change: 1 addition & 0 deletions src/petab_gui/views/main_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
1 change: 1 addition & 0 deletions src/petab_gui/views/task_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down