model_egfr_net = sbmlimport('egfr_net.xml');
clean_ssa_sbml_model(model_egfr_net)
cs = getconfigset(model_egfr_net);
cs.SolverType = 'ssa';
cs.StopTime = 100.0;
[t, x, names] = sbiosimulate(model_egfr_net);
function [] = clean_ssa_sbml_model(model)
parameters = sbioselect(model, 'Type', 'parameter');
for paramIndex = 1:numel(parameters)
parameter = parameters(paramIndex);
[~, usageTable] = findUsages(parameter);
if isempty(usageTable)
continue
end
reactions = usageTable.Component(usageTable.Property == "ReactionRate");
for reactionIndex = 1:numel(reactions)
reaction = reactions(reactionIndex);
oldRate = reaction.ReactionRate;
kineticLaw = reaction.KineticLaw;
if isempty(kineticLaw)
kineticLaw = addkineticlaw(reaction, 'MassAction');
else
kineticLaw.KineticLawName = 'MassAction';
end
kineticLaw.ParameterVariableNames = parameter.Name;
newRate = reaction.ReactionRate;
if ~strcmp(oldRate, newRate)
warning("Reaction rate for reaction %s changed from %s to %s.", ...
reaction.Name, oldRate, newRate);
end
end
end
end