E-Cell4 meso API

class ecell4.meso.MesoscopicFactory

A factory class creating a MesoscopicWorld instance and a MesoscopicSimulator instance.

MesoscopicFactory(matrix_sizes=None, subvolume_length=None)

Methods

create_simulator((arg1, ...) Return a MesoscopicSimulator instance.
create_world((arg1=None) -> MesoscopicWorld) Return a MesoscopicWorld instance.
rng(...) Set a random number generator, and return self.
create_simulator(arg1, arg2) → MesoscopicSimulator

Return a MesoscopicSimulator instance.

Parameters:

arg1 : MesoscopicWorld

A world

or

arg1 : Model

A simulation model

arg2 : MesoscopicWorld

A world

Returns:

MesoscopicSimulator:

the created simulator

create_world(arg1=None) → MesoscopicWorld

Return a MesoscopicWorld instance.

Parameters:

arg1 : Real3

The lengths of edges of a MesoscopicWorld created

or

arg1 : str

The path of a HDF5 file for MesoscopicWorld

Returns:

MesoscopicWorld:

the created world

rng(GSLRandomNumberGenerator) → MesoscopicFactory

Set a random number generator, and return self.

class ecell4.meso.MesoscopicSimulator

A class running the simulation with the meso algorithm.

MesoscopicSimulator(m, w)

Methods

check_reaction Return if any reaction occurred at the last step, or not.
dt Return the step interval.
initialize Initialize the simulator.
last_reactions(() -> [(ReactionRule, ...) Return reactions occuring at the last step.
model Return the model bound.
next_time Return the scheduled time for the next step.
num_steps Return the number of steps.
run(duration, observers) Run the simulation.
set_dt(dt) Set a step interval.
set_t(t) Set the current time.
step((upto=None) -> bool) Step the simulation.
t Return the time.
world Return the world bound.
check_reaction()

Return if any reaction occurred at the last step, or not.

dt()

Return the step interval.

initialize()

Initialize the simulator.

last_reactions() → [(ReactionRule, ReactionInfo)]

Return reactions occuring at the last step.

Returns:

list:

The list of reaction rules and infos.

model()

Return the model bound.

next_time()

Return the scheduled time for the next step.

num_steps()

Return the number of steps.

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_dt(dt)

Set a step interval.

Parameters:

dt : Real

A step interval

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.meso.MesoscopicWorld

A class containing the properties of the meso world.

MesoscopicWorld(edge_lengths=None, matrix_sizes=None, GSLRandomNumberGenerator rng=None)

Methods

actual_lengths(() -> Real3) Return the actual edge lengths of the world.
add_molecules(sp, num[, c]) Add some molecules.
add_structure(sp, shape) Add a structure.
as_base Return self as a base class.
bind_to(m) Bind a model to the world
check_structure((sp, g) -> bool) Check if the given subvolume is belonging to the structure.
coord2global((coord) -> Integer3) Transform a coordinate to a global coordinate.
edge_lengths(() -> Real3) Return the edge lengths of the world.
get_occupancy((sp, g) -> Real) Return the occupancy of the structure in the subvolume.
get_value((sp) -> Real) Return the value (number) corresponding the given Species.
get_value_exact((sp) -> Real) Return the value (number) corresponding the given Species.
get_volume((sp) -> Real) Return a volume of the given structure.
global2coord((g) -> Integer) Transform a global coordinate to a coordinate.
has_structure((sp) -> bool) Return if the given structure is in the space or not.
list_coordinates((sp) -> [Integer]) Return a list of coordinates of molecules belonging to the given species.
list_coordinates_exact((sp) -> [Integer]) Return a list of coordinates of molecules belonging to the given species.
list_particles((sp) -> [(ParticleID, Particle)]) Return the list of particles.
list_particles_exact((sp) -> [(ParticleID, ...) Return the list of particles of a given species.
list_species Return a list of species.
load(filename) Load the world from a file.
matrix_sizes(() -> Integer3) Return the number of subvolumes along axes.
new_particle(arg1[, arg2]) Create a new particle.
num_molecules((sp[, c]) Return the number of molecules within the suggested subvolume.
num_molecules_exact((sp[, c]) Return the number of molecules within the suggested subvolume.
num_subvolumes((sp=None) -> Integer) Return the number of subvolumes.
on_structure((sp, g) -> bool) Check if the given species would be on the proper structure at the coordinate.
position2coordinate((pos) -> Integer) Transform a position to a coordinate.
position2global((pos) -> Integer3) Transform a position to a global coordinate.
remove_molecules(sp, num[, c]) Remove the molecules.
rng Return a random number generator object.
save(filename) Save the world to a file.
set_t(t) Set the value of the time of the world.
set_value(sp, value) Set the value of the given species.
subvolume Return the subvolume of each cell.
subvolume_edge_lengths Return the edge lengths of a subvolume.
t Return the time of the world.
volume Return the volume of the world.
actual_lengths() → Real3

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

add_molecules(sp, num, c=None)

Add some molecules.

Parameters:

sp : Species

a species of molecules to add

num : Integer

the number of molecules to add

c : Integer or Shape, optional

a coordinate or shape to add molecules on

add_structure(sp, shape)

Add a structure.

Parameters:

sp : Species

a species suggesting the shape.

shape : Shape

a shape of the structure.

as_base()

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

bind_to(m)

Bind a model to the world

Parameters:

m : Model

a model to bind

check_structure(sp, g) → bool

Check if the given subvolume is belonging to the structure.

Parameters:

sp : Species

A species for the target structure.

g : Integer3

a global coordinate pointing a subvolume

Returns:

bool:

True if the subvolume is belonging to the structure.

coord2global(coord) → Integer3

Transform a coordinate to a global coordinate.

edge_lengths() → Real3

Return the edge lengths of the world.

get_occupancy(sp, g) → Real

Return the occupancy of the structure in the subvolume.

Parameters:

sp : Species

A species for the target structure.

g : Integer3

a global coordinate pointing a subvolume

Returns:

Real:

The occupancy of the structure. As a default, return 1 if the subvolume overlaps with the structure, and return 0 otherwise.

get_value(sp) → Real

Return the value (number) corresponding the given Species.

Parameters:

sp : Species

a species whose value you require

Returns:

Real:

the value

get_value_exact(sp) → Real

Return the value (number) corresponding the given Species.

Parameters:

sp : Species

a species whose value you require

Returns:

Real:

the value

get_volume(sp) → Real

Return a volume of the given structure.

Parameters:

sp : Species

A species for the target structure.

Returns:

Real:

A total volume of subvolumes belonging to the structure.

global2coord(g) → Integer

Transform a global coordinate to a coordinate.

Parameters:

g : Integer3

a global coordinate

Returns:

Integer:

A coordinate

has_structure(sp) → bool

Return if the given structure is in the space or not.

Parameters:

sp : Species

A species for the target structure.

Returns:

bool:

True if the given structure is in self.

list_coordinates(sp) → [Integer]

Return a list of coordinates of molecules belonging to the given species.

Parameters:

sp : Species

A species of molecules.

Returns:

list:

A list of coordinates.

list_coordinates_exact(sp) → [Integer]

Return a list of coordinates of molecules belonging to the given species.

Parameters:

sp : Species

A species of molecules.

Returns:

list:

A list of coordinates.

list_particles(sp) → [(ParticleID, Particle)]

Return the list of particles.

Parameters:

sp : Species, optional

The species of particles to list up If no species is given, return the whole list of particles.

Returns:

list:

The list of particles (of the given species)

list_particles_exact(sp) → [(ParticleID, Particle)]

Return the list of particles of a given species.

Parameters:

sp : Species

The species of particles to list up

Returns:

list:

The list of particles of a given species

list_species()

Return a list of species.

load(filename)

Load the world from a file.

Parameters:

filename : str

a filename to load from

matrix_sizes() → Integer3

Return the number of subvolumes along axes.

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, c=None) → Integer

Return the number of molecules within the suggested subvolume.

Parameters:

sp : Species

A species whose molecules you count

c : Integer, optional

A coordinate.

Returns:

Integer:

The number of molecules (of a given species)

num_molecules_exact(sp, c=None) → Integer

Return the number of molecules within the suggested subvolume.

Parameters:

sp : Species

The species of molecules to count

c : Integer, optional

A coordinate.

Returns:

Integer:

The number of molecules of a given species

num_subvolumes(sp=None) → Integer

Return the number of subvolumes.

Parameters:

sp : Species, optional

A species specifying a structure. When no species is given, return the total number of subvolumes.

Returns:

Integer:

The number of subvolumes.

on_structure(sp, g) → bool

Check if the given species would be on the proper structure at the coordinate.

Parameters:

sp : Species

a species scheduled to be placed

g : Integer3

a global coordinate pointing a subvolume

Returns:

bool:

True if it is on the proper structure.

position2coordinate(pos) → Integer

Transform a position to a coordinate.

Parameters:

pos : Real3

A position

Returns:

Integer:

A coordinate

position2global(pos) → Integer3

Transform a position to a global coordinate.

Parameters:

pos : Real3

A position

Returns:

Integer3:

A global coordinate

remove_molecules(sp, num, c=None)

Remove the molecules.

Parameters:

sp : Species

a species whose molecules to remove

num : Integer

a number of molecules to be removed

c : Integer, optional

A coordinate.

rng()

Return a random number generator object.

save(filename)

Save the world to a file.

Parameters:

filename : str

a filename to save to

set_t(t)

Set the value of the time of the world.

Parameters:

t : Real

The time of the world

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

subvolume()

Return the subvolume of each cell.

subvolume_edge_lengths()

Return the edge lengths of a subvolume.

t()

Return the time of the world.

volume()

Return the volume of the world.

class ecell4.meso.ReactionInfo

A class stores detailed information about a reaction in meso.

ReactionInfo(t, reactants, products, coord)

Methods

coordinate Return a coordinate where a reaction occurred.
products
reactants Return a list of reactants
t Return a time when a reaction occurred.
coordinate()

Return a coordinate where a reaction occurred.

reactants()

Return a list of reactants

Returns:
list: A list of Species.
t()

Return a time when a reaction occurred.