I am setting up a SimBiology model programmatically, but am running into errors adding parameters and setting up reactions. The documentation suggests that parameters can be scoped to specific kinetic laws or to the model (in which case they are available to all kinetic laws and reactions). Since some of my parameters are used in several reactions, I figured it would be good to scope them to the model. However, I get the following error among others:
Error using SBCompiler.SimulationObject/simulate
--> Error reported from KineticLaw Validation:
Cannot find parameter with name ''.
To me this reads as if there is a scoping problem - the kinetic law can't find my parameter. I made the stripped down version of my model below:
test=sbiomodel('test');
Acell=addcompartment(test,'Acell',30,'CapacityUnits','picoliter','ConstantCapacity',false);
cytoplasm=addcompartment(Acell,'cytoplasm',15,'CapacityUnits','picoliter','ConstantCapacity',false);
nucleus=addcompartment(Acell,'nucleus',15,'CapacityUnits','picoliter','ConstantCapacity',false);
B=addspecies(cytoplasm,'B',0,'InitialAmountUnits','molecule');
A=addspecies(nucleus,'A',1943,'InitialAmountUnits','molecule');
gB=addspecies(nucleus,'gB',4,'InitialAmountUnits','molecule');
gB_A=addspecies(nucleus,'gB_A',0,'InitialAmountUnits','molecule');
bB_A=addparameter(test,'bB_A',.1,'ValueUnits','1/(molecule*second)');
ubB_A=addparameter(test,'ubB_A',1.0,'ValueUnits','1/(second)');
deg_A=addparameter(test,'deg_A',0.05,'ValueUnits','1/(second)');
deg_B=addparameter(test,'deg_B',0.005,'ValueUnits','1/(second)');
synth_B=addparameter(test,'synth_B',2,'ValueUnits','1/(second)');
PRODB_A=addreaction(test,'nucleus.gB_A -> cytoplasm.B + nucleus.gB_A','ReactionRate','synth_B*nucleus.gB_A');
BINDgB_A=addreaction(test,'nucleus.gB + nucleus.A <-> nucleus.gB_A','ReactionRate','bB_A*nucleus.gB*nucleus.A - ubB_A*nucleus.gB_A');
DEGA=addreaction(test,'nucleus.A -> null','ReactionRate','deg_A*nucleus.A');
DEGB=addreaction(test,'cytoplasm.B -> null','ReactionRate','deg_B*cytoplasm.B');
kPRODB_A=addkineticlaw(PRODB_A,'MassAction');
kBINDgB_A=addkineticlaw(BINDgB_A,'MassAction');
kDEGA=addkineticlaw(DEGA,'MassAction');
kDEGB=addkineticlaw(DEGB,'MassAction');
cs=getconfigset(test,'active');
cs.SolverType = 'ssa';
cs.StopTime = 50*60;
solver = cs.SolverOptions;
solver.LogDecimation = 10;
cs.CompileOptions.DimensionalAnalysis = false;
When I run this I get several errors:
>> [time,x,names]=sbiosimulate(test);
Error using SBCompiler.SimulationObject/simulate
--> Error reported from KineticLaw Validation:
Cannot find parameter with name ''.
--> Error reported from KineticLaw Validation:
Cannot find parameter with name ''.
--> Error reported from KineticLaw Validation:
Cannot find parameter with name ''.
--> Error reported from KineticLaw Validation:
Cannot find parameter with name ''.
--> Error reported from Expression Validation:
Invalid reaction rate '' for reaction 'nucleus.gB_A -> cytoplasm.B + nucleus.gB_A'. Reaction rates must be valid MATLAB expressions and
cannot end in semicolons, commas, comments ('%' and optional text), or line continuations ('...
--> Error reported from Expression Validation:
Invalid reaction rate '' for reaction 'nucleus.gB + nucleus.A <-> nucleus.geB_A'. Reaction rates must be valid MATLAB expressions and
cannot end in semicolons, commas, comments ('%' and optional text), or line continuations ('...
--> Error reported from Expression Validation:
Invalid reaction rate '' for reaction 'nucleus.A -> null'. Reaction rates must be valid MATLAB expressions and cannot end in semicolons,
commas, comments ('%' and optional text), or line continuations ('...
--> Error reported from Expression Validation:
Invalid reaction rate '' for reaction 'cytoplasm.B -> null'. Reaction rates must be valid MATLAB expressions and cannot end in semicolons,
commas, comments ('%' and optional text), or line continuations ('...
Error in sbiosimulate (line 143)
[t, x] = simobj.simulate(mobj, cs, variants, doses);
I'm quite puzzled as to why the model is incorrectly specified.
One solution is to reorganize everything so that I add a reaction, add a kinetic law, add parameter scoped to that kinetic law, then set the kinetic law constants. But if I do this, how do share a parameter between reactions (not in the stripped down example above, but in my larger model)?