ecoli.composites.ecoli_master
Composer
used to generate the processes,
steps, topology, and initial state of the E. coli whole cell model.
Note
Use the EcoliSim
interface
to configure and run simulations with this composer.
- class ecoli.composites.ecoli_master.Ecoli(config)[source]
Bases:
Composer
The main composer used to create the
Composite
that is given toEngine
to run the E. coli whole cell model.Loads pickled simulation data object (from ParCa, see
fit_sim_data_1
) and instantiates all processes and steps (also dynamically generates flow for steps).- load_sim_data
Instance of
LoadSimData
- config
Cached copy of
config
- processes_and_steps
Processes, steps, and flow generated by
generate_processes_and_steps()
- Parameters:
config (dict[str, Any]) – Configuration dictionary that is typically supplied by
EcoliSim
-
defaults
{ 'agent_id': '0', 'amp_lysis': False, 'chromosome_path': ('unique', ' full_chromosome'), 'divide': False, 'division_threshold': 668, 'division_variable': ('listeners', 'mass', 'dry_mass'), 'flow': {}, 'log_updates': False, 'mar_regulon': False, 'process_configs': {}, 'seed': 0, 'sim_data_path': '/home/runner/work/vEcoli/vEcoli/reconstruction/sim_data/kb/simData.cPickle', 'time_step': 2.0}
A subset of configuration options with default values for testing purposes (see
ecoli_topology_plot()
). For normal users, this composer should only be called indirectly via theEcoliSim
interface, whose defaults are laid out in the JSON file atecoli/composites/ecoli_configs/default.json
.
- generate_flow(config)[source]
Retrieve cached flow generated by
generate_processes_and_steps()
whengenerate()
is called on this composer.
- generate_processes(config)[source]
Retrieve cached processes generated by
generate_processes_and_steps()
whengenerate()
is called on this composer.
- generate_processes_and_steps(config)[source]
Helper function that dynamically initializes all processes and steps (including their flow) according to options supplied in
config
. This method is called whenEcoli
is initialized and its return value is cached as the instance variableprocesses_and_steps
. This allows theinitial_state
method to be run before callinggenerate()
on this composer.- Parameters:
Important key-value pairs in this dictionary include:
process_configs
:Mapping of process names (
str
) to process configs. The configs can either be dictionaries that will be used to initialize said process, the string"sim_data"
to indicate that the process config should be loaded from the pickled simulation data object usingget_config_by_name()
, or the string"default"
to indicate that thedefaults
attribute of the process should be used as its config. In the case of a dictionary config, the dictionary will be merged with the result ofget_config_by_name()
if possible, or thedefaults
attribute if not.
processes
:Mapping of all process names (
str
) to theProcess
,Step
, orPartitionedProcess
instances that they refer to.
log_updates
:Boolean option indicating whether to emit the updates of all processes in
config['processes']
(separately log the updates from theRequester
andEvolver
created from eachPartitionedProcess
) at the path('log_update',)
by wrapping them withmake_logging_process()
. Seeblame
for a plotting script that can be used to visualize how each process changes bulk molecule counts.
flow
:Mapping of process names to their dependencies. Note that the only names allowed must correspond to instances of either
Step
orPartitionedProcess
. This method parses the names of partitioned processes and edits the flow to create the four execution layers detailed in Implementation.
divide
:Boolean option that adds
Division
if true.
division_threshold
:Config option for
Division
agent_id
:Config option for
Division
d_period
:Boolean option that only matters if
division
is true. AddsMarkDPeriod
if true.
generations
:If not
None
anddivide
isTrue
, addsStopAfterDivision
- Returns:
Tuple consisting of a mapping of process names to fully initialized
Process
instances, a mapping of step names to fully initializedStep
instances, and a flow describing the dependencies between steps.- Return type:
tuple[dict[str, Process], dict[str, Step], dict[str, list[tuple[str]]]]
- generate_steps(config)[source]
Retrieve cached steps generated by
generate_processes_and_steps()
whengenerate()
is called on this composer.
- generate_topology(config)[source]
Creates simulation topology when
generate()
is called on this composer.- Parameters:
Uses the same
config
supplied to this composer inEcoli
that was used to generate the processes and steps ingenerate_processes_and_steps()
. Important key-value pairs include:topology
:Mapping of process names to topologies. Names of
PartitionedProcess
instances are automatically split into two separate topologies, one for theRequester
and another for theEvolver
that is created for each partitioned process (see Partitioning).
log_updates
:Boolean, adds additional
log_update
topology path to write the updates of each process when true. Seemake_logging_process()
.
divide
:Boolean, adds toplogy for
Division
when true.
d_period
:Boolean, adds topology for
MarkDPeriod
when true.
- Returns:
Full topology for an E. coli simulation.
- Return type:
- initial_state(config=None)[source]
Users have three options for configuring the simulation initial state:
config['initial_state']
2. Load the JSON file at
f'data/{config['initial_state_file]}.json'
usingget_state_from_file()
.3. Generate initial state from simulation data object (see
generate_initial_state()
)This method will go through these options in order until a dictionary is loaded. This dictionary will serve as the base initial state.
Users can override values in the initial state by specifying one or more override filenames in
config['initial_state_overrides']
. For each filename, the JSON at the pathf'data/{override_filename}.json'
is loaded. Bulk molecule overrides (anything under thebulk
key in the loaded JSON) take the form of key-value pairs where keys are bulk molecule IDs and values are the desired counts of those molecules. These key-value pairs are parsed to change the desired counts for the correct rows in the bulk molecule structured Numpy array (see Bulk Molecules). All other overrides are directly used to update the initial state with no further processing.As explained in Partitioning, instances of
PartitionedProcess
are turned into twoStep
instances in the final model: aRequester
and anEvolver
. To ensure that both of these steps have access to the same mutable parameters (e.g. if a Requester changes a parameter, the Evolver will see the change), this method places the thePartitionedProcess
that they share into the simulation state under the('process',)
path.Warning
This method will NOT work if run after calling
generate()
on this composer.
- ecoli.composites.ecoli_master.ecoli_topology_plot(config=None)[source]
Make a topology plot of Ecoli
- ecoli.composites.ecoli_master.run_ecoli(filename='default', total_time=10, divide=False, progress_bar=True, log_updates=False, emitter='timeseries', time_series=True)[source]
Run E. coli simulations.
- Parameters:
total_time (int) – the total runtime of the experiment
divide (bool) – whether to incorporate division
progress_bar (bool) – whether to show a progress bar
log_updates (bool) – whether to save updates from each process (refer to
make_logging_process()
)emitter (str) – type of emitter to use (refer to
emitter
argument forEngine
)time_series (bool) – whether to return data in timeseries format (refer to
query()
)filename (str)
- Returns:
Data emitted by simulation.
Note
If data is not set up to be emitted to a MongoDB database (e.g.
emitter
is notdatabase
), users will not have easy access to the listener metadata that is emitted whenemit_config
is true (seeEcoliSim
,Engine
, andlistener_schema()
for details).