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: 2 additions & 2 deletions .github/workflows/test-force-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
run: |
cp -r . ${{ env.PROJECT_DIR }}
cd ${{ env.PROJECT_DIR }}
# Yes to cell_based component and Python bindings, defaults otherwise, yes to confirm
printf '\ny\ny\n\n\ny\ny\n' | python3 setup_project.py
# Yes to cell_based component and Python bindings, no to SBML, defaults otherwise, yes to confirm
printf '\ny\n\n\n\ny\nn\ny\n' | python3 setup_project.py

- name: Add MyForce to the project bindings
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
run: |
cp -r . ${{ env.PROJECT_DIR }}
cd ${{ env.PROJECT_DIR }}
# Use prompt defaults, yes to final confirmation
printf '\n\n\n\n\nn\ny\n' | python3 setup_project.py
# Prompt defaults (no components, no Python bindings, no SBML), yes to confirm
printf '\n\n\n\n\nn\nn\ny\n' | python3 setup_project.py

- name: Configure
run: ${{ env.PROJECT_DIR }}/scripts/configure.sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-python-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
run: |
cp -r . ${{ env.PROJECT_DIR }}
cd ${{ env.PROJECT_DIR }}
# Yes to python bindings prompt and final confirmation prompt
printf '\n\n\n\n\ny\ny\n' | python3 setup_project.py
# Yes to Python bindings, no to SBML, yes to final confirmation
printf '\n\n\n\n\ny\nn\ny\n' | python3 setup_project.py

- name: Configure
run: |
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/test-sbml-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Test SBML Project

on:
push:
branches: ["main"]
pull_request:
branches: ["**"]

concurrency:
group: test-sbml-project-${{ github.ref }}
cancel-in-progress: true

jobs:
test-sbml-project:
runs-on: ubuntu-latest

container:
image: chaste/base
options: --user root

env:
CHASTE_BUILD_DIR: /tmp/build
CHASTE_TEST_OUTPUT: /tmp/testoutput
PROJECT_DIR: /tmp/myproject

steps:
- name: Checkout template
uses: actions/checkout@v7

- name: Checkout Chaste source
run: |
git clone --depth 1 --branch develop https://github.com/Chaste/Chaste.git "${CHASTE_SOURCE_DIR}"
git config --global --add safe.directory "${CHASTE_SOURCE_DIR}"

- name: Install clang-format and curl
run: apt-get update && apt-get install -y clang-format curl

- name: Create test project
run: |
cp -r . ${{ env.PROJECT_DIR }}
cd ${{ env.PROJECT_DIR }}
# Prompt defaults for proceed/components/no-python-bindings, yes to SBML, yes to confirm
printf '\n\n\n\n\n\ny\ny\n' | python3 setup_project.py

- name: Install SBML code generator
run: ${{ env.PROJECT_DIR }}/scripts/sbml_install.sh

- name: Import the Goldbeter 1991 model
run: |
cd ${{ env.PROJECT_DIR }}
# Use the vendored model (examples/goldbeter_1991/Goldbeter1991.xml) so the
# job does not depend on reaching BioModels at run time.
cp examples/goldbeter_1991/Goldbeter1991.xml .
.virtualenv/bin/chaste_codegen_sbml Goldbeter1991.xml --model-type srn --output-dir src/
cp examples/goldbeter_1991/TestGoldbeter1991SbmlSrnModel.hpp test/
echo "TestGoldbeter1991SbmlSrnModel.hpp" >> test/ContinuousTestPack.txt

- name: Configure
run: ${{ env.PROJECT_DIR }}/scripts/configure.sh

- name: Compile
run: ${{ env.PROJECT_DIR }}/scripts/compile.sh

- name: Test
run: ${{ env.PROJECT_DIR }}/scripts/test.sh
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,70 @@ Then see the [User Projects](https://chaste.github.io/docs/user-guides/user-proj

If you clone this repository, you should make sure to rename the template_project folder with your project name and run the 'setup_project.py' script to avoid conflicts if you have multiple projects.

## SBML models

This template can turn an [SBML](https://sbml.org/) model into a Chaste model using
[chaste-codegen-sbml](https://github.com/Chaste/chaste-codegen-sbml). For a complete,
worked example see [examples/goldbeter_1991/README.md](examples/goldbeter_1991/README.md).

### 1. Enable SBML support

When you run `setup_project.py`, answer **yes** to:

```
Do you want to create an SBML user project?
```

### 2. Activate the virtualenv

```sh
source .virtualenv/bin/activate
```

(If you ever need to (re)install the generator by hand, run `scripts/sbml_install.sh`.)

### 3. Convert an SBML model into a Chaste model

```sh
chaste_codegen_sbml my_model.xml --model-type srn --output-dir src/
```

* `--model-type` is one of `generic`, `srn` (sub-cellular reaction network), or
`cell-cycle`.
* The generated class and file names are derived from the **input file name**, suffixed
with `Sbml`. For example `my_model.xml` produces `MyModelSbmlOdeSystem.{hpp,cpp}`, plus
`MyModelSbmlSrnModel.{hpp,cpp}` (for `srn`) or `MyModelSbmlCellCycleModel.{hpp,cpp}`
(for `cell-cycle`).

### 4. Write a test

Add a test under `test/` that `#include`s the generated model, then list it in
`test/ContinuousTestPack.txt`. See the walkthrough for a full example.

### 5. Build and run the test

From the project directory (with `CHASTE_SOURCE_DIR` pointing at your Chaste source):

```sh
scripts/configure.sh # register the project and configure the Chaste build
scripts/compile.sh # build the project
scripts/test.sh # run the project's tests
```

### The SBML base classes

These live in `src/` and are required by the generated code:

| File | Purpose |
| --- | --- |
| `AbstractSbmlOdeSystem.{hpp,cpp}` | Base ODE system for a generated SBML model. |
| `AbstractSbmlSrnModel.{hpp,cpp}` | Base sub-cellular reaction network (SRN) model. |
| `AbstractSbmlCellCycleModel.{hpp,cpp}` | Base cell-cycle model. |
| `SbmlEventType.hpp` | Enum of SBML event types (e.g. cell division). |
| `SbmlMath.{hpp,cpp}` | Math helper functions used by generated equations. |
| `fortests/SbmlTestHelpers.{hpp,cpp}` | Utility helpers for tests. |
| `fortests/SbmlTestOdeSolution.{hpp,cpp}` | `OdeSolution` recording per-step parameters, for tests. |

## Python bindings

This template can build [PyChaste](https://chaste.github.io/) Python bindings for your
Expand Down
Loading