Using generated code¶
The generated classes are ordinary Chaste C++, designed to live in a Chaste user project. This page shows a typical user project layout.
Project layout¶
A Chaste user project sits under projects/ in your Chaste source tree and has
a src/ directory for code and a test/ directory for tests:
Chaste/projects/MyProject/
├── CMakeLists.txt
├── src/
│ ├── AbstractSbmlOdeSystem.hpp/.cpp # copied base classes
│ ├── AbstractSbmlSrnModel.hpp/.cpp
│ ├── SbmlMath.hpp
│ ├── ...
│ ├── MyModelSbmlOdeSystem.hpp/.cpp # generated
│ └── MyModelSbmlSrnModel.hpp/.cpp # generated
└── test/
├── CMakeLists.txt
├── ContinuousTestPack.txt
└── TestMyModelSbml.hpp # generated placeholder test
CMakeLists.txt configures the user project:
find_package(Chaste COMPONENTS cell_based)
chaste_do_project(MyProject)
test/CMakeLists.txt configures the tests:
chaste_do_test_project(MyProject)
Project setup¶
Copy the base classes into your project’s src/:
chaste-sbml --copy-base-classes --output-dir Chaste/projects/MyProject/src
Note
Do this once per project, and again whenever you upgrade chaste-sbml. See
the base classes for what gets copied.
Generate the model into src/, and the placeholder test into test/
(--test-output-dir asks for the placeholder as well as placing it):
chaste-sbml my_model.xml \
--model-type srn \
--output-dir Chaste/projects/MyProject/src \
--test-output-dir Chaste/projects/MyProject/test
Chaste discovers tests through test packs, which are text files in test/
listing the test headers to build. Add the generated placeholder to one:
# test/ContinuousTestPack.txt
TestMyModelSbml.hpp
Configure and build from your Chaste build directory as usual:
cd Chaste/build
cmake ..
cmake --build . --target project_MyProject
Run the user-project tests:
ctest -R MyProject
Using the classes in a simulation¶
Once compiled, the generated classes are used like any other Chaste ODE system, SRN model, or cell-cycle model.
For a generic model, construct the ODE system and hand it to a Chaste ODE solver:
#include "MyModelSbmlOdeSystem.hpp"
MyModelSbmlOdeSystem ode_system;
// solve with any AbstractIvpOdeSolver, then read state / derived quantities
For an SRN model, attach it to a cell so it runs as that cell’s subcellular reaction network:
#include "MyModelSbmlSrnModel.hpp"
#include "UniformCellCycleModel.hpp"
MAKE_PTR(WildTypeCellMutationState, p_state);
MAKE_PTR(StemCellProliferativeType, p_type);
CellPtr p_cell(new Cell(p_state, new UniformCellCycleModel(), new MyModelSbmlSrnModel()));
p_cell->SetCellProliferativeType(p_type);
p_cell->InitialiseCellCycleModel();
p_cell->InitialiseSrnModel();
For a cell-cycle model, pass it as the cell’s cell-cycle model; division is driven by the SBML cell-division event:
#include "MyModelSbmlCellCycleModel.hpp"
CellPtr p_cell(new Cell(p_state, new MyModelSbmlCellCycleModel()));
p_cell->InitialiseCellCycleModel();
See also
Anatomy of generated code: what each class and method does.
The Goldbeter 1991 tutorial: an end-to-end SRN example.
The Chaste user-project documentation: for project setup details not specific to SBML.