- class openff.nagl.toolkits.NAGLRDKitToolkitWrapper[source]
Bases:
NAGLToolkitWrapperBase
,RDKitToolkitWrapper
Methods
Compute partial charges with RDKit, and assign the new values to the partial_charges attribute.
Compute the similarity between two molecules using a fingerprinting method.
Determine whether each atom in a molecule is in a ring of a given size.
Compute the lowest all-atom RMSD between a reference and target conformer, allowing for symmetry-equivalent atoms to be permuted.
Determine whether each bond in a molecule is in a ring of a given size.
Get the hybridization of each atom in a molecule.
Convert a mapped SMILES string to a SMILES string.
Convert a SMILES string to a mapped SMILES string.
Stream molecules from an SDF file.
Stream molecules to an SDF file using a context manager.
Create an RDKit molecule Requires the RDKit to be installed.
Attributes
- assign_partial_charges(molecule, partial_charge_method=None, use_conformers=None, strict_n_conformers=False, normalize_partial_charges=True, _cls=None)[source]
Compute partial charges with RDKit, and assign the new values to the partial_charges attribute.
Warning
This API is experimental and subject to change.
- Parameters:
molecule (
openff.toolkit.topology.Molecule
) – Molecule for which partial charges are to be computedpartial_charge_method (
str
, optional, defaultNone
) –The charge model to use. One of [‘mmff94’, ‘gasteiger’]. If None, ‘mmff94’ will be used.
- ’mmff94’: Applies partial charges using the Merck Molecular Force Field
(MMFF). This method does not make use of conformers, and hence
use_conformers
andstrict_n_conformers
will not impact the partial charges produced.
use_conformers (
iterable
ofunit-wrapped numpy arrays
,each with
) – shape (n_atoms, 3) and dimension of distance. Optional, default = None Coordinates to use for partial charge calculation. If None, an appropriate number of conformers will be generated.strict_n_conformers (
bool
, defaultFalse
) – Whether to raise an exception if an invalid number of conformers is provided for the given charge method. If this is False and an invalid number of conformers is found, a warning will be raised.normalize_partial_charges (
bool
, defaultTrue
) – Whether to offset partial charges so that they sum to the total formal charge of the molecule. This is used to prevent accumulation of rounding errors when the partial charge generation method has low precision._cls (
class
) – Molecule constructor
- Raises:
ChargeMethodUnavailableError – if the requested charge method can not be handled by this toolkit
ChargeCalculationError – if the charge method is supported by this toolkit, but fails
- calculate_circular_fingerprint_similarity(molecule: Molecule, reference_molecule: Molecule, radius: int = 3, nbits: int = 2048) float [source]
Compute the similarity between two molecules using a fingerprinting method. Uses a Morgan fingerprint with RDKit and a Circular fingerprint with OpenEye.
- Parameters:
molecule (
openff.toolkit.topology.Molecule
) – The molecule to compute the fingerprint for.reference_molecule (
openff.toolkit.topology.Molecule
) – The molecule to compute the fingerprint for.radius (
int
, default3
) – The radius of the fingerprint to use.nbits (
int
, default2048
) – The length of the fingerprint to use. Not used in RDKit.
- Returns:
similarity (
float
) – The Dice similarity between the two molecules.
- get_atoms_are_in_ring_size(molecule: Molecule, ring_size: int) List[bool] [source]
Determine whether each atom in a molecule is in a ring of a given size.
- Parameters:
molecule (
openff.toolkit.topology.Molecule
) – The molecule to compute ring perception forring_size (
int
) – The size of the ring to check for.
- Returns:
in_ring_size (
List[bool]
)
- get_best_rmsd(molecule: Molecule, reference_conformer: ndarray | Quantity, target_conformer: ndarray | Quantity) Quantity [source]
Compute the lowest all-atom RMSD between a reference and target conformer, allowing for symmetry-equivalent atoms to be permuted.
- Parameters:
molecule (
openff.toolkit.topology.Molecule
) – The molecule to compute the RMSD forreference_conformer (
np.ndarray
oropenff.units.unit.Quantity
) – The reference conformer to compare to the target conformer. If a numpy array, it is assumed to be in units of angstrom.target_conformer (
np.ndarray
oropenff.units.unit.Quantity
) – The target conformer to compare to the reference conformer. If a numpy array, it is assumed to be in units of angstrom.
- Returns:
rmsd (
unit.Quantity
)
Examples
>>> from openff.units import unit >>> from openff.toolkit.topology import Molecule >>> from openff.toolkit.utils.toolkits import RDKitToolkitWrapper >>> toolkit_wrapper = RDKitToolkitWrapper() >>> molecule = Molecule.from_smiles("CCCCO") >>> molecule.generate_conformers(n_conformers=2) >>> rmsd = toolkit_wrapper.get_best_rmsd(molecule, molecule.conformers[0], molecule.conformers[1]) >>> print(f"RMSD in angstrom: {rmsd.m_as(unit.angstrom)}")
- get_bonds_are_in_ring_size(molecule: Molecule, ring_size: int) List[bool] [source]
Determine whether each bond in a molecule is in a ring of a given size.
- Parameters:
molecule (
openff.toolkit.topology.Molecule
) – The molecule to compute ring perception forring_size (
int
) – The size of the ring to check for.
- Returns:
in_ring_size (
List[bool]
) – Bonds are in the same order as the molecule’sbonds
attribute.
- get_molecule_hybridizations(molecule: Molecule) List[HybridizationType] [source]
Get the hybridization of each atom in a molecule.
- Parameters:
molecule (
openff.toolkit.topology.Molecule
) – The molecule to get the hybridizations of.- Returns:
hybridizations (
List[HybridizationType]
) – The hybridization of each atom in the molecule.
- classmethod mapped_smiles_to_smiles(mapped_smiles: str) str [source]
Convert a mapped SMILES string to a SMILES string.
- classmethod smiles_to_mapped_smiles(smiles: str) str [source]
Convert a SMILES string to a mapped SMILES string.
- classmethod stream_molecules_from_sdf_file(file: str, as_smiles: bool = False, mapped_smiles: bool = False, explicit_hydrogens: bool = True, **kwargs)[source]
Stream molecules from an SDF file.
- Parameters:
file (
str
) – The path to the SDF file to stream molecules from.as_smiles (
bool
, defaultFalse
) – If True, return a SMILES string instead of an OpenFF Moleculemapped_smiles (
bool
, defaultFalse
) – If True, return a SMILES string with atom indices as atom map numbers.explicit_hydrogens (
bool
, defaultTrue
) – If True, keep explicit hydrogens in SMILES outputs.
- Returns:
molecules (
Generator[openff.toolkit.topology.Molecule
orstr]
)
- stream_molecules_to_file(file: str)[source]
Stream molecules to an SDF file using a context manager.
- Parameters:
file (
str
) – The path to the SDF file to stream molecules to.
Examples
>>> from openff.toolkit.topology import Molecule >>> from openff.toolkit.utils.toolkits import RDKitToolkitWrapper >>> toolkit_wrapper = RDKitToolkitWrapper() >>> molecule1 = Molecule.from_smiles("CCO") >>> molecule2 = Molecule.from_smiles("CCC") >>> with toolkit_wrapper.stream_molecules_to_file("molecules.sdf") as writer: ... writer(molecule1) ... writer(molecule2)
- to_rdkit(molecule: Molecule)[source]
Create an RDKit molecule Requires the RDKit to be installed.
Warning
This API is experimental and subject to change.
- Parameters:
aromaticity_model (
str
, optional, default"OEAroModel_MDL"
) – The aromaticity model to use. Only OEAroModel_MDL is supported.- Returns:
rdmol (
rkit.RDMol
) – An RDKit molecule
Examples
Convert a molecule to RDKit >>> from openff.toolkit import Molecule >>> ethanol = Molecule.from_smiles(‘CCO’) >>> rdmol = ethanol.to_rdkit()