diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 3a48ace..02614f2 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -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 diff --git a/markov_builder/MarkovChain.py b/markov_builder/MarkovChain.py index 9c1f687..584cd96 100644 --- a/markov_builder/MarkovChain.py +++ b/markov_builder/MarkovChain.py @@ -4,6 +4,7 @@ from typing import List, Tuple import myokit +import myokit.formats.sympy import networkx as nx import numpy as np import pandas as pd @@ -22,24 +23,24 @@ class MarkovChain(): """ def __init__(self, states: list = [], state_attributes_class: - MarkovStateAttributes = None, seed: int = None, - name: str = None): + MarkovStateAttributes = None, seed: int = None, name: str = + None, open_state: str = None, rates: list = None, + rate_dictionary: dict = None, auxiliary_expression: str = + None, auxiliary_symbol: str = None, shared_variables_dict: dict + = None, auxiliary_params_dict: dict = None): # Initialise the graph representing the states. Each directed edge has # a `rate` attribute which is a string representing the transition rate # between the two nodes self.graph = nx.DiGraph() - if states: - self.graph.add_nodes_from(states) self.rates = set() # Initialise a random number generator for simulation. Optionally, a # seed can be specified. self.rng = default_rng(seed) self.name = name - self.shared_rate_variables = set() - + self.shared_variables = {} self.rate_expressions = {} self.default_values = {} @@ -52,8 +53,22 @@ def __init__(self, states: list = [], state_attributes_class: self.reserved_names = [] self.auxiliary_variable = 'auxiliary_expression' - if not issubclass(self.state_attributes_class, MarkovStateAttributes): - raise Exception("state_attirbutes_class must be a dataclass") + if states: + for state in states: + self.add_state(state) + + if rates: + for r in rates: + self.add_both_transitions(*r) + if shared_variables_dict: + self.parameterise_rates(rate_dictionary, shared_variables_dict) + + if states and open_state and rates and rate_dictionary and auxiliary_expression and\ + auxiliary_symbol and shared_variables_dict and auxiliary_params_dict: + open_state = self.get_state_symbol(open_state) + self.define_auxiliary_expression(sp.sympify(auxiliary_expression.format(open_state)), + auxiliary_symbol, + auxiliary_params_dict) def mirror_model(self, prefix: str, new_rates: bool = False) -> None: """ Duplicate all states and rates in the model such that there are two identical components. @@ -250,9 +265,13 @@ def get_transition_matrix(self, use_parameters: bool = False, else: edge = self.graph.get_edge_data(current_state, incident_state) if edge is not None: - row.append(edge["rate"]) + rate = edge['rate'] + if isinstance(rate, str): + row.append(edge['rate']) + else: + row.append(edge['rate'][0]) else: - row.append(0) + row.append(sp.sympify('0')) matrix.append(row) matrix = sp.Matrix(matrix) @@ -268,7 +287,7 @@ def get_transition_matrix(self, use_parameters: bool = False, if label_order is None: return list(self.graph.nodes), matrix else: - if len(label_order) != self.graph.nodes(): + if len(label_order) != len(self.graph.nodes()): raise Exception("Not all states accounted for in label order") permutation = [label_order.index(n) for n in self.graph.nodes] @@ -403,16 +422,19 @@ def sample_trajectories(self, no_trajectories: int, time_range: list = [0, 1], # default missing values to those in self.default_values param_dict = {param: param_dict[param] if param in param_dict - else self.default_values[param] + else {**self.default_values, **self.shared_variables}[param] for param in param_list} else: param_dict = self.default_values if starting_distribution is None: + # If there is no user specified starting_distribution, create one starting_distribution = np.around(np.array([no_trajectories] * no_nodes) / no_nodes) starting_distribution[0] += no_trajectories - starting_distribution.sum() + else: + starting_distribution = np.array(starting_distribution) - distribution = starting_distribution + distribution = np.around(starting_distribution * no_trajectories / starting_distribution.sum()) labels, mean_waiting_times, e_chain = self.get_embedded_chain(param_dict) @@ -468,8 +490,8 @@ def get_equilibrium_distribution(self, param_dict: dict = None) -> Tuple[List[st ss = -np.array(A.LUsolve(B).evalf(subs=param_dict)).astype(np.float64) except TypeError as exc: - logging.warning("Couldn't evaluate equilibrium distribution as float." - "Is every parameter defined?" + logging.warning("Error evaluating equilibrium distribution " + f"A={A}\nB={B}\nparams={param_dict}\n" "%s" % str(exc)) raise exc @@ -477,9 +499,21 @@ def get_equilibrium_distribution(self, param_dict: dict = None) -> Tuple[List[st ss = np.append(ss, 1 - ss.sum()) return labels, ss + def is_connected(self) -> bool: + """Checks if the graph is strongly connected that is, if each state can be + reached from every other state. This function returns true even if all + transition rates are 0. + + :return: A bool which is true if the graph is strongly connected and + false otherwise + + """ + + return nx.algorithms.components.is_strongly_connected(self.graph) + def is_reversible(self) -> bool: - """Checks symbolically whether or not the Markov chain is reversible for any - set of non-zero transition rate values. + """Checks symbolically if the Markov chain is reversible for any set of non-zero + transition rate values. We assume that all transition rates are always non-zero and follow Colquhoun et al. (2004) https://doi.org/10.1529/biophysj.103. @@ -491,7 +525,7 @@ def is_reversible(self) -> bool: # Digraph must be strongly connected in order for the chain to be # reversible. In other words it must be possible to transition from any # state to any other state in some finite number of transitions - if not nx.algorithms.components.is_strongly_connected(self.graph): + if not self.is_connected(): return False undirected_graph = self.graph.to_undirected(reciprocal=False, as_view=True) @@ -501,9 +535,16 @@ def is_reversible(self) -> bool: cycle.append(cycle[0]) logging.debug("Checking cycle {}".format(cycle)) - iter = list(zip(cycle, itertools.islice(cycle, 1, None))) - forward_rate_list = [sp.sympify(self.graph.get_edge_data(frm, to)['rate']) for frm, to in iter] - backward_rate_list = [sp.sympify(self.graph.get_edge_data(frm, to)['rate']) for to, frm in iter] + iterator = list(zip(cycle, itertools.islice(cycle, 1, None))) + forward_rate_list = [sp.sympify(self.graph.get_edge_data(frm, to)['rate']) for frm, to in iterator] + backward_rate_list = [sp.sympify(self.graph.get_edge_data(frm, to)['rate']) for to, frm in iterator] + + logging.debug(self.rate_expressions) + + # Substitute in expressions + forward_rate_list = [rate.subs(self.rate_expressions) for rate in forward_rate_list] + backward_rate_list = [rate.subs(self.rate_expressions) for rate in + backward_rate_list] logging.debug("Rates moving forwards around the cycle are: %s", forward_rate_list) logging.debug("Rates moving backwards around the cycle are: %s", backward_rate_list) @@ -512,19 +553,22 @@ def is_reversible(self) -> bool: logging.debug("Not all rates were specified.") return False - forward_rate_product = sp.prod(forward_rate_list) - backward_rate_product = sp.prod(backward_rate_list) + forward_rate_product = sp.prod(forward_rate_list).subs(self.rate_expressions) + backward_rate_product = sp.prod(backward_rate_list).subs(self.rate_expressions) + if (forward_rate_product - backward_rate_product).evalf() != 0: return False return True def draw_graph(self, filepath: str = None, show_options: bool = - False, show_rates: bool = False, show_parameters: bool = False): + False, show_rates: bool = False, show_parameters: bool = False, + show_html=False): """Visualise the graph as a webpage using pyvis. :param filepath: An optional filepath to save the file to. If this is None, will be opened as a webpage instead. :param show_options: Whether or not the options menu should be displayed on the webpage :param show_parameters: Whether or not we should display the transition rates instead of their labels + :param show_html: Whether or not to open the outputted html file in the browser """ for _, _, data in self.graph.edges(data=True): @@ -534,7 +578,7 @@ def draw_graph(self, filepath: str = None, show_options: bool = if len(self.rate_expressions) == 0: raise Exception() else: - data['label'] = str(self.rate_expressions[data['rate']]) + data['label'] = str(sp.sympify(data['rate']).subs(self.rate_expressions)) nt = pyvis.network.Network(directed=True) nt.from_nx(self.graph) @@ -543,7 +587,7 @@ def draw_graph(self, filepath: str = None, show_options: bool = nt.show_buttons() if filepath is not None: nt.save_graph(filepath) - else: + if show_html: nt.show('Markov_builder_graph.html') def substitute_rates(self, rates_dict: dict): @@ -564,7 +608,7 @@ def substitute_rates(self, rates_dict: dict): d['label'] = d['rate'] d['rate'] = str(sp.sympify(d['rate']).subs(rates_dict)) - def parameterise_rates(self, rate_dict: dict, shared_variables: list = []) -> None: + def parameterise_rates(self, rate_dict: dict, shared_variables: dict = {}) -> None: """Define a set of parameters for the transition rates. Parameters declared as @@ -575,18 +619,10 @@ def parameterise_rates(self, rate_dict: dict, shared_variables: list = []) -> No V is the membrane voltage (a variable shared between transition rates). :param rate_dict: A dictionary with a 2-tuple containing an expression and dummy variables for each rate. - :param shared_variables: A list of variables that may be shared between transition rates + :param shared_variables: A dictionary of variables that may be shared between transition rates """ - # Check that shared_variables is a list (and not a string!) - if isinstance(shared_variables, str): - raise TypeError("shared_variables is a string but must be a list") - - for v in shared_variables: - if v in self.reserved_names: - raise Exception('name %s is reserved', v) - # Validate rate dictionary for r in rate_dict: if r not in self.rates: @@ -594,13 +630,21 @@ def parameterise_rates(self, rate_dict: dict, shared_variables: list = []) -> No rate_expressions = {} default_values_dict = {} + for r in self.rates: if r in rate_dict: - if len(rate_dict[r]) == 2: + default_values = [] + dummy_variables = [] + if len(rate_dict[r]) == 1: + expression = rate_dict[r][0] + elif len(rate_dict[r]) == 2: expression, dummy_variables = rate_dict[r] - default_values = [] - else: + elif len(rate_dict[r]) == 3: expression, dummy_variables, default_values = rate_dict[r] + else: + raise ValueError(f"Rate dictionary was malformed. \ + Entry with key {r} ({rate_dict[r]}) should be a tuple/list of length 1-3") + if len(dummy_variables) < len(default_values): raise ValueError("dummy variables list and default values list have mismatching lengths.\ Lengths {} and {}".format(len(dummy_variables), len(default_values))) @@ -608,10 +652,11 @@ def parameterise_rates(self, rate_dict: dict, shared_variables: list = []) -> No expression = sp.sympify(expression) for symbol in expression.free_symbols: - variables = list(dummy_variables) + list(shared_variables) - if str(symbol) not in variables: - raise Exception( - f"Symbol, {symbol} was not found in dummy variables or shared_variables, {variables}.") + symbol = str(symbol) + variables = list(dummy_variables) + list(shared_variables.keys()) + if symbol not in variables: + # Add symbol to shared variables dictionary + shared_variables[symbol] = None subs_dict = {u: f"{r}_{u}" for i, u in enumerate(dummy_variables)} rate_expressions[r] = sp.sympify(expression).subs(subs_dict) @@ -619,13 +664,17 @@ def parameterise_rates(self, rate_dict: dict, shared_variables: list = []) -> No for u, v in zip(dummy_variables, default_values): new_var_name = f"{r}_{u}" if new_var_name in default_values_dict: - raise Exception(f"A parameter with label {new_var_name} is already present in the model.") + raise ValueError(f"A parameter with label {new_var_name} is already present in the model.") default_values_dict[new_var_name] = v - self.rate_expressions = {**self.rate_expressions, **rate_expressions} - self.default_values = {**self.default_values, **default_values_dict} + rate_expressions = {rate: expr.subs(rate_expressions) for rate, expr in + rate_expressions.items()} - self.shared_rate_variables = self.shared_rate_variables.union(shared_variables) + self.rate_expressions = rate_expressions + self.default_values = default_values_dict + + for key in shared_variables.keys(): + self.default_values[key] = shared_variables[key] def get_parameter_list(self) -> List[str]: """ @@ -640,7 +689,7 @@ def get_parameter_list(self) -> List[str]: for symbol in self.rate_expressions[r].free_symbols: rates.add(str(symbol)) - rates = rates.union([str(sym) for sym in self.shared_rate_variables]) + rates = rates.union([str(sym) for sym in self.shared_variables]) return sorted(rates) @@ -713,9 +762,21 @@ def generate_myokit_model(self, name: str = "", comp.add_variable(parameter) if parameter in self.default_values: comp[parameter].set_rhs(self.default_values[parameter]) + elif parameter in self.auxiliary_variables: + comp[parameter].set_rhs(self.auxiliary_variables[parameter]) + elif parameter in self.shared_variables: + comp[parameter].set_rhs(self.shared_variables[parameter]) for rate in self.rates: - comp.add_variable(rate) + free_symbols = sp.parse_expr(rate).free_symbols + for symb in free_symbols: + if symb not in comp.variables(): + try: + comp.add_variable(str(symb)) + except myokit.DuplicateName: + # Variable has already been added + pass + if rate in self.rate_expressions: expr = self.rate_expressions[rate] comp[rate].set_rhs(str(expr)) @@ -725,17 +786,21 @@ def generate_myokit_model(self, name: str = "", state = self.get_state_symbol(state) comp.add_variable(state) + connected_components = list(nx.connected_components(self.graph.to_undirected())) + # Write down differential equations for the states (unless we chose to # eliminate it from the ODE system) - for state in states: - var = comp[state] - var.promote() - var.set_rhs(str(d_equations[state])) - var.set_state_value(0) + for state in self.graph.nodes(): + state_symbol = self.get_state_symbol(state) + var = comp[state_symbol] - # All but one states start with 0 occupancy. If they were all 0 nothing - # would happen! - comp[states[-1]].set_state_value(1) + # Give all of the states equal occupancy + component = [c for c in connected_components if state in c][0] + initial_value = 1.0 / float(len(component)) + + if state != eliminate_state: + var.promote(initial_value) + var.set_rhs(str(d_equations[state_symbol])) # Write equation for eliminated state using the fact that the state # occupancies/probabilities must sum to 1. @@ -749,12 +814,14 @@ def generate_myokit_model(self, name: str = "", comp[self.get_state_symbol(eliminate_state)].set_rhs(rhs_str) # Add auxiliary equation if required - if self.auxiliary_expression is not None: + if self.auxiliary_expression is not None and self.auxiliary_variable: comp.add_variable(self.auxiliary_variable) - comp[self.auxiliary_variable].set_rhs(str(self.auxiliary_expression)) + comp[self.auxiliary_variable].set_rhs(str(self.auxiliary_expression).replace('**', '^')) + return model - def define_auxiliary_expression(self, expression: sp.Expr, label: str = None, default_values: dict = {}) -> None: + def define_auxiliary_expression(self, expression: sp.Expr, label: str = + None, default_values: dict = {}) -> None: """Define an auxiliary output variable for the model. :param expression: A sympy expression defining the auxiliary variable @@ -773,12 +840,6 @@ def define_auxiliary_expression(self, expression: sp.Expr, label: str = None, de raise Exception() state_symbols = [self.get_state_symbol(state) for state in self.graph.nodes()] - for symbol in expression.free_symbols: - if str(symbol) not in state_symbols: - if self.shared_rate_variables is None: - self.shared_rate_variables = set(str(symbol)) - else: - self.shared_rate_variables.add(str(symbol)) for symbol in default_values: symbol = sp.sympify(symbol) @@ -787,9 +848,21 @@ def define_auxiliary_expression(self, expression: sp.Expr, label: str = None, de if symbol in self.default_values: raise Exception() - self.default_values = {**self.default_values, **default_values} + for symbol in expression.free_symbols: + if str(symbol) not in state_symbols: + symbol = str(symbol) + if symbol in default_values.keys(): + self.shared_variables[symbol] = default_values[symbol] + elif symbol in self.shared_variables: + continue + else: + self.shared_variables[symbol] = np.NaN + self.auxiliary_expression = expression + # TODO check these variables are not elsewhere in the model + self.auxiliary_variables = default_values + def get_states(self): return list(self.graph) @@ -826,7 +899,9 @@ def as_latex(self, state_to_remove: str = None, include_auxiliary_expression: bo if column_vector: matrix_str = str(sp.latex(Q.T)) eqn = r'\begin{equation}\dfrac{dX}{dt} = %s X \\end{equation}' % matrix_str - X_defn = r'\begin{equation} %s \end{equation}' % sp.latex(sp.Matrix(label_order)) + + x_vars = [[sp.sympify(self.get_state_symbol(label))] for label in label_order] + X_defn = r'\begin{equation} %s \end{equation}' % sp.latex(sp.Matrix(x_vars)) else: matrix_str = str(sp.latex(Q)) diff --git a/markov_builder/example_models.py b/markov_builder/example_models.py index 744d9ec..1eeae20 100644 --- a/markov_builder/example_models.py +++ b/markov_builder/example_models.py @@ -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)") @@ -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') @@ -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') diff --git a/markov_builder/models/__init__.py b/markov_builder/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/markov_builder/models/thirty_models/__init__.py b/markov_builder/models/thirty_models/__init__.py new file mode 100644 index 0000000..39fda86 --- /dev/null +++ b/markov_builder/models/thirty_models/__init__.py @@ -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'] diff --git a/markov_builder/models/thirty_models/model0.py b/markov_builder/models/thirty_models/model0.py new file mode 100644 index 0000000..4c76d29 --- /dev/null +++ b/markov_builder/models/thirty_models/model0.py @@ -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) diff --git a/markov_builder/models/thirty_models/model1.py b/markov_builder/models/thirty_models/model1.py new file mode 100644 index 0000000..76f4edf --- /dev/null +++ b/markov_builder/models/thirty_models/model1.py @@ -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) diff --git a/markov_builder/models/thirty_models/model10.py b/markov_builder/models/thirty_models/model10.py new file mode 100644 index 0000000..ef68b93 --- /dev/null +++ b/markov_builder/models/thirty_models/model10.py @@ -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) diff --git a/markov_builder/models/thirty_models/model11.py b/markov_builder/models/thirty_models/model11.py new file mode 100644 index 0000000..13e2e5f --- /dev/null +++ b/markov_builder/models/thirty_models/model11.py @@ -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) diff --git a/markov_builder/models/thirty_models/model12.py b/markov_builder/models/thirty_models/model12.py new file mode 100644 index 0000000..78057c9 --- /dev/null +++ b/markov_builder/models/thirty_models/model12.py @@ -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) diff --git a/markov_builder/models/thirty_models/model13.py b/markov_builder/models/thirty_models/model13.py new file mode 100644 index 0000000..ee1ba2b --- /dev/null +++ b/markov_builder/models/thirty_models/model13.py @@ -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) diff --git a/markov_builder/models/thirty_models/model14.py b/markov_builder/models/thirty_models/model14.py new file mode 100644 index 0000000..de7308d --- /dev/null +++ b/markov_builder/models/thirty_models/model14.py @@ -0,0 +1,49 @@ +from numpy import NaN + +from markov_builder.MarkovChain import MarkovChain + + +class model_14(MarkovChain): + description = "" + states = ('O', 'C2', 'C1', 'C3', 'I') + rates = [ + ('C1', 'O', 'am', '3*bm'), + ('C2', 'C1', '2*am', '2*bm'), + ('C3', 'C2', '3*am', 'bm'), + ('O', 'I', 'b1', 'a1'), + ] + + 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': 0.1524 + } + + rate_dictionary = { + 'am': ('p1 * exp( p2 * V)',), + 'bm': ('p3 * exp(-p4 * V)',), + 'b1': ('p5 * exp(p6 * V)',), + 'a1': ('p7 * exp(-p8 * V)',), + } + + auxiliary_expression = "p9 * {} * (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) diff --git a/markov_builder/models/thirty_models/model2.py b/markov_builder/models/thirty_models/model2.py new file mode 100644 index 0000000..da4fcf1 --- /dev/null +++ b/markov_builder/models/thirty_models/model2.py @@ -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) diff --git a/markov_builder/models/thirty_models/model3.py b/markov_builder/models/thirty_models/model3.py new file mode 100644 index 0000000..92fa2c2 --- /dev/null +++ b/markov_builder/models/thirty_models/model3.py @@ -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) diff --git a/markov_builder/models/thirty_models/model30.py b/markov_builder/models/thirty_models/model30.py new file mode 100644 index 0000000..10b094a --- /dev/null +++ b/markov_builder/models/thirty_models/model30.py @@ -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) diff --git a/markov_builder/models/thirty_models/model4.py b/markov_builder/models/thirty_models/model4.py new file mode 100644 index 0000000..88dc1da --- /dev/null +++ b/markov_builder/models/thirty_models/model4.py @@ -0,0 +1,52 @@ +from numpy import NaN + +from markov_builder.MarkovChain import MarkovChain + + +class model_04(MarkovChain): + description = "" + states = ('O', 'C', 'I', 'IC') + rates = [('O', 'C', 'b1', 'a1'), + ('I', 'IC', 'a3', 'b3'), + ('O', 'I', 'a4', 'b4'), + ('C', 'IC', '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': 5.15e-3, + 'p10': 0.03158, + 'p11': 0.15240, + } + + rate_dictionary = {'a1': ('p1 * exp(p2*V)',), + 'b1': ('p3 * exp(-p4*V)',), + 'a4': ('p5 * exp(p6*V)',), + 'b4': ('p7 * exp(-p8*V)',), + 'a3': ('p9 * exp(-p10*V)',), + 'b3': ('(a3*a1)/b1',) + } + + 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) diff --git a/markov_builder/models/thirty_models/model5.py b/markov_builder/models/thirty_models/model5.py new file mode 100644 index 0000000..106513c --- /dev/null +++ b/markov_builder/models/thirty_models/model5.py @@ -0,0 +1,50 @@ +from numpy import NaN + +from markov_builder.MarkovChain import MarkovChain + + +class model_05(MarkovChain): + description = "" + states = ('O', 'C', 'I', 'IC') + rates = [('O', 'C', 'bm', 'am'), + ('I', 'IC', 'bm', 'am'), + ('O', 'I', 'b1', 'a1'), + ('C', 'IC', 'b2', 'a2')] + + 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': 5.15e-3, + 'p10': 0.03158, + 'p11': 0.15240, + } + + rate_dictionary = {'am': ('p1 * exp(p2*V)',), + 'bm': ('p3 * exp(-p4*V)',), + 'b1': ('p5 * exp(p6*V)',), + 'a1': ('p7 * exp(-p8*V)',), + 'b2': ('p9 * exp(p10*V)',), + 'a2': ('(b2*a1)/b1',) + } + + auxiliary_expression = "p11 * {} * (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) diff --git a/markov_builder/models/thirty_models/model6.py b/markov_builder/models/thirty_models/model6.py new file mode 100644 index 0000000..73fa696 --- /dev/null +++ b/markov_builder/models/thirty_models/model6.py @@ -0,0 +1,57 @@ +from numpy import NaN + +from markov_builder.MarkovChain import MarkovChain + + +class model_06(MarkovChain): + description = "" + states = ('O', 'C', 'I', 'IC') + rates = [('O', 'C', 'a1', 'b1'), + ('O', 'I', 'a2', 'b2'), + ('I', 'IC', 'a3', 'b3'), + ('C', 'IC', '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': 5.15e-3, + 'p10': 0.03158, + 'p11': 5.15e-3, + 'p12': 0.03158, + 'p13': 5.15e-3, + 'p14': 0.03158, + 'p15': 0.15240 + } + + rate_dictionary = { + 'b1': ('p1 * exp(p2*V)',), + 'a1': ('p3 * exp(-p4*V)',), + 'a2': ('p5 * exp(p6*V)',), + 'b2': ('p7 * exp(-p8*V)',), + 'b3': ('p9 * exp(p10*V)',), + 'a3': ('p11 * exp(-p12*V)',), + 'a4': ('p13 * exp(p14*V)',), + 'b4': ('(b3*b2*a1*a4)/(b1*a2*a3)',) + } + + auxiliary_expression = "p15 * {} * (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) diff --git a/markov_builder/models/thirty_models/model7.py b/markov_builder/models/thirty_models/model7.py new file mode 100644 index 0000000..fdfba85 --- /dev/null +++ b/markov_builder/models/thirty_models/model7.py @@ -0,0 +1,48 @@ +from numpy import NaN + +from markov_builder.MarkovChain import MarkovChain + + +class model_07(MarkovChain): + description = "" + states = ('O', 'C1', 'C2', 'I') + rates = [ + ('O', 'C1', 'bm*2', 'am'), + ('C1', 'C2', 'bm', 'am*2'), + ('O', 'I', 'a1', 'b1') + ] + + 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': 0.15240, + } + + rate_dictionary = { + 'am': ('p1 * exp(p2*V)',), + 'bm': ('p3 * exp(-p4*V)',), + 'a1': ('p5 * exp(p6*V)',), + 'b1': ('p7 * exp(-p8*V)',), + } + + auxiliary_expression = "p9 * {} * (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) diff --git a/markov_builder/models/thirty_models/model8.py b/markov_builder/models/thirty_models/model8.py new file mode 100644 index 0000000..bb2c3fe --- /dev/null +++ b/markov_builder/models/thirty_models/model8.py @@ -0,0 +1,54 @@ +from numpy import NaN + +from markov_builder.MarkovChain import MarkovChain + + +class model_08(MarkovChain): + description = "" + states = ('O', 'Y1', 'Y2', 'Y4') + rates = [ + ('O', 'Y2', 'k43', 'k34'), + ('O', 'Y4', 'k56', 'k65'), + ('Y1', 'Y2', 'k12', 'k21') + ] + + 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': 0.08730, + 'p10': 8.91e-3, + 'p11': 5.15e-3, + 'p12': 0.03158, + 'p13': 0.15240 + } + + rate_dictionary = { + 'k12': ('p1 * exp( p2 * V)',), + 'k21': ('p3 * exp(-p4 * V)',), + 'k34': ('p5 * exp( p6 * V)',), + 'k43': ('p7 * exp(-p8 * V)',), + 'k56': ('p9 * exp( p10 * V)',), + 'k65': ('p11 * exp(-p12 * V)',) + } + + auxiliary_expression = "p13 * {} * (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) diff --git a/markov_builder/models/thirty_models/model9.py b/markov_builder/models/thirty_models/model9.py new file mode 100644 index 0000000..543fe19 --- /dev/null +++ b/markov_builder/models/thirty_models/model9.py @@ -0,0 +1,45 @@ +from numpy import NaN + +from markov_builder.MarkovChain import MarkovChain + + +class model_09(MarkovChain): + description = "" + states = ('O', 'C', 'O2', 'I') + rates = [('C', 'O', 'am', 'bm'), + ('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.15240, + } + + rate_dictionary = { + 'am': ('p1 * exp(p2*V)',), + 'bm': ('p3 * exp(-p4*V)',), + 'bh': ('p5 * exp(p6*V)',), + 'ah': ('p7 * exp(-p8*V)',), + } + + open_state = 'O' + auxiliary_expression = "p9 * state_O ** 2 * 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) diff --git a/tests/models_myokit/model-0.mmt b/tests/models_myokit/model-0.mmt new file mode 100644 index 0000000..e717a94 --- /dev/null +++ b/tests/models_myokit/model-0.mmt @@ -0,0 +1,54 @@ +[[model]] +name: Beattie-2017-IKr +author: Michael Clerx +desc: Kylie's model as imported from the Mex file +# Initial values +ikr.y1 = 0 +ikr.y2 = 0 +ikr.y3 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p9 * y3 * (V - nernst.EK) +y4 = 1 - y1 - y2 - y3 +k12 = p1 * exp( p2 * V) +k21 = p3 * exp(-p4 * V) +k41 = p5 * exp( p6 * V) +k14 = p7 * exp(-p8 * V) +dot(y1) = -(k12 + k14) * y1 + k21 * y2 + k41 * y4 +dot(y2) = -(k14 + k21) * y2 + k41 * y3 + k12 * y1 +dot(y3) = -(k21 + k41) * y3 + k12 * y4 + k14 * y2 + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.44e-5 [1/ms] +p4 = 0.0546 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params = 9 + diff --git a/tests/models_myokit/model-1.mmt b/tests/models_myokit/model-1.mmt new file mode 100644 index 0000000..39d1ce6 --- /dev/null +++ b/tests/models_myokit/model-1.mmt @@ -0,0 +1,44 @@ +[[model]] +name: model-1 +author: Sanmitra Ghosh +desc: Check associated model deifintion document +# Initial values +ikr.O = 0 + + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p5 * O * (V - nernst.EK) +k12 = p1 * exp( p2 * V) +k21 = p3 * exp(-p4 * V) +dot(O) = k12 * (1-O) - k21*O + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] + +p5 = 0.15240 [mS/uF] + +n_params = 5 \ No newline at end of file diff --git a/tests/models_myokit/model-10.mmt b/tests/models_myokit/model-10.mmt new file mode 100644 index 0000000..bdcb019 --- /dev/null +++ b/tests/models_myokit/model-10.mmt @@ -0,0 +1,64 @@ +[[model]] +name: model-10 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C1 = 0 +ikr.Om = 0 +ikr.h = 0#5.202995292628385e-06 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p13 * O * (V - nernst.EK) +C2 = 1 -(Om+C1) +O = Om*h +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) + +h_inf = ah/(ah + bh) +tauh = 1/(ah + bh) + +dot(C1) = b2*Om + a1*C2 - C1*(a2 +b1) +dot(Om) = a2*C1 - b2*Om +dot(h) = (h_inf - h)/tauh + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.08730 [1/ms] +p10 = 8.91e-3 [1/mV] +p11 = 5.15e-3 [1/ms] +p12 = 0.03158 [1/mV] +p13 = 0.15240 [mS/uF] + +n_params = 13 + diff --git a/tests/models_myokit/model-11.mmt b/tests/models_myokit/model-11.mmt new file mode 100644 index 0000000..4f6a92a --- /dev/null +++ b/tests/models_myokit/model-11.mmt @@ -0,0 +1,82 @@ +[[model]] +name: model-11 +author: Sanmitra Ghosh +desc: Check associated model deifintion document +# Initial values +ikr.C2 = 1 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# MODEL +# a4 a3 +# IC2 <==> IC1 <==> I +# || b4* || b3* || +# bh||ah bh||ah bh||ah +# || a2 || a1 || +# C2 <==> C1 <==> O +# b2 b1 +# +[ikr] +use membrane.V +IKr = p17 * O * (V - nernst.EK) + +IC2 = 1 - (C1 + C2 + O + I + IC1) + +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) +a3 = p13 * exp( p14 * V) +b3 = (a3*b1)/a1 +a4 = p15 * exp(p16* V) +b4 = (a4*b2)/a2 + +dot(C2) = ah*IC2 + b2*C1 - C2*(a2 + bh) +dot(C1) = ah*IC1 + b1*O + a2*C2 -C1*(a1+bh+b2) +dot(O) = ah*I + a1*C1 - O*(bh+b1) +dot(I) = bh*O + a3* IC1 - I*(ah+b3) +dot(IC1) = b3*I + a4*IC2 + bh*C1 - IC1*(a3 + ah + b4) + + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 0.15240 [mS/uF] + +n_params = 17 + diff --git a/tests/models_myokit/model-12.mmt b/tests/models_myokit/model-12.mmt new file mode 100644 index 0000000..4051862 --- /dev/null +++ b/tests/models_myokit/model-12.mmt @@ -0,0 +1,77 @@ +[[model]] +name: model-12 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C2 = 1 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# MODEL +# 2am am +# IC2 <==> IC1 <==> I +# || bm || 2bm || +# b3*||a3 b2*||a2 b1||a1 +# || 2am || am || +# C2 <==> C1 <==> O +# bm 2bm +# +[ikr] +use membrane.V +IKr = p13 * O * (V - nernst.EK) + +IC2 = 1 - (C1 + C2 + O + I + IC1) + +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 + +dot(C2) = b3*IC2 + bm*C1 - C2*(a3 + 2*am) +dot(C1) = b2*IC1 + 2*bm*O + 2*am*C2 -C1*(am + bm + a2) +dot(O) = b1*I + am*C1 -O*(a1+2*bm) +dot(I) = a1*O + am* IC1 - I*(b1 + 2*bm) +dot(IC1) = 2*bm*I + 2*am*IC2 + a2*C1 - IC1*(am + bm + b2) + + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.15240 [mS/uF] + +n_params = 13 + diff --git a/tests/models_myokit/model-13.mmt b/tests/models_myokit/model-13.mmt new file mode 100644 index 0000000..08d125d --- /dev/null +++ b/tests/models_myokit/model-13.mmt @@ -0,0 +1,88 @@ +[[model]] +name: model-13 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C2 = 1 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + + +# +[ikr] +use membrane.V +IKr = p25 * O * (V - nernst.EK) + +IC2 = 1 - (C1 + C2 + O + I + IC1) + +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) + +dot(C2) = b5*IC2 + b1*C1 - C2*(a1 + a5) +dot(C1) = b4*IC1 + b2*O + a1*C2 -C1*(a4 + b1 + a2) +dot(O) = b3*I + a2*C1 - O*(a3+b2) +dot(I) = a3*O + a7* IC1 - I*(b3 + b7) +dot(IC1) = b7*I + a6*IC2 + a4*C1 - IC1*(a7 + b4 + b6) + + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 2.26e-4 [1/ms] +p14 = 0.06990 [1/mV] +p15 = 3.45e-5 [1/ms] +p16 = 0.05462 [1/mV] +p17 = 0.08730 [1/ms] +p18 = 8.91e-3 [1/mV] +p19 = 5.15e-3 [1/ms] +p20 = 0.03158 [1/mV] +p21 = 2.26e-4 [1/ms] +p22 = 0.06990 [1/mV] +p23 = 3.45e-5 [1/ms] +p24 = 0.05462 [1/mV] +p25 = 0.15240 [mS/uF] + +n_params = 25 + + diff --git a/tests/models_myokit/model-14.mmt b/tests/models_myokit/model-14.mmt new file mode 100644 index 0000000..f23ce83 --- /dev/null +++ b/tests/models_myokit/model-14.mmt @@ -0,0 +1,57 @@ +[[model]] +name: model-14 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 1 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p9 * O * (V - nernst.EK) +I = 1 - (O + C1 + C2 + C3) + +am = p1 * exp( p2 * V) +bm = p3 * exp(-p4 * V) +b1 = p5 * exp( p6 * V) +a1 = p7 * exp(-p8 * V) + + +dot(C1) = 3*bm * O + 2*am * C2 -C1*(am + 2*bm) +dot(C2) = 2*bm * C1 + 3*am * C3 - C2*(2*am + bm) +dot(C3) = bm * C2 - 3*am * C3 +dot(O) = a1 * I + am * C1 - O*(b1 + 3*bm) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params = 9 diff --git a/tests/models_myokit/model-15.mmt b/tests/models_myokit/model-15.mmt new file mode 100644 index 0000000..3b121f6 --- /dev/null +++ b/tests/models_myokit/model-15.mmt @@ -0,0 +1,69 @@ +[[model]] +name: model-15 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 1 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p17 * O * (V - nernst.EK) +I = 1 - (O + C1 + C2 + C3) + +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) + + +dot(C1) = b3 * O + a2 * C2 -C1*(a3 + b2) +dot(C2) = b2 * C1 + a1 * C3 - C2*(a2 + b1) +dot(C3) = b1 * C2 - a1 * C3 +dot(O) = b4 * I + a3 * C1 - O*(a4 + b3) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 0.15240 [mS/uF] + +n_params = 17 diff --git a/tests/models_myokit/model-16.mmt b/tests/models_myokit/model-16.mmt new file mode 100644 index 0000000..2489967 --- /dev/null +++ b/tests/models_myokit/model-16.mmt @@ -0,0 +1,66 @@ +[[model]] +name: model-16 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 1 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# Wang et al. 1997 Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p15 * O * (V - nernst.EK) +I = 1 - (O + C1 + C2 + C3) +a1 = p1 * exp( p2 * V) +b1 = p3 * exp(-p4 * V) +a3 = p5 * exp( p6 * V) +b3 = p7 * exp(-p8 * V) +a4 = p9 * exp( p10 * V) +b4 = p11 * exp(-p12 * V) +a2 = p13 +b2 = p14 + +dot(C1) = b3 * O + a2 * C2 -(a3 + b2) * C1 +dot(C2) = b2 * C1 + a1 * C3 - (a2 +b1) * C2 +dot(C3) = b1 * C2 - a1 * C3 +dot(O) = b4 * I + a3 * C1 - (a4 + b3) * O + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.08730 [1/ms] +p10 = 8.91e-3 [1/mV] +p11 = 5.15e-3 [1/ms] +p12 = 0.03158 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 0.15240 [mS/uF] + +n_params = 15 diff --git a/tests/models_myokit/model-17.mmt b/tests/models_myokit/model-17.mmt new file mode 100644 index 0000000..4ea03b2 --- /dev/null +++ b/tests/models_myokit/model-17.mmt @@ -0,0 +1,60 @@ +[[model]] +name: model-17 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 1 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p11 * O * (V - nernst.EK) +I = 1 - (O + C1 + C2 + C3) + +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) +b2 = (a2*3*bm*b1)/(am*a1) + +dot(C3) = bm * C2 - 3*am * C3 +dot(C2) = 2*bm * C1 + 3*am * C3 - C2*(2*am + bm) +dot(C1) = 3*bm * O + 2*am * C2 + b2*I -C1*(am + 2*bm + a2) +dot(O) = b1 * I + am * C1 - O*(a1 + 3*bm) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 5.15e-3 [1/ms] +p10 = 0.03158 [1/mV] +p11 = 0.15240 [mS/uF] + +n_params = 11 diff --git a/tests/models_myokit/model-18.mmt b/tests/models_myokit/model-18.mmt new file mode 100644 index 0000000..dc12305 --- /dev/null +++ b/tests/models_myokit/model-18.mmt @@ -0,0 +1,72 @@ +[[model]] +name: model-18 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 1 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p19 * O * (V - nernst.EK) +I = 1 - (O + C1 + C2 + C3) + +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) +a5 = p17 * exp(p18 * V) +b5 = (a5*b3*b4)/(a3*a4) + +dot(C3) = +b1*C2 - a1*C3 +dot(C2) = +b2*C1 + a1*C3 - C2*(a2 + b1) +dot(C1) = +b3*O + a2*C2 + b5*I - C1*(a3 + b2 + a5) +dot(O) = +b4*I + a3*C1 - O*(b3 + a4) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 5.15e-3 [1/ms] +p10 = 0.03158 [1/mV] +p11 = 2.26e-4 [1/ms] +p12 = 0.06990 [1/mV] +p13 = 3.45e-5 [1/ms] +p14 = 0.05462 [1/mV] +p15 = 0.08730 [1/ms] +p16 = 8.91e-3 [1/mV] +p17 = 5.15e-3 [1/ms] +p18 = 0.03158 [1/mV] +p19 = 0.15240 [mS/uF] + +n_params = 19 diff --git a/tests/models_myokit/model-19.mmt b/tests/models_myokit/model-19.mmt new file mode 100644 index 0000000..6fb0c19 --- /dev/null +++ b/tests/models_myokit/model-19.mmt @@ -0,0 +1,60 @@ +[[model]] +name: model-19 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.m = 0#7.421666396065612e-06 +ikr.h = 0#5.202995292628385e-06 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p9 * O * (V - nernst.EK) + +O = m*m*m*h +am = p1 * exp(p2*V) +bm = p3 * exp(-p4*V) +bh = p5 * exp(p6*V) +ah = p7 * exp(-p8*V) + +m_inf = am/(am + bm) +taum = 1/(am + bm) +h_inf = ah/(ah + bh) +tauh = 1/(ah + bh) + +dot(m) = (m_inf - m)/taum +dot(h) = (h_inf - h)/tauh + + + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params = 9 + diff --git a/tests/models_myokit/model-2.mmt b/tests/models_myokit/model-2.mmt new file mode 100644 index 0000000..10bfd09 --- /dev/null +++ b/tests/models_myokit/model-2.mmt @@ -0,0 +1,52 @@ +[[model]] +name: model-2 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.O = 0 +ikr.C = 1 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + + +[ikr] +use membrane.V +IKr = p9 * O * (V - nernst.EK) +I = 1 - (O + C) +am = p1 * exp( p2 * V) +bm = p3 * exp(-p4 * V) +b = p5 * exp( p6 * V) +a = p7 * exp(-p8 * V) + +dot(O) = -(bm+b)*O + am*C + a*I +dot(C) = -am*C + bm*O + + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params = 9 + diff --git a/tests/models_myokit/model-20.mmt b/tests/models_myokit/model-20.mmt new file mode 100644 index 0000000..87b7a20 --- /dev/null +++ b/tests/models_myokit/model-20.mmt @@ -0,0 +1,74 @@ +[[model]] +name: model-20 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C2 = 0 +ikr.C1 = 0 +ikr.Om = 0 +ikr.h = 0 #5.202995292628385e-06 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p17 * O * (V - nernst.EK) +O = Om*h + + +C3 = 1 - (Om + C1 + C2) +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) +a3 = p13 * exp(p14*V) +b3 = p15 * exp(-p16*V) + +h_inf = ah/(ah + bh) +tauh = 1/(ah + bh) + +dot(C2) = b2*C1 + a1*C3 - C2*(a2 +b1) +dot(C1) = b3*Om + a2*C2 - C1*(a3 +b2) +dot(Om) = a3*C1 - b3*Om +dot(h) = (h_inf - h)/tauh + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.08730 [1/ms] +p10 = 8.91e-3 [1/mV] +p11 = 5.15e-3 [1/ms] +p12 = 0.03158 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 0.15240 [mS/uF] + +n_params = 17 + diff --git a/tests/models_myokit/model-21.mmt b/tests/models_myokit/model-21.mmt new file mode 100644 index 0000000..4e4c6eb --- /dev/null +++ b/tests/models_myokit/model-21.mmt @@ -0,0 +1,88 @@ +[[model]] +name: model-21 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 1 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 +ikr.IC2 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p23 * O * (V - nernst.EK) + +IC3 = 1 - (C1 + C2 + C3 + O + I + IC1 + IC2) + +ah = p1 * exp( p2 * V) +bh = p3 * exp(-p4 * V) +a1 = p5 * exp( p6 * V) +b1 = p7 * exp(-p8 * V) +a2 = p9 * exp( p10 * V) +b2 = p11 * exp(-p12* V) +a3 = p13 * exp( p14 * V) +b3 = p15 * exp(-p16 * V) +a4 = p17 * exp(p18* V) +b4 = (a4*b1)/a1 +a5 = p19 * exp(p20 * V) +b5 = (a5*b2)/a2 +a6 = p21 * exp(p22 * V) +b6 = (a6*b3)/a3 + +dot(C3) = b1*C2 + bh*IC3 - C3*(a1 + ah) +dot(C2) = b2*C1 + a1*C3 +bh*IC2 - C2*(a2 + b1 + ah) +dot(C1) = b3*O + a2*C2 + bh*IC1 - C1*(a3 + b2 + ah) +dot(O) = bh*I + a3*C1 - O*(b3 + ah) +dot(I) = ah*O + a6*IC1 - I*(bh + b6) +dot(IC1) = b6*I + a5*IC2 + ah*C1 - IC1*(a6 + bh + b5) +dot(IC2) = b5*IC1 + a4*IC3 + ah*C2 - IC2*(a5 + bh + b4) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 0.08730 [1/ms] +p18 = 8.91e-3 [1/mV] +p19 = 5.15e-3 [1/ms] +p20 = 0.03158 [1/mV] +p21 = 5.15e-3 [1/ms] +p22 = 0.03158 [1/mV] +p23 = 0.15240 [mS/uF] + +n_params = 23 + diff --git a/tests/models_myokit/model-22.mmt b/tests/models_myokit/model-22.mmt new file mode 100644 index 0000000..4df1a60 --- /dev/null +++ b/tests/models_myokit/model-22.mmt @@ -0,0 +1,77 @@ +[[model]] +name: model-22 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 1 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 +ikr.IC2 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p15 * O * (V - nernst.EK) + +IC3 = 1 - (C1 + C2 + C3 + O + I + IC1 + IC2) + +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) +b2 = (a2*b1)/a1 +a3 = p11 * exp( p12* V) +b3 = (a3*b2)/a2 +a4 = p13 * exp( p14 * V) +b4 = (a4*b3)/a3 + +dot(C3) = bm*C2 + b4*IC3 - C3*(a4 + 3*am) +dot(C2) = 2*bm*C1 + 3*am*C3 + b3*IC2 - C2*(a3 + 2*am + bm) +dot(C1) = 3*bm*O + 2*am*C2 + b2*IC1 - C1*(am + 2*bm + a2) +dot(O) = b1*I + am*C1 - O*(3*bm + a1) +dot(I) = a1*O + am*IC1 - I*(b1 + 3*bm) +dot(IC1) = 3*bm*I + 2*am*IC2 + a2*C1 - IC1*(2*bm + am + b2) +dot(IC2) = 2*bm*IC1 + 3*am*IC3 + a3*C2 - IC2*(2*am + b3 + bm) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 0.15240 [mS/uF] + +n_params = 15 + diff --git a/tests/models_myokit/model-23.mmt b/tests/models_myokit/model-23.mmt new file mode 100644 index 0000000..501ee72 --- /dev/null +++ b/tests/models_myokit/model-23.mmt @@ -0,0 +1,107 @@ +[[model]] +name: model-23 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 1 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 +ikr.IC2 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p35 * O * (V - nernst.EK) + +IC3 = 1 - (C1 + C2 + C3 + O + I + IC1 + IC2) + +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) + +dot(C3) = b1*C2 + b7*IC3 - C3*(a1 + a7) +dot(C2) = b2*C1 + a1*C3 +b6*IC2 - C2*(a2 + b1 + a6) +dot(C1) = b3*O + a2*C2 + b5*IC1 - C1*(a3 + b2 + a5) +dot(O) = b4*I + a3*C1 - O*(b3 + a4) +dot(I) = a4*O + a10*IC1 - I*(b4 + b10) +dot(IC1) = b10*I + a9*IC2 + a5*C1 - IC1*(b9 + a10 + b5) +dot(IC2) = b9*IC1 + a8*IC3 + a6*C2 - IC2*(a9 + b8 + b6) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 0.08730 [1/ms] +p18 = 8.91e-3 [1/mV] +p19 = 5.15e-3 [1/ms] +p20 = 0.03158 [1/mV] +p21 = 0.06990 [1/mV] +p22 = 3.45e-5 [1/ms] +p23 = 0.05462 [1/mV] +p24 = 0.08730 [1/ms] +p25 = 8.91e-3 [1/mV] +p26 = 5.15e-3 [1/ms] +p27 = 0.03158 [1/mV] +p28 = 0.08730 [1/ms] +p29 = 8.91e-3 [1/mV] +p30 = 5.15e-3 [1/ms] +p31 = 0.03158 [1/mV] +p32 = 5.15e-3 [1/ms] +p33 = 0.03158 [1/mV] +p34 = 0.03158 [1/mV] +p35 = 0.15240 [mS/uF] + +n_params = 35 + + diff --git a/tests/models_myokit/model-24.mmt b/tests/models_myokit/model-24.mmt new file mode 100644 index 0000000..a194f35 --- /dev/null +++ b/tests/models_myokit/model-24.mmt @@ -0,0 +1,58 @@ +[[model]] +name: model-24 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C4 = 1 +ikr.C3 = 0 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p9 * O * (V - nernst.EK) +I = 1 - (O + C1 + C2 + C3 + C4) + +am = p1 * exp( p2 * V) +bm = p3 * exp(-p4 * V) +a1 = p5 * exp( p6 * V) +b1 = p7 * exp(-p8 * V) + +dot(C4) = bm*C3 - 4*am*C4 +dot(C3) = 2*bm * C2 + 4*am * C4 - C3*(3*am + bm) +dot(C2) = 3*bm * C1 + 3*am * C3 - C2*(2*am + 2*bm) +dot(C1) = 4*bm * O + 2*am * C2 -C1*(am + 3*bm) +dot(O) = b1 * I + am * C1 - O*(a1 + 4*bm) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params = 9 diff --git a/tests/models_myokit/model-25.mmt b/tests/models_myokit/model-25.mmt new file mode 100644 index 0000000..75d7287 --- /dev/null +++ b/tests/models_myokit/model-25.mmt @@ -0,0 +1,76 @@ +[[model]] +name: model-25 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C4 = 1 +ikr.C3 = 0 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p21 * O * (V - nernst.EK) +I = 1 - (O + C1 + C2 + C3 + C4) + +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) +a5 = p17 * exp( p18 * V) +b5 = p19 * exp(-p20 * V) + +dot(C4) = b1 * C3 - a1 * C4 +dot(C3) = b2 * C2 - a1 * C4 - C3*(a2 + b1) +dot(C2) = b3 * C1 + a2 * C3 - C2*(a3 + b2) +dot(C1) = b4 * O + a3 * C2 - C1*(a4 + b3) +dot(O) = b5 * I + a4 * C1 - O*(a5 + b4) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 5.15e-3 [1/ms] +p18 = 0.03158 [1/mV] +p19 = 5.15e-3 [1/ms] +p20 = 0.03158 [1/mV] +p21 = 0.15240 [mS/uF] + +n_params = 21 diff --git a/tests/models_myokit/model-26.mmt b/tests/models_myokit/model-26.mmt new file mode 100644 index 0000000..d82f40d --- /dev/null +++ b/tests/models_myokit/model-26.mmt @@ -0,0 +1,58 @@ +[[model]] +name: model-26 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.m = 0 #7.421666396065612e-06 +ikr.h = 0 #5.202995292628385e-06 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p9 * O * (V - nernst.EK) + +O = m*m*m*m*h +am = p1 * exp(p2*V) +bm = p3 * exp(-p4*V) +bh = p5 * exp(p6*V) +ah = p7 * exp(-p8*V) + +m_inf = am/(am + bm) +taum = 1/(am + bm) +h_inf = ah/(ah + bh) +tauh = 1/(ah + bh) + +dot(m) = (m_inf - m)/taum +dot(h) = (h_inf - h)/tauh + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params = 9 + diff --git a/tests/models_myokit/model-27.mmt b/tests/models_myokit/model-27.mmt new file mode 100644 index 0000000..17bbc4c --- /dev/null +++ b/tests/models_myokit/model-27.mmt @@ -0,0 +1,81 @@ +[[model]] +name: model-27 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C3 = 0 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.Om = 0 +ikr.h = 0 #5.202995292628385e-06 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p21 * O * (V - nernst.EK) + +O = Om*h +C4 = 1 - (Om + C1 + C2 + C3) +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) +a3 = p13 * exp(p14*V) +b3 = p15 * exp(-p16*V) +a4 = p17 * exp(p18*V) +b4 = p19 * exp(-p20*V) + +h_inf = ah/(ah + bh) +tauh = 1/(ah + bh) + +dot(C3) = b3*C2 + a4*C4 - C3*(a3 +b4) +dot(C2) = b2*C1 + a3*C3 - C2*(a2 +b3) +dot(C1) = b1*Om + a2*C2 - C1*(a1 +b2) +dot(Om) = a1*C1 - b1*Om +dot(h) = (h_inf - h)/tauh + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.08730 [1/ms] +p10 = 8.91e-3 [1/mV] +p11 = 5.15e-3 [1/ms] +p12 = 0.03158 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 5.15e-3 [1/ms] +p18 = 0.03158 [1/mV] +p19 = 5.15e-3 [1/ms] +p20 = 0.03158 [1/mV] +p21 = 0.15240 [mS/uF] + +n_params = 21 + diff --git a/tests/models_myokit/model-28.mmt b/tests/models_myokit/model-28.mmt new file mode 100644 index 0000000..6bfbe3d --- /dev/null +++ b/tests/models_myokit/model-28.mmt @@ -0,0 +1,102 @@ +[[model]] +name: model-28 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C4 = 1 +ikr.C3 = 0 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 +ikr.IC2 = 0 +ikr.IC3 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p29 * O * (V - nernst.EK) + +IC4 = 1 - (C1 + C2 + C3 + C4 + O + I + IC1 + IC2 + IC3) + +bh = p1 * exp( p2 * V) +ah = p3 * exp(-p4 * V) +a1 = p5 * exp( p6 * V) +b1 = p7 * exp(-p8 * V) +a2 = p9 * exp( p10 * V) +b2 = p11 * exp(-p12* V) +a3 = p13 * exp( p14 * V) +b3 = p15 * exp(-p16 * V) +a4 = p17 * exp(p18* V) +b4 = (a4*b1)/a1 +a5 = p19 * exp(p20 * V) +b5 = (a5*b2)/a2 +a6 = p21 * exp(p22 * V) +b6 = (a6*b3)/a3 +a7 = p23 * exp(p24 * V) +b7 = p25 * exp(-p26 * V) +a8 = p27 * exp(p28 * V) +b8 = (a8*b7)/a7 + +dot(C4) = ah*IC4 +b7*C3 - C4*(a7+bh) +dot(C3) = b1*C2 + ah*IC3 + a7*C4 - C3*(a1 + bh + b7) +dot(C2) = b2*C1 + a1*C3 +ah*IC2 - C2*(a2 + b1 + bh) +dot(C1) = b3*O + a2*C2 + ah*IC1 - C1*(a3 + b2 + bh) +dot(O) = ah*I + a3*C1 - O*(b3 + bh) +dot(I) = bh*O + a6*IC1 - I*(ah + b6) +dot(IC1) = b6*I + a5*IC2 + ah*C1 - IC1*(a6 + ah + b5) +dot(IC2) = b5*IC1 + a4*IC3 + ah*C2 - IC2*(a5 + ah + b4) +dot(IC3) = a8*IC4 + bh*C3 + b4*IC2 - IC3*(ah + a4 + b8) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 0.08730 [1/ms] +p18 = 8.91e-3 [1/mV] +p19 = 5.15e-3 [1/ms] +p20 = 0.03158 [1/mV] +p21 = 5.15e-3 [1/ms] +p22 = 0.03158 [1/mV] +p23 = 5.15e-3 [1/ms] +p24 = 0.03158 [1/mV] +p25 = 5.15e-3 [1/ms] +p26 = 0.03158 [1/mV] +p27 = 5.15e-3 [1/ms] +p28 = 0.03158 [1/mV] +p29 = 0.15240 [mS/uF] + +n_params = 29 + diff --git a/tests/models_myokit/model-29.mmt b/tests/models_myokit/model-29.mmt new file mode 100644 index 0000000..d0f582c --- /dev/null +++ b/tests/models_myokit/model-29.mmt @@ -0,0 +1,85 @@ +[[model]] +name: model-29 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C4 = 1 +ikr.C3 = 0 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 +ikr.IC2 = 0 +ikr.IC3 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p17 * O * (V - nernst.EK) + +IC4 = 1 - (C1 + C2 + C3 + C4 + O + I + IC1 + IC2 + IC3) + +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) +b2 = (a2*b1)/a1 +a3 = p11 * exp( p12* V) +b3 = (a3*b2)/a2 +a4 = p13 * exp( p14 * V) +b4 = (a4*b3)/a3 +a5 = p15 * exp( p16 * V) +b5 = (a5*b4)/a4 + +dot(C4) = bm*C3 + b5*IC4 - C4*(4*am+a5) +dot(C3) = 2*bm*C2 + 4*am*C4 + b4*IC3 - C3*(a4 + 3*am - bm) +dot(C2) = 3*bm*C1 + 3*am*C3 + b3*IC2 - C2*(a3 + 2*am + 2*bm) +dot(C1) = 4*bm*O + 2*am*C2 + b2*IC1 - C1*(am + 3*bm + a2) +dot(O) = b1*I + am*C1 - O*(4*bm + a1) +dot(I) = a1*O + am*IC1 - I*(b1 + 4*bm) +dot(IC1) = 4*bm*I + 2*am*IC2 + a2*C1 - IC1*(3*bm + am + b2) +dot(IC2) = 3*bm*IC1 + 3*am*IC3 + a3*C2 - IC2*(2*am + b3 + 2*bm) +dot(IC3) = 2*bm*IC2 + 4*am*IC4 + a4*C3 - IC3*(3*am + b4 + bm) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 0.08730 [1/ms] +p16 = 8.91e-3 [1/mV] +p17 = 0.15240 [mS/uF] + +n_params = 17 + diff --git a/tests/models_myokit/model-3.mmt b/tests/models_myokit/model-3.mmt new file mode 100644 index 0000000..fd7ead2 --- /dev/null +++ b/tests/models_myokit/model-3.mmt @@ -0,0 +1,57 @@ +[[model]] +name: model-3 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.m = 0#7.421666396065612e-06 +ikr.h = 0#5.202995292628385e-06 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -88 [mV] + +[ikr] +use membrane.V +IKr = p9 * O * (V - nernst.EK) + +am = p1 * exp(p2*V) +bm = p3 * exp(-p4*V) +ah = p5 * exp(p6*V) +bh = p7 * exp(-p8*V) + +m_inf = am/(am + bm) +taum = 1/(am + bm) +h_inf = bh/(ah + bh) +tauh = 1/(ah + bh) + +O = m*h + +dot(m) = (m_inf - m)/taum +dot(h) = (h_inf - h)/tauh + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params = 9 + diff --git a/tests/models_myokit/model-30.mmt b/tests/models_myokit/model-30.mmt new file mode 100644 index 0000000..b7f0036 --- /dev/null +++ b/tests/models_myokit/model-30.mmt @@ -0,0 +1,127 @@ +[[model]] +name: model-30 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C4 = 1 +ikr.C3 = 0 +ikr.C2 = 0 +ikr.C1 = 0 +ikr.O = 0 +ikr.I = 0 +ikr.IC1 = 0 +ikr.IC2 = 0 +ikr.IC3 = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p45 * O * (V - nernst.EK) + +IC4 = 1 - (C1 + C2 + C3 + C4 + O + I + IC1 + IC2 + IC3) + +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) + +dot(C4) = b13*IC4 + b12*C3 - C4*(a13+a12) +dot(C3) = b1*C2 + a12*C4 + b7*IC3 - C3*(a1 + a7 + b12) +dot(C2) = b2*C1 + a1*C3 + b6*IC2 - C2*(a2 + b1 + a6) +dot(C1) = b3*O + a2*C2 + b5*IC1 - C1*(a3 + b2 + a5) +dot(O) = b4*I + a3*C1 - O*(b3 + a4) +dot(I) = a4*O + a10*IC1 - I*(b4 + b10) +dot(IC1) = b10*I + a9*IC2 + a5*C1 - IC1*(b9 + a10 + b5) +dot(IC2) = b9*IC1 + a8*IC3 + a6*C2 - IC2*(a9 + b8 + b6) +dot(IC3) = b8*IC2 + a11*IC4 + a7*C3 - IC3*(a8 + b7 + b11) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 2.26e-4 [1/ms] +p10 = 0.06990 [1/mV] +p11 = 3.45e-5 [1/ms] +p12 = 0.05462 [1/mV] +p13 = 0.08730 [1/ms] +p14 = 8.91e-3 [1/mV] +p15 = 5.15e-3 [1/ms] +p16 = 0.03158 [1/mV] +p17 = 0.08730 [1/ms] +p18 = 8.91e-3 [1/mV] +p19 = 5.15e-3 [1/ms] +p20 = 0.03158 [1/mV] +p21 = 0.06990 [1/mV] +p22 = 3.45e-5 [1/ms] +p23 = 0.05462 [1/mV] +p24 = 0.08730 [1/ms] +p25 = 8.91e-3 [1/mV] +p26 = 5.15e-3 [1/ms] +p27 = 0.03158 [1/mV] +p28 = 0.08730 [1/ms] +p29 = 8.91e-3 [1/mV] +p30 = 5.15e-3 [1/ms] +p31 = 0.03158 [1/mV] +p32 = 5.15e-3 [1/ms] +p33 = 0.03158 [1/mV] +p34 = 0.03158 [1/mV] +p35 = 8.91e-3 [1/mV] +p36 = 5.15e-3 [1/ms] +p37 = 0.03158 [1/mV] +p38 = 0.08730 [1/ms] +p39 = 8.91e-3 [1/mV] +p40 = 5.15e-3 [1/ms] +p41 = 0.03158 [1/mV] +p42 = 5.15e-3 [1/ms] +p43 = 0.03158 [1/mV] +p44 = 0.03158 [1/mV] +p45 = 0.15240 [mS/uF] + +n_params = 45 + + diff --git a/tests/models_myokit/model-4.mmt b/tests/models_myokit/model-4.mmt new file mode 100644 index 0000000..f289199 --- /dev/null +++ b/tests/models_myokit/model-4.mmt @@ -0,0 +1,60 @@ +[[model]] +name: model-4 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C = 1 +ikr.O = 0 +ikr.I = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p11 * O * (V - nernst.EK) +IC = 1 - (I + O + C) + +a1 = p1 * exp(p2*V) +b1 = p3 * exp(-p4*V) +a4 = p5 * exp(p6*V) +b4 = p7 * exp(-p8*V) +a3 = p9 * exp(-p10*V) +b3 = (a3*a1)/b1 + + +dot(C) = b1*O + b4*IC - C*(a1+a4) +dot(O) = a1*C + b4*I - O*(a4+b1) +dot(I) = a4*O + b3*IC -I*(b4 + a3) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 5.15e-3 [1/ms] +p10 = 0.03158 [1/mV] +p11 = 0.15240 [mS/uF] + +n_params = 11 + diff --git a/tests/models_myokit/model-5.mmt b/tests/models_myokit/model-5.mmt new file mode 100644 index 0000000..9820657 --- /dev/null +++ b/tests/models_myokit/model-5.mmt @@ -0,0 +1,60 @@ +[[model]] +name: model-5 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.C = 1 +ikr.O = 0 +ikr.I = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# +[ikr] +use membrane.V +IKr = p11 * O * (V - nernst.EK) +IC = 1 - (I + O + C) + +am = p1 * exp(p2*V) +bm = p3 * exp(-p4*V) +b1 = p5 * exp(p6*V) +a1 = p7 * exp(-p8*V) +b2 = p9 * exp(p10*V) +a2 = (b2*a1)/b1 + +dot(C) = bm*O + a2*IC - C*(am+b2) +dot(O) = a1*I + am*C - O*(bm+b1) +dot(I) = b1*O + am*IC -I*(a1 + bm) + + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 5.15e-3 [1/ms] +p10 = 0.03158 [1/mV] +p11 = 0.15240 [mS/uF] + +n_params = 11 + diff --git a/tests/models_myokit/model-6.mmt b/tests/models_myokit/model-6.mmt new file mode 100644 index 0000000..9b8c069 --- /dev/null +++ b/tests/models_myokit/model-6.mmt @@ -0,0 +1,66 @@ +[[model]] +name: model-6 +author: Sanmitra Ghosh +desc: Check associated model deifintion document +# Initial values +ikr.C = 1 +ikr.O = 0 +ikr.I = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membane potential + in [mV] + +[nernst] +EK = -88 [mV] + +# +# Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p15 * O * (V - nernst.EK) +IC = 1 - (I + O + C) + +b1 = p1 * exp(p2*V) +a1 = p3 * exp(-p4*V) +a2 = p5 * exp(p6*V) +b2 = p7 * exp(-p8*V) +b3 = p9 * exp(p10*V) +a3 = p11* exp(-p12*V) +a4 = p13* exp(p14*V) +b4 = (b3*b2*a1*a4)/(b1*a2*a3) + +dot(C) = a1*O + b4*IC - C*(b1+a4) +dot(O) = b1*C + b2*I - O*(a2+a1) +dot(I) = a2*O + b3*IC -I*(b2 + a3) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 5.15e-3 [1/ms] +p10 = 0.03158 [1/mV] +p11 = 5.15e-3 [1/ms] +p12 = 0.03158 [1/mV] +p13 = 5.15e-3 [1/ms] +p14 = 0.03158 [1/mV] +p15 = 0.15240 [mS/uF] + +n_params = 15 + diff --git a/tests/models_myokit/model-7.mmt b/tests/models_myokit/model-7.mmt new file mode 100644 index 0000000..7e4e9fc --- /dev/null +++ b/tests/models_myokit/model-7.mmt @@ -0,0 +1,57 @@ +[[model]] +name: model-7 +author: Sanmitra Ghosh +desc: Check associated model defintion document +# Initial values +ikr.C2 = 1 +ikr.C1 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -88 [mV] + +# +# Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p9 * O * (V - nernst.EK) + +I = 1 - (C1 + C2 + O) + +am = p1 * exp( p2 * V) +bm = p3 * exp(-p4 * V) +a1 = p5 * exp( p6 * V) +b1 = p7 * exp(-p8 * V) + + +dot(C2) = bm*C1 - 2*am*C2 +dot(C1) = 2*am*C2 + 2*bm*O - C1*(bm+am) +dot(O) = am*C1 + b1*I -O*(a1 + 2*bm) + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params =9 diff --git a/tests/models_myokit/model-8.mmt b/tests/models_myokit/model-8.mmt new file mode 100644 index 0000000..dc014b2 --- /dev/null +++ b/tests/models_myokit/model-8.mmt @@ -0,0 +1,61 @@ +[[model]] +name: model-8 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.y1 = 1 +ikr.y2 = 0 +ikr.O = 0 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p13 * O * (V - nernst.EK) +y4 = 1 - (y1 + y2 + O) +k12 = p1 * exp( p2 * V) +k21 = p3 * exp(-p4 * V) +k34 = p5 * exp( p6 * V) +k43 = p7 * exp(-p8 * V) +k56 = p9 * exp( p10 * V) +k65 = p11 * exp(-p12 * V) + +dot(y1) = -k12 * y1 + k21 * y2 +dot(y2) = -(k21 + k34) * y2 + k12 * y1 + k43 * O +dot(O) = -(k43 + k56) * O + k34 * y2 + k65 * y4 + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.08730 [1/ms] +p10 = 8.91e-3 [1/mV] +p11 = 5.15e-3 [1/ms] +p12 = 0.03158 [1/mV] +p13 = 0.15240 [mS/uF] + + +n_params = 13 diff --git a/tests/models_myokit/model-9.mmt b/tests/models_myokit/model-9.mmt new file mode 100644 index 0000000..6d95851 --- /dev/null +++ b/tests/models_myokit/model-9.mmt @@ -0,0 +1,61 @@ +[[model]] +name: model-9 +author: Sanmitra Ghosh +desc: Check associated model definition document +# Initial values +ikr.m = 0#7.421666396065612e-06 +ikr.h = 0#5.202995292628385e-06 + +# +# Simulation engine variables +# +[engine] +time = 0 bind time +pace = 0 bind pace + +# +# Membrane potential +# +[membrane] +V = engine.pace + desc: membrane potential + in [mV] + +[nernst] +EK = -85 [mV] + +# +# Model from Kylie's mex file (HH) +# +[ikr] +use membrane.V +IKr = p9 * O * (V - nernst.EK) + +O = m*m*h +am = p1 * exp(p2*V) +bm = p3 * exp(-p4*V) +bh = p5 * exp(p6*V) +ah = p7 * exp(-p8*V) + +m_inf = am/(am + bm) +taum = 1/(am + bm) +h_inf = ah/(ah + bh) +tauh = 1/(ah + bh) + +dot(m) = (m_inf - m)/taum +dot(h) = (h_inf - h)/tauh + + + +p1 = 2.26e-4 [1/ms] +p2 = 0.06990 [1/mV] +p3 = 3.45e-5 [1/ms] +p4 = 0.05462 [1/mV] +p5 = 0.08730 [1/ms] +p6 = 8.91e-3 [1/mV] +p7 = 5.15e-3 [1/ms] +p8 = 0.03158 [1/mV] +p9 = 0.15240 [mS/uF] + +n_params = 9 + diff --git a/tests/models_myokit/simplified-staircase.mmt b/tests/models_myokit/simplified-staircase.mmt new file mode 100644 index 0000000..f15b398 --- /dev/null +++ b/tests/models_myokit/simplified-staircase.mmt @@ -0,0 +1,35 @@ +[[protocol]] +# V start duration period repeats +-80 0 250 0 0 +-120 next 50 0 0 +-120 next 400 0 0 +-80 next 200 0 0 +40 next 1000 0 0 +-120 next 500 0 0 +-80 next 1000 0 0 +-40 next 500 0 0 +-60 next 500 0 0 +-20 next 500 0 0 +-40 next 500 0 0 +0 next 500 0 0 +-20 next 500 0 0 +20 next 500 0 0 +0 next 500 0 0 +40 next 500 0 0 +20 next 500 0 0 +40 next 500 0 0 +0 next 500 0 0 +20 next 500 0 0 +-20 next 500 0 0 +0 next 500 0 0 +-40 next 500 0 0 +-20 next 500 0 0 +-60 next 500 0 0 +-40 next 500 0 0 +-80 next 1000 0 0 +40 next 500 0 0 +-70 next 10 0 0 +-70 next 100 0 0 +-120 next 390 0 0 +-80 next 500 0 0 + diff --git a/tests/test_30_models.py b/tests/test_30_models.py new file mode 100644 index 0000000..6906323 --- /dev/null +++ b/tests/test_30_models.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python3 + +import itertools +import logging +import os +import unittest + +import matplotlib.pyplot as plt +import myokit +import myokit as mk +import networkx as nx +import numpy as np +import sympy as sp + +from markov_builder.models.thirty_models import ( + 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, +) + + +class TestThirtyModels(unittest.TestCase): + + def setUp(self): + """This is run by unittest before the tests in this class are performed. + + Create an output directory (if it doesn't already exist). An + alternative output path can be used by setting the + MARKOVBUILDER_TEST_OUTPUT environment variable + + """ + test_output_dir = os.environ.get('MARKOVBUILDER_TEST_OUTPUT', os.path.join( + 'test_output', self.__class__.__name__)) + if not os.path.exists(test_output_dir): + os.makedirs(test_output_dir) + self.output_dir = test_output_dir + logging.info("outputting to " + test_output_dir) + + self.models = [ + 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 + ] + + self.disconnected_models = [model_09, model_10] + + self.model_indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 30] + + def test_generate_myokit(self): + for model in self.models: + name = model.__name__ + logging.debug(f"initiating {name}") + mc = model() + myokit_model = mc.generate_myokit_model() + myokit.save(os.path.join(self.output_dir, f"{model.__name__}.mmt"), myokit_model) + return + + def test_visualise_graphs(self): + for model in self.models: + name = model.__name__ + logging.debug(f"initiating {name}") + mc = model() + + mc.draw_graph(os.path.join(self.output_dir, f"{name}_graph.html"), + show_parameters=False) + mc.draw_graph(os.path.join(self.output_dir, f"{name}_graph_with_parameters.html"), + show_parameters=True) + + nx.drawing.nx_agraph.write_dot(mc.graph, os.path.join(self.output_dir, + "%s_dotfile.dot" % name)) + + def test_connected(self): + for model in self.models: + name = model.__name__ + logging.debug(f"initiating {name}") + + mc = model() + self.assertTrue(mc.is_connected() ^ (model in self.disconnected_models)) + + def test_reversible(self): + for model in self.models: + name = model.__name__ + logging.debug(f"initiating {name}") + + if model in self.disconnected_models: + continue + + mc = model() + if not mc.is_reversible(): + undirected_graph = mc.graph.to_undirected(reciprocal=False, as_view=True) + cycle_basis = nx.cycle_basis(undirected_graph) + + for cycle in cycle_basis: + iterator = list(zip(cycle, itertools.islice(cycle, 1, None))) + forward_rate_list = [sp.sympify(mc.graph.get_edge_data(frm, to)['rate']) for frm, to in iterator] + backward_rate_list = [sp.sympify(mc.graph.get_edge_data(frm, to)['rate']) for to, frm in iterator] + + logging.debug(mc.rate_expressions) + + # Substitute in expressions + forward_rate_list = [rate.subs(mc.rate_expressions) for + rate in forward_rate_list] + backward_rate_list = [rate.subs(mc.rate_expressions) for rate in + backward_rate_list] + + forward_rate_product = sp.prod(forward_rate_list) + backward_rate_product = sp.prod(backward_rate_list) + if (forward_rate_product - backward_rate_product).evalf() != 0: + logging.error("Rates moving forwards around the cycle are: %s", forward_rate_list) + logging.error("Rates moving backwards around the cycle are: %s", backward_rate_list) + + self.assertTrue(mc.is_reversible()) + + def test_myokit_simulation_output(self): + mmt_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'models_myokit') + Erev = -88 + + comparison_plot_dir = os.path.join(self.output_dir, 'comparison_plots') + + if not os.path.exists(comparison_plot_dir): + os.makedirs(comparison_plot_dir) + + for i, model in zip(self.model_indices, self.models): + if i is None or model is None: + continue + name = model.__name__ + logging.debug(f"initiating {name}") + + mc = model() + mk_protocol_filename = os.path.join(mmt_dir, + 'simplified-staircase.mmt') + mk_protocol = mk.load_protocol(mk_protocol_filename) + + mk_model = mk.load_model(os.path.join(mmt_dir, + f"model-{i}.mmt")) + + sim = mk.Simulation(mk_model, mk_protocol) + sim.set_tolerance(1e-9, 1e-9) + sim.set_constant('nernst.EK', Erev) + + tmax = mk_protocol.characteristic_time() + times = np.linspace(0, tmax, int(tmax) + 1) + sim.pre(5000) + + log = sim.run(tmax, log_times=times, log=['ikr.IKr']) + + mk_IKr = np.array(log['ikr.IKr']) + + generated_mk_model = mc.generate_myokit_model() + + sim = mk.Simulation(generated_mk_model, mk_protocol) + sim.set_tolerance(1e-9, 1e-9) + sim.set_constant('markov_chain.E_Kr', Erev) + sim.pre(5000) + + log = sim.run(tmax, log_times=times, log=['markov_chain.I_Kr']) + gen_mk_IKr = np.array(log['markov_chain.I_Kr']) + + fig = plt.figure(figsize=(12, 9)) + fig.gca().plot(times[:-1], mk_IKr, label='original myokit simulation') + fig.gca().plot(times[:-1], gen_mk_IKr, label='generated markov_builder simulation') + + fig.gca().legend() + + fig.savefig(os.path.join(comparison_plot_dir, + f"{name}_myokit_comparison")) + + error = np.sqrt(np.mean((gen_mk_IKr - mk_IKr)**2)) + self.assertLess(error, 1e-2) + + +if __name__ == "__main__": + logging.getLogger().setLevel(logging.DEBUG) + unittest.main() diff --git a/tests/test_MarkovChain.py b/tests/test_MarkovChain.py index e4bef52..4eef5ef 100644 --- a/tests/test_MarkovChain.py +++ b/tests/test_MarkovChain.py @@ -23,8 +23,9 @@ def setUp(self): MARKOVBUILDER_TEST_OUTPUT environment variable """ - test_output_dir = os.environ.get('MARKOVBUILDER_TEST_OUTPUT', os.path.join( - 'test_output', os.path.dirname(os.path.abspath(__file__)), self.__class__.__name__)) + test_output_dir = os.environ.get('MARKOVBUILDER_TEST_OUTPUT', os.path.join('test_output', + os.path.dirname(os.path.abspath(__file__)), + self.__class__.__name__)) if not os.path.exists(test_output_dir): os.makedirs(test_output_dir) @@ -85,7 +86,6 @@ def test_construct_examples(self): name), show_parameters=True) nx.drawing.nx_agraph.write_dot(mc.graph, "%s_dotfile.dot" % name) - nx.drawing.nx_agraph.write_dot(mc.graph, "%s_dotfile.dot" % name) def test_parameterise_rates_no_default(self): """Test parameterise rates using a dictionary with no default parameter values. @@ -101,7 +101,7 @@ def test_parameterise_rates_no_default(self): 'k_4': negative_rate_expr, } - mc.parameterise_rates(rate_dictionary, shared_variables=('V',)) + mc.parameterise_rates(rate_dictionary, shared_variables={'V': 'V'}) def test_myokit_output(self): """