- Author:
- Shelley Fong <s.fong@auckland.ac.nz>
- Date:
- 2021-12-16 14:03:37+13:00
- Desc:
- Init
- Permanent Source URI:
- http://models.cellml.org/workspace/7e8/rawfile/3658dba9638e60010e18bef5e63e81168427d9d8/python_cellml_text/write_cellml_script.py
import csv
def read_IDs(path):
data = []
with open(path,'r') as f:
reader = csv.reader(f)
for row in reader:
data.append(row[0])
f.close()
return data
Knames = read_IDs('..\\data\\Kname.txt')
rxnID = read_IDs('..\\data\\rxnID.txt')
rxnID_act = read_IDs('..\\data\\rxnID_act.txt')
rxnID_inh = read_IDs('..\\data\\rxnID_inh.txt')
with open('cellmlscript_temp.txt','w') as c:
for name in rxnID:
c.write('def import using "kraetler_functions.cellml" for\n\
comp f_%s_module using comp f_module;\n\
enddef;\n' %(name))
for name in Knames:
c.write('var %s: mM {init: 0, pub: out};\n' %name)
for name in Knames:
c.write('var tau_%s: second {init: 0, pub: out};\n' %name)
for rx in rxnID:
c.write('var EC50_%s: dimensionless {init: 0.5, pub: out};\n' %rx)
for rx in rxnID:
c.write('var W_%s: dimensionless {init: 1, pub: out};\n' %rx)
for rx in rxnID_act:
c.write('var f_act_%s: dimensionless {pub: in};\n' %rx)
for rx in rxnID_inh:
c.write('var f_inh_%s: dimensionless {pub: in};\n' %rx)
for name in Knames:
c.write('ode(%s, time) = (ppp)/tau_%s;\n' %(name, name))
for rx in rxnID_act:
reactant_name = rx.split('_')[0]
c.write(' def map between env and f_%s_module for\n\
vars W_%s and W;\n\
vars n and n;\n\
vars EC50_%s and EC50;\n\
vars %s and X;\n\
vars f_act_%s and f_act;\n\
enddef;\n' %(rx,rx,rx,reactant_name,rx))
for rx in rxnID_inh:
reactant_name = rx.split('_')[0]
c.write(' def map between env and f_%s_module for\n\
vars W_%s and W;\n\
vars n and n;\n\
vars EC50_%s and EC50;\n\
vars %s and X;\n\
vars f_inh_%s and f_inhib;\n\
enddef;\n' %(rx,rx,rx,reactant_name,rx))