chemprop.featurizers.molgraph.reaction#

Attributes#

Classes#

RxnMode

The mode by which a reaction should be featurized into a MolGraph

CondensedGraphOfReactionFeaturizer

A CondensedGraphOfReactionFeaturizer featurizes reactions using the condensed

Module Contents#

chemprop.featurizers.molgraph.reaction.logger#
class chemprop.featurizers.molgraph.reaction.RxnMode[source]#

Bases: chemprop.utils.utils.EnumMapping

The mode by which a reaction should be featurized into a MolGraph

REAC_PROD#

concatenate the reactant features with the product features.

REAC_PROD_BALANCE#

concatenate the reactant features with the products feature and balances imbalanced reactions

REAC_DIFF#

concatenates the reactant features with the difference in features between reactants and products

REAC_DIFF_BALANCE#

concatenates the reactant features with the difference in features between reactants and product and balances imbalanced reactions

PROD_DIFF#

concatenates the product features with the difference in features between reactants and products

PROD_DIFF_BALANCE#

concatenates the product features with the difference in features between reactants and products and balances imbalanced reactions

class chemprop.featurizers.molgraph.reaction.CondensedGraphOfReactionFeaturizer[source]#

Bases: chemprop.featurizers.molgraph.mixins._MolGraphFeaturizerMixin, chemprop.featurizers.base.GraphFeaturizer[chemprop.types.Rxn]

A CondensedGraphOfReactionFeaturizer featurizes reactions using the condensed reaction graph method utilized in [1]

NOTE: This class does not accept a AtomFeaturizer instance. This is because it requries the num_only() method, which is only implemented in the concrete AtomFeaturizer class

Parameters:
  • atom_featurizer (AtomFeaturizer, default=AtomFeaturizer()) – the featurizer with which to calculate feature representations of the atoms in a given molecule

  • bond_featurizer (BondFeaturizerBase, default=BondFeaturizer()) – the featurizer with which to calculate feature representations of the bonds in a given molecule

  • mode (Union[str, ReactionMode], default=ReactionMode.REAC_DIFF) – the mode by which to featurize the reaction as either the string code or enum value

References

mode_: dataclasses.InitVar[str | RxnMode]#
__post_init__(mode_)[source]#
Parameters:

mode_ (str | RxnMode)

property mode: RxnMode#
Return type:

RxnMode

__call__(rxn, atom_features_extra=None, bond_features_extra=None)[source]#

Featurize the input reaction into a molecular graph

Parameters:
  • rxn (Rxn) – a 2-tuple of atom-mapped rdkit molecules, where the 0th element is the reactant and the 1st element is the product

  • atom_features_extra (np.ndarray | None, default=None) – UNSUPPORTED maintained only to maintain parity with the method signature of the MoleculeFeaturizer

  • bond_features_extra (np.ndarray | None, default=None) – UNSUPPORTED maintained only to maintain parity with the method signature of the MoleculeFeaturizer

Returns:

the molecular graph of the reaction

Return type:

MolGraph

classmethod map_reac_to_prod(reacs, pdts)[source]#

Map atom indices between corresponding atoms in the reactant and product molecules

Parameters:
  • reacs (Chem.Mol) – An RDKit molecule of the reactants

  • pdts (Chem.Mol) – An RDKit molecule of the products

Returns:

  • ri2pi (dict[int, int]) – A dictionary of corresponding atom indices from reactant atoms to product atoms

  • pdt_idxs (list[int]) – atom indices of poduct atoms

  • rct_idxs (list[int]) – atom indices of reactant atoms

Return type:

tuple[dict[int, int], list[int], list[int]]

type chemprop.featurizers.molgraph.reaction.CGRFeaturizer = CondensedGraphOfReactionFeaturizer#