cellsystem.logging package

Submodules

cellsystem.logging.full module

class cellsystem.logging.full.FullLog(*args, **kwargs)[source]

Bases: cellsystem.logging.core.multi.MultiLog

An aggregate log that records geometric information, mutations, ancestry and prints the actions to the screen. (Technically is a multilog that contains a GeometricLog, a MutationsLog, an AncestryLog and a PrinterLog.)

Each part can be accesed with:

log[{{logname}}]

where {{logname}} can be one of: ‘geometry’, ‘mutations’, ‘ancestry’ or ‘printer’.

also, each log can be (de)activated with:

# Deactivate log
log[{{logname}}].silence()

# Reactivate log
log[{{logname}}].activate()
ancestry(prune_death=False)[source]

Fetch information of the cells’ “family tree”.

mutations(prune_death=False)[source]

Fetch information of the cells’ mutational history.

worldlines(prune_death=False)[source]

Fetch information of the cells’ evolution in space and time.

cellsystem.logging.geometric module

Geometric Logging

This module defines functionality for following the geometric evolution of the cell blob through time.

The classes GeometricLog and WorldLines are defined here.

class cellsystem.logging.geometric.GeometricLog(*args, **kwargs)[source]

Bases: cellsystem.logging.core.weak.WeakLog

Registers the geometric positions of the cells in time.

One may view the state of a GeometricLog object ‘glog’ by ‘glog.worldlines().show()’

iter_changes()[source]

Iterate through every action

iter_states()[source]

Generate the intermediate states.

log_death(cell)[source]

Register the disappeareance of the cell.

log_division(daughters)[source]
log_migration(cell)[source]
log_newcell(cell)[source]
preparefor_division(cell)[source]
worldlines(prune_death=False)[source]

Get the geometric evolution of individual cells in space and time.

class cellsystem.logging.geometric.WorldLines(initial_state=None, time=0)[source]

Bases: object

A class that represents the worldlines of a set of cells.

A worldline is the place in time and space that a cell occupies throughout it’s existence.

In other words, it stores for each cell ‘c’, a list of space-time points in which the cell has been (a spacetime point is a pair t, x where t is time and x is the geometric position of the cell at that time).

A world line may store a state similar to:

# wl is an initialized Worldline object >>> wl.worldlines {0: [(0, 50, 50), (1, 51, 51), (2, 52, 50)],

1: [(3, 51, 50), (2, 52, 50), (4, 51, 50), (5, 51, 50), (6, 51, 50)], 2: [(3, 52, 49), (2, 52, 50), (4, 52, 49), (5, 52, 48), (6, 52, 48)]

}

add_event(cell, event)[source]

Add an event (a spacetime coordinate) for the cell.

classmethod from_log(geometric_log, prune_death=False)[source]

Initialize from a geometric log.

last_state_of(cell)[source]

Return the last recorded event of the given cell.

remove(cell)[source]

Remove the given cell’s timeline.

show(div_marker='o', end_marker='', savefig=None)[source]

Render the 3D worldlines as a plot.

update(state, transition, time, prune_death=False)[source]

Add the event described by the transition, time and final state.

cellsystem.logging.simple module

cellsystem.logging.treelogs module

class cellsystem.logging.treelogs.AncestryLog(*args, **kwargs)[source]

Bases: cellsystem.logging.treelogs.TreeLog

A tree log that maintains a “family tree”.

Each leaf represents a cell. When that cell divides, the leaf branches into leaves representing the daughters.

The current state of an object ‘tree’ is handily accessible by ‘print(tree)’

add_child(*args, **kwargs)[source]
log_division(daughters)[source]

Add 2 new branches to the father of the cells.

log_newcell(cell)[source]
class cellsystem.logging.treelogs.MutationsLog(*args, **kwargs)[source]

Bases: cellsystem.logging.treelogs.TreeLog

A tree log that maintains a record of genome branching events.

Each leaf represents a genome that may be present in one or more cells. When one of those cells mutates, the new genome is added as a child of that leaf.

The current state of an object ‘tree’ is handily accessible by ‘print(tree)’

log_division(daughters)[source]

Remove the father from the alive cells.

log_mutation(cell)[source]

Add a new child to the parent genome.

log_newcell(cell)[source]
class cellsystem.logging.treelogs.TreeLog(*args, **kwargs)[source]

Bases: cellsystem.logging.core.weak.WeakLog

Base class for logs that grow trees.

add_child(parent=None, name=None)[source]
alive_nodes
fetch_tree(prune_death=False)[source]

Fetch a copy of the tree.

If prune_death is True, remove the leaves that correspond to death cells.

log_death(cell)[source]
preparefor_division(cell)[source]

Module contents

Logging classes.

Classes related to the recording of the simulation progress, analysis and history.

class cellsystem.logging.FullLog(*args, **kwargs)[source]

Bases: cellsystem.logging.core.multi.MultiLog

An aggregate log that records geometric information, mutations, ancestry and prints the actions to the screen. (Technically is a multilog that contains a GeometricLog, a MutationsLog, an AncestryLog and a PrinterLog.)

Each part can be accesed with:

log[{{logname}}]

where {{logname}} can be one of: ‘geometry’, ‘mutations’, ‘ancestry’ or ‘printer’.

also, each log can be (de)activated with:

# Deactivate log
log[{{logname}}].silence()

# Reactivate log
log[{{logname}}].activate()
ancestry(prune_death=False)[source]

Fetch information of the cells’ “family tree”.

mutations(prune_death=False)[source]

Fetch information of the cells’ mutational history.

worldlines(prune_death=False)[source]

Fetch information of the cells’ evolution in space and time.

class cellsystem.logging.PrinterLog(*args, **kwargs)[source]

Bases: cellsystem.logging.core.log.Log

Simple logger that prints the steps to the screen.

log_death(cell)[source]
log_division(daughters)[source]
log_migration(cell)[source]
log_mutation(cell)[source]
log_newcell(cell)[source]
preparefor_death(cell)[source]
preparefor_division(cell)[source]
preparefor_migration(cell)[source]
preparefor_mutation(cell)[source]
class cellsystem.logging.MutationsLog(*args, **kwargs)[source]

Bases: cellsystem.logging.treelogs.TreeLog

A tree log that maintains a record of genome branching events.

Each leaf represents a genome that may be present in one or more cells. When one of those cells mutates, the new genome is added as a child of that leaf.

The current state of an object ‘tree’ is handily accessible by ‘print(tree)’

log_division(daughters)[source]

Remove the father from the alive cells.

log_mutation(cell)[source]

Add a new child to the parent genome.

log_newcell(cell)[source]
class cellsystem.logging.AncestryLog(*args, **kwargs)[source]

Bases: cellsystem.logging.treelogs.TreeLog

A tree log that maintains a “family tree”.

Each leaf represents a cell. When that cell divides, the leaf branches into leaves representing the daughters.

The current state of an object ‘tree’ is handily accessible by ‘print(tree)’

add_child(*args, **kwargs)[source]
log_division(daughters)[source]

Add 2 new branches to the father of the cells.

log_newcell(cell)[source]
class cellsystem.logging.GeometricLog(*args, **kwargs)[source]

Bases: cellsystem.logging.core.weak.WeakLog

Registers the geometric positions of the cells in time.

One may view the state of a GeometricLog object ‘glog’ by ‘glog.worldlines().show()’

iter_changes()[source]

Iterate through every action

iter_states()[source]

Generate the intermediate states.

log_death(cell)[source]

Register the disappeareance of the cell.

log_division(daughters)[source]
log_migration(cell)[source]
log_newcell(cell)[source]
preparefor_division(cell)[source]
worldlines(prune_death=False)[source]

Get the geometric evolution of individual cells in space and time.

cellsystem.logging.logged(action_name, prepare=True)[source]

Decorate an action with logging.

Allows to specify if a prelogging action is called.

An action is a function ‘f’. The decorated function is another function ` logf = logged('action', prepare)(f) ` such that, if ‘log’ is a Log, then calling ‘logf(*args, log=log, **kwargs)’ also triggers transparently the log for the action name specified, that is, roughly the next steps are followed: ``` if prepare:

log.preparefor(‘action’)

result = f(*args, **kwargs)

log.log(‘action’, result)

return result ```