pyLM.RDME#
Functions
|
|
|
Set the logger to write to the console as the code is working |
|
Set up file handler to print log to file |
|
Set the level of the logger for the application |
|
Visualize the RDME simulation volume inside Jupyter. |
|
Classes
|
|
|
A class that represents a type region of an RDME simulation. |
|
A class that contains all regions, reactions, diffusions and rules for a RDME simulation |
|
Decorate an iterable object, returning an iterator which acts exactly like the original iterable, but prints a dynamically updating progressbar every time a value is requested. |
- class pyLM.RDME.IntRDMESimulation(dimensions, spacing, name='unnamed', defaultRegion='default')[source]#
Bases:
RDMESimulation
- addCuboidRegion(name, a, b)#
Add a cuboid to the builder
- Parameters:
name – Name of the site type for this region
a – tuple for the first corner in continous space
b – tuple for the second corner in continous space
- addParticleAt(index, particleType)#
Add a particle/ to a particular site
- Parameters:
index (x,y,z) – a list of spatial location
specie – The specie type to add
- addParticleAtIdx(index, particleType)#
Add a particle/ to a particular site
- Parameters:
index (x,y,z) – a list of lattice site indices
specie – The specie type to add
- addParticles(species='unknown', region='default', count=1)#
Add a specified number of particles of the specified type to the specified region
- Parameters:
species – The species to add to the region
region – The region to add particles to
count – Number of particles to add (default: 1)
- Returns:
The simulation object
- addRegion(region)#
Add a region to the simulation
- Parameters:
region – The region to add to the simulation
- Returns:
region just added
- addShape(shape)#
Add a Shape to the builder
- Parameters:
shape – The Shape to add to the builder
- buildCapsidCell(length, diameter, membraneThickness, points=False)#
Build a capsule based shell in this RDMESimulation centered within the simulation domain that includes a membrane and cytoplasm
- Parameters:
length – The length of the capsule from one sphere origin to the other diameter The diameter of the cell
membraneThickness – The thickness of the membrane
points – OPTIONAL: List of lists containing the coordinates of the centers of the sphereoids that cap the capsid cell, e.g. [[x1, y1, z1], [x2, y2, z2]]. If not given, cell is centered in the volume and aligned in the z-direction
- Returns:
The simulation object
- buildDifference(arg1, arg2, arg3)#
- buildDiffusionModel()#
Return the Lattice Microbes DiffusionModel object for fine-tuning
- Returns:
Simulation diffusion model
- buildEllipse(arg1, arg2, arg3, arg4, arg5, arg6, arg7)#
- buildPoint(arg1, arg2, arg3)#
- buildReactionModel()#
Return the Lattice Microbes ReactionModel object for fine-tuning
- Returns:
The reaction model for this simulation
- buildSpatialModel()#
Return the Lattice Microbes SpatialModel object for fine-tuning
- Returns:
The spatial model (i.e. obstacles, sites, etc.) for this simulation
- buildSphere(arg1, arg2, arg3)#
- buildSphericalCell(diameter, membraneThickness, point=False)#
Build a spherical based shell in this RDMESimulation centered within the simulation domain that includes a membrane and cytoplasm
- Parameters:
diameter – The diameter of the cell
membraneThickness – The thickness of the membrane
point – The center of the spherical cell
- Returns:
The simulation object
- buildVector(arg1, arg2, arg3)#
- defineSpecies(species)#
Define a specie/s of particles that exist in the simulation
- Parameters:
species – A list of species to add to the simulation
- Returns:
The simulation object
- getLattice(force=False)#
Get a discretized version of the simulation domain. Call this after building all spherical and capsule cells
- Parameters:
force – Force a rediscretization of the lattice. This will throw away any additional changes made after the first call.
- Returns:
A lattice object. This function should usually only be called once.
- getLatticeSite(index)#
Get a particular lattice site
- Parameters:
index (x,y,z) – a list of coordinates
- Returns:
The type of the lattice site (string)
- modifyRegion(region)#
Return a pointer to a region so that it may be modified
- Parameters:
region – Get a region that is attached to the simulation for modification
- Returns:
The region to modify
- packRegion(region, radius, percentage, obstacleID)#
Add nonmoving obstacles to a particular region
- Parameters:
region – The name of the region in which to add particles to
radius – The radius of the particles
percentage – The percentage of the total region volume that should be packed
obstacleID – an identifier for the obstacle
- Returns:
The simulation object
- run(filename, method, replicates=1, seed=None, cudaDevices=None, checkpointInterval=0)#
Run the simulation using the specified solver (e.g. NextSubvolume, MultiParticleDiffusion, etc.) for the specified amount of time
- Parameters:
filename – The HDF file to write to
method – The class name for the solver to use (e.g., lm::rdme::MpdRdmeSolver”)
replicates – The number of replicates to serially run
seed – A seed for the random number generator to use when running the simulation; None indicates default
- runMPI(filename, method, replicates=1, driver='mpirun', ppe=1, seed=None)#
Run the simulation using a call to mpirun with the given options
- Parameters:
filename – The HDF file to write to
method – The class name for the solver to use (e.g., lm::cme::GillespieDSolver”)
replicates – The number of replicates to serially run
driver – The program to execute the parallel run, e.g. “mpirun”, “aprun”, “ibrun”, etc.
ppe – The number of processing elements to use (e.g. number of nodes)
seed – A seed for the random number generator to use when running the simulation; None indicates default
- runSolver(filename, solver, replicates=1, cudaDevices=None, checkpointInterval=0)#
Run a simulation with a given solver
- Parameters:
filename – The HDF file to write to
solver – An MESolver object
replicates – The number of replicates to serially run
- save(filename)#
Create an HDF5 version of the simulation amenable for later running or stand-alone running
- Parameters:
filename – A file to write the simulation to
- setHookInterval(time)#
Set the hook interval
- Parameters:
time – The interval to call hookSimulation
- setLatticeSite(index, siteType)#
Set a particular lattice site type
- Parameters:
index (x,y,z) – A list of coordinates
siteType – The type to set the lattice point to. This would be the name of a region that has previously been performed
- setLatticeWriteInterval(time)#
Set the time interval to write latticedata at during simulation
- Parameters:
time – The length of time between lattice data writes
- setOverflowHandler(mode)#
- setRandomSeed(seed)#
Set a known random seed
- Parameters:
seed – The seed value
- setSimulationTime(time)#
Set the simulation time length
- Parameters:
time – The length of simulation time
- setTimestep(time)#
Set the simulation time step
- Parameters:
time – The length of simulation timestep for RDME
- setTransitionRate(species, via, to, rate)#
Specify the diffusion rate between species; this is a one directional rate e.g. membrane->cytosol or extracellular->membrane
- Parameters:
species – The specie that can transition between regions
via – From this region
to – To this region
rate – Diffusion rate between regions
- Returns:
The simulation object
- setTwoWayTransitionRate(species, one, two, rate)#
Specify the diffusion rate between species; this is a two directional rate
- Parameters:
species – The specie that can transition between regions
one – A region
two – The other region
rate – Diffusion rate between regions
- Returns:
The simulation object
- setWriteInterval(time)#
Set the time interval to write data at during simulation
- Parameters:
time – The length of time between data writes
- siteVolume()#
Get the actual volume of a specific site in L
- Returns:
The volume of the site in L
- class pyLM.RDME.RDMERegion(name)[source]#
Bases:
object
A class that represents a type region of an RDME simulation.
Reactions may be specified that live within a region. In addition a specie’s diffusion constant is region dependent and diffusion between regions must be specified. For example: cytosol, membrane, extracellular, nucleoid, etc.
- Parameters:
name – The name of the region (e.g. cytosol)
- addReaction(reactant, product, rate)[source]#
Adds a 0th, 1st or 2nd order reaction that can occur in the region
Reaction rates are specified as stochastic rates: i.e. in units of \(1/\mathrm{s}\).
- Parameters:
reactant – A set of reactants either as a singleton or a list
product – A set of products either as a singeton or a list
rate – The stochastic rate of the reaction.
- Returns:
RDMERegion
- getReactionCount()[source]#
Return the number of reactions defined in this region
- Returns:
Get the number of reactions in the region
- class pyLM.RDME.RDMESimulation(dimensions, spacing, name='unnamed', defaultRegion='default')[source]#
Bases:
object
A class that contains all regions, reactions, diffusions and rules for a RDME simulation
Specify a cuboid region that represents the extents to the reaction region as well as the lattice spacing
- Parameters:
dimensions – A list of [x,y,z]
spacing – Lattice spacing
name – The name of the RDME simulation; default: “unnamed”
defaultRegion – The name of the region that is associated with the lattice sites before any other regions are added; default:”default”
- addCuboidRegion(name, a, b)[source]#
Add a cuboid to the builder
- Parameters:
name – Name of the site type for this region
a – tuple for the first corner in continous space
b – tuple for the second corner in continous space
- addParticleAt(index, particleType)[source]#
Add a particle/ to a particular site
- Parameters:
index (x,y,z) – a list of spatial location
specie – The specie type to add
- addParticleAtIdx(index, particleType)[source]#
Add a particle/ to a particular site
- Parameters:
index (x,y,z) – a list of lattice site indices
specie – The specie type to add
- addParticles(species='unknown', region='default', count=1)[source]#
Add a specified number of particles of the specified type to the specified region
- Parameters:
species – The species to add to the region
region – The region to add particles to
count – Number of particles to add (default: 1)
- Returns:
The simulation object
- addRegion(region)[source]#
Add a region to the simulation
- Parameters:
region – The region to add to the simulation
- Returns:
region just added
- addShape(shape)[source]#
Add a Shape to the builder
- Parameters:
shape – The Shape to add to the builder
- buildCapsidCell(length, diameter, membraneThickness, points=False)[source]#
Build a capsule based shell in this RDMESimulation centered within the simulation domain that includes a membrane and cytoplasm
- Parameters:
length – The length of the capsule from one sphere origin to the other diameter The diameter of the cell
membraneThickness – The thickness of the membrane
points – OPTIONAL: List of lists containing the coordinates of the centers of the sphereoids that cap the capsid cell, e.g. [[x1, y1, z1], [x2, y2, z2]]. If not given, cell is centered in the volume and aligned in the z-direction
- Returns:
The simulation object
- buildDiffusionModel()[source]#
Return the Lattice Microbes DiffusionModel object for fine-tuning
- Returns:
Simulation diffusion model
- buildReactionModel()[source]#
Return the Lattice Microbes ReactionModel object for fine-tuning
- Returns:
The reaction model for this simulation
- buildSpatialModel()[source]#
Return the Lattice Microbes SpatialModel object for fine-tuning
- Returns:
The spatial model (i.e. obstacles, sites, etc.) for this simulation
- buildSphericalCell(diameter, membraneThickness, point=False)[source]#
Build a spherical based shell in this RDMESimulation centered within the simulation domain that includes a membrane and cytoplasm
- Parameters:
diameter – The diameter of the cell
membraneThickness – The thickness of the membrane
point – The center of the spherical cell
- Returns:
The simulation object
- defineSpecies(species)[source]#
Define a specie/s of particles that exist in the simulation
- Parameters:
species – A list of species to add to the simulation
- Returns:
The simulation object
- getLattice(force=False)[source]#
Get a discretized version of the simulation domain. Call this after building all spherical and capsule cells
- Parameters:
force – Force a rediscretization of the lattice. This will throw away any additional changes made after the first call.
- Returns:
A lattice object. This function should usually only be called once.
- getLatticeSite(index)[source]#
Get a particular lattice site
- Parameters:
index (x,y,z) – a list of coordinates
- Returns:
The type of the lattice site (string)
- modifyRegion(region)[source]#
Return a pointer to a region so that it may be modified
- Parameters:
region – Get a region that is attached to the simulation for modification
- Returns:
The region to modify
- packRegion(region, radius, percentage, obstacleID)[source]#
Add nonmoving obstacles to a particular region
- Parameters:
region – The name of the region in which to add particles to
radius – The radius of the particles
percentage – The percentage of the total region volume that should be packed
obstacleID – an identifier for the obstacle
- Returns:
The simulation object
- run(filename, method, replicates=1, seed=None, cudaDevices=None, checkpointInterval=0)[source]#
Run the simulation using the specified solver (e.g. NextSubvolume, MultiParticleDiffusion, etc.) for the specified amount of time
- Parameters:
filename – The HDF file to write to
method – The class name for the solver to use (e.g., lm::rdme::MpdRdmeSolver”)
replicates – The number of replicates to serially run
seed – A seed for the random number generator to use when running the simulation; None indicates default
- runMPI(filename, method, replicates=1, driver='mpirun', ppe=1, seed=None)[source]#
Run the simulation using a call to mpirun with the given options
- Parameters:
filename – The HDF file to write to
method – The class name for the solver to use (e.g., lm::cme::GillespieDSolver”)
replicates – The number of replicates to serially run
driver – The program to execute the parallel run, e.g. “mpirun”, “aprun”, “ibrun”, etc.
ppe – The number of processing elements to use (e.g. number of nodes)
seed – A seed for the random number generator to use when running the simulation; None indicates default
- runSolver(filename, solver, replicates=1, cudaDevices=None, checkpointInterval=0)[source]#
Run a simulation with a given solver
- Parameters:
filename – The HDF file to write to
solver – An MESolver object
replicates – The number of replicates to serially run
- save(filename)[source]#
Create an HDF5 version of the simulation amenable for later running or stand-alone running
- Parameters:
filename – A file to write the simulation to
- setHookInterval(time)[source]#
Set the hook interval
- Parameters:
time – The interval to call hookSimulation
- setLatticeSite(index, siteType)[source]#
Set a particular lattice site type
- Parameters:
index (x,y,z) – A list of coordinates
siteType – The type to set the lattice point to. This would be the name of a region that has previously been performed
- setLatticeWriteInterval(time)[source]#
Set the time interval to write latticedata at during simulation
- Parameters:
time – The length of time between lattice data writes
- setSimulationTime(time)[source]#
Set the simulation time length
- Parameters:
time – The length of simulation time
- setTimestep(time)[source]#
Set the simulation time step
- Parameters:
time – The length of simulation timestep for RDME
- setTransitionRate(species, via, to, rate)[source]#
Specify the diffusion rate between species; this is a one directional rate e.g. membrane->cytosol or extracellular->membrane
- Parameters:
species – The specie that can transition between regions
via – From this region
to – To this region
rate – Diffusion rate between regions
- Returns:
The simulation object
- setTwoWayTransitionRate(species, one, two, rate)[source]#
Specify the diffusion rate between species; this is a two directional rate
- Parameters:
species – The specie that can transition between regions
one – A region
two – The other region
rate – Diffusion rate between regions
- Returns:
The simulation object