In the following we will give a detailed overview how to specify models in Python and how to call the generated simulation files.
This document provides an overview of different interfaces to import models in AMICI. Further examples are available in the AMICI repository in the python/examples directory.
AMICI can import SBML
models via the :pyamici.sbml_import.SbmlImporter
class.
Python-AMICI currently passes 1030 out of the 1821 (~57%) test cases from the semantic SBML Test Suite (current status).
The following SBML test suite tags are currently supported (i.e., at least one test case with the respective test passes; tag descriptions):
Component tags:
- AssignmentRule
- Compartment
- CSymbolAvogadro
- CSymbolTime
- EventNoDelay
- FunctionDefinition
- InitialAssignment
- Parameter
- RateRule
- Reaction
- Species
Test tags:
- 0D-Compartment
- Amount
- AssignedConstantStoichiometry
- AssignedVariableStoichiometry
- BoolNumericSwap
- BoundaryCondition
- Concentration
- ConstantSpecies
- ConversionFactors
- DefaultValue
- EventT0Firing
- HasOnlySubstanceUnits
- InitialValueReassigned
- L3v2MathML
- LocalParameters
- MultiCompartment
- NoMathML
- NonConstantCompartment
- NonConstantParameter
- NonUnityCompartment
- NonUnityStoichiometry
- ReversibleReaction
- SpeciesReferenceInMath
- UncommonMathML
- VolumeConcentrationRates
In addition, we currently plan to add support for the following features (see corresponding issues for details and progress):
- Algebraic rules (#760)
However, the following features are unlikely to be supported:
- any SBML extensions
- factorial(), ceil(), floor(), due to incompatibility with symbolic sensitivity computations
- delay() due to missing
SUNDIALS
solver support - events with delays, events with non-persistent triggers
A basic tutorial on how to import and simulate SBML models is available in the Getting Started notebook, while a more detailed example including customized import and sensitivity computation is available in the Example Steadystate notebook.
AMICI can import PySB
models via :pyamici.pysb_import.pysb2amici
.
AMICI can import BNGL
models via :pyamici.bngl_import.bngl2amici
.
AMICI can import PEtab
-based model definitions and run simulations for the specified simulations conditions. For usage, see python/examples/example_petab/petab.ipynb.
The AMICI Python interface does not currently support direct import of ODEs. However, it is straightforward to encode them as RateRules in an SBML model. The yaml2sbml package may come in handy, as it facilitates generating SBML models from a YAML-based specification of an ODE model. Besides the SBML model it can also create PEtab files.
We also plan to implement support for the Simulation Experiment Description Markup Language (SED-ML).
GettingStarted.ipynb ExampleSteadystate.ipynb petab.ipynb ExampleExperimentalConditions.ipynb ExampleEquilibrationLogic.ipynb example_errors.ipynb
In addition to the environment variables listed here <amici_python_install_env_vars>
, the following environment variables control various behaviours during model import and compilation:
Variable | Purpose | Example |
---|---|---|
AMICI_EXTRACT_CSE |
Extract common subexpressions. May significantly reduce file size and compile time for large models, but makes the generated code less readable. Disabled by default. | AMICI_EXTRACT_CSE=1 |
AMICI_IMPORT_NPROCS |
Number of processes to be used for model import. Defaults to 1. Speeds up import of large models. Will slow down import of small models, benchmarking recommended. | AMICI_IMPORT_NPROCS=4 |
AMICI_EXPERIMENTAL_SBML_NONCONST_CLS |
Compute conservation laws for non-constant species. SBML-import only. See :pyamici.sbml_import.SbmlImporter.sbml2amici . |
AMICI can be built with OpenMP support, which allows to parallelize model simulations for multiple experimental conditions.
On Linux and OSX this is enabled by default. This can be verified using:
import amici
amici.compiledWithOpenMP()
If not already enabled by default, you can enable OpenMP support by setting the environment variables AMICI_CXXFLAGS
and AMICI_LDFLAGS
to the correct OpenMP flags of your compiler and linker, respectively. This has to be done for both AMICI package installation and model compilation. When using gcc
on Linux, this would be:
# on your shell:
AMICI_CXXFLAGS=-fopenmp AMICI_LDFLAGS=-fopenmp pip3 install amici
# in python, before model compilation:
import os
os.environ['AMICI_CXXFLAGS'] = '-fopenmp'
os.environ['AMICI_LDFLAGS'] = '-fopenmp'