*Note: this is the stoichBondGraph.ipynb notebook. The PDF version "The stoichBondGraph module: From Stoichiometry to Bond Graph" is available here.*
The bond graph approach to modelling biomolecular systems of interest to systems biologists developed independently from the stoichiometric approach .
However, the conceptual point of intersection of the two approaches is the fact that the stoichiometric matrix is the modulus of the conceptual multiport transformer linking reactions to species. This means that the two approaches are complementary and each can build on the strengths of the other.
This tutorial illustrates how a stoichiometric system description can be used to automatically create the corresponding bond graph. However, more compex systems such as the ecoli core model can also be translated in the same way.
The bond graph analysis uses a number of Python modules:
## Some useful imports
import BondGraphTools as bgt
import numpy as np
## Stoichiometry to BG
import stoichBondGraph as stbg
In this context a stoichimetric representation is a python dictionary with the following fields
Optionally, the forward and reverse stoichometric matrices Nf and Nr can be included instead of N
Note that there is one species per row, and one reaction per column, of N
A file name.py is written containing the function model() which returns the bg in bgt form
This example corresponds to ABCD_abg.svg in Tutorial svgBondGraph.
## Stoichiometric matrix N
N = np.array(
[
[-1, 0, 0, 0],
[ 0,-1, 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 1],
[-1, 0, 0, 1],
[ 1,-1, 0, 0],
[ 0, 1,-1, 0],
[ 0, 0, 1,-1]
]
)
## Species and reactions
species = ['A', 'B', 'C', 'D', 'E1', 'E2', 'E3', 'E4']
reaction = ['r1', 'r2', 'r3', 'r4']
## Pack into a dict with name 'ABCDE_abg'
s = {
'name':'BG_abg',
'N':N,
'species':species,
'reaction':reaction
}
## Convert to a bondgraph
stbg.model(s)
## And import
import BG_abg
## Draw the BG
bgt.draw(BG_abg.model())