say I have a list of strings representing equations
['', '-protein_0*Kdeg_protein_0+mRNA_0*Ktrans_0',
'-mRNA_0*Kdeg_mRNA_0+gene_0*Kprod_0', '+mRNA_0*Kdeg_mRNA_0+protein_0*Kdeg_protein_0']
a dictionary with parameter values as floats
{'Kdeg_protein_0': 0.5865674906323503, 'Kdeg_mRNA_0': 0.873345564768431, 'Kprod_0': 13.403565061372824, 'Ktrans_0': 10.37622098808632}
and a dictionary of states
{'Bin': 'y[3]', 'gene_0': 'y[0]', 'mRNA_0': 'y[2]', 'protein_0': 'y[1]'}
I want to get it into the form such that it can be solved by scipy integrate.odeint something like
def ODEs(y,t,input_1,input_2,input_3):
Equations = input_1
Parameters = input_2
States = input_3
for key,value in Parameters.items():
exec(key + '=value')
for key,value in States.items():
exec(key + '=value')
for i in range(len(Equations)):
Equations[i] = eval(Equations[i])
return Equations
def main():
t = numpy.linspace(0,24,24*60)
y0 = [10,0,0,0]
y = integrate.odeint(ODEs,y0,t,(GG,PP,LL),)
print y
I havent been able to work it out, any suggestions to solve this or another approach, it is imperative that the initial data is in list or dictionary form containing strings
at the moment im getting this error: bad operand type for unary +: 'str' for the equations being evaluated