rdmc.conformer_generation.align#
This module provides class and methods for reaction path analysis.
- class rdmc.conformer_generation.align.NaiveAlign(coords: array, atom_maps: List[List], formed_bonds: List[tuple], broken_bonds: List[tuple])#
Bases:
object
This is a naive alignment algorithm aligns reactant conformers.
For 1 reactant system, the algorithm simply put the center of the reactant at the origin.
For 2 reactant system, the resulting alignment has the following characteristics:
the centroid for fragment 1 is at the origin.
the centroid for fragment 2 is at (R1 + R2 + D), where R1 is the radius of fragment 1, R2 is the radius of fragment 2, and D is a pre-set distance value defined by the user.
the centroid of the reacting atoms in fragment 1 should be around the line (0,0,0) => (1,0,0).
the centroid of the reacting atoms in fragment 2 should be around the line (0,0,0) => (1,0,0).
the distance between atoms to form bonds are minimized.
The following are under development:
For 3 reactant system, the feature is under-development. There should be two cases: close-linear alignment and triangle alignment, depending on the max number of interactions among fragments.
For 4 reactant system, the feature is under-development. There should be three cases: close-linear, square, and tetrahedron alignment, depending on the max number of interactions among fragments.
- dist = 2.0#
- classmethod from_complex(r_complex: RDKitMol, formed_bonds: List[tuple], broken_bonds: List[tuple], conf_id: int = 0)#
Initialize from a reactant complex.
- Parameters:
r_complex (RDKitMol) – The reactant complex.
formed_bonds (List[tuple]) – bonds formed in the reaction.
broken_bonds (List[tuple]) – bonds broken in the reaction.
conf_id (int, optional) – The conformer id to be used in the
r_complex
. Defaults to0
.
- classmethod from_r_and_p_complex(r_complex: RDKitMol, p_complex: RDKitMol, conf_id: int = 0)#
Initialize from the reactant complex and the product complex. The product complex does not need to have conformers embedded, however, it should be atom mapped with the reactant complex.
- Parameters:
r_complex (RDKitMol) – The reactant complex.
p_complex (RDKitMol) – The product complex.
conf_id (int, optional) – The conformer id to be used in the reactant complex
r_complex
. Defaults to0
.
- classmethod from_reactants(mols: List[RDKitMol], formed_bonds: List[tuple], broken_bonds: List[tuple], conf_ids: List[int] = None)#
Create a complex in place by stacking the molecules together.
- Parameters:
mols (RDKitMol) – A list of reactants.
formed_bonds (List[tuple]) – bonds formed in the reaction.
broken_bonds (List[tuple]) – bonds broken in the reaction.
conf_id1 (int, optional) – The conformer id to be used in mol1. Defaults to
0
.conf_id2 (int, optional) – The conformer id to be used in mol2. Defaults to
0
.
- get_alignment_coords(dist: float = None) array #
Get coordinates of the alignment.
- Parameters:
dist (float, optional) – The a preset distance used to separate molecules. Defaults to
None meaning
using the value ofdist
.- Returns:
np.array – The coordinates of the alignment.
- get_fragment_radii() List[float] #
Get the radius of each fragment defined by the distance between the centroid to the farthest element.
- Returns:
list – A list of radius.
- get_reacting_atoms_in_fragments() List[list] #
Get the reacting atoms in each reactant.
- Returns:
- A list of the list of reacting atoms in each reactant.
- A list of the list of non reacting atoms in each reactant.
- initialize_align(dist: float = None)#
Initialize the alignment for the reactants. Currently only available for 1 reactant and 2 reactant systems.
- Parameters:
dist (float, optional) – The a preset distance used to separate molecules. Defaults to
None
, meaning using the default value ofdist
.
- rotate_fragment_separately(*angles: array, about_reacting: bool = False) array #
Rotate the molecule fragments in the complex by angles. The length of angles should be same as the length of self.atom_maps.
- Parameters:
angles (np.array) – Rotation angles for molecule fragment 1. It should be an array with a size of
(1,3)
indicate the rotation angles about the x, y, and z axes, respectively.about_reacting (bool, optional) – If rotate about the reactor center instead of the centroid. Defaults to
False
.
- Returns:
np.array – The coordinates after the rotation operation.
- score_bimolecule(angles: array) float #
Calculate the score of bimolecular reaction alignment.
- Parameters:
angles (np.array) – an array with 6 elements. The first 3 angles correspond to the rotation of the first fragment, and the last 3 angles correspond to the rotation of the second fragment.
- Returns:
float – The score value.
- rdmc.conformer_generation.align.align_reactant_fragments(r_mol: RDKitMol, p_mol: RDKitMol) RDKitMol #
Given reactant and product mols, find details of formed and broken bonds and generate reacting reactant complex.
- Parameters:
r_mol ('RDKitMol' or 'Mol') – An RDKit Mol object for reactant.
p_mol ('RDKitMol' or 'Mol') – An RDKit Mol object for product.
- Returns:
RDKitMol – The new reactant with aligned fragments.
- rdmc.conformer_generation.align.prepare_mols(r_mol: RDKitMol, p_mol: RDKitMol, align_bimolecular: bool = True) Tuple[RDKitMol, RDKitMol] #
Prepare mols for reaction path analysis. If reactant has multiple fragments, first orient reactants in reacting orientation. Then, reinitialize coordinates of product using
reset_pmol
function.- Parameters:
r_mol ('RDKitMol' or 'Mol') – An RDKit Mol object for reactant.
p_mol ('RDKitMol' or 'Mol') – An RDKit Mol object for product.
align_bimolecular (bool, optional) – Whether or not to use alignment algorithm on bimolecular reactions. Defaults to
True
- Returns:
r_mol (‘RDKitMol’) – The new reactant molecule.
p_mol_new (‘RDKitMol’) – The new product molecule.
- rdmc.conformer_generation.align.reset_pmol(r_mol: RDKitMol, p_mol: RDKitMol) RDKitMol #
Reset the product mol to best align with the reactant. This procedure consists of initializing the product 3D structure with the reactant coordinates and then 1) minimizing the product structure with constraints for broken bonds and 2) performing a second minimization with no constraints.
- Parameters:
r_mol ('RDKitMol' or 'Mol') – An RDKit Mol object for reactant.
p_mol ('RDKitMol' or 'Mol') – An RDKit Mol object for product.
- Returns:
RDKitMol – The new product mol with changed coordinates.