Reactions

class hippo.reaction.Reaction(db: Database, id: int, type: str, product: int, product_yield: float)[source]

A Reaction is a simplified representation of a synthetic pathway to create a product Compound. Reactants (also Compound objects) as well as a reaction type are required.

Attention

Reaction objects should not be created directly. Instead use HIPPO.register_reaction() or HIPPO.reactions()

self == other: int | Reaction bool[source]

compare this reaction to a Reaction object or ID

hash(self) int[source]

Integer hash from ID

repr(self) str[source]

ANSI Formatted string representation

str(self) str[source]

Unformatted string representation

check_chemistry(debug: bool = False) bool[source]

Sanity check the chemistry of this reaction

Parameters:

debug – increase verbosity (Default value = False)

check_reactant_availability(supplier: None | str = None, debug: bool = False) bool[source]

Check the availability of reactant compounds

Parameters:
  • supplier – Limit to quotes from this supplier (Default value = None)

  • debug – increase verbosity (Default value = False)

property db: Database

Returns a pointer to the parent database

draw() None[source]

Draw the molecules involved in this reaction

get_dict(smiles: bool = True, mols: bool = True) dict[str][source]

Returns a dictionary representing this Reaction

Parameters:
  • smiles – include smiles string (Default value = True)

  • mols – include rdkit.Chem.Mol (Default value = True)

get_reactant_amount_pairs(compound_object: bool = True) list[tuple][source]

Returns pairs of reactants and their amounts

Parameters:

compound_object – return Compound object instead of ID, (Default value = True)

Returns:

list of tuples containing Compound ID/object and amount in mg

get_reactant_ids() list[int][source]

Returns list of reactants Compound IDs

Returns:

list of Compound IDs

get_recipes(amount: float = 1, debug: bool = False, pick_cheapest: bool = False, permitted_reactions: None | ReactionSet = None, supplier: str | None = None) Recipe | list[Recipe][source]

Get a Recipe describing how to make the product

Parameters:
  • amount – Amount in mg, defaults to 1

  • debug – Increase verbosity, (Default value = False)

  • pick_cheapest – pick the cheapest Recipe, (Default value = False)

  • permitted_reactions – Limit the reactions to consider to members of this set, (Default value = None)

  • supplier – Limit to reactants from this supplier (Default value = None)

Returns:

Recipe object or list thereof

property id: int

Returns the Reaction ID

property metadata: MetaData

Returns the compound’s metadata dict

property plain_repr: str

Unformatted long string representation

property price_estimate: float

Estimate the price of this Reaction

property product: Compound

Returns the reaction’s product Compound

property product_id: int

Returns the product Compound ID

property product_mol

Product Compound rdkit.Chem.Mol object

property product_smiles: str

Product Compound SMILES string

property product_yield: float

Returns the reaction’s product yield (fraction)

property reactant_ids: set[int]

Returns a set of reactant ID’s

property reactant_mols

List of reactant Compound rdkit.Chem.Mol object

property reactant_smiles: list[str]

List of reactant Compound SMILES strings

property reactant_str_ids: str

Return an SQL formatted tuple string of the reactant Compound IDs

property reactants: CompoundSet

Returns a CompoundSet of the reactants

property reaction_str: str

Returns a string representing the reaction

summary(draw: bool = True) None[source]

Print a summary of this reaction’s information

Parameters:

draw – draw the reaction compounds (Default value = True)

property type: str

Returns the Reaction tyoe

class hippo.rset.ReactionSet(db: Database, indices: list = None, *, sort: bool = True, name: str | None = None)[source]

Object representing a subset of the ‘reaction’ table in the Database.

Attention

ReactionSet objects should not be created directly. Instead use the HIPPO.reactions() property. See Getting started with HIPPO and Adding data into HIPPO.

Use as an iterable

Iterate through Reaction objects in the set:

rset = animal.reactions[:100]

for reaction in rset:
        ...

Check membership

To determine if a Reaction is present in the set:

is_member = reaction in cset

Selecting compounds in the set

The ReactionSet can be indexed like standard Python lists by their indices

rset = animal.reactions[1:100]

# indexing individual compounds
reaction = rset[0]  # get the first reaction
reaction = rset[1]  # get the second reaction
reaction = rset[-1] # get the last reaction

# getting a subset of compounds using a slice
rset2 = rset[13:18] # using a slice
repr(self) str[source]

ANSI Formatted string representation

str(self) str[source]

Unformatted string representation

add(r: Reaction) None[source]

Add a Reaction to this set

Parameters:

rReaction to be added

copy() ReactionSet[source]

Return a copy of this set

property db: Database

Returns the associated Database

get_df(smiles=True, mols=True, **kwargs) pandas.DataFrame[source]

Construct a pandas.DataFrame of this ReactionSet

Parameters:
  • smiles – Include smiles column (Default value = True)

  • mols – Include rdkit.Chem.Mol column (Default value = True)

  • kwargs – keyword arguments are passed on to :meth:`.Reaction.get_dict:

get_dict() dict[str][source]

Serializable dictionary

get_recipes(amounts: float | list[float] = 1.0, **kwargs) Recipe | list[Recipe][source]

Get the Recipe object(s) from this set of recipes

Parameters:
  • amounts – float or list/generator of product amounts in mg, (Default value = 1.0)

  • kwargs – keyword arguments are passed on to :meth:`.Recipe.from_reactions:

property ids: list[int]

Returns the ids of poses in this set

property indices: list[int]

Returns the ids of poses in this set

interactive()[source]

Creates a ipywidget to interactively navigate this PoseSet.

property intermediates: CompoundSet

Get all intermediate compounds that can be synthesised with these reactions

property name: str | None

Returns the name of set

property products: CompoundSet

Get all product compounds that can be synthesised with these reactions (no intermediates)

property reactants: CompoundSet

Get all reactant compounds that are used by these reactions

reverse() None[source]

In-place reversal of indices

property str_ids: str

Return an SQL formatted tuple string of the Compound IDs

summary() None[source]

Print a summary of the Reactions

property table: str

Returns the name of the Database table

property types: list[str]

Returns the types of poses in this set