rdmc.reaction#
Module for Reaction
- class rdmc.reaction.Reaction(reactant: List[RDKitMol] | RDKitMol, product: List[RDKitMol] | RDKitMol, ts: RDKitMol | None = None)#
Bases:
object
The Reaction class that stores the reactant, product, and transition state information.
- property active_atoms#
- property active_bonds#
- apply_resonance_correction(inplace: bool = True) Reaction #
Apply resonance correction to the reactant and product complexes.
- bond_analysis()#
Perform bond analysis on the reaction.
- property broken_bonds#
- property changed_bonds#
- draw_2d(figsize: Tuple[int, int] = (800, 300), font_scale: float = 1.0, highlight_by_reactant: bool = True) str #
This is a modified version of the drawReaction2D function in RDKit.
- Parameters:
font_scale (float, optional) – The font scale for the atom map number. Defaults to 1.0.
highlightByReactant (bool, optional) – Whether to highlight the reactant(s) or product(s). Defaults to True.
- Returns:
str – The SVG string. To display the SVG, use IPython.display.SVG(svg_string).
- draw_3d(**kwargs)#
Display the reaction in 3D.
- property formed_bonds#
- classmethod from_reactant_and_product_smiles(rsmi: List[str] | str, psmi: List[str] | str)#
Initialize the Reaction class from reactant and product smile(s).
Args:
- classmethod from_reaction_smiles(smiles: str)#
Initialize the Reaction class from reaction SMILES.
- Parameters:
smiles (str) – The reaction SMILES.
- Returns:
Reaction – The Reaction class.
- get_fingerprint(mode: str = 'REAC_DIFF', fp_type: str = 'morgan', count: bool = False, num_bits: int = 2048, **kwargs) np.array #
Get the fingerprint of the reaction.
- Parameters:
mode (str) – The fingerprint combination of
'REAC'
(reactant),'PROD'
(product),'DIFF'
(reactant - product),'REVD'
(product - reactant),'SUM'
(reactant + product), separated by'_'
. Defaults toREAC_DIFF
, with the fingerprint to be a concatenation of reactant fingerprint and the difference between the reactant complex and the product complex.fp_type (str, optional) – The type of fingerprint to generate. Options are:
'atom_pair'
,'morgan'
(default),'rdkit'
,'topological_torsion'
,'avalon'
, and'maccs'
.num_bits (int, optional) – The length of the molecular fingerprint. For a mode with N blocks, the eventual length is
num_bits * N
. Default is2048
. It has no effect on'maccs'
generator.dtype (str, optional) – The data type of the output numpy array. Defaults to
'int32'
.
- get_reverse_reaction()#
Get the reverse reaction.
- has_same_products(other: Reaction, resonance: bool = False) bool #
Check if the reaction has the same products as the other reaction.
- Parameters:
other (Reaction) – The other reaction to compare.
- Returns:
bool – Whether the reaction has the same products as the other reaction.
- has_same_reactants(other: Reaction, resonance: bool = False) bool #
Check if the reaction has the same reactants as the other reaction.
- Parameters:
other (Reaction) – The other reaction to compare.
- Returns:
bool – Whether the reaction has the same reactants as the other reaction.
- init_reactant_product(reactant: List[RDKitMol] | RDKitMol, product: List[RDKitMol] | RDKitMol)#
- property involved_atoms#
- property involved_bonds#
- property is_charge_balanced: bool#
Whether the charge in the reactant(s) and product(s) are balanced.
- property is_element_balanced: bool#
Whether the elements in the reactant(s) and product(s) are balanced.
- is_equivalent(reaction: Reaction, resonance: bool = False, both_directions: bool = False) bool #
Check if the reaction is equivalent to the given reaction.
- Parameters:
reaction (Reaction) – The reaction to compare.
resonance (bool, optional) – Whether to consider resonance structures. Defaults to
False
.both_directions (bool, optional) – Whether to check both directions. Defaults to
False
.
- Returns:
bool – Whether the reaction is equivalent to the given reaction.
- property is_mult_equal: bool#
Whether the spin multiplicity in the reactant(s) and product(s) are equal.
- property is_num_atoms_balanced: bool#
Whether the number of atoms in the reactant(s) and product(s) are balanced.
- property is_resonance_corrected: bool#
Whether the reaction is resonance corrected.
- is_same_products(products: List[RDKitMol] | RDKitMol, resonance: bool = False)#
Check if the reaction has the same products as the given products or product complex.
- Parameters:
product (Union[List[RDKitMol], RDKitMol]) – The products or product complex to compare.
resonance (bool, optional) – Whether to consider resonance structures. Defaults to
False
.
- Returns:
bool – Whether the reaction has the same products as the given products or product complex.
- is_same_reactants(reactants: List[RDKitMol] | RDKitMol, resonance: bool = False) bool #
Check if the reaction has the same reactants as the given reactants or reactant complex.
- Parameters:
reactant (Union[List[RDKitMol], RDKitMol]) – The reactants or reactant complex to compare.
resonance (bool, optional) – Whether to consider resonance structures. Defaults to
False
.
- Returns:
bool – Whether the reaction has the same reactants as the given reactants or reactant complex.
- make_ts()#
Make the transition state of the reaction based on the reactant and product. This method assumes that the reactant complex and product complex are atom-mapped already.
- map_h_atoms(add_hs: bool = False) Reaction #
Atom map H atoms. This is useful if the reactions are initialized with only heavy atoms or the reactant and product complex only has heavy atom mapped.
- Parameters:
add_hs (bool, optional) – If the reaction is initialized with only heavy atoms presenting, set it to
True
. Defaults toFalse
.- Returns:
Reaction – a new reaction instance with h atoms mapped.
- property num_atoms: bool#
The number of atoms involved in the reactant(s) and product(s).
- property num_broken_bonds#
- property num_changed_bonds#
- property num_formed_bonds#
- property num_heavy_atoms: bool#
The number of heavy atoms involved in the reaction.
- property num_products: int#
The number of products.
- property num_reactants: int#
The number of reactants.
- property product_element_count: dict#
The element count in the reactant(s) and product(s).
- property reactant_element_count: dict#
The element count in the reactant(s) and product(s).
- require_bond_analysis()#
Timer decorator for recording the time of a function.
- Parameters:
func (function) – The function to be decorated.
- Returns:
function – The decorated function.
- to_rdkit_reaction() ChemicalReaction #
Convert the reaction to RDKit ChemicalReaction.
- to_smiles(remove_hs: bool = False, remove_atom_map: bool = False, **kwargs) str #
Convert the reaction to reaction SMILES.
- property ts#
The transition state of the reaction.