Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thirty models #13

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
be57ad5
Change default parameter handling
joeyshuttleworth Oct 24, 2022
9d952fc
Remove unnecessary line from test
joeyshuttleworth Oct 24, 2022
2297bf9
Add first 4 models. Add tests to generate .mmt and graph files
joeyshuttleworth Oct 24, 2022
ae770ab
Add tests for connectedness as reversibility. Add models 4,5
joeyshuttleworth Oct 25, 2022
0b6f9d8
Fix draw_graph handling of transition rates
joeyshuttleworth Nov 1, 2022
d502827
Add more models
joeyshuttleworth Nov 1, 2022
beacf8f
Fix get_transition_matrix. Fix reversibility check. Add show_html swi…
joeyshuttleworth Apr 28, 2023
8904c6b
Merge branch 'master' into fix_transition_matrix
joeyshuttleworth Apr 28, 2023
051a36f
Add models 11 and 30. Remove duplicated test file
joeyshuttleworth May 3, 2023
a4b97e2
Merge branch 'fix_transition_matrix' of github.com:CardiacModelling/M…
joeyshuttleworth May 3, 2023
5310b55
Lint and isort
joeyshuttleworth May 3, 2023
57415dc
Update test_parameterise_rates
joeyshuttleworth May 3, 2023
f199b6f
Add test_30_models.py
joeyshuttleworth May 3, 2023
79f7295
Add myokit files for testing
joeyshuttleworth May 3, 2023
7e21caf
Update pytest.yml
joeyshuttleworth May 3, 2023
0afb97b
Update pytest.yml
joeyshuttleworth May 3, 2023
bc4c4c9
Make single quote use more consistent
joeyshuttleworth Jun 13, 2023
2d6c990
Fix indentation. Distribute trajectories according to number of traje…
joeyshuttleworth Jun 13, 2023
17027f4
Fix sympy depreciation warning (latex output)
joeyshuttleworth Jun 13, 2023
fe4f333
Add test for dataclass exception (must be subclass of state_attribute…
joeyshuttleworth Jun 13, 2023
23835be
Merge branch 'fix_transition_matrix' of github.com:CardiacModelling/M…
joeyshuttleworth Jun 13, 2023
b6ef7da
Raise TypeError not Exception
joeyshuttleworth Jun 13, 2023
215898f
Remove old, broken test output
joeyshuttleworth Jun 13, 2023
de33024
Fix test_bad_dataclass_exception
joeyshuttleworth Jun 13, 2023
4d86220
Remove unnecessary checks on attribute dataclass
joeyshuttleworth Jun 13, 2023
fef0edf
Lint
joeyshuttleworth Jun 13, 2023
f1e03cb
Add models
joeyshuttleworth Jun 13, 2023
f58dcc7
Add some models with HH-style gating
joeyshuttleworth Jun 16, 2023
c2ccada
Sort imports
joeyshuttleworth Jun 16, 2023
93b454f
Fix myokit model generation
joeyshuttleworth Jun 16, 2023
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
211 changes: 143 additions & 68 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.
22 changes: 22 additions & 0 deletions markov_builder/models/thirty_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 .model9 import model_09
from .model10 import model_10
from .model11 import model_11
from .model12 import model_12
from .model13 import model_13
from .model14 import model_14
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_09',
'model_10',
'model_11', 'model_12', 'model_13', 'model_14', '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)
54 changes: 54 additions & 0 deletions markov_builder/models/thirty_models/model10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from numpy import NaN

from markov_builder.MarkovChain import MarkovChain


class model_10(MarkovChain):
description = ""
states = ('O', 'C1', 'C2', 'O2', 'I')
rates = [
('C1', 'O', 'a2', 'b2'),
('C2', 'C1', 'a1', 'b1'),
('I', 'O2', 'ah', 'bh')
]

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': 0.08730,
'p10': 8.91e-3,
'p11': 5.15e-3,
'p12': 0.03158,
'p13': 0.15240,
}

rate_dictionary = {
'a1': ('p1 * exp(p2*V)',),
'b1': ('p3 * exp(-p4*V)',),
'bh': ('p5 * exp(p6*V)',),
'ah': ('p7 * exp(-p8*V)',),
'a2': ('p9 * exp(p10*V)',),
'b2': ('p11 * exp(-p12*V)',),
}

open_state = 'O'
auxiliary_expression = "p13 * state_O * state_O2 * (V - E_Kr)"
auxiliary_symbol = 'I_Kr'

auxiliary_params_dict = {'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)
61 changes: 61 additions & 0 deletions markov_builder/models/thirty_models/model12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from numpy import NaN

from markov_builder.MarkovChain import MarkovChain


class model_12(MarkovChain):
description = ""
states = ('O', 'I', 'IC1', 'IC2', 'C2', 'C1')
rates = [
('O', 'I', 'a1', 'b1'),
('C1', 'O', 'am', '2*bm'),
('IC1', 'I', 'am', '2*bm'),
('IC2', 'IC1', '2*am', 'bm'),
('C2', 'C1', '2*am', 'bm'),
('C2', 'IC2', 'a3', 'b3'),
('C1', 'IC1', 'a2', 'b2')
]

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.15240
}

rate_dictionary = {
'am': ('p1 * exp( p2 * V)',),
'bm': ('p3 * exp(-p4 * V)',),
'a1': ('p5 * exp( p6 * V)',),
'b1': ('p7 * exp(-p8 * V)',),
'a2': ('p9 * exp( p10 * V)',),
'a3': ('p11 * exp( p12 * V)',),

'b2': ('a2 * b1 / a1',),
'b3': ('a3 * b2 / a2',),
}

auxiliary_expression = "p13 * {} * (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)
78 changes: 78 additions & 0 deletions markov_builder/models/thirty_models/model13.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from numpy import NaN

from markov_builder.MarkovChain import MarkovChain


class model_13(MarkovChain):
description = ""
states = ('O', 'I', 'IC1', 'IC2', 'C2', 'C1')
rates = [
('O', 'I', 'a3', 'b3'),
('C1', 'O', 'a2', 'b2'),
('IC1', 'I', 'a7', 'b7'),
('IC2', 'IC1', 'a6', 'b6'),
('C2', 'C1', 'a1', 'b1'),
('C2', 'IC2', 'a5', 'b5'),
('C1', 'IC1', 'a4', 'b4')
]

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': 2.26e-4,
'p14': 0.06990,
'p15': 3.45e-5,
'p16': 0.05462,
'p17': 0.08730,
'p18': 8.91e-3,
'p19': 5.15e-3,
'p20': 0.03158,
'p21': 2.26e-4,
'p22': 0.06990,
'p23': 3.45e-5,
'p24': 0.05462,
'p25': 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': ('(a7*b3*b2*a4)/(a2*a3*b7)',),
'a5': ('p15 * exp( p16 * V)',),
'b5': ('(a5*a6*b4*b1)/(a1*a4*b6)',),
'a6': ('p17 * exp( p18 * V)',),
'b6': ('p19 * exp(-p20 * V)',),
'a7': ('p21 * exp(p22 * V)',),
'b7': ('p23 * exp(-p24 * V)',),
}

auxiliary_expression = "p25 * {} * (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