SyMBac.cell_simulation

SyMBac.cell_simulation.create_space()[source]

Creates a pymunk space

Return pymunk.Space space

A pymunk space

SyMBac.cell_simulation.run_simulation(trench_length, trench_width, cell_max_length, cell_width, sim_length, pix_mic_conv, gravity, phys_iters, max_length_var, width_var, save_dir, lysis_p=0, show_window=True, streamlit_mode=False)[source]

Runs the rigid body simulation of bacterial growth based on a variety of parameters. Opens up a Pyglet window to display the animation in real-time. If the simulation looks bad to your eye, restart the kernel and rerun the simulation. There is currently a bug where if you try to rerun the simulation in the same kernel, it will be extremely slow.

Parameters
  • trench_length (float) – Length of a mother machine trench (micron)

  • trench_width (float) – Width of a mother machine trench (micron)

  • cell_max_length (float) – Maximum length a cell can reach before dividing (micron)

  • cell_width (float) – the average cell width in the simulation (micron)

  • pix_mic_conv (float) – The micron/pixel size of the image

  • gravity (float) – Pressure forcing cells into the trench. Typically left at zero, but can be varied if cells start to fall into each other or if the simulation behaves strangely.

  • phys_iters (int) – Number of physics iterations per simulation frame. Increase to resolve collisions if cells are falling into one another, but decrease if cells begin to repel one another too much (too high a value causes cells to bounce off each other very hard). 20 is a good starting point

  • max_length_var (float) – Variance of the maximum cell length

  • width_var (float) – Variance of the maximum cell width

  • save_dir (str) – Location to save simulation output

  • lysis_p (float) – probability of cell lysis

Returns

  • cell_timeseries (lists) – A list of parameters for each cell, such as length, width, position, angle, etc. All used in the drawing of the scene later

  • space (a pymunk space object) – Contains the rigid body physics objects which are the cells.

SyMBac.cell_simulation.step_and_update(dt, cells, space, phys_iters, ylim, cell_timeseries, x, sim_length, save_dir)[source]

Evolves the simulation forward

Parameters
  • dt (float) – The simulation timestep

  • cells (list(SyMBac.cell.Cell)) – A list of all cells in the current timestep

  • space (pymunk.Space) – The simulations’s pymunk space.

  • phys_iters (int) – The number of physics iteration in each timestep

  • ylim (int) – The y coordinate threshold beyond which to delete cells

  • cell_timeseries (list) – A list to store the cell’s properties each time the simulation steps forward

  • list (int) – A list with a single value to store the simulation’s progress.

  • sim_length (int) – The number of timesteps to run.

  • save_dir (str) – The directory to save the simulation information.

Returns

cells

Return type

list(SyMBac.cell.Cell)

SyMBac.cell_simulation.update_cell_lengths(cells)[source]

Iterates through all cells in the simulation and updates their length according to their growth law.

Parameters

cells (list(SyMBac.cell.Cell)) – A list of all cells in the current timepoint of the simulation.

SyMBac.cell_simulation.update_cell_parents(cells, new_cells)[source]

Takes two lists of cells, one in the previous frame, and one in the frame after division, and updates the parents of each cell

Parameters
SyMBac.cell_simulation.update_cell_positions(cells)[source]

Iterates through all cells in the simulation and updates their positions, keeping the cell object’s position synchronised with its corresponding pymunk shape and body inside the pymunk space.

Parameters

cells (list(SyMBac.cell.Cell)) – A list of all cells in the current timepoint of the simulation.

SyMBac.cell_simulation.update_pm_cells(cells)[source]

Iterates through all cells in the simulation and updates their pymunk body and shape objects. Contains logic to check for cell division, and create daughters if necessary.

Parameters

cells (list(SyMBac.cell.Cell)) – A list of all cells in the current timepoint of the simulation.

SyMBac.cell_simulation.wipe_space(space)[source]

Deletes all cells in the simulation pymunk space.

Parameters

space (pymunk.Space) –