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
8 changes: 5 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include example/*.csv
include example/*.tsv
include example/*.xml
include example/*/*.csv
include example/*/*.tsv
include example/*/*.xml
include example/*/*.yaml
include example/*/*.yml
exclude .git_archival.txt
exclude .gitattributes
4 changes: 0 additions & 4 deletions example/data_matrix.csv

This file was deleted.

11 changes: 11 additions & 0 deletions example/simple_conversion_measurements.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
time obs_A obs_B
0 10.1 0.1
2 8.0 2.1
4 6.8 3.4
6 5.6 4.6
8 4.4 5.4
10 3.8 6.4
12 3.1 7.2
15 2.3 7.9
18 1.6 8.2
20 1.3 8.5
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ include-package-data = true

[tool.setuptools.package-data]
"petab_gui.assets" = ["PEtab.png"]
"petab_gui.example" = ["*/*.yaml", "*/*.yml", "*/*.tsv", "*/*.csv", "*/*.xml", "*/*.sbml"]

[tool.setuptools_scm]

Expand Down
75 changes: 75 additions & 0 deletions src/petab_gui/controllers/mother_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,23 @@ def setup_actions(self):
actions["add"].triggered.connect(
partial(self.open_file, mode="append")
)
# Load Examples
actions["load_example_boehm"] = QAction(
qta.icon("mdi6.book-open-page-variant"),
"Load Example: Boehm",
self.view,
)
actions["load_example_boehm"].triggered.connect(
partial(self.load_example, "Boehm")
)
actions["load_example_simple"] = QAction(
qta.icon("mdi6.book-open-page-variant"),
"Load Example: Simple Conversion",
self.view,
)
actions["load_example_simple"].triggered.connect(
partial(self.load_example, "Simple_Conversion")
)
# Save
actions["save"] = QAction(
qta.icon("mdi6.content-save-all"), "&Save As...", self.view
Expand Down Expand Up @@ -1072,6 +1089,64 @@ def new_file(self):
self.view.plot_dock.plot_it()
self.unsaved_changes_change(False)

def load_example(self, example_name):
"""Load an internal example PEtab problem.

Parameters
----------
example_name : str
Name of the example subdirectory (e.g., "Boehm", "Simple_Conversion").

Finds and loads the example dataset from the package directory.
No internet connection required - the example is bundled with the package.
"""
try:
# Use importlib.resources to access packaged example files
from importlib.resources import as_file, files

example_files = files("petab_gui.example")

# Check if the example package exists
if not example_files.is_dir():
error_msg = (
"Could not find the example dataset. "
"The example folder may not be properly installed."
)
self.logger.log_message(error_msg, color="red")
QMessageBox.warning(self.view, "Example Not Found", error_msg)
return

# Get the problem.yaml file path for the specified example
yaml_file = example_files.joinpath(example_name, "problem.yaml")

with as_file(yaml_file) as yaml_path:
if not yaml_path.exists():
error_msg = f"Example '{example_name}' not found or problem.yaml file is missing."
self.logger.log_message(error_msg, color="red")
QMessageBox.warning(
self.view, "Example Invalid", error_msg
)
return

# Load the example
self.logger.log_message(
f"Loading '{example_name}' example dataset...",
color="blue",
)
self.open_yaml_and_load_files(str(yaml_path))

except ModuleNotFoundError as e:
error_msg = (
"Example dataset not found. It may not be installed properly. "
f"Error: {str(e)}"
)
self.logger.log_message(error_msg, color="red")
QMessageBox.warning(self.view, "Example Not Found", error_msg)
except Exception as e:
error_msg = f"Failed to load example: {str(e)}"
self.logger.log_message(error_msg, color="red")
QMessageBox.critical(self.view, "Error Loading Example", error_msg)

def check_model(self):
"""Check the consistency of the model. And log the results."""
capture_handler = CaptureLogHandler()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/petab_gui/example/Simple_Conversion/conditions.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
conditionId conditionName
cond_1
21 changes: 21 additions & 0 deletions src/petab_gui/example/Simple_Conversion/measurements.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
observableId simulationConditionId time measurement
obs_A cond_1 0.0 10.1
obs_A cond_1 2.0 8.0
obs_A cond_1 4.0 6.8
obs_A cond_1 6.0 5.6
obs_A cond_1 8.0 4.4
obs_A cond_1 10.0 3.8
obs_A cond_1 12.0 3.1
obs_A cond_1 15.0 2.3
obs_A cond_1 18.0 1.6
obs_A cond_1 20.0 1.3
obs_B cond_1 0.0 0.1
obs_B cond_1 2.0 2.1
obs_B cond_1 4.0 3.4
obs_B cond_1 6.0 4.6
obs_B cond_1 8.0 5.4
obs_B cond_1 10.0 6.4
obs_B cond_1 12.0 7.2
obs_B cond_1 15.0 7.9
obs_B cond_1 18.0 8.2
obs_B cond_1 20.0 8.5
34 changes: 34 additions & 0 deletions src/petab_gui/example/Simple_Conversion/model.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model metaid="SimpleConversion" id="SimpleConversion">
<listOfCompartments>
<compartment sboTerm="SBO:0000410" id="default_compartment" spatialDimensions="3" size="1" constant="true"/>
</listOfCompartments>
<listOfSpecies>
<species id="A" compartment="default_compartment" initialConcentration="10" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
<species id="B" compartment="default_compartment" initialConcentration="0" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
</listOfSpecies>
<listOfParameters>
<parameter id="k_conversion" value="0.1" constant="true"/>
</listOfParameters>
<listOfReactions>
<reaction id="conversion" reversible="true">
<listOfReactants>
<speciesReference species="A" stoichiometry="1" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="B" stoichiometry="1" constant="true"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> k_conversion </ci>
<ci> A </ci>
</apply>
</math>
</kineticLaw>
</reaction>
</listOfReactions>
</model>
</sbml>
3 changes: 3 additions & 0 deletions src/petab_gui/example/Simple_Conversion/observables.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
observableId observableFormula noiseFormula
obs_A A 0.5
obs_B B 0.5
2 changes: 2 additions & 0 deletions src/petab_gui/example/Simple_Conversion/parameters.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameterId parameterScale lowerBound upperBound nominalValue estimate
k_conversion log10 0.001 100.0 0.1 1
11 changes: 11 additions & 0 deletions src/petab_gui/example/Simple_Conversion/problem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameter_file: parameters.tsv
format_version: 1
problems:
- condition_files:
- conditions.tsv
measurement_files:
- measurements.tsv
sbml_files:
- model.xml
observable_files:
- observables.tsv
5 changes: 5 additions & 0 deletions src/petab_gui/example/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Example PEtab dataset bundled with PEtab GUI.

This package contains an example PEtab problem that can be loaded
without an internet connection.
"""
2 changes: 2 additions & 0 deletions src/petab_gui/views/task_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def __init__(self, parent, actions):
self.menu.addAction(actions["new"])
self.menu.addAction(actions["open"])
self.menu.addAction(actions["add"])
self.menu.addAction(actions["load_example_boehm"])
self.menu.addAction(actions["load_example_simple"])
self.menu.addAction(actions["save"])
self.menu.addMenu(actions["recent_files"])
self.menu.addSeparator()
Expand Down