openforcefield.utils.toolkits.
RDKitToolkitWrapper
[source]¶RDKit toolkit wrapper
Warning
This API is experimental and subject to change.
toolkit_file_read_formats
List of file formats that this toolkit can read.
toolkit_file_write_formats
List of file formats that this toolkit can write.
toolkit_installation_instructions
classmethod(function) -> method
toolkit_name
The name of the toolkit wrapped by this class.
Methods
|
Find all SMARTS matches for the specified molecule, using the specified aromaticity model. |
|
Create an openforcefield.topology.Molecule from a file using this toolkit. |
|
Return an openforcefield.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit. |
|
If given an rdchem.Mol (or rdchem.Mol-derived object), this function will load it into an openforcefield.topology.molecule. |
|
Create a Molecule from an RDKit molecule. |
|
Create a Molecule from a SMILES string using the RDKit toolkit. |
|
Generate molecule conformers using RDKit. |
Check whether the RDKit toolkit can be imported |
|
|
|
|
Writes an OpenFF Molecule to a file-like object |
|
Writes an OpenFF Molecule to a file-like object |
|
Create an RDKit molecule |
|
Uses the RDKit toolkit to convert a Molecule into a SMILES string. |
__init__
(self, /, *args, **kwargs)¶Initialize self. See help(type(self)) for accurate signature.
Methods
|
Initialize self. |
|
Find all SMARTS matches for the specified molecule, using the specified aromaticity model. |
|
Create an openforcefield.topology.Molecule from a file using this toolkit. |
|
Return an openforcefield.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit. |
|
If given an rdchem.Mol (or rdchem.Mol-derived object), this function will load it into an openforcefield.topology.molecule. |
|
Create a Molecule from an RDKit molecule. |
|
Create a Molecule from a SMILES string using the RDKit toolkit. |
|
Generate molecule conformers using RDKit. |
Check whether the RDKit toolkit can be imported |
|
|
|
|
Writes an OpenFF Molecule to a file-like object |
|
Writes an OpenFF Molecule to a file-like object |
|
Create an RDKit molecule |
|
Uses the RDKit toolkit to convert a Molecule into a SMILES string. |
Attributes
List of file formats that this toolkit can read. |
|
List of file formats that this toolkit can write. |
|
classmethod(function) -> method |
|
The name of the toolkit wrapped by this class. |
is_available
()[source]¶Check whether the RDKit toolkit can be imported
True if RDKit is installed, False otherwise.
from_object
(self, object, allow_undefined_stereo=False)[source]¶If given an rdchem.Mol (or rdchem.Mol-derived object), this function will load it into an openforcefield.topology.molecule. Otherwise, it will return False.
An object to be type-checked and converted into a Molecule, if possible.
Whether to accept molecules with undefined stereocenters. If False, an exception will be raised if a molecule with undefined stereochemistry is passed into this function.
An openforcefield.topology.molecule Molecule.
If the object could not be converted into a Molecule.
from_file
(self, file_path, file_format, allow_undefined_stereo=False)[source]¶Create an openforcefield.topology.Molecule from a file using this toolkit.
The file to read the molecule from
Format specifier, usually file suffix (eg. ‘MOL2’, ‘SMI’) Note that not all toolkits support all formats. Check ToolkitWrapper.toolkit_file_read_formats for details.
If false, raises an exception if oemol contains undefined stereochemistry.
a list of Molecule objects is returned.
from_file_obj
(self, file_obj, file_format, allow_undefined_stereo=False)[source]¶Return an openforcefield.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit.
Warning
This API is experimental and subject to change.
The file-like object to read the molecule from
Format specifier, usually file suffix (eg. ‘MOL2’, ‘SMI’) Note that not all toolkits support all formats. Check ToolkitWrapper.toolkit_file_read_formats for details.
If false, raises an exception if oemol contains undefined stereochemistry.
a list of Molecule objects is returned.
to_file_obj
(self, molecule, file_obj, file_format)[source]¶Writes an OpenFF Molecule to a file-like object
The molecule to write
The file-like object to write to
The format for writing the molecule data
to_file
(self, molecule, file_path, file_format)[source]¶Writes an OpenFF Molecule to a file-like object
The molecule to write
The file path to write to
The format for writing the molecule data
to_smiles
(molecule)[source]¶Uses the RDKit toolkit to convert a Molecule into a SMILES string.
The molecule to convert into a SMILES.
The SMILES of the input molecule.
from_smiles
(self, smiles, hydrogens_are_explicit=False, allow_undefined_stereo=False)[source]¶Create a Molecule from a SMILES string using the RDKit toolkit.
Warning
This API is experimental and subject to change.
The SMILES string to turn into a molecule
If False, RDKit will perform hydrogen addition using Chem.AddHs
Whether to accept SMILES with undefined stereochemistry. If False, an exception will be raised if a SMILES with undefined stereochemistry is passed into this function.
An openforcefield-style molecule.
generate_conformers
(self, molecule, n_conformers=1, clear_existing=True)[source]¶Generate molecule conformers using RDKit.
Warning
This API is experimental and subject to change.
Molecule
The molecule to generate conformers for.
Maximum number of conformers to generate.
Whether to overwrite existing conformers for the molecule.
from_rdkit
(self, rdmol, allow_undefined_stereo=False)[source]¶Create a Molecule from an RDKit molecule.
Requires the RDKit to be installed.
Warning
This API is experimental and subject to change.
An RDKit molecule
If false, raises an exception if rdmol contains undefined stereochemistry.
An openforcefield molecule
Examples
Create a molecule from an RDKit molecule
>>> from rdkit import Chem
>>> from openforcefield.tests.utils import get_data_file_path
>>> rdmol = Chem.MolFromMolFile(get_data_file_path('systems/monomers/ethanol.sdf'))
>>> toolkit_wrapper = RDKitToolkitWrapper()
>>> molecule = toolkit_wrapper.from_rdkit(rdmol)
to_rdkit
(molecule, aromaticity_model='OEAroModel_MDL')[source]¶Create an RDKit molecule
Requires the RDKit to be installed.
Warning
This API is experimental and subject to change.
The aromaticity model to use
An RDKit molecule
Examples
Convert a molecule to RDKit
>>> from openforcefield.topology import Molecule
>>> ethanol = Molecule.from_smiles('CCO')
>>> rdmol = ethanol.to_rdkit()
find_smarts_matches
(self, molecule, smarts, aromaticity_model='OEAroModel_MDL')[source]¶Find all SMARTS matches for the specified molecule, using the specified aromaticity model.
Warning
This API is experimental and subject to change.
The molecule for which all specified SMARTS matches are to be located
SMARTS string with optional SMIRKS-style atom tagging
Aromaticity model to use during matching
toolkit_file_read_formats
¶List of file formats that this toolkit can read.
toolkit_file_write_formats
¶List of file formats that this toolkit can write.
toolkit_installation_instructions
¶classmethod(function) -> method
Convert a function to be a class method.
A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:
- class C:
@classmethod def f(cls, arg1, arg2, …):
…
It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.
Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.
toolkit_name
¶The name of the toolkit wrapped by this class.