ecell4.util.
run_simulation
(t, y0=None, volume=1.0, model=None, solver='ode', ndiv=None, species_list=None, structures=None, observers=(), rndseed=None)¶Run a simulation with the given model and plot the result on IPython notebook with matplotlib.
A sequence of time points for which to solve for ‘m’.
Initial condition.
A size of the simulation volume. Keyword ‘v’ is a shortcut for specifying ‘volume’.
Keyword ‘m’ is a shortcut for specifying ‘model’.
Solver type. Choose one from ‘ode’, ‘gillespie’, ‘spatiocyte’, ‘meso’, ‘bd’, ‘egfrd’, and ‘sgfrd’. Default is ‘ode’. When tuple is given, the first value must be str as explained above. All the rest is used as arguments for the corresponding factory class. Keyword ‘s’ is a shortcut for specifying ‘solver’.
A number of time points. If t is an array, ignored. If None, log all.
A list of names of Species observed. If None, log all. Default is None.
A dictionary which gives pairs of a name and shape of structures. Not fully supported yet.
A list of extra observer references.
A random seed for a simulation. This argument will be ignored when ‘solver’ is given NOT as a string.
ecell4.util.
ensemble_simulations
(t, y0=None, volume=1.0, model=None, solver='ode', ndiv=None, species_list=None, structures=None, observers=(), rndseed=None, repeat=1, method=None, \*\*kwargs)¶Run simulations multiple times and return its ensemble.
Arguments are almost same with ecell4.util.simulation.run_simulation
.
observers and progressbar is not available here.
A number of runs. Default is 1.
The way for running multiple jobs. Choose one from ‘serial’, ‘multiprocessing’, ‘sge’, ‘slurm’, ‘azure’. Default is None, which works as ‘serial’.
Optional keyword arugments are passed through to run_serial, run_sge, or run_multiprocessing. See each function for more details.
See also
ecell4.util.simulation.run_simulation
ecell4.extra.ensemble.run_serial
ecell4.extra.ensemble.run_sge
ecell4.extra.ensemble.run_slurm
ecell4.extra.ensemble.run_multiprocessing
ecell4.extra.ensemble.run_azure
ecell4.util.
load_world
(filename)¶Load a world from the given HDF5 filename.
The return type is determined by ecell4_base.core.load_version_information
.
A HDF5 filename.
Return one from BDWorld
, EGFRDWorld
, MesoscopicWorld
,
ODEWorld
, GillespieWorld
and SpatiocyteWorld
.
ecell4.util.
number_observer
(t=None, targets=None)¶Return a number observer. If t is None, return NumberObserver. If t is a number, return FixedIntervalNumberObserver. If t is an iterable (a list of numbers), return TimingNumberObserver.
A timing of the observation. See above.
A list of strings suggesting Species observed.
ecell4.util.
get_model
(is_netfree=False, without_reset=False, seeds=None, effective=False)¶Generate a model with parameters in the global scope, SPECIES_ATTRIBUTES
and REACTIONRULES
.
Return NetfreeModel
if True, and NetworkModel
if else.
Default is False.
Do not reset the global variables after the generation if True. Default is False.
A list of seed Species
for expanding the model.
If this is not None, generate a NetfreeModel
once, and return a
NetworkModel
, which is an expanded form of that with the given seeds.
Default is None.
See NetfreeModel.effective
and Netfree.set_effective
.
Only meaningfull with option is_netfree=True
.
Default is False
ecell4.util.
show
(target, \*args, \*\*kwargs)¶An utility function to display the given target object in the proper way.
ecell4.util.
Session
(model=None, y0=None, structures=None, volume=1.0)¶Bases: object
Methods
|
Run simulations multiple times and return its ensemble. |
|
Run a simulation with the given model and return the result |
ensemble
(self, t, solver='ode', rndseed=None, ndiv=None, species_list=None, observers=(), repeat=1, method=None, \*\*kwargs)¶Run simulations multiple times and return its ensemble.
Arguments are almost same with ecell4.util.simulation.run_simulation
.
observers and progressbar is not available here.
A sequence of time points for which to solve for ‘m’.
Solver type. Choose one from ‘ode’, ‘gillespie’, ‘spatiocyte’, ‘meso’, ‘bd’ and ‘egfrd’. Default is ‘ode’. When tuple is given, the first value must be str as explained above. All the rest is used as arguments for the corresponding factory class.
A number of time points. If t is an array, ignored. If None, log all.
A list of names of Species observed. If None, log all. Default is None.
A list of extra observer references.
A number of runs. Default is 1.
The way for running multiple jobs. Choose one from ‘serial’, ‘multiprocessing’, ‘sge’, ‘slurm’, ‘azure’. Default is None, which works as ‘serial’.
Optional keyword arugments are passed through to run_serial, run_sge, or run_multiprocessing. See each function for more details.
A list of Result objects. The list contains n results.
See also
run
(self, t, solver='ode', rndseed=None, ndiv=None, species_list=None, observers=())¶Run a simulation with the given model and return the result
A sequence of time points for which to solve for ‘m’.
Solver type. Choose one from ‘ode’, ‘gillespie’, ‘spatiocyte’, ‘meso’, ‘bd’ and ‘egfrd’. Default is ‘ode’. When tuple is given, the first value must be str as explained above. All the rest is used as arguments for the corresponding factory class.
A random seed for a simulation.
A number of time points. If t is an array, ignored. If None, log all.
A list of names of Species observed. If None, log all. Default is None.
A list of extra observer references.
The result object
ecell4.datasource.
description
(entity, collections=None)¶ecell4.datasource.
whereis
(entity, collections=None)¶ecell4.datasource.
citation
(entity, formatter=<class 'ecell4.datasource.pubmed.Formatter'>)¶ecell4.extra.ensemble.
genseeds
(n)¶Return a random number generator seed for ensemble_simulations.
A seed for a single run is given by getseed(rngseed, i)
.
A size of the seed.
A random number seed for multiple runs.
ecell4.extra.ensemble.
getseed
(myseed, i)¶Return a single seed from a long seed given by genseeds.
A long seed given by genseeds(n).
An index less than n.
A seed (less than (2 ** 31))
ecell4.extra.ensemble.
run_azure
(target, jobs, n=1, nproc=None, path='.', delete=True, config=None, \*\*kwargs)¶Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel with Microsoft Azure Batch.
This function is the work in progress. The argument nproc doesn’t work yet. See ecell4.extra.azure_batch.run_azure for details.
See also
ecell4.extra.ensemble.
run_ensemble
(target, jobs, repeat=1, method=None, \*\*kwargs)¶Evaluate the given function with each set of arguments, and return a list of results.
A function to be evaluated. The function must accepts three arguments, which are a list of arguments given as jobs, a job and task id (int).
A list of arguments passed to the function.
A number of tasks. Repeat the evaluation n times for each job. 1 for default.
The way for running multiple jobs. Choose one from ‘serial’, ‘multiprocessing’, ‘sge’, ‘slurm’, ‘azure’. Default is None, which works as ‘serial’.
A list of results. Each element is a list containing repeat results.
ecell4.extra.ensemble.
run_multiprocessing
(target, jobs, n=1, nproc=None, \*\*kwargs)¶Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel by using multiprocessing.
A function to be evaluated. The function must accepts three arguments, which are a list of arguments given as jobs, a job and task id (int).
A list of arguments passed to the function. All the argument must be picklable.
A number of tasks. Repeat the evaluation n times for each job. 1 for default.
A number of cores available once. If nothing is given, all available cores are used.
A list of results. Each element is a list containing n results.
See also
Examples
>>> jobs = ((1, 'spam'), (2, 'ham'), (3, 'eggs'))
>>> target = lambda args, job_id, task_id: (args[1] * args[0])
>>> run_multiprocessing(target, jobs, nproc=2)
[['spam'], ['hamham'], ['eggseggseggs']]
>>> target = lambda args, job_id, task_id: "{:d} {}".format(task_id, args[1] * args[0])
>>> run_multiprocessing(target, jobs, n=2, nproc=2)
[['1 spam', '2 spam'], ['1 hamham', '2 hamham'], ['1 eggseggseggs', '2 eggseggseggs']]
ecell4.extra.ensemble.
run_serial
(target, jobs, n=1, \*\*kwargs)¶Evaluate the given function with each set of arguments, and return a list of results. This function does in series.
A function to be evaluated. The function must accepts three arguments, which are a list of arguments given as jobs, a job and task id (int).
A list of arguments passed to the function.
A number of tasks. Repeat the evaluation n times for each job. 1 for default.
A list of results. Each element is a list containing n results.
See also
Examples
>>> jobs = ((1, 'spam'), (2, 'ham'), (3, 'eggs'))
>>> target = lambda args, job_id, task_id: (args[1] * args[0])
>>> run_serial(target, jobs)
[['spam'], ['hamham'], ['eggseggseggs']]
>>> target = lambda args, job_id, task_id: "{:d} {}".format(task_id, args[1] * args[0])
>>> run_serial(target, jobs, n=2)
[['1 spam', '2 spam'], ['1 hamham', '2 hamham'], ['1 eggseggseggs', '2 eggseggseggs']]
>>> seeds = genseeds(3)
>>> def target(arg, job_id, task_id):
... from ecell4.extra.ensemble import getseed
... return getseed(arg, task_id)
>>> run_serial(target, (seeds, ), n=3)
[[127152315, 2028054913, 253611282]]
ecell4.extra.ensemble.
run_sge
(target, jobs, n=1, nproc=None, path='.', delete=True, wait=True, environ=None, modules=(), \*\*kwargs)¶Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel on the Sun Grid Engine einvironment.
A function to be evaluated. The function must accepts three arguments, which are a list of arguments given as jobs, a job and task id (int). This function can not be a lambda.
A list of arguments passed to the function. All the argument must be picklable.
A number of tasks. Repeat the evaluation n times for each job. 1 for default.
A number of cores available once. If nothing is given, it runs with no limit.
A path for temporary files to be saved. The path is created if not exists. The current directory is used as its default.
Whether it removes temporary files after the successful execution. True for default.
Whether it waits until all jobs are finished. If False, it just submits jobs. True for default.
An environment variables used when running jobs. “PYTHONPATH” and “LD_LIBRARY_PATH” is inherited when no environ is given.
A list of module names imported before evaluating the given function. The modules are loaded as: from [module] import *.
A list of results. Each element is a list containing n results.
See also
Examples
>>> jobs = ((1, 'spam'), (2, 'ham'), (3, 'eggs'))
>>> def target(args, job_id, task_id):
... return (args[1] * args[0])
...
>>> run_sge(target, jobs, nproc=2, path='.tmp')
[['spam'], ['hamham'], ['eggseggseggs']]
>>> def target(args, job_id, task_id):
... return "{:d} {}".format(task_id, args[1] * args[0])
...
>>> run_sge(target, jobs, n=2, nproc=2, path='.tmp')
[['1 spam', '2 spam'], ['1 hamham', '2 hamham'], ['1 eggseggseggs', '2 eggseggseggs']]
ecell4.extra.ensemble.
run_slurm
(target, jobs, n=1, nproc=None, path='.', delete=True, wait=True, environ=None, modules=(), \*\*kwargs)¶Evaluate the given function with each set of arguments, and return a list of results. This function does in parallel with Slurm Workload Manager.
A function to be evaluated. The function must accepts three arguments, which are a list of arguments given as jobs, a job and task id (int). This function can not be a lambda.
A list of arguments passed to the function. All the argument must be picklable.
A number of tasks. Repeat the evaluation n times for each job. 1 for default.
A number of cores available once. If nothing is given, it runs with no limit.
A path for temporary files to be saved. The path is created if not exists. The current directory is used as its default.
Whether it removes temporary files after the successful execution. True for default.
Whether it waits until all jobs are finished. If False, it just submits jobs. True for default.
An environment variables used when running jobs. “PYTHONPATH” and “LD_LIBRARY_PATH” is inherited when no environ is given.
A list of module names imported before evaluating the given function. The modules are loaded as: from [module] import *.
A list of results. Each element is a list containing n results.
See also
Examples
>>> jobs = ((1, 'spam'), (2, 'ham'), (3, 'eggs'))
>>> def target(args, job_id, task_id):
... return (args[1] * args[0])
...
>>> run_slurm(target, jobs, nproc=2, path='.tmp')
[['spam'], ['hamham'], ['eggseggseggs']]
>>> def target(args, job_id, task_id):
... return "{:d} {}".format(task_id, args[1] * args[0])
...
>>> run_slurm(target, jobs, n=2, nproc=2, path='.tmp')
[['1 spam', '2 spam'], ['1 hamham', '2 hamham'], ['1 eggseggseggs', '2 eggseggseggs']]
ecell4.extra.unit.
getUnitRegistry
(length='meter', time='second', substance='item', volume=None, other=())¶Return a pint.UnitRegistry made compatible with ecell4.
A default unit for ‘[length]’. ‘meter’ is its default.
A default unit for ‘[time]’. ‘second’ is its default.
A default unit for ‘[substance]’ (the number of molecules). ‘item’ is its default.
A default unit for ‘[volume]’. Its default is None, thus ‘[length]**3’.
A list of user-defined default units other than the above.
ecell4.extra.unit.
get_application_registry
()¶Just return pint._APP_REGISTRY.
ecell4.extra.unit.
wrap_quantity
(cls)¶ecell4.extra.unit.
check_model
(m, Quantity=None)¶ecell4.extra.unit.
DimensionalityMismatchError
¶Bases: ValueError
ecell4.mca.
generate_full_rank_matrix
(input_matrix)¶do Gaussian elimination and return the decomposed matrices input_matrix: (matrix) return (link_matrix, kernel_matrix, independent_list)
ecell4.mca.
unscaled_control_coefficients
(stoichiometry, elasticity)¶ecell4.mca.
invdiag
(trace)¶return numpy.lib.twodim_base.diag(1.0 / trace) if there’re zeros in the array, set zero for that trace: (array) one dimensional array return (matrix)
ecell4.mca.
scale_control_coefficients
(ccc, fcc, v, x)¶ecell4.mca.
scaled_control_coefficients
(stoichiometry, elasticity, fluxes, x)¶ecell4.plotting: Visualizer of particles based on D3.js, THREE.js and Elegans.
ecell4.plotting.
display_pdb
(entity, width=400, height=400)¶ecell4.plotting.
logo
(x=1, y=None)¶ecell4.plotting.
plot_movie
(\*args, backend=None, \*\*kwargs)¶Generate a movie from received instances of World and show them. See also plot_movie_with_elegans and plot_movie_with_matplotlib.
Worlds to render.
backend. Either one of ‘matplotlib’ or ‘elegans’ is supported.
ecell4.plotting.
plot_movie_with_attractive_mpl
(worlds, marker_size=6, figsize=6, grid=True, wireframe=False, species_list=None, max_count=None, angle=None, noaxis=False, interval=0.16, repeat_delay=3000, stride=1, rotate=None, legend=True, whratio=1.33, scale=1, output=None, crf=10, bitrate='1M', \*\*kwargs)¶Generate a move from the received list of instances of World, and show it on IPython notebook. This function may require ffmpeg.
A list of Worlds to render.
Marker size for all species. Size is passed to scatter function as argument, s=(2 ** marker_size).
Size of the plotting area. Given in inch.
If set, plot_world will not search the list of species.
The maximum number of particles to show for each species. None means no limitation.
A tuple of view angle which is given as (azim, elev, dist). If None, use default assumed to be (-60, 30, 10).
Parameters for matplotlib.animation.ArtistAnimation.
Stride per frame.
A pair of rotation angles, elev and azim, for animation. None means no rotation, same as (0, 0).
A ratio between figure width and height. Customize this to keep a legend within the figure.
A length-scaling factor
The CRF value can be from 4-63. Lower values mean better quality.
Target bitrate
An output filename. ‘.webm’ or ‘.mp4’ is only accepted. If None, display a movie on IPython Notebook.
ecell4.plotting.
plot_number_observer
(\*args, backend=None, \*\*kwargs)¶Generate a plot from NumberObservers and show it. See plot_number_observer_with_matplotlib and _with_nya for details.
backend. Either one of ‘matplotlib’, ‘plotly’ or ‘elegans’ is supported.
Examples
>>> plot_number_observer(obs1)
>>> plot_number_observer(obs1, backend='plotly')
ecell4.plotting.
plot_trajectory
(\*args, backend=None, \*\*kwargs)¶Generate a plot from received instance of TrajectoryObserver and show it See also plot_trajectory_with_plotly, plot_trajectory_with_elegans and plot_trajectory_with_matplotlib.
TrajectoryObserver to render.
backend. Either one of ‘matplotlib’, ‘plotly’ or ‘elegans’ is supported.
Examples
>>> plot_trajectory(obs)
ecell4.plotting.
plot_world
(\*args, backend=None, \*\*kwargs)¶Generate a plot from received instance of World and show it. See also plot_world_with_elegans and plot_world_with_matplotlib.
World or a HDF5 filename to render.
backend. Either one of ‘matplotlib’, ‘plotly’ or ‘elegans’ is supported.
Examples
>>> plot_world(w)
>>> plot_world(w, backend='plotly')
ecell4.plotting.
plot_world_with_attractive_mpl
(world, marker_size=6, figsize=6, grid=True, wireframe=False, species_list=None, max_count=1000, angle=None, legend=True, noaxis=False, whratio=1.33, scale=1.0, \*\*kwargs)¶Generate a plot from received instance of World and show it on IPython notebook.
World to render. A HDF5 filename is also acceptable.
Marker size for all species. Size is passed to scatter function as argument, s=(2 ** marker_size).
Size of the plotting area. Given in inch.
If set, plot_world will not search the list of species.
The maximum number of particles to show for each species. None means no limitation.
A tuple of view angle which is given as (azim, elev, dist). If None, use default assumed to be (-60, 30, 10).
A ratio between figure width and height. Customize this to keep a legend within the figure.
A length-scaling factor