Getting and setting reaction parameters and reactions

[1]:
import sys
sys.path.append('../..')
%matplotlib inline
[2]:
from basico import *

Load model

[3]:
biomod = load_example("LM-test1")

Getting/setting global quantities

It is possible to set:

  • initial_value

  • initial_expression

  • expression

  • status

  • type

[4]:
get_parameters()
[4]:
type unit initial_value initial_expression expression value rate key sbml_id display_name
name
epsilon fixed 0.78 0.78 0.0 ModelValue_0 Values[epsilon]
offset fixed 0.10 0.10 0.0 ModelValue_1 Values[offset]
signal assignment 0.10 [P] * Values[epsilon] + Values[offset] 0.10 NaN ModelValue_2 Values[signal]
[5]:
set_parameters(name= 'offset', initial_value = 50)
[6]:
set_parameters('signal', expression='[P] * Values[epsilon] + Values[offset]')
[7]:
get_parameters()
[7]:
type unit initial_value initial_expression expression value rate key sbml_id display_name
name
epsilon fixed 0.78 0.78 0.0 ModelValue_0 Values[epsilon]
offset fixed 50.00 0.10 0.0 ModelValue_1 Values[offset]
signal assignment 50.00 [P] * Values[epsilon] + Values[offset] 0.10 NaN ModelValue_2 Values[signal]

Getting/setting species (metabolites)

[8]:
get_species()
[8]:
compartment type unit initial_concentration initial_particle_number initial_expression expression concentration particle_number rate particle_number_rate key sbml_id transition_time display_name
name
S compartment reactions mmol/ml 10.000001 6.022142e+21 10.000001 6.022142e+21 -13.000003 -7.828785e+21 Metabolite_0 0.769231 S
E compartment reactions mmol/ml 0.010000 6.022142e+18 0.010000 6.022142e+18 -13.000003 -7.828785e+21 Metabolite_1 0.000769 E
ES compartment reactions mmol/ml 0.000000 0.000000e+00 0.000000 0.000000e+00 13.000003 7.828785e+21 Metabolite_2 0.000000 ES
P compartment reactions mmol/ml 0.000000 0.000000e+00 0.000000 0.000000e+00 0.000000 0.000000e+00 Metabolite_3 NaN P
[9]:
get_species(name = 'E')[['initial_concentration']]
[9]:
initial_concentration
name
E 0.01
ES 0.00

Setting

The following values can be set:

  • name via new_name

  • unit

  • initial_concentration

  • initial_particle_number

  • initial_expression

  • expression

[10]:
set_species(name = 'E', new_name = 'Lilija')
[11]:
set_species(name = 'Lilija', initial_concentration = 123456)
[12]:
get_species(name = 'Lilija')
[12]:
compartment type unit initial_concentration initial_particle_number initial_expression expression concentration particle_number rate particle_number_rate key sbml_id transition_time display_name
name
Lilija compartment reactions mmol/ml 123456.0 7.434694e+25 0.01 6.022142e+18 -13.000003 -7.828785e+21 Metabolite_1 0.000769 Lilija
[13]:
# change it back
set_species(new_name = 'E', name = 'Lilija')

Getting/setting reaction parameters

[14]:
get_reaction_parameters()
[14]:
value reaction type mapped_to
name
(R1).k1 130.0 R1 local
(R1).k2 1.0 R1 local
(R2).k1 1.0 R2 local

For reaction parameters you can change the value of local parameters, and you can map them to global parameters using mapped_to.

[15]:
set_reaction_parameters(name = '(R1).k1', value=123)
[16]:
get_reaction_parameters()
[16]:
value reaction type mapped_to
name
(R1).k1 123.0 R1 local
(R1).k2 1.0 R1 local
(R2).k1 1.0 R2 local

lets demonstrate how to change the mapping. Here i first introduce a new global parameter global1 and assign it to the Reaction 2:

[17]:
add_parameter('global1', value=2.0)
set_reaction_parameters('(R2).k1', mapped_to='global1')
get_reaction_parameters()
[17]:
value reaction type mapped_to
name
(R1).k1 123.0 R1 local
(R1).k2 1.0 R1 local
(R2).k1 1.0 R2 global global1

to remove the mapping, pass None to mapped_to:

[18]:
set_reaction_parameters('(R2).k1', mapped_to=None)
get_reaction_parameters()
[18]:
value reaction type mapped_to
name
(R1).k1 123.0 R1 local
(R1).k2 1.0 R1 local
(R2).k1 1.0 R2 local

Getting/setting reactions

[19]:
get_reactions()
[19]:
scheme flux particle_flux function key sbml_id display_name mapping
name
R1 S + E = ES 13.000003 7.828785e+21 Mass action (reversible) Reaction_0 (R1) {'k1': 123.0, 'substrate': ['S', 'E'], 'k2': 1...
R2 ES -> E + P 0.000000 0.000000e+00 Mass action (irreversible) Reaction_1 (R2) {'k1': 1.0, 'substrate': 'ES'}

Setting scheme

[20]:
set_reaction(name = 'R1', scheme = 'S + E + F = ES')
[21]:
get_reactions()
[21]:
scheme flux particle_flux function key sbml_id display_name mapping
name
R1 S + E + F = ES 13.000003 7.828785e+21 Mass action (reversible) Reaction_0 (R1) {'k1': 123.0, 'substrate': ['S', 'E', 'F'], 'k...
R2 ES -> E + P 0.000000 0.000000e+00 Mass action (irreversible) Reaction_1 (R2) {'k1': 1.0, 'substrate': 'ES'}

Setting reaction name

[22]:
set_reaction(name = 'R1', new_name = 'Reaction 1')
[23]:
get_reactions()
[23]:
scheme flux particle_flux function key sbml_id display_name mapping
name
Reaction 1 S + E + F = ES 13.000003 7.828785e+21 Mass action (reversible) Reaction_0 (Reaction 1) {'k1': 123.0, 'substrate': ['S', 'E', 'F'], 'k...
R2 ES -> E + P 0.000000 0.000000e+00 Mass action (irreversible) Reaction_1 (R2) {'k1': 1.0, 'substrate': 'ES'}

Modifying the mapping

You can change the mapping of a parameter also directly viia dictionary. Lets look at the mapping for Reaction 1:

[24]:
get_reaction_mapping('Reaction 1')
[24]:
{'k1': 123.0, 'substrate': ['S', 'E', 'F'], 'k2': 1.0, 'product': 'ES'}

here you can directly change the value of the parameter k1:

[25]:
d = get_reaction_mapping('Reaction 1')
d['k1'] = 10
set_reaction_mapping('Reaction 1', d)
get_reaction_mapping('Reaction 1')

[25]:
{'k1': 10.0, 'substrate': ['S', 'E', 'F'], 'k2': 1.0, 'product': 'ES'}

or map it to a global parameter:

[26]:
d = get_reaction_mapping('Reaction 1')
d['k1'] = 'global1'
set_reaction_mapping('Reaction 1', d)
get_reaction_mapping('Reaction 1')
[26]:
{'k1': 'global1', 'substrate': ['S', 'E', 'F'], 'k2': 1.0, 'product': 'ES'}

to map it to a value, you simply set the number of the dictionary