pyplate.Recipe
- class Recipe[source]
Bases:
objectA list of instructions for transforming one set of containers into another. The intended workflow is to declare the source containers, enumerate the desired transformations, and call recipe.bake(). The name of each object used by the Recipe must be unique. This method will ensure that all solid and liquid handling instructions are valid. If they are indeed valid, then the updated containers will be generated. Once recipe.bake() has been called, no more instructions can be added and the Recipe is considered immutable.
- locked
Is the recipe locked from changes?
- Type:
boolean
- steps
A list of steps to be completed upon bake() bring called.
- Type:
list
- used
A list of Containers and Plates to be used in the recipe.
- Type:
list
- results
A dictionary used in bake to return the mutated objects.
- Type:
dict
- stages
A dictionary of stages in the recipe.
- Type:
dict
Methods
__init__()bake()Completes steps stored in recipe.
create_container(name[, max_volume, ...])Adds a step to the recipe which creates a container.
create_solution(solute, solvent[, name])Adds a step to the recipe which creates a solution.
create_solution_from(source, solute, ...[, name])Adds a step to create a diluted solution from an existing solution.
dilute(destination, solute, concentration, ...)Adds a step to dilute solute in destination to concentration.
end_stage(name)End the current stage in the recipe.
fill_to(destination, solvent, quantity)Adds a step to fill destination container/plate/slice with solvent up to quantity.
get_amount_remaining(container[, timeframe, ...])get_container_flows(container[, timeframe, unit])Returns the inflow and outflow of a container in the recipe.
get_substance_used(substance[, timeframe, ...])Returns the amount of substance used in the recipe.
remove(destination[, what])Adds a step to removes substances from destination.
start_stage(name)Start a new stage in the recipe.
transfer(source, destination, quantity)Adds a step to the recipe which will move quantity from source to destination.
uses(*args)Declare *args (iterable of Containers and Plates) as being used in the recipe.
visualize(what, mode, unit[, timeframe, ...])Provide visualization of what happened during the step.
- bake() dict[str, Container | Plate][source]
Completes steps stored in recipe. Checks validity of each step and ensures all declared objects have been used. Locks Recipe from further modification.
- Returns:
Copies of all used objects in the order they were declared.
- create_container(name: str, max_volume: str = 'inf L', initial_contents: Iterable[tuple[Substance, str]] | None = None) Container[source]
Adds a step to the recipe which creates a container.
- Parameters:
name – Name of container
max_volume – Maximum volume that can be stored in the container. (‘10 mL’)
initial_contents – (optional) Iterable of tuples of the form (Substance, quantity)
- Returns:
A new Container so that it may be used in later recipe steps.
- create_solution(solute: Substance | Iterable[Substance], solvent: Substance | Container, name=None, **kwargs) Container[source]
Adds a step to the recipe which creates a solution.
Two out of concentration, quantity, and total_quantity must be specified.
Multiple solutes can be, optionally, provided as a list. Each solute will have the desired concentration or quantity in the final solution.
If one value is specified for concentration or quantity and multiple solutes are provided, the value will be used for all solutes.
- Parameters:
solute – What to dissolve. Can be a single Substance or an iterable of Substances.
solvent – What to dissolve with. Can be a Substance or a Container.
name – Optional name for new container.
concentration – Desired concentration(s). (‘1 M’, ‘0.1 umol/10 uL’, etc.)
quantity – Desired quantity of solute(s). (‘3 mL’, ‘10 g’)
total_quantity – Desired total quantity. (‘3 mL’, ‘10 g’)
- Returns:
A new Container so that it may be used in later recipe steps.
- create_solution_from(source: Container, solute: Substance, concentration: str, solvent: Substance, quantity: str, name=None) Container[source]
Adds a step to create a diluted solution from an existing solution.
- Parameters:
source – Solution to dilute.
solute – What to dissolve.
concentration – Desired concentration. (‘1 M’, ‘0.1 umol/10 uL’, etc.)
solvent – What to dissolve with.
quantity – Desired total quantity. (‘3 mL’, ‘10 g’)
name – Optional name for new container.
- Returns:
A new Container so that it may be used in later recipe steps.
- dilute(destination: Container, solute: Substance, concentration: str, solvent: Substance, new_name=None) None[source]
Adds a step to dilute solute in destination to concentration.
- Parameters:
destination – Container to dilute.
solute – Substance which is subject to dilution.
concentration – Desired concentration in mol/L.
solvent – What to dilute with.
new_name – Optional name for new container.
- end_stage(name: str) None[source]
End the current stage in the recipe.
- Parameters:
name – Name of the stage.
- fill_to(destination: Container | Plate | PlateSlicer, solvent: Substance, quantity: str) None[source]
Adds a step to fill destination container/plate/slice with solvent up to quantity.
- Parameters:
destination – Container/Plate/Slice to fill.
solvent – Substance to use to fill.
quantity – Desired final quantity in container.
- get_amount_remaining(container: Container | Plate, timeframe: str = 'all', unit: str | None = None, mode: str = 'after') float[source]
- get_container_flows(container: Container | Plate, timeframe: str = 'all', unit: str | None = None) dict[str, int | str][source]
Returns the inflow and outflow of a container in the recipe.
- Parameters:
container – Container to check.
timeframe – ‘all’ or a stage defined in the recipe.
unit – Unit to return amount in.
- get_substance_used(substance: Substance, timeframe: str = 'all', unit: str | None = None, destinations: Iterable[Container | Plate] | str = 'plates')[source]
Returns the amount of substance used in the recipe.
- Parameters:
substance – Substance to check.
timeframe – ‘before’ or ‘during’. Before refers to the initial state of the containers aka recipe “prep”, and
to (during refers) –
unit – Unit to return amount in.
destinations – Containers or plates to check. Defaults to “plates”.
Returns: Amount of substance used in the recipe.
- remove(destination: Container | Plate | PlateSlicer, what=2) None[source]
Adds a step to removes substances from destination.
- Parameters:
destination – What to remove from.
what – What to remove. Can be a type of substance or a specific substance. Defaults to LIQUID.
- start_stage(name: str) None[source]
Start a new stage in the recipe.
- Parameters:
name – Name of the stage.
- transfer(source: Container | Plate | PlateSlicer, destination: Container | Plate | PlateSlicer, quantity: str) None[source]
Adds a step to the recipe which will move quantity from source to destination. Note that all Substances in the source will be transferred in proportion to their respective ratios.
- uses(*args: Container | Plate | Iterable[Container | Plate]) Recipe[source]
Declare *args (iterable of Containers and Plates) as being used in the recipe.
- visualize(what: Plate, mode: str, unit: str, timeframe: int | str | RecipeStep = 'all', substance: str | Substance = 'all', cmap: str = None) str | pandas.io.formats.style.Styler[source]
Provide visualization of what happened during the step.
- Parameters:
what – Plate we are interested in.
mode – ‘delta’, or ‘final’
timeframe – Number of the step or the name of the stage to visualize.
unit – Unit we are interested in. (‘mmol’, ‘uL’, ‘mg’)
substance – Substance we are interested in. (‘all’, water, ATP)
cmap – Colormap to use. Defaults to default_colormap from config.
Returns: A dataframe with the requested information.