Location: Incorporation of sarcolemmal calcium transporters into the Shorten et al. (2007) model of skeletal muscle @ afd4d5cb20ec / Fig07.py

Author:
David Nickerson <david.nickerson@gmail.com>
Date:
2020-08-25 16:56:45+12:00
Desc:
finish comment on running the fig 7 script in the console
Permanent Source URI:
https://models.physiomeproject.org/workspace/5c6/rawfile/afd4d5cb20ecdcbc0b10198fe31795520488a34e/Fig07.py

# To reproduce the data needed for Figure 7 in associated Physiome 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 Fig07.py
#
# NOTE: these are very time consuming simulations to perform in the graphical
#       user interface. Running them using the command line client version of
#       OpenCOR is much quicker. In a command window/console, run the following
#
#       $> path/to/opencor/bin/OpenCOR -c PythonShell Fig07.py

import opencor as opencor

# our cache of results to save
header = []
cols = []

# open the SED-ML for this simulation
simulation = opencor.open_simulation("Fig07.sedml")

# reset everything in case we are running interactively and have existing results
simulation.reset(True)

# clear the results
simulation.clear_results()

# loop over desired values for nu_SR
nu_SR_values = [4.875, 15, 25, 35]
for nu_SR in nu_SR_values:
    print("nu_SR = " + str(nu_SR))
    simulation.data().constants()["wal_environment/razumova/nu_SR"] = nu_SR

    # run to steady state
    simulation.data().set_starting_point(0)
    simulation.data().set_ending_point(7200000)
    simulation.data().set_point_interval(1000)
    simulation.run()

    # run simulation we want to save
    simulation.data().set_starting_point(7200000)
    simulation.data().set_ending_point(7300000)
    simulation.data().set_point_interval(1)
    simulation.run()

    # cache the contraction results
    ds = simulation.results().data_store()
    variables = ds.voi_and_variables()
    header.append(nu_SR)
    cols.append(list(variables["wal_environment/razumova/A_2"].values()))

outfile = open("Fig07.csv", 'w')
for i in range(0, len(header)):
    outfile.write(str(header[i]) + ",")
outfile.write("\n")

for i in range(0, len(cols[0])):
    for j in range(0, len(cols)):
        outfile.write(str(cols[j][i]) + ",")
    outfile.write("\n")
outfile.close()