wholecell.utils.make_media
Functions for making media
# Example use of make_media
### Create media object > media_obj = Media(raw_data)
### Retrieve stock media > base_media = media_obj.stock_media[‘M9_GLC’] > base_media2 = media_obj.stock_media[‘5X_supplement_EZ’]
### Define a dict of ingredients Ingredients is a dict with molecule ids as the keys. Each ingredient’s value is a dict with {‘weight’: value * (units.g), ‘counts’: value * (units.mmol), ‘volume’: value * (units.L)}. Only one of ‘weights’ (in units.g) or ‘counts’ (in units.mmol) is required; if both are specified, it will use weight. If weight or counts is Infinity, it sets the final concentration to inf. If weight or counts is -Infinity, it sets the final concentration to 0.
Example: > ingredients = {
‘L-ALPHA-ALANINE’: {‘weight’: 1.78 * units.g, ‘volume’: 0.025 * units.L}, ‘ARG’: {‘weight’: 8.44 * units.g, ‘volume’: 0.1 * units.L}, ‘UREA’: {‘counts’: 102.0 * units.mmol, ‘volume’: 1.0 * units.L}, ‘LEU’: {‘weight’: float(“inf”) * units.g, ‘volume’: 0 * units.L}, ‘OXYGEN-MOLECULE’: {‘weight’: float(“-inf”) * units.g, ‘volume’: 0 * units.L},
}
### Add ingredients directly into an existing media > new_media1 = media_obj.add_ingredients(base_media, 0.8 * units.L, ingredients)
### Combine two medias > new_media2 = media_obj.combine_media(base_media, 0.8 * units.L, base_media2, 0.2 * units.L)
- class wholecell.utils.make_media.Media(raw_data)[source]
Bases:
object
A media object is a factory for making new media by either combining two saved media at different volumes (with self.combine_media(), or adding ingredients to a saved media (with self.add_ingredients()). Ingredients can be added by either specifying their weight (in grams) or the counts (in mmol) in addition to the volume. The new media dicts are returned to the caller, and are not saved in this object. A media object holds dicts about stock media in
`self.stock_media`
and the formula weight of environmental molecules in`self.environment_molecules_fw`
, which is needed for mixing in ingredients at weights.- _get_environment_molecules_fw(raw_data)[source]
get formula weight (units.g / units.mol) for all environmental molecules
- add_ingredients(base_media, base_media_volume, ingredients)[source]
Combines ingredients to existing media to make new media.
- Parameters:
base_media (dict) – {molecule_id: concentrations}
base_media_volume
ingredients (dict) –
keys are ingredient ids, values are dicts with weight, counts, volume. Only one of weights (in g) or counts (in mmol) is needed; if both are specified, it will use weight. If weight or counts is Infinity, the new concentration is set to inf. If the weight or counts is -Infinity, the new concentration is set to 0. Example format of ingredients:
{mol_id_1: {‘weight’: 1.78 * units.g, ‘volume’: 0.025 * units.L), mol_id_2: {‘counts’: 0.2 * units.mmol, ‘volume’: 0.1 * units.L), }
- Returns:
{molecule_id: concentrations}
- Return type:
new_media (dict)
- combine_media(base_media, base_media_volume, mix_media, mix_media_volume)[source]
Combines two medias and returns a new media
- Parameters:
base_media (dict) – dicts with {molecule_id: concentration}
mix_media (dict) – dicts with {molecule_id: concentration}
base_media_volume (unum) – the volumes of base_media and mix_media (floats) with a volume units (i.e. units.L)
mix_media_volume (unum) – the volumes of base_media and mix_media (floats) with a volume units (i.e. units.L)
- Returns:
{molecule_id: concentrations}
- Return type:
new_media (dict)
- make_timeline(timeline_str)[source]
Make a timeline from a string
- Parameters:
timeline_str (str) – ‘time1 media_id1, time2 media_id2’
- Returns:
a list of tuples with (time (float), media_id (str))
- Return type:
TODO (Eran) make a parsing expression grammar for this: https://github.com/erikrose/parsimonious TODO (Eran) expand capabilities to also pass in ingredients to be added from the prior event