pyxtal.molecule module
Module for handling molecules.
- class pyxtal.molecule.Box(dims)[source]
Bases:
object
Class for storing the binding box for a molecule.
- Parameters:
dims – [length, width, height]
- class pyxtal.molecule.Orientation(matrix=None, degrees=2, axis=None)[source]
Bases:
object
Stores orientations for molecules based on vector constraints. Can be stored to regenerate orientations consistent with a given constraint vector, without re-calling orientation_in_wyckoff_position. Allows for generating orientations which differ only in their rotation about a given axis.
- Parameters:
matrix – a 3x3 rotation matrix describing the orientation (and/or inversion) to store
degrees – the number of degrees of freedom… 0 - The orientation refers to a single rotation matrix 1 - The orientation can be rotated about a single axis 2 - The orientation can be any pure rotation matrix
axis – an optional axis about which the orientation can rotate. Only used if degrees is equal to 1
- change_orientation(angle='random', flip=False)[source]
Allows for specification of an angle (possibly random) to rotate about the constraint axis.
- Parameters:
angle (only apply on) – an angle to rotate about the constraint axis.
"random" (If)
angle. (chooses a random rotation)
self.degrees==2 (If)
matrix. (chooses a random rotation)
self.degrees==1 (If)
angle
self.degrees==0 (If)
change (no)
- get_matrix(angle='random')[source]
Generate a 3x3 rotation matrix consistent with the orientation’s constraints. Allows for specification of an angle (possibly random) to rotate about the constraint axis.
- Parameters:
angle – an angle to rotate about the constraint axis. If “random”, chooses a random rotation angle. If self.degrees==2, chooses a random 3d rotation matrix to multiply by. If the original matrix is wanted, set angle=0, or call self.matrix
- Returns:
a 3x3 rotation (and/or inversion) matrix (numpy array)
- get_op()[source]
Generate a SymmOp object consistent with the orientation’s constraints. Allows for specification of an angle (possibly random) to rotate about the constraint axis.
- Parameters:
angle – an angle to rotate about the constraint axis. If “random”, chooses a random rotation angle. If self.degrees==2, chooses a random 3d rotation matrix to multiply by. If the original matrix is wanted, set angle=0, or call self.matrix
- Returns:
pymatgen.core.structure. SymmOp object
- random_orientation()[source]
Applies random rotation (if possible) and returns a new orientation with the new base matrix.
- Returns:
a new orientation object with a different base rotation matrix
- pyxtal.molecule.compare_mol_connectivity(mol1, mol2, ignore_name=False)[source]
Compare two molecules by connectivity
- pyxtal.molecule.find_rotor_from_smile(smile)[source]
Find the positions of rotatable bonds in the molecule.
- pyxtal.molecule.generate_molecules(smile, wps=None, N_iter=5, N_conf=10, tol=0.5)[source]
generate pyxtal_molecules from smiles codes.
- Parameters:
smile – smiles code
wps – list of wps
N_iter – rdkit parameter
N_conf – number of conformers
tol – rdkit parameter
- Returns:
a list of pyxtal molecules
- pyxtal.molecule.get_inertia_tensor(coords, weights=None)[source]
Calculate the symmetric inertia tensor for a molecule.
- Parameters:
coords – [N, 3] array of coordinates
- Returns:
a 3x3 numpy array representing the inertia tensor
- pyxtal.molecule.has_non_aromatic_ring(smiles)[source]
Determine if a molecule has a non-aromatic ring. Mainly used to check if a cyclic ring exists.
- Parameters:
smiles – smiles string
- Returns:
True or False
- pyxtal.molecule.is_compatible_symmetry(mol, wp)[source]
Tests if a molecule meets the symmetry requirements of a Wyckoff position
- Parameters:
mol – a pymatgen Molecule object.
wp – a pyxtal.symmetry.Wyckoff_position object
- class pyxtal.molecule.pyxtal_molecule(mol=None, symmetrize=True, fix=False, torsions=None, seed=None, tm=<pyxtal.tolerance.Tol_matrix object>, symtol=0.3)[source]
Bases:
object
Extended molecule class based on pymatgen.core.structure.Molecule The added features include: 0, parse the input 1, estimate volume/tolerance/radii 2, find and store symmetry 3, get the principle axis 4, re-align the molecule
The molecule is always centered at (0, 0, 0).
If the smile format is used, the center is defined as in https://www.rdkit.org/docs/source/rdkit.Chem.rdMolTransforms.html
Otherwise, the center is just the mean of atomic positions
- Parameters:
mol – a string to reprent the molecule
tm – tolerance matrix
- align(conf, reflect=False, torsionlist=None)[source]
Align the molecule and return the xyz The default CanonicalizeConformer function may also include inversion
- get_box(padding=None)[source]
Given a molecule, find a minimum orthorhombic box containing it. Size is calculated using min and max x, y, and z values, plus the padding defined by the vdw radius For best results, call oriented_molecule first.
- Parameters:
padding – float (default is 3.4 according to the vdw radius of C)
- Returns:
a Box object
- Return type:
box
- get_box_coordinates(xyz, padding=0, resolution=1.0)[source]
create the points cloud to describe the molecular box
- Parameters:
center – molecular center position
orientation – orientation matrix
padding – padding of the box
resolution – float in angstrom
- Returns:
box axis vertices: [N, 3] array, Cartesian coordinates to describe the box. center: box center
- Return type:
cell
- get_coefs_matrix(mol2=None, ignore_error=True)[source]
Get the Atom-Atom potential parameters E = A*exp(-B*R) - C*R^(-6) according to Gavezotti, Acc. Chem. Res., 27, 1994 in Kcal/mol and angstrom
- Parameters:
mol2 – the 2nd pyxtal_molecule object
tm – tolerance class
- Returns:
a 3D matrix for computing the intermolecular energy
- get_orientation(xyz, rtol=0.15)[source]
For the given xyz, compute the orientation
- Parameters:
xyz – molecular xyz
- get_orientations_in_wp(wp, rtol=0.01)[source]
Compute the valid orientations from a given Wyckoff site symmetry.
- Parameters:
wp – a pyxtal.symmetry.Wyckoff_position object
- Returns:
a list of pyxtal.molecule.Orientation objects
- get_orientations_in_wps(wps=None, rtol=0.01)[source]
Compute the valid orientations from a given Wyckoff site symmetry.
- Parameters:
wp – a pyxtal.symmetry.Wyckoff_position object
- Returns:
a list of operations.Orientation objects
- get_principle_axes(xyz, rdmt=True)[source]
get the principle axis for a rotated xyz, sorted by the moments
- get_rmsd(xyz, debug=False)[source]
Compute the rmsd with another 3D xyz coordinates
- Parameters:
xyz – 3D coordinates
- Returns:
rmsd values transition matrix: 4*4 matrix match: True or False
- Return type:
rmsd (float)
- get_rmsd2(xyz0, xyz1)[source]
Compute the rmsd with another 3D xyz coordinates
- Parameters:
xyz – 3D coordinates
- Returns:
transition matrix:
- Return type:
rmsd
- get_symmetry(xyz=None, symmetrize=False, rtol=0.3)[source]
- Set the molecule’s point symmetry.
pga: pymatgen.symmetry.analyzer.PointGroupAnalyzer object
pg: pyxtal.symmetry.Group object
symops: a list of SymmOp objects
- Parameters:
symmetrize – boolean, whether or not symmetrize the coordinates
- get_tols_matrix(mol2=None, tm=None)[source]
Compute the 2D tolerance matrix between the current and other molecules
- Parameters:
mol2 – the 2nd pyxtal_molecule object
tm – tolerance class
- Returns:
a 2D matrix which is used internally for distance checking.
- rdkit_mol_init(smile, fix, torsions)[source]
initialize the mol xyz and torsion list
- Parameters:
smile – smile string
fix – whether or not fix the seed
torsions – None or list
- relax(xyz, align=False)[source]
Relax the input xyz coordinates with rdit MMFF
- Parameters:
xyz – 3D coordinates
align – whether or not align the xyz
- Returns:
new xyz eng: energy value
- Return type:
xyz
- set_labels()[source]
Set atom labels for the given molecule for H-bond caculation. Needs to identify the following: - (O)N-H - acid-O - amide-O - alcohol-O - N with NH2 - N with NH
- pyxtal.molecule.random() x in the interval [0, 1).