You can retrieve the sate of a tellurium model. You can edit that state but you can't save the state back.
(possible related to #25)
Model:
model_string = '''
//Equations
J01: A -> B; k01*A;
J02: B -> A; k02*B;
//Parameters
k01 = 0.1;
k02 = 0.1;
//Initial Conditions
A = 1;
B = 0;
'''
Loaded with;
RRinst = self.add_antimony_to_cell(model_string=model_string, model_name='ts', cell=cell, step_size=0.1 )
Then;
state = cell.sbml.ts
print(state)
returns:
<roadrunner.ExecutableModel() { this = 000002B5850462D0 }>
But
print(dir(state))
returns:
['INTEGRATION', 'OPTIMIZE_REACTION_RATE_SELECTION', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__weakref__', 'applyEvents', 'getAllTimeCourseComponentIds', 'getAssignmentRuleIds', 'getBoundarySpeciesAmounts', 'getBoundarySpeciesConcentrationIds', 'getBoundarySpeciesConcentrations', 'getBoundarySpeciesId', 'getBoundarySpeciesIds', 'getBoundarySpeciesInitAmounts', 'getBoundarySpeciesInitConcentrations', 'getCompartmentId', 'getCompartmentIds', 'getCompartmentIndexForBoundarySpecies', 'getCompartmentIndexForFloatingSpecies', 'getCompartmentInitVolumes', 'getCompartmentVolumes', 'getConservedMoietyId', 'getConservedMoietyIds', 'getConservedMoietyValues', 'getCurrentStoichiometryMatrix', 'getEvent', 'getEventId', 'getEventIds', 'getEventIndex', 'getEventListener', 'getEventRoots', 'getExecutableModelDesc', 'getFlags', 'getFloatingSpeciesAmountRate', 'getFloatingSpeciesAmounts', 'getFloatingSpeciesConcentrationIds', 'getFloatingSpeciesConcentrationRates', 'getFloatingSpeciesConcentrations', 'getFloatingSpeciesId', 'getFloatingSpeciesIds', 'getFloatingSpeciesInitAmountIds', 'getFloatingSpeciesInitAmounts', 'getFloatingSpeciesInitConcentrationIds', 'getFloatingSpeciesInitConcentrations', 'getGlobalParameterId', 'getGlobalParameterIds', 'getGlobalParameterInitValues', 'getGlobalParameterValues', 'getIds', 'getInfo', 'getInitialAssignmentIds', 'getModelName', 'getNumBoundarySpecies', 'getNumCompartments', 'getNumConservedMoieties', 'getNumDepFloatingSpecies', 'getNumEvents', 'getNumFloatingSpecies', 'getNumGlobalParameters', 'getNumIndFloatingSpecies', 'getNumRateRules', 'getNumReactions', 'getRandom', 'getRandomSeed', 'getRateRuleIds', 'getRateRuleRates', 'getRateRuleSymbols', 'getReactionIds', 'getReactionRates', 'getStateVectorId', 'getStoichiometry', 'getSupportedIdTypes', 'getTime', 'getValue', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'reset', 'setBoundarySpeciesAmounts', 'setBoundarySpeciesConcentrations', 'setBoundarySpeciesInitAmounts', 'setBoundarySpeciesInitConcentrations', 'setCompartmentInitVolumes', 'setCompartmentVolumes', 'setConservedMoietyValues', 'setEventListener', 'setFlags', 'setFloatingSpeciesAmounts', 'setFloatingSpeciesConcentrations', 'setFloatingSpeciesInitAmounts', 'setFloatingSpeciesInitConcentrations', 'setGlobalParameterInitValues', 'setGlobalParameterValues', 'setIntegrationStartTime', 'setRandomSeed', 'setTime', 'setValue', 'this', 'thisown', 'values']
But the below fails
self.set_sbml_state(model_name='ts', cell=cell, state=state) # this fails
returns:
Error: A new SelectionRecord should not have this value: SelectionRecord({'index' : -1, 'p1' : 'A', 'p2' : '', 'selectionType' : UNKNOWN})
Traceback (most recent call last):
File "C:\CompuCell3D\Miniconda3\envs\cc3d\lib\site-packages\cc3d\CompuCellSetup\sim_runner.py", line 79, in run_cc3d_project
exec(code, globals(), locals())
File "C:\Users\jsluka\OneDrive - Indiana University\Desktop\Jims Compucell\Gillespie_demo\Gillespie_demo\Simulation\Gillespie_demo.py", line 6, in
CompuCellSetup.run()
File "C:\CompuCell3D\Miniconda3\envs\cc3d\lib\site-packages\cc3d\CompuCellSetup\simulation_setup.py", line 160, in run
main_loop_fcn(simulator, simthread=simthread, steppable_registry=steppable_registry)
File "C:\CompuCell3D\Miniconda3\envs\cc3d\lib\site-packages\cc3d\player5\Simulation\main_loops.py", line 39, in main_loop_player
steppable_registry.start()
File "C:\CompuCell3D\Miniconda3\envs\cc3d\lib\site-packages\cc3d\core\SteppableRegistry.py", line 123, in start
steppable.start()
File "C:\Users\jsluka\OneDrive - Indiana University\Desktop\Jims Compucell\Gillespie_demo\Gillespie_demo\Simulation\Gillespie_demoSteppables.py", line 99, in start
self.set_sbml_state(model_name='ts', cell=cell, state=state) # this fails
File "C:\CompuCell3D\Miniconda3\envs\cc3d\lib\site-packages\cc3d\core\SBMLSolverHelper.py", line 1224, in set_sbml_state
for name, value in state.items():
File "C:\CompuCell3D\Miniconda3\envs\cc3d\lib\site-packages\roadrunner\roadrunner.py", line 1898, in items
return [(k, self.getValue(k)) for k in self.keys(types)]
File "C:\CompuCell3D\Miniconda3\envs\cc3d\lib\site-packages\roadrunner\roadrunner.py", line 1898, in
return [(k, self.getValue(k)) for k in self.keys(types)]
File "C:\CompuCell3D\Miniconda3\envs\cc3d\lib\site-packages\roadrunner\roadrunner.py", line 1125, in getValue
return _roadrunner.ExecutableModel_getValue(self, id)
RuntimeError: Invalid selection '[A]'' for setting value