# openforcefield.utils.toolkits.RDKitToolkitWrapper

class `openforcefield.utils.toolkits.``RDKitToolkitWrapper`

  RDKit toolkit wrapper

  Warning

  This API is experimental and subject to change.

  Attributes
    `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_smarts_matches`(self, molecule, smarts) | Find all SMARTS matches for the specified molecule, using the specified aromaticity model.
  `from_file`(self, filename, file_format[, …]) | Create an openforcefield.topology.Molecule from a file using this toolkit.
  `from_file_obj`(self, file_obj, file_format[, …]) | Return an openforcefield.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit.
  `from_object`(self, object) | If given an rdchem.Mol (or rdchem.Mol-derived object), this function will load it into an openforcefield.topology.molecule.
  `from_rdkit`(self, rdmol[, allow_undefined_stereo]) | Create a Molecule from an RDKit molecule.
  `from_smiles`(self, smiles[, …]) | Create a Molecule from a SMILES string using the RDKit toolkit.
  `generate_conformers`(self, molecule[, …]) | Generate molecule conformers using RDKit.
  `is_available`() | Check whether toolkit is available for use.
  `requires_toolkit`() |
  `to_file`(self, molecule, outfile, outfile_format) | Writes an OpenFF Molecule to a file-like object
  `to_file_obj`(self, molecule, file_obj, …) | Writes an OpenFF Molecule to a file-like object
  `to_rdkit`(molecule[, aromaticity_model]) | Create an RDKit molecule
  `to_smiles`(molecule) | Uses the RDKit toolkit to convert a Molecule into a SMILES string.
  `toolkit_is_available`() | Check whether the RDKit toolkit can be imported

  `__init__`(self, /, *args, **kwargs)

    Initialize self. See help(type(self)) for accurate signature.

  Methods

  `find_smarts_matches`(self, molecule, smarts) | Find all SMARTS matches for the specified molecule, using the specified aromaticity model.
  `from_file`(self, filename, file_format[, …]) | Create an openforcefield.topology.Molecule from a file using this toolkit.
  `from_file_obj`(self, file_obj, file_format[, …]) | Return an openforcefield.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit.
  `from_object`(self, object) | If given an rdchem.Mol (or rdchem.Mol-derived object), this function will load it into an openforcefield.topology.molecule.
  `from_rdkit`(self, rdmol[, allow_undefined_stereo]) | Create a Molecule from an RDKit molecule.
  `from_smiles`(self, smiles[, …]) | Create a Molecule from a SMILES string using the RDKit toolkit.
  `generate_conformers`(self, molecule[, …]) | Generate molecule conformers using RDKit.
  `is_available`() | Check whether toolkit is available for use.
  `requires_toolkit`() |
  `to_file`(self, molecule, outfile, outfile_format) | Writes an OpenFF Molecule to a file-like object
  `to_file_obj`(self, molecule, file_obj, …) | Writes an OpenFF Molecule to a file-like object
  `to_rdkit`(molecule[, aromaticity_model]) | Create an RDKit molecule
  `to_smiles`(molecule) | Uses the RDKit toolkit to convert a Molecule into a SMILES string.
  `toolkit_is_available`() | Check whether the RDKit toolkit can be imported

  Attributes

  `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.

  static `toolkit_is_available`()

    Check whether the RDKit toolkit can be imported

    Returns
      is_installed bool

        True if RDKit is installed, False otherwise.

  classmethod `is_available`()

    Check whether toolkit is available for use.

    Parameters
      is_available bool

        True if toolkit is available for use, False otherwise

  `from_object`(self, object)

    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.

    Parameters
      object A rdchem.Mol-derived object

        An object to be type-checked and converted into a Molecule, if possible.

    Returns
      Molecule or False

        An openforcefield.topology.molecule Molecule.

    Raises
      NotImplementedError

        If the object could not be converted into a Molecule.

  `from_file`(self, filename, file_format, allow_undefined_stereo=False)

    Create an openforcefield.topology.Molecule from a file using this toolkit.

    Parameters
      filename str

        The file to read the molecule from

      file_format str

        Format specifier, usually file suffix (eg. ‘MOL2’, ‘SMI’) Note that not all toolkits support all formats. Check ToolkitWrapper.toolkit_file_read_formats for details.

      allow_undefined_stereo bool, default=False

        If false, raises an exception if oemol contains undefined stereochemistry.

    Returns
      molecules iterable of Molecules

        a list of Molecule objects is returned.

  `from_file_obj`(self, file_obj, file_format, allow_undefined_stereo=False)

    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.

    Parameters
      file_obj file-like object

        The file-like object to read the molecule from

      file_format str

        Format specifier, usually file suffix (eg. ‘MOL2’, ‘SMI’) Note that not all toolkits support all formats. Check ToolkitWrapper.toolkit_file_read_formats for details.

      allow_undefined_stereo bool, default=False

        If false, raises an exception if oemol contains undefined stereochemistry.

    Returns
      molecules Molecule or list of Molecules

        a list of Molecule objects is returned.

  `to_file_obj`(self, molecule, file_obj, outfile_format)

    Writes an OpenFF Molecule to a file-like object

    Parameters
      molecule an OpenFF Molecule

        The molecule to write

      file_obj

        The file-like object to write to

      outfile_format

        The format for writing the molecule data

  `to_file`(self, molecule, outfile, outfile_format)

    Writes an OpenFF Molecule to a file-like object

    Parameters
      molecule an OpenFF Molecule

        The molecule to write

      outfile

        The filename to write to

      outfile_format

        The format for writing the molecule data

      Returns
      ——
  classmethod `to_smiles`(molecule)

    Uses the RDKit toolkit to convert a Molecule into a SMILES string.

    Parameters
      molecule An openforcefield.topology.Molecule

        The molecule to convert into a SMILES.

    Returns
      smiles str

        The SMILES of the input molecule.

  `from_smiles`(self, smiles, hydrogens_are_explicit=False)

    Create a Molecule from a SMILES string using the RDKit toolkit.

    Warning

    This API is experimental and subject to change.

    Parameters
      smiles str

        The SMILES string to turn into a molecule

      hydrogens_are_explicit bool, default=False

        If False, RDKit will perform hydrogen addition using Chem.AddHs

    Returns
      molecule openforcefield.topology.Molecule

        An openforcefield-style molecule.

  `generate_conformers`(self, molecule, num_conformers=1, clear_existing=True)

    Generate molecule conformers using RDKit.

    Warning

    This API is experimental and subject to change.

    moleculea `Molecule`

      The molecule to generate conformers for.

    num_conformersint, default=1

      Maximum number of conformers to generate.

    clear_existingbool, default=True

      Whether to overwrite existing conformers for the molecule.

  `from_rdkit`(self, rdmol, allow_undefined_stereo=False)

    Create a Molecule from an RDKit molecule.

    Requires the RDKit to be installed.

    Warning

    This API is experimental and subject to change.

    Parameters
      rdmol rkit.RDMol

        An RDKit molecule

      allow_undefined_stereo bool, default=False

        If false, raises an exception if rdmol contains undefined stereochemistry.

    Returns
      molecule openforcefield.Molecule

        An openforcefield molecule

    Examples

    Create a molecule from an RDKit molecule

        >>> from rdkit import Chem
        >>> from openforcefield.tests.utils import get_data_filename
        >>> rdmol = Chem.MolFromMolFile(get_data_filename('systems/monomers/ethanol.sdf'))

        >>> toolkit_wrapper = RDKitToolkitWrapper()
        >>> molecule = toolkit_wrapper.from_rdkit(rdmol)

  classmethod `to_rdkit`(molecule, aromaticity_model='OEAroModel_MDL')

    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=DEFAULT_AROMATICITY_MODEL

        The aromaticity model to use

    Returns
      rdmol rkit.RDMol

        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')

    Find all SMARTS matches for the specified molecule, using the specified aromaticity model.

    Warning

    This API is experimental and subject to change.

    Parameters
      molecule openforcefield.topology.Molecule

        The molecule for which all specified SMARTS matches are to be located

      smarts str

        SMARTS string with optional SMIRKS-style atom tagging

      aromaticity_model str, optional, default=’OEAroModel_MDL’

        Aromaticity model to use during matching

      .. note :: Currently, the only supported ``aromaticity_model`` is ``OEAroModel_MDL``
  `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.