Location: Yoast_2020 @ c7060d13dd45 / Simulations / Fig6_10_sim.py

Author:
Leyla <noroozbabaee@gmail.com>
Date:
2021-11-17 16:24:01+13:00
Desc:
The final update of Yoast-2020.
Permanent Source URI:
https://staging.physiomeproject.org/workspace/7b5/rawfile/c7060d13dd45168e33fb9666440a421f84c24ab1/Simulations/Fig6_10_sim.py

# Author : Leyla Noroozbabaee
# Bioengineering Institute
# The University of Auckland
# Date: 2/11/2021

# To reproduce the data needed for Figure 1A in associated original paper,
# execute this script in the Python console in OpenCOR. This can be done
# with the following commands at the prompt in the OpenCOR Python console:

#  In [1]: cd path/to/folder_this_file_is_in
#  In [2]: run Fig6_sim.py
# The current Python script is able to reproduce all the data related to Figure 6A, B, C,
# To reproduce required data for Figure 6D, run Fig6D_sim.py
# To plot Figure 6, run Plot_Fig6.py in Python console.

import opencor as oc
import numpy as np
import json
f = open('ORAI.json', 'r')
J_ORAI = json.load(f)
f.close()
# for key, value in J_ORAI.items():
#      print(key, '->', value)

simfile = 'Yoast_2020.sedml'
simulation = oc.open_simulation(simfile)
data = simulation.data()

simulation.reset(True)
# # Set constant parameter values
start = 0
end = 197
pointInterval = 0.01
data.set_starting_point(start)
data.set_ending_point(end)
data.set_point_interval(pointInterval)
scale = 0.15
scale_ce = 50

ORAI_HEK_293, ORAI_2_SKO, ORAI_23_DKO,   ORAI_12_DKO, ORAI_1_SKO  = [0,0,0, 0,1]

if ORAI_HEK_293:
    data.constants() [ 'ca/H_ca_c_init' ] = 1
    data.constants() [ 'ca/H_ca_e_init' ] = 1
    prefilename = 'ORAI_HEK'
    data.constants()['ca/J_in/J_in_ORAI'] = scale * J_ORAI["ORAI_HEK"][0]

elif ORAI_2_SKO:
    data.constants() [ 'ca/H_ca_c_init' ] = 1
    data.constants() [ 'ca/H_ca_e_init' ] = 1
    prefilename = 'ORAI2_SKO'
    data.constants()['ca/J_in/J_in_ORAI'] = scale*J_ORAI["ORAI2_SKO"][0]

elif ORAI_23_DKO:
    data.constants() [ 'ca/H_ca_c_init' ] = 1
    data.constants() [ 'ca/H_ca_e_init' ] = 1
    prefilename = 'ORAI23_DKO'
    data.constants()['ca/J_in/J_in_ORAI'] = scale * J_ORAI["ORAI23_DKO"][0]

elif ORAI_12_DKO:
    data.constants() [ 'ca/H_ca_c_init' ] = 0
    data.constants() [ 'ca/H_ca_e_init' ] = 0
    data.constants() [ 'ca/L_ca_c_init' ] = 1
    data.constants() [ 'ca/L_ca_e_init' ] = 1
    prefilename = 'ORAI12_DKO'
    data.constants()['ca/J_in/J_in_ORAI'] = scale*J_ORAI["ORAI12_DKO"][0]

elif ORAI_1_SKO:
    data.constants() [ 'ca/H_ca_c_init' ] = 0
    data.constants() [ 'ca/H_ca_e_init' ] = 0
    data.constants() [ 'ca/L_ca_c_init' ] = 0
    data.constants() [ 'ca/L_ca_e_init' ] = 0
    prefilename = 'ORAI1_SKO'
    data.constants()['ca/J_in/J_in_ORAI'] = scale * J_ORAI["ORAI1_SKO"][0]

else:
    data.constants() [ 'ca/H_ca_c_init' ] = 0
    data.constants() [ 'ca/H_ca_e_init' ] = 0
    data.constants() [ 'ca/L_ca_c_init' ] = 1
    data.constants() [ 'ca/L_ca_e_init' ] = 1
    prefilename = 'ORAI_TKO'
    data.constants()['ca/J_in/off_on'] = 1

data.constants() [ 'ca/delta' ] = 1.5
data.constants() [ 'ca/gamma' ] = 5.5 * scale_ce
data.constants() [ 'ca/J_in/k_e' ] = 200
data.constants() [ 'ca/J_SERCA/k_bar' ] = 0.00001957 / scale_ce ** 2
data.constants() [ 'ca/J_IPR/k_f' ] = 10 / scale_ce
# # Run simulation
simulation.run()
# Access simulation results
results = simulation.results()
# Grab the selected results
varName = np.array(["time", "ca_c", "ca_e"])
vars = np.reshape(varName, (1, 3))
rows = end * 100 + 1
print(rows)
r = np.zeros((rows, len(varName)))

r[:, 0] = results.voi().values()
r[:, 1] = results.states()['ca/ca_c'].values()
r[:, 2] = results.states()['ca/ca_e'].values()
#
# # Save the data
filename = '%s.csv' % prefilename
np.savetxt(filename, vars, fmt='%s', delimiter=",")
with open(filename, "ab") as f:
    np.savetxt(f, r, delimiter=",")
f.close