E-Cell4 ode API

class ecell4.ode.ODEFactory

A factory class creating a ODEWorld instance and a ODESimulator instance.

ODEFactory(ODESolverType solver_type=None, Real dt=None, Real abs_tol=None, Real rel_tol=None)

Methods

create_simulator((arg1, arg2) -> ODESimulator) Return a ODESimulator instance.
create_world((arg1=None) -> ODEWorld) Return a ODEWorld instance.
rng((GSLRandomNumberGenerator) -> ODEFactory) Just return self.
create_simulator(arg1, arg2) → ODESimulator

Return a ODESimulator instance.

Parameters:

arg1 : ODEWorld

a world

or

arg1 : ODENetworkModel or NetworkModel

a simulation model

arg2 : ODEWorld

a world

Returns:

ODESimulator:

the created simulator

create_world(arg1=None) → ODEWorld

Return a ODEWorld instance.

Parameters:

arg1 : Real3

The lengths of edges of a ODEWorld created

or

arg1 : str

The path of a HDF5 file for ODEWorld

Returns:

ODEWorld:

the created world

rng(GSLRandomNumberGenerator) → ODEFactory

Just return self. This method is for the compatibility between Factory classes.

class ecell4.ode.ODENetworkModel

A network model class for ODE simulations.

ODENetworkModel(NetworkModel m=None)

Methods

add_reaction_rule(rr) Add a new reaction rule.
add_reaction_rules
has_network_model Return if this model is bound to a Model or not.
list_species Return a list of species, contained in reaction rules in the model.
num_reaction_rules Return a number of reaction rules contained in the model.
ode_reaction_rules(() -> [ODEReactionRule]) Return a list of ODE reaction rules.
reaction_rules(() -> [ODEReactionRule]) Return a list of ODE reaction rules.
update_model Update self to fit the given Model.
add_reaction_rule(rr)

Add a new reaction rule.

Parameters:

rr : ReactionRule or ODEReactionRule

A new reaction rule.

has_network_model()

Return if this model is bound to a Model or not.

list_species()

Return a list of species, contained in reaction rules in the model.

num_reaction_rules()

Return a number of reaction rules contained in the model.

ode_reaction_rules() → [ODEReactionRule]

Return a list of ODE reaction rules.

reaction_rules() → [ODEReactionRule]

Return a list of ODE reaction rules.

update_model()

Update self to fit the given Model.

class ecell4.ode.ODERatelaw

An abstract base class for ratelaws bound to ODEReactionRule.

ODERatelaw()

Methods

as_base Return self as a base class.
as_string “Return a name of the function
to_derivative
as_base()

Return self as a base class. Only for developmental use.

as_string()

“Return a name of the function

class ecell4.ode.ODERatelawCallback

A class for general ratelaws with a callback.

ODERatelawCallback(pyfunc, name)

Methods

as_base Return self as a base class.
as_string “Return a name of the function
get_callback
get_pyfunc
set_callback(pyfunc)
Parameters:
set_name “Set the name of a function
as_base()

Return self as a base class. Only for developmental use.

as_string()

“Return a name of the function

set_callback(pyfunc)
Parameters:

pyfunc : function

A Python function for the callback The function must accept five arguments, and return a velocity. The number of reactants, the number of products, a volume, the current time, and a ODEReactionRule are given as the arguments in this order.

Examples

The following callback represents a simple Michaelis-Menten-like equation:

>>> rl = ODERatelawCallback()
>>> rl.set_callback(lambda r, p, v, t, rr: 2.0 * r[0] * r[1] / (1.0 + r[1]))

Here, we expect that the first reactant is an enzyme, and that the second one is a substrate.

set_name()

“Set the name of a function

class ecell4.ode.ODERatelawMassAction

A class for mass action ratelaws.

ODERatelawMassAction(Real k)

Methods

as_base Return self as a base class.
as_string “Return a name of the function
get_k Return the kinetic rate constant as a float value.
is_available Check if this ratelaw is available or not.
set_k(k) Set a kinetic rate constant.
as_base()

Return self as a base class. Only for developmental use.

as_string()

“Return a name of the function

get_k()

Return the kinetic rate constant as a float value.

is_available()

Check if this ratelaw is available or not. Return True always.

set_k(k)

Set a kinetic rate constant.

Parameters:

k : float

A kinetic rate constant.

class ecell4.ode.ODEReactionRule

A class representing a reaction rule between Species, which accepts at most one rate law to calculate the flux.

ODEReactionRule(rr)

Methods

add_product(sp[, coeff]) Append a product to the end.
add_reactant(sp[, coeff]) Append a reactant to the end.
as_string(() -> str) Return an unicode string describing this object.
get_ratelaw Return a ratelaw
has_ratelaw Return if a ratelaw is bound or not.
is_massaction Return if a mass action ratelaw is bound or not.
k Return the kinetic rate constant as a float value.
products List all products.
products_coefficients(() -> [Integer]) List all coefficients for products.
reactants List all reactants.
reactants_coefficients(() -> [Integer]) List all coefficients for reactants.
set_k(k) Set a kinetic rate constant.
set_product_coefficient(index, coeff) Set a stoichiometry coefficient of a product at the given index.
set_ratelaw(ratelaw_obj) Bind a ratelaw.
set_ratelaw_massaction(ratelaw_obj) Bind a mass action ratelaw.
set_reactant_coefficient(index, coeff) Set a stoichiometry coefficient of a reactant at the given index.
add_product(sp, coeff=None)

Append a product to the end.

Parameters:

sp : Species

A new product.

coeff : Integer

A stoichiometry coefficient.

add_reactant(sp, coeff=None)

Append a reactant to the end.

Parameters:

sp : Species

A new reactant.

coeff : Integer

A stoichiometry coefficient.

as_string() → str

Return an unicode string describing this object.

Returns:

str:

An unicode string describing this object.

get_ratelaw()

Return a ratelaw

has_ratelaw()

Return if a ratelaw is bound or not.

is_massaction()

Return if a mass action ratelaw is bound or not.

k()

Return the kinetic rate constant as a float value.

products()

List all products.

Returns:

list:

A list of product Species.

products_coefficients() → [Integer]

List all coefficients for products.

Returns:

list:

A list of product coefficients.

reactants()

List all reactants.

Returns:

list:

A list of reactant Species.

reactants_coefficients() → [Integer]

List all coefficients for reactants.

Returns:

list:

A list of reactant coefficients.

set_k(k)

Set a kinetic rate constant.

Parameters:

k : float

A kinetic rate constant.

set_product_coefficient(index, coeff)

Set a stoichiometry coefficient of a product at the given index.

Parameters:

index : Integer

An index pointing the target product.

coeff : Integer

A stoichiometry coefficient.

set_ratelaw(ratelaw_obj)

Bind a ratelaw.

Parameters:

ratelaw_obj : ODERatelaw

A ratelaw

set_ratelaw_massaction(ratelaw_obj)

Bind a mass action ratelaw. This will be deprecated soon.

Parameters:

ratelaw_obj : ODERatelawMassAction

A ratelaw

set_reactant_coefficient(index, coeff)

Set a stoichiometry coefficient of a reactant at the given index.

Parameters:

index : Integer

An index pointing the target reactant.

coeff : Integer

A stoichiometry coefficient.

class ecell4.ode.ODESimulator

A class running the simulation with the ode algorithm.

ODESimulator(m, w, solver_type)

Methods

absolute_tolerance Return the absolute tolerance.
check_reaction Return if any reaction occurred at the last step, or not.
dt Return the step interval.
initialize Initialize the simulator.
model Return the model bound.
next_time Return the scheduled time for the next step.
num_steps Return the number of steps.
relative_tolerance Return the relative tolerance.
run(duration, observers) Run the simulation.
set_absolute_tolerance(abs_tol) Set the absolute tolerance.
set_dt(dt) Set a step interval.
set_relative_tolerance(rel_tol) Set the relative tolerance.
set_t(t) Set the current time.
step((upto=None) -> bool) Step the simulation.
t Return the time.
world Return the world bound.
absolute_tolerance()

Return the absolute tolerance.

check_reaction()

Return if any reaction occurred at the last step, or not. This function always returns False.

dt()

Return the step interval.

initialize()

Initialize the simulator.

model()

Return the model bound.

next_time()

Return the scheduled time for the next step.

num_steps()

Return the number of steps.

relative_tolerance()

Return the relative tolerance.

run(duration, observers)

Run the simulation.

Parameters:

duration : Real

a duration for running a simulation.

A simulation is expected to be stopped at t() + duration.

observers : list of Obeservers, optional

observers

set_absolute_tolerance(abs_tol)

Set the absolute tolerance.

Parameters:

abs_tol : Real

an absolute tolerance.

set_dt(dt)

Set a step interval.

Parameters:

dt : Real

a step interval

set_relative_tolerance(rel_tol)

Set the relative tolerance.

Parameters:

rel_tol : Real

an relative tolerance.

set_t(t)

Set the current time.

Parameters:

t : Real

a current time.

step(upto=None) → bool

Step the simulation.

Parameters:

upto : Real, optional

the time which to step the simulation up to

Returns:

bool:

True if the simulation did not reach the given time. When upto is not given, nothing will be returned.

t()

Return the time.

world()

Return the world bound.

class ecell4.ode.ODEWorld

A class representing the World for ODE simulations.

ODEWorld(edge_lengths=None)

Methods

actual_lengths(() -> Real3) Return the actual edge lengths of the world.
add_molecules(sp, num[, shape]) Add some molecules.
as_base Return self as a base class.
bind_to(m) Bind a model.
edge_lengths(() -> Real3) Return edge lengths for the space.
evaluate
get_value((sp) -> Real) Return the value matched to a given species.
get_value_exact((sp) -> Real) Return the value connected to a given species.
has_species((sp) -> bool) Check if the given species is belonging to this.
list_species Return a list of species.
load(filename) Load a HDF5 file to the current state.
new_particle(arg1[, arg2]) Create a new particle.
num_molecules((sp) -> Integer) Return the number of molecules.
num_molecules_exact((sp) -> Integer) Return the number of molecules of a given species.
release_species(sp) Release a value for the given species.
remove_molecules(sp, num) Remove molecules
reserve_species(sp) Reserve a value for the given species.
save(filename) Save the current state to a HDF5 file.
set_t(t) Set the current time.
set_value(sp, value) Set the value of the given species.
set_volume(volume) Set a volume.
t Return the current time.
volume Return a volume.
actual_lengths() → Real3

Return the actual edge lengths of the world. Same as edge_lengths.

add_molecules(sp, num, shape=None)

Add some molecules.

Parameters:

sp : Species

a species of molecules to add

num : Integer

the number of molecules to add

shape : Shape, optional

a shape to add molecules on [not supported yet]

as_base()

Return self as a base class. Only for developmental use.

bind_to(m)

Bind a model.

Parameters:

m : ODENetworkModel or NetworkModel

a model to be bound

edge_lengths() → Real3

Return edge lengths for the space.

get_value(sp) → Real

Return the value matched to a given species.

Parameters:

sp : Species

a pattern whose value you get

Returns:

Real:

the value matched to a given species

get_value_exact(sp) → Real

Return the value connected to a given species.

Parameters:

sp : Species

a species whose value you get

Returns:

Real:

the value connected to a given species

has_species(sp) → bool

Check if the given species is belonging to this.

Parameters:

sp : Species

a species to be checked.

Returns:

bool:

True if the given species is contained.

list_species()

Return a list of species.

load(filename)

Load a HDF5 file to the current state.

Parameters:

filename : str

a file name to be loaded.

new_particle(arg1, arg2=None) -> (ParticleID, Particle)

Create a new particle.

Parameters:

arg1 : Particle

A particle to be placed.

or

arg1 : Species

A species of a particle

arg2 : Real3

A position to place a particle

Returns:

tuple:

A pair of ParticleID and Particle of a new particle

num_molecules(sp) → Integer

Return the number of molecules. A value is rounded to an integer. See set_value also.

Parameters:

sp : Species, optional

a species whose molecules you count

Returns:

Integer:

the number of molecules (of a given species)

num_molecules_exact(sp) → Integer

Return the number of molecules of a given species. A value is rounded to an integer. See get_value_exact also.

Parameters:

sp : Species

a species whose molecules you count

Returns:

Integer:

the number of molecules of a given species

release_species(sp)

Release a value for the given species. This function is mainly for developers.

Parameters:

sp : Species

a species to be released.

remove_molecules(sp, num)

Remove molecules

Parameters:

sp : Species

a species whose molecules to remove

num : Integer

a number of molecules to be removed

reserve_species(sp)

Reserve a value for the given species. Use set_value.

Parameters:

sp : Species

a species to be reserved.

save(filename)

Save the current state to a HDF5 file.

Parameters:

filename : str

a file name to be saved.

set_t(t)

Set the current time.

set_value(sp, value)

Set the value of the given species.

Parameters:

sp : Species

a species whose value you set

value : Real

a value set

set_volume(volume)

Set a volume.

t()

Return the current time.

volume()

Return a volume.