recipe

recipe

Contains the Reaction Recipe, RecipeStep and RecipeCollection.

Classes

Name Description
Bind Change topology to form a bond
BondOperation Handle a bond operation on the recipe step.
Break Change topology to break a bond
CustomTopMod A custom recipe step that can be used to define a custom topology modification.
Place Change topology and/or coordinates to place an atom.
Recipe A reaction path defined by one series of RecipeSteps.
RecipeCollection A RecipeCollection encompasses a list of reaction paths.
RecipeStep Base class for all RecipeSteps.
Relax Start a relaxation MD.

Bind

recipe.Bind(
    self
    atom_ix_1=None
    atom_ix_2=None
    atom_id_1=None
    atom_id_2=None
)

Change topology to form a bond

Parameters

Name Type Description Default
atom_ix_1 int The index of the first atom. zero-based, by default None None
atom_ix_2 int The index of the second atom. zero-based, by default None None
atom_id_1 str The ID of the first atom. one-based, by default None None
atom_id_2 str The ID of the second atom. one-based, by default None None

BondOperation

recipe.BondOperation(
    self
    atom_ix_1=None
    atom_ix_2=None
    atom_id_1=None
    atom_id_2=None
)

Handle a bond operation on the recipe step.

This class takes in either zero-based indices or one-base IDs for two atoms.

Parameters

Name Type Description Default
atom_ix_1 int The index of the first atom. zero-based, by default None None
atom_ix_2 int The index of the second atom. zero-based, by default None None
atom_id_1 str The ID of the first atom. one-based, by default None None
atom_id_2 str The ID of the second atom. one-based, by default None None

Raises

Name Type Description
ValueError If neither an index nor an ID is provided for any of the atoms.

Notes

Internally, this class stores the atom indices and converts IDs to indices as needed.

Break

recipe.Break(
    self
    atom_ix_1=None
    atom_ix_2=None
    atom_id_1=None
    atom_id_2=None
)

Change topology to break a bond

Parameters

Name Type Description Default
atom_ix_1 int The index of the first atom. zero-based, by default None None
atom_ix_2 int The index of the second atom. zero-based, by default None None
atom_id_1 str The ID of the first atom. one-based, by default None None
atom_id_2 str The ID of the second atom. one-based, by default None None

CustomTopMod

recipe.CustomTopMod(self, f)

A custom recipe step that can be used to define a custom topology modification.

Parameters

Name Type Description Default
f Callable[[Topology], Topology] A function that takes a Topology object and modifies it in place. required

Place

recipe.Place(self, new_coords, ix_to_place=None, id_to_place=None)

Change topology and/or coordinates to place an atom.

Either provide the index (ix_to_place) or the ID (id_to_place) of the atom to place.

Parameters

Name Type Description Default
new_coords tuple[float, float, float] New xyz coordinates for atom to place to. Valid for the end point of the recipe timespan. required
ix_to_place int Index of atom to place. 0-based. None
id_to_place str Index of atom to place. 1-based None

Recipe

recipe.Recipe(self, recipe_steps, rates, timespans)

A reaction path defined by one series of RecipeSteps. Defines everything necessart to build the product state from the educt state.

Parameters

Name Type Description Default
recipe_steps list[RecipeStep] | DeferredRecipeSteps Can be a single sequence of RecipeSteps to modify the topology or a tuple with a key and a function that takes said key to generate the RecipeSteps once it has been choosen. It is up to the ReactionPlugins to choose how to match the key to the their internal state and return the RecipeSteps. required
rates list[float] Reaction rates corresponding 1:1 to timespans. required
timespans list[list[float, float]] List of half-open timespans (t1, t2] in ps, at which this rate is valid. Recipe steps which change the coordinates only need to be applicable at the first time in the interval. Must have same number of timespans as rates. t1 can equal t2 for the last frame. required

Methods

Name Description
check_consistency Run consistency checks for correct size of variables
combine_with Combines this Recipe with another with the same RecipeSteps.
get_vmd_selection Get a VMD selection string
check_consistency
recipe.Recipe.check_consistency()

Run consistency checks for correct size of variables

combine_with
recipe.Recipe.combine_with(other)

Combines this Recipe with another with the same RecipeSteps.

Parameters
Name Type Description Default
other Recipe required
get_vmd_selection
recipe.Recipe.get_vmd_selection()

Get a VMD selection string

for the atoms involved in the recipe steps.

RecipeCollection

recipe.RecipeCollection(self, recipes)

A RecipeCollection encompasses a list of reaction paths. They can originate from multiple reaction plugins, but do not need to.

Parameters

Name Type Description Default
recipes list[Recipe] List of Recipe objects. required

Methods

Name Description
aggregate_reactions Combines reactions having the same sequence of RecipeSteps.
calc_cumprob Calculate cumulative probability of all contained recipe steps.
calc_ratesum Calculate the sum of rates over all timesteps
from_csv Create a RecipeCollection object from a CSV file
plot Plot reaction rates over time
to_csv Write a ReactionResult as defined in the reaction module to a csv file
aggregate_reactions
recipe.RecipeCollection.aggregate_reactions()

Combines reactions having the same sequence of RecipeSteps.

Returns
Name Type Description
unique_recipes_ixs List of lists binning the old recipe indices and maps to the new recipes list.
calc_cumprob
recipe.RecipeCollection.calc_cumprob()

Calculate cumulative probability of all contained recipe steps. Sums up to 1 over all recipes. Assumes constant rate for given timespan and rate zero otherwise.

calc_ratesum
recipe.RecipeCollection.calc_ratesum()

Calculate the sum of rates over all timesteps

Returns
Name Type Description
boarders flat list containing times of rate changes marking the boarders of the windows
rate_windows flat list containing all rates in between the boarders. Each window is orderd as in recipe_windows
recipe_windows flat list containing the recipes of the corresponding window. Each window is orderd as in rate_windows
from_csv
recipe.RecipeCollection.from_csv(path)

Create a RecipeCollection object from a CSV file Returns the recipe collection and a single recipe that was picked, otherwise None

plot
recipe.RecipeCollection.plot(outfile, highlight_r=None, highlight_t=None)

Plot reaction rates over time

Parameters
Name Type Description Default
outfile Path Where to save the plot, must have compatible suffix. required
highlight_r Recipe Recipe to highlight, by default None None
highlight_t float Time at which the reactions starts None
to_csv
recipe.RecipeCollection.to_csv(path, picked_recipe=None)

Write a ReactionResult as defined in the reaction module to a csv file

RecipeStep

recipe.RecipeStep()

Base class for all RecipeSteps. Indices can be accessed as 0-based or 1-based. ix: 0-based, int id: 1-based, str

Methods

Name Description
from_str Parses expressions of the following forms into RecipeStep objects:
from_str
recipe.RecipeStep.from_str(s)

Parses expressions of the following forms into RecipeStep objects:

  • Place: Place(ix_to_place=0, new_coords=(0.0, 0.0, 0.0))
  • Break: Break(atom_ix_1=0, atom_ix_2=1)
  • Bind: Bind(atom_ix_1=0, atom_ix_2=1)
  • Relax: Relax()
  • CustomTopMod: CustomTopMod(f=<function f at 0x7f7f7f7f7f7f>)
Parameters
Name Type Description Default
s str String representation of a RecipeStep object. required

Relax

recipe.Relax(self)

Start a relaxation MD.

The molecular system coordinates are far out of equilibrium after most topology changes. A relaxtion MD simulation using for example the slow growth method helps to reach the new equilibrium.

Back to top