Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
be57ad5
Change default parameter handling
Oct 24, 2022
9d952fc
Remove unnecessary line from test
Oct 24, 2022
2297bf9
Add first 4 models. Add tests to generate .mmt and graph files
Oct 24, 2022
ae770ab
Add tests for connectedness as reversibility. Add models 4,5
Oct 25, 2022
0b6f9d8
Fix draw_graph handling of transition rates
Nov 1, 2022
d502827
Add more models
Nov 1, 2022
beacf8f
Fix get_transition_matrix. Fix reversibility check. Add show_html swi…
Apr 28, 2023
8904c6b
Merge branch 'master' into fix_transition_matrix
Apr 28, 2023
051a36f
Add models 11 and 30. Remove duplicated test file
May 3, 2023
a4b97e2
Merge branch 'fix_transition_matrix' of github.com:CardiacModelling/M…
May 3, 2023
5310b55
Lint and isort
May 3, 2023
57415dc
Update test_parameterise_rates
May 3, 2023
f199b6f
Add test_30_models.py
May 3, 2023
79f7295
Add myokit files for testing
May 3, 2023
7e21caf
Update pytest.yml
May 3, 2023
0afb97b
Update pytest.yml
May 3, 2023
bc4c4c9
Make single quote use more consistent
Jun 13, 2023
2d6c990
Fix indentation. Distribute trajectories according to number of traje…
Jun 13, 2023
17027f4
Fix sympy depreciation warning (latex output)
Jun 13, 2023
fe4f333
Add test for dataclass exception (must be subclass of state_attribute…
Jun 13, 2023
23835be
Merge branch 'fix_transition_matrix' of github.com:CardiacModelling/M…
Jun 13, 2023
b6ef7da
Raise TypeError not Exception
Jun 13, 2023
215898f
Remove old, broken test output
Jun 13, 2023
de33024
Fix test_bad_dataclass_exception
Jun 13, 2023
4d86220
Remove unnecessary checks on attribute dataclass
Jun 13, 2023
fef0edf
Lint
Jun 13, 2023
f1e03cb
Add models
Jun 13, 2023
f58dcc7
Add some models with HH-style gating
Jun 16, 2023
c2ccada
Sort imports
Jun 16, 2023
93b454f
Fix myokit model generation
Jun 16, 2023
663313a
Modify model3 to be disconnected model
Aug 2, 2023
351f199
Update tests for disceonnected model_03. Add auxiliary_variables dict…
Aug 2, 2023
fed5036
Change model parameterisation
Sep 5, 2023
846a079
Standardise model parameterisation
Sep 6, 2023
205efd3
Fix model generation
Nov 14, 2023
6ed6f62
Simplify Kemp model into two connected components
Dec 6, 2023
a1a2777
Replace depcreciated np.NaN with np.nan
Jun 25, 2024
a9916e4
NaN -> nan
Jul 8, 2024
f440e56
Add model 20
Mar 17, 2025
aa7b755
Add model20.py
Mar 17, 2025
ab8aed9
Parameterise Mazhari model. Fix parameter bug
Mar 18, 2025
b5e072c
Change order of state addition
Mar 18, 2025
c4843a3
Reorder parameters
Mar 18, 2025
2f43fa2
Strenghten test for "get_eliminate_state..." Move permutation code to…
Oct 6, 2025
909b14b
Remove print
Oct 6, 2025
bd92d1c
Fix doctstring
Oct 7, 2025
a3dbc80
Update build system
Nov 20, 2025
a1206b3
Fix whitespace
Nov 20, 2025
cb10d50
Update docstrings, .gitignore, and type hints
Nov 27, 2025
b37b182
Update init and use clearer param names. Update models
Nov 27, 2025
1fc213e
Update models and tests
Nov 27, 2025
d277853
Simplify exception for undefined parameters
Nov 27, 2025
2c29004
Change error type to align with code
Nov 27, 2025
c62b4bd
More docstring change. Variable name change
Nov 28, 2025
7ee29d3
Lint
Nov 28, 2025
09c802a
Add drug_bound field by default
Nov 28, 2025
84f6bf2
Update param names. Remove debug format string
Nov 28, 2025
b997979
Turn off E501 "line too long"
Nov 28, 2025
f3da65d
Lint
Nov 28, 2025
b39677f
Remove () from class defn
Nov 28, 2025
3f166b5
Fix unused var
Nov 28, 2025
4654c81
Modify project setup for isort
Nov 28, 2025
94ecad8
Merge branch 'master' into HEAD
Nov 28, 2025
035f681
Update workflow
Nov 28, 2025
f42b1df
Update isort conf
Nov 28, 2025
32c6d39
Update isort settings (again)
Nov 28, 2025
95dedd7
Change isort settings
Nov 28, 2025
afd9926
Update isort settings
Nov 28, 2025
fb54457
Remove unnecessary "get" function
Nov 28, 2025
d6f257c
Fix docstrings using ruff. Add ruff and sphinx to docs optional depen…
Dec 2, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install libsundials-dev -y
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Lint with flake8
Expand Down
184 changes: 126 additions & 58 deletions markov_builder/MarkovChain.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions markov_builder/example_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def construct_four_state_chain():
'k_3': positive_rate_expr + ((0.0873, 8.91E-3),),
'k_4': negative_rate_expr + ((5.15E-3, 0.003158),)}

mc.parameterise_rates(rate_dictionary, shared_variables=('V',))
mc.parameterise_rates(rate_dictionary)

open_state = mc.get_state_symbol('O')
auxiliary_expression = sp.sympify(f"g_Kr * {open_state} * (V - E_Kr)")
Expand Down Expand Up @@ -115,7 +115,7 @@ def construct_wang_chain():
'b_1': negative_rate_expr + ((0.006497, 0.03268),)
}

mc.parameterise_rates(rate_dictionary, shared_variables=('V',))
mc.parameterise_rates(rate_dictionary)

open_state = mc.get_state_symbol('O')

Expand Down Expand Up @@ -217,7 +217,7 @@ def construct_kemp_model():
'b_h': positive_rate_expr + ((2.70e-01, 1.58e-02),),
}

mc.parameterise_rates(rate_dictionary, shared_variables=('V',))
mc.parameterise_rates(rate_dictionary)

open_state = mc.get_state_symbol('O')

Expand Down
Empty file.
15 changes: 15 additions & 0 deletions markov_builder/models/thirty_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .model0 import model_00
from .model1 import model_01
from .model2 import model_02
from .model3 import model_03
from .model4 import model_04
from .model5 import model_05
from .model6 import model_06
from .model7 import model_07
from .model8 import model_08
from .model11 import model_11
from .model30 import model_30


__all__ = ['model_00', 'model_01', 'model_02', 'model_03', 'model_04',
'model_05', 'model_06', 'model_07', 'model_08', 'model_11', 'model_30']
37 changes: 37 additions & 0 deletions markov_builder/models/thirty_models/model0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import numpy as np

from markov_builder import MarkovChain
from markov_builder.rate_expressions import negative_rate_expr, positive_rate_expr


class model_00(MarkovChain):
description = ""
states = ('O', 'C', 'I', 'IC')
rates = [('O', 'C', 'k_2', 'k_1'),
('I', 'IC', 'k_2', 'k_1'),
('O', 'I', 'k_3', 'k_4'),
('C', 'IC', 'k_3', 'k_4')]

open_state = 'O'
shared_variables_dict = {'V': np.NaN}

rate_dictionary = {'k_1': positive_rate_expr + ((2.26E-4, 6.99E-2),),
'k_2': negative_rate_expr + ((3.45E-5, 5.460E-2),),
'k_3': positive_rate_expr + ((0.0873, 8.91E-3),),
'k_4': negative_rate_expr + ((5.15E-3, 0.03158),)}
auxiliary_expression = "g_Kr * {} * (V - E_Kr)"
auxiliary_symbol = 'I_Kr'

auxiliary_params_dict = {'g_Kr': 0.1524,
'E_Kr': -88
}

def __init__(self):
super().__init__(states=self.states,
open_state=self.open_state,
rates=self.rates,
rate_dictionary=self.rate_dictionary,
auxiliary_expression=self.auxiliary_expression,
auxiliary_symbol=self.auxiliary_symbol,
shared_variables_dict=self.shared_variables_dict,
auxiliary_params_dict=self.auxiliary_params_dict)
32 changes: 32 additions & 0 deletions markov_builder/models/thirty_models/model1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from numpy import NaN

from markov_builder.MarkovChain import MarkovChain
from markov_builder.rate_expressions import negative_rate_expr, positive_rate_expr


class model_01(MarkovChain):
description = ""
states = ('O', 'C')
rates = [('O', 'C', 'k_21', 'k_12')]

open_state = 'O'
shared_variables_dict = {'V': NaN}
rate_dictionary = {'k_12': positive_rate_expr + ((2.26E-4, 6.99E-2),),
'k_21': negative_rate_expr + ((3.45e-5, 0.05462),)}

auxiliary_expression = "g_Kr * {} * (V - E_Kr)"
auxiliary_symbol = 'I_Kr'

auxiliary_params_dict = {'g_Kr': 0.1524,
'E_Kr': -88
}

def __init__(self):
super().__init__(states=self.states,
open_state=self.open_state,
rates=self.rates,
rate_dictionary=self.rate_dictionary,
auxiliary_expression=self.auxiliary_expression,
auxiliary_symbol=self.auxiliary_symbol,
shared_variables_dict=self.shared_variables_dict,
auxiliary_params_dict=self.auxiliary_params_dict)
66 changes: 66 additions & 0 deletions markov_builder/models/thirty_models/model11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from numpy import NaN

from markov_builder.MarkovChain import MarkovChain


class model_11(MarkovChain):
description = ""
states = ('O', 'I', 'IC1', 'IC2', 'C2', 'C1')
rates = [
('O', 'I', 'ah', 'bh'),
('C1', 'O', 'a1', 'b1'),
('IC1', 'I', 'a3', 'b3'),
('IC2', 'IC1', 'a4', 'b4'),
('C2', 'C1', 'a2', 'b2'),
('C2', 'IC2', 'ah', 'bh'),
('C1', 'IC1', 'ah', 'bh')
]

open_state = 'O'
shared_variables_dict = {'V': NaN,
'p1': 2.26e-4,
'p2': 0.06990,
'p3': 3.45e-5,
'p4': 0.05462,
'p5': 0.08730,
'p6': 8.91e-3,
'p7': 5.15e-3,
'p8': 0.03158,
'p9': 2.26e-4,
'p10': 0.06990,
'p11': 3.45e-5,
'p12': 0.05462,
'p13': 0.08730,
'p14': 8.91e-3,
'p15': 5.15e-3,
'p16': 0.03158,
'p17': 0.15240
}

rate_dictionary = {
'a1': ('p1 * exp( p2 * V)',),
'b1': ('p3 * exp(-p4 * V)',),
'ah': ('p5 * exp( p6 * V)',),
'bh': ('p7 * exp(-p8 * V)',),
'a2': ('p9 * exp( p10 * V)',),
'b2': ('p11 * exp(-p12 * V)',),
'a3': ('p13 * exp( p14 * V)',),
'b3': ('(a3*b1)/a1',),
'a4': ('p15 * exp(p16* V)',),
'b4': ('(a4*b2)/a2',)
}

auxiliary_expression = "p17 * {} * (V - E_Kr)"
auxiliary_symbol = 'I_Kr'

auxiliary_params_dict = {'E_Kr': -85}

def __init__(self):
super().__init__(states=self.states,
open_state=self.open_state,
rates=self.rates,
rate_dictionary=self.rate_dictionary,
auxiliary_expression=self.auxiliary_expression,
auxiliary_symbol=self.auxiliary_symbol,
shared_variables_dict=self.shared_variables_dict,
auxiliary_params_dict=self.auxiliary_params_dict)
36 changes: 36 additions & 0 deletions markov_builder/models/thirty_models/model2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from numpy import NaN

from markov_builder.MarkovChain import MarkovChain
from markov_builder.rate_expressions import negative_rate_expr, positive_rate_expr


class model_02(MarkovChain):
description = ""
states = ('O', 'C', 'I')
rates = [('O', 'C', 'bm', 'am'),
('O', 'I', 'ah', 'bh')]

open_state = 'O'
shared_variables_dict = {'V': NaN}
rate_dictionary = {'am': positive_rate_expr + ((2.26E-4, 6.99E-2),),
'bm': negative_rate_expr + ((3.45E-5, 5.462E-2),),
'ah': positive_rate_expr + ((0.08730, 8.91e-3),),
'bh': negative_rate_expr + ((5.15e-3, 0.03158),),
}

auxiliary_expression = "g_Kr * {} * (V - E_Kr)"
auxiliary_symbol = 'I_Kr'

auxiliary_params_dict = {'g_Kr': 0.1524,
'E_Kr': -88
}

def __init__(self):
super().__init__(states=self.states,
open_state=self.open_state,
rates=self.rates,
rate_dictionary=self.rate_dictionary,
auxiliary_expression=self.auxiliary_expression,
auxiliary_symbol=self.auxiliary_symbol,
shared_variables_dict=self.shared_variables_dict,
auxiliary_params_dict=self.auxiliary_params_dict)
38 changes: 38 additions & 0 deletions markov_builder/models/thirty_models/model3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from numpy import NaN

from markov_builder.MarkovChain import MarkovChain
from markov_builder.rate_expressions import negative_rate_expr, positive_rate_expr


class model_03(MarkovChain):
description = ""
states = ('O', 'C', 'I', 'IC')
rates = [('O', 'C', 'bm', 'am'),
('I', 'IC', 'bm', 'am'),
('O', 'I', 'ah', 'bh'),
('C', 'IC', 'ah', 'bh')]

open_state = 'O'
shared_variables_dict = {'V': NaN}
rate_dictionary = {'am': positive_rate_expr + ((2.26E-4, 6.99E-2),),
'bm': negative_rate_expr + ((3.45E-5, 5.462E-2),),
'ah': positive_rate_expr + ((0.08730, 8.91e-3),),
'bh': negative_rate_expr + ((5.15e-3, 0.03158),),
}

auxiliary_expression = "g_Kr * {} * (V - E_Kr)"
auxiliary_symbol = 'I_Kr'

auxiliary_params_dict = {'g_Kr': 0.1524,
'E_Kr': -88
}

def __init__(self):
super().__init__(states=self.states,
open_state=self.open_state,
rates=self.rates,
rate_dictionary=self.rate_dictionary,
auxiliary_expression=self.auxiliary_expression,
auxiliary_symbol=self.auxiliary_symbol,
shared_variables_dict=self.shared_variables_dict,
auxiliary_params_dict=self.auxiliary_params_dict)
116 changes: 116 additions & 0 deletions markov_builder/models/thirty_models/model30.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
from numpy import NaN

from markov_builder.MarkovChain import MarkovChain


class model_30(MarkovChain):
description = ""
states = ('O', 'I', 'IC1', 'IC2', 'C2', 'C1', 'C3', 'IC3', 'IC4', 'C4')
rates = [
('C1', 'O', 'a3', 'b3'),
('C4', 'C3', 'a12', 'b12'),
('C3', 'C2', 'a1', 'b1'),
('IC1', 'I', 'a10', 'b10'),
('IC2', 'IC1', 'a9', 'b9'),
('IC3', 'IC2', 'a8', 'b8'),
('IC4', 'IC3', 'a11', 'b11'),
('C2', 'C1', 'a2', 'b2'),
('O', 'I', 'a4', 'b4'),
('C2', 'IC2', 'a6', 'b6'),
('C1', 'IC1', 'a5', 'b5'),
('C4', 'IC4', 'a13', 'b13'),
('C3', 'IC3', 'a7', 'b7')
]

open_state = 'O'
shared_variables_dict = {'V': NaN,
'p1': 2.26e-4,
'p2': 0.06990,
'p3': 3.45e-5,
'p4': 0.05462,
'p5': 0.08730,
'p6': 8.91e-3,
'p7': 5.15e-3,
'p8': 0.03158,
'p9': 2.26e-4,
'p10': 0.06990,
'p11': 3.45e-5,
'p12': 0.05462,
'p13': 0.08730,
'p14': 8.91e-3,
'p15': 5.15e-3,
'p16': 0.03158,
'p17': 0.08730,
'p18': 8.91e-3,
'p19': 5.15e-3,
'p20': 0.03158,
'p21': 0.06990,
'p22': 3.45e-5,
'p23': 0.05462,
'p24': 0.08730,
'p25': 8.91e-3,
'p26': 5.15e-3,
'p27': 0.03158,
'p28': 0.08730,
'p29': 8.91e-3,
'p30': 5.15e-3,
'p31': 0.03158,
'p32': 5.15e-3,
'p33': 0.03158,
'p34': 0.03158,
'p35': 8.91e-3,
'p36': 5.15e-3,
'p37': 0.03158,
'p38': 0.08730,
'p39': 8.91e-3,
'p40': 5.15e-3,
'p41': 0.03158,
'p42': 5.15e-3,
'p43': 0.03158,
'p44': 0.03158,
'p45': 0.15240
}

rate_dictionary = {
'a1': ('p1 * exp( p2 * V)',),
'b1': ('p3 * exp(-p4 * V)',),
'a2': ('p5 * exp( p6 * V)',),
'b2': ('p7 * exp(-p8 * V)',),
'a3': ('p9 * exp( p10 * V)',),
'b3': ('p11 * exp(-p12* V)',),
'a4': ('p13 * exp( p14 * V)',),
'b4': ('p15 * exp(-p16 * V)',),
'a8': ('p17 * exp(p18* V)',),
'b8': ('p19 * exp(-p20 * V)',),
'a9': ('p21 * exp(p22* V)',),
'b9': ('p23 * exp(-p24 * V)',),
'a10': ('p25 * exp(p26* V)',),
'b10': ('p27 * exp(-p28 * V)',),
'a5': ('p29 * exp(p30 * V)',),
'b5': ('a10*a5*b4*(b3)/(a3*a4*b10)',),
'a6': ('p31 * exp(p32 * V)',),
'b6': ('a9*a6*b5*(b2)/(a2*a5*b9)',),
'a7': ('p33 * exp(p34 * V)',),
'b7': ('a8*a7*b1*(b6)/(a1*a6*b8)',),
'a11': ('p35 * exp(p36* V)',),
'b11': ('p37 * exp(-p38 * V)',),
'a12': ('p39 * exp(p40* V)',),
'b12': ('p41 * exp(-p42 * V)',),
'a13': ('p43 * exp(p44 * V)',),
'b13': ('a13*a11*b7*b12/(a12*a7*b11)',),
}

auxiliary_expression = "p45 * {} * (V - E_Kr)"
auxiliary_symbol = 'I_Kr'

auxiliary_params_dict = {'E_Kr': -85}

def __init__(self):
super().__init__(states=self.states,
open_state=self.open_state,
rates=self.rates,
rate_dictionary=self.rate_dictionary,
auxiliary_expression=self.auxiliary_expression,
auxiliary_symbol=self.auxiliary_symbol,
shared_variables_dict=self.shared_variables_dict,
auxiliary_params_dict=self.auxiliary_params_dict)
Loading