dgllife.utils.get_mol_3d_coordinates

dgllife.utils.get_mol_3d_coordinates(mol)[source]

Get 3D coordinates of the molecule.

This function requires that molecular conformation has been initialized.

Parameters

mol (rdkit.Chem.rdchem.Mol) – RDKit molecule instance.

Returns

The 3D coordinates of atoms in the molecule. N for the number of atoms in the molecule. For failures in getting the conformations, None will be returned.

Return type

numpy.ndarray of shape (N, 3) or None

Examples

An error will occur in the example below since the molecule object does not carry conformation information.

>>> from rdkit import Chem
>>> from dgllife.utils import get_mol_3d_coordinates
>>> mol = Chem.MolFromSmiles('CCO')

Below we give a working example based on molecule conformation initialized from calculation.

>>> from rdkit.Chem import AllChem
>>> AllChem.EmbedMolecule(mol)
>>> AllChem.MMFFOptimizeMolecule(mol)
>>> coords = get_mol_3d_coordinates(mol)
>>> print(coords)
array([[ 1.20967478, -0.25802181,  0.        ],
       [-0.05021255,  0.57068079,  0.        ],
       [-1.15946223, -0.31265898,  0.        ]])