openforcefield.utils.toolkits.OpenEyeToolkitWrapper

class openforcefield.utils.toolkits.OpenEyeToolkitWrapper[source]

OpenEye 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

Return the name of the toolkit wrapped by this class as a str

toolkit_version

Return the version of the wrapped toolkit as a str

Methods

assign_fractional_bond_orders(molecule[, …])

Update and store list of bond orders this molecule.

assign_partial_charges(molecule[, …])

Compute partial charges with OpenEye quacpac, and assign the new values to the partial_charges attribute.

canonical_order_atoms(molecule)

Canonical order the atoms in the molecule using the OpenEye toolkit.

compute_partial_charges_am1bcc(molecule[, …])

Compute AM1BCC partial charges with OpenEye quacpac.

enumerate_protomers(molecule[, max_states])

Enumerate the formal charges of a molecule to generate different protomoers.

enumerate_stereoisomers(molecule[, …])

Enumerate the stereocenters and bonds of the current molecule.

enumerate_tautomers(molecule[, max_states])

Enumerate the possible tautomers of the current molecule

find_smarts_matches(molecule, smarts[, …])

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

from_file(file_path, file_format[, …])

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

from_file_obj(file_obj, file_format[, …])

Return an openforcefield.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit.

from_inchi(inchi[, allow_undefined_stereo])

Construct a Molecule from a InChI representation

from_iupac(iupac_name[, allow_undefined_stereo])

Construct a Molecule from an IUPAC name

from_object(object[, allow_undefined_stereo])

If given an OEMol (or OEMol-derived object), this function will load it into an openforcefield.topology.molecule

from_openeye(oemol[, allow_undefined_stereo])

Create a Molecule from an OpenEye molecule.

from_smiles(smiles[, …])

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

generate_conformers(molecule[, …])

Generate molecule conformers using OpenEye Omega.

get_tagged_smarts_connectivity(smarts)

Returns a tuple of tuples indicating connectivity between tagged atoms in a SMARTS string.

is_available([oetools])

Check if the given OpenEye toolkit components are available.

requires_toolkit()

to_file(molecule, file_path, file_format)

Writes an OpenFF Molecule to a file-like object

to_file_obj(molecule, file_obj, file_format)

Writes an OpenFF Molecule to a file-like object

to_inchi(molecule[, fixed_hydrogens])

Create an InChI string for the molecule using the RDKit Toolkit.

to_inchikey(molecule[, fixed_hydrogens])

Create an InChIKey for the molecule using the RDKit Toolkit.

to_iupac(molecule)

Generate IUPAC name from Molecule

to_openeye(molecule[, aromaticity_model])

Create an OpenEye molecule using the specified aromaticity model

to_smiles(molecule[, isomeric, …])

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

__init__()[source]

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

Methods

__init__()

Initialize self.

assign_fractional_bond_orders(molecule[, …])

Update and store list of bond orders this molecule.

assign_partial_charges(molecule[, …])

Compute partial charges with OpenEye quacpac, and assign the new values to the partial_charges attribute.

canonical_order_atoms(molecule)

Canonical order the atoms in the molecule using the OpenEye toolkit.

compute_partial_charges_am1bcc(molecule[, …])

Compute AM1BCC partial charges with OpenEye quacpac.

enumerate_protomers(molecule[, max_states])

Enumerate the formal charges of a molecule to generate different protomoers.

enumerate_stereoisomers(molecule[, …])

Enumerate the stereocenters and bonds of the current molecule.

enumerate_tautomers(molecule[, max_states])

Enumerate the possible tautomers of the current molecule

find_smarts_matches(molecule, smarts[, …])

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

from_file(file_path, file_format[, …])

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

from_file_obj(file_obj, file_format[, …])

Return an openforcefield.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit.

from_inchi(inchi[, allow_undefined_stereo])

Construct a Molecule from a InChI representation

from_iupac(iupac_name[, allow_undefined_stereo])

Construct a Molecule from an IUPAC name

from_object(object[, allow_undefined_stereo])

If given an OEMol (or OEMol-derived object), this function will load it into an openforcefield.topology.molecule

from_openeye(oemol[, allow_undefined_stereo])

Create a Molecule from an OpenEye molecule.

from_smiles(smiles[, …])

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

generate_conformers(molecule[, …])

Generate molecule conformers using OpenEye Omega.

get_tagged_smarts_connectivity(smarts)

Returns a tuple of tuples indicating connectivity between tagged atoms in a SMARTS string.

is_available([oetools])

Check if the given OpenEye toolkit components are available.

requires_toolkit()

to_file(molecule, file_path, file_format)

Writes an OpenFF Molecule to a file-like object

to_file_obj(molecule, file_obj, file_format)

Writes an OpenFF Molecule to a file-like object

to_inchi(molecule[, fixed_hydrogens])

Create an InChI string for the molecule using the RDKit Toolkit.

to_inchikey(molecule[, fixed_hydrogens])

Create an InChIKey for the molecule using the RDKit Toolkit.

to_iupac(molecule)

Generate IUPAC name from Molecule

to_openeye(molecule[, aromaticity_model])

Create an OpenEye molecule using the specified aromaticity model

to_smiles(molecule[, isomeric, …])

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

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

Return the name of the toolkit wrapped by this class as a str

toolkit_version

Return the version of the wrapped toolkit as a str

static is_available(oetools='oechem', 'oequacpac', 'oeiupac', 'oeomega')[source]

Check if the given OpenEye toolkit components are available.

If the OpenEye toolkit is not installed or no license is found for at least one the given toolkits , False is returned.

Parameters
oetoolsstr or iterable of strings, optional, default=(‘oechem’, ‘oequacpac’, ‘oeiupac’, ‘oeomega’)

Set of tools to check by their Python module name. Defaults to the complete set of tools supported by this function. Also accepts a single tool to check as a string instead of an iterable of length 1.

Returns
all_installedbool

True if all tools in oetools are installed and licensed, False otherwise

from_object(object, allow_undefined_stereo=False)[source]

If given an OEMol (or OEMol-derived object), this function will load it into an openforcefield.topology.molecule

Parameters
objectA molecule-like object

An object to by type-checked.

allow_undefined_stereobool, default=False

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.

Returns
Molecule

An openforcefield.topology.molecule Molecule.

Raises
NotImplementedError

If the object could not be converted into a Molecule.

from_file(file_path, file_format, allow_undefined_stereo=False)[source]

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

Parameters
file_pathstr

The file to read the molecule from

file_formatstr

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_stereobool, default=False

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

Returns
moleculesList[Molecule]

The list of Molecule objects in the file.

Raises
GAFFAtomTypeWarning

If the loaded mol2 file possibly uses GAFF atom types, which are not supported.

Examples

Load a mol2 file into an OpenFF Molecule object.

>>> from openforcefield.utils import get_data_file_path
>>> mol2_file_path = get_data_file_path('molecules/cyclohexane.mol2')
>>> toolkit = OpenEyeToolkitWrapper()
>>> molecule = toolkit.from_file(mol2_file_path, file_format='mol2')
from_file_obj(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.

Parameters
file_objfile-like object

The file-like object to read the molecule from

file_formatstr

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_stereobool, default=False

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

Returns
moleculesList[Molecule]

The list of Molecule objects in the file object.

Raises
GAFFAtomTypeWarning

If the loaded mol2 file possibly uses GAFF atom types, which are not supported.

to_file_obj(molecule, file_obj, file_format)[source]

Writes an OpenFF Molecule to a file-like object

Parameters
moleculean OpenFF Molecule

The molecule to write

file_obj

The file-like object to write to

file_format

The format for writing the molecule data

to_file(molecule, file_path, file_format)[source]

Writes an OpenFF Molecule to a file-like object

Parameters
moleculean OpenFF Molecule

The molecule to write

file_path

The file path to write to.

file_format

The format for writing the molecule data

enumerate_protomers(molecule, max_states=10)[source]

Enumerate the formal charges of a molecule to generate different protomoers.

Parameters
molecule: openforcefield.topology.Molecule

The molecule whose state we should enumerate

max_states: int optional, default=10,

The maximum number of protomer states to be returned.

Returns
molecules: List[openforcefield.topology.Molecule],

A list of the protomers of the input molecules not including the input.

enumerate_stereoisomers(molecule, undefined_only=False, max_isomers=20, rationalise=True)[source]

Enumerate the stereocenters and bonds of the current molecule.

Parameters
molecule: openforcefield.topology.Molecule

The molecule whose state we should enumerate

undefined_only: bool optional, default=False

If we should enumerate all stereocenters and bonds or only those with undefined stereochemistry

max_isomers: int optional, default=20

The maximum amount of molecules that should be returned

rationalise: bool optional, default=True

If we should try to build and rationalise the molecule to ensure it can exist

Returns
molecules: List[openforcefield.topology.Molecule]

A list of openforcefield.topology.Molecule instances

enumerate_tautomers(molecule, max_states=20)[source]

Enumerate the possible tautomers of the current molecule

Parameters
molecule: openforcefield.topology.Molecule

The molecule whose state we should enumerate

max_states: int optional, default=20

The maximum amount of molecules that should be returned

Returns
molecules: List[openforcefield.topology.Molecule]

A list of openforcefield.topology.Molecule instances excluding the input molecule.

static from_openeye(oemol, allow_undefined_stereo=False)[source]

Create a Molecule from an OpenEye molecule. If the OpenEye molecule has implicit hydrogens, this function will make them explicit.

OEAtom s have a different set of allowed value for partial charges than openforcefield.topology.Molecule s. In the OpenEye toolkits, partial charges are stored on individual OEAtom s, and their values are initialized to 0.0. In the Open Force Field Toolkit, an openforcefield.topology.Molecule’s partial_charges attribute is initialized to None and can be set to a simtk.unit.Quantity-wrapped numpy array with units of elementary charge. The Open Force Field Toolkit considers an OEMol where every OEAtom has a partial charge of float('nan') to be equivalent to an Open Force Field Molecule’s partial_charges = None. This assumption is made in both to_openeye and from_openeye.

Warning

This API is experimental and subject to change.

Parameters
oemolopeneye.oechem.OEMol

An OpenEye molecule

allow_undefined_stereobool, default=False

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

Returns
moleculeopenforcefield.topology.Molecule

An openforcefield molecule

Examples

Create a Molecule from an OpenEye OEMol

>>> from openeye import oechem
>>> from openforcefield.tests.utils import get_data_file_path
>>> ifs = oechem.oemolistream(get_data_file_path('systems/monomers/ethanol.mol2'))
>>> oemols = list(ifs.GetOEGraphMols())
>>> toolkit_wrapper = OpenEyeToolkitWrapper()
>>> molecule = toolkit_wrapper.from_openeye(oemols[0])
static to_openeye(molecule, aromaticity_model='OEAroModel_MDL')[source]

Create an OpenEye molecule using the specified aromaticity model

OEAtom s have a different set of allowed value for partial charges than openforcefield.topology.Molecule s. In the OpenEye toolkits, partial charges are stored on individual OEAtom s, and their values are initialized to 0.0. In the Open Force Field Toolkit, an openforcefield.topology.Molecule’s partial_charges attribute is initialized to None and can be set to a simtk.unit.Quantity-wrapped numpy array with units of elementary charge. The Open Force Field Toolkit considers an OEMol where every OEAtom has a partial charge of float('nan') to be equivalent to an Open Force Field Molecule’s partial_charges = None. This assumption is made in both to_openeye and from_openeye.

Warning

This API is experimental and subject to change.

Parameters
moleculeopenforcefield.topology.molecule.Molecule object

The molecule to convert to an OEMol

aromaticity_modelstr, optional, default=DEFAULT_AROMATICITY_MODEL

The aromaticity model to use

Returns
oemolopeneye.oechem.OEMol

An OpenEye molecule

Examples

Create an OpenEye molecule from a Molecule

>>> from openforcefield.topology import Molecule
>>> toolkit_wrapper = OpenEyeToolkitWrapper()
>>> molecule = Molecule.from_smiles('CC')
>>> oemol = toolkit_wrapper.to_openeye(molecule)
to_smiles(molecule, isomeric=True, explicit_hydrogens=True, mapped=False)[source]

Uses the OpenEye toolkit to convert a Molecule into a SMILES string. A partially mapped smiles can also be generated for atoms of interest by supplying an atom_map to the properties dictionary.

Parameters
moleculeAn openforcefield.topology.Molecule

The molecule to convert into a SMILES.

isomeric: bool optional, default= True

return an isomeric smiles

explicit_hydrogens: bool optional, default=True

return a smiles string containing all hydrogens explicitly

mapped: bool optional, default=False

return a explicit hydrogen mapped smiles, the atoms to be mapped can be controlled by supplying an atom map into the properties dictionary. If no mapping is passed all atoms will be mapped in order, else an atom map dictionary from the current atom index to the map id should be supplied with no duplicates. The map ids (values) should start from 0 or 1.

Returns
smilesstr

The SMILES of the input molecule.

to_inchi(molecule, fixed_hydrogens=False)[source]

Create an InChI string for the molecule using the RDKit Toolkit. InChI is a standardised representation that does not capture tautomers unless specified using the fixed hydrogen layer.

For information on InChi see here https://iupac.org/who-we-are/divisions/division-details/inchi/

Parameters
moleculeAn openforcefield.topology.Molecule

The molecule to convert into a SMILES.

fixed_hydrogens: bool, default=False

If a fixed hydrogen layer should be added to the InChI, if True this will produce a non standard specific InChI string of the molecule.

Returns
inchi: str

The InChI string of the molecule.

to_inchikey(molecule, fixed_hydrogens=False)[source]

Create an InChIKey for the molecule using the RDKit Toolkit. InChIKey is a standardised representation that does not capture tautomers unless specified using the fixed hydrogen layer.

For information on InChi see here https://iupac.org/who-we-are/divisions/division-details/inchi/

Parameters
moleculeAn openforcefield.topology.Molecule

The molecule to convert into a SMILES.

fixed_hydrogens: bool, default=False

If a fixed hydrogen layer should be added to the InChI, if True this will produce a non standard specific InChI string of the molecule.

Returns
inchi_key: str

The InChIKey representation of the molecule.

to_iupac(molecule)[source]

Generate IUPAC name from Molecule

Parameters
moleculeAn openforcefield.topology.Molecule

The molecule to convert into a SMILES.

Returns
iupac_namestr

IUPAC name of the molecule

Examples

>>> from openforcefield.topology import Molecule
>>> from openforcefield.utils import get_data_file_path
>>> sdf_filepath = get_data_file_path('molecules/ethanol.sdf')
>>> molecule = Molecule(sdf_filepath)
>>> toolkit = OpenEyeToolkitWrapper()
>>> iupac_name = toolkit.to_iupac(molecule)
canonical_order_atoms(molecule)[source]

Canonical order the atoms in the molecule using the OpenEye toolkit.

Parameters
molecule: openforcefield.topology.Molecule

The input molecule

Returns
moleculeopenforcefield.topology.Molecule

The input molecule, with canonically-indexed atoms and bonds.

from_smiles(smiles, hydrogens_are_explicit=False, allow_undefined_stereo=False)[source]

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

Warning

This API is experimental and subject to change.

Parameters
smilesstr

The SMILES string to turn into a molecule

hydrogens_are_explicitbool, default = False

If False, OE will perform hydrogen addition using OEAddExplicitHydrogens

allow_undefined_stereobool, default=False

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.

Returns
moleculeopenforcefield.topology.Molecule

An openforcefield-style molecule.

from_inchi(inchi, allow_undefined_stereo=False)[source]

Construct a Molecule from a InChI representation

Parameters
inchistr

The InChI representation of the molecule.

allow_undefined_stereobool, default=False

Whether to accept InChI with undefined stereochemistry. If False, an exception will be raised if a InChI with undefined stereochemistry is passed into this function.

Returns
moleculeopenforcefield.topology.Molecule
from_iupac(iupac_name, allow_undefined_stereo=False, **kwargs)[source]

Construct a Molecule from an IUPAC name

Parameters
iupac_namestr

The IUPAC or common name of the molecule.

allow_undefined_stereobool, default=False

Whether to accept a molecule name with undefined stereochemistry. If False, an exception will be raised if a molecule name with undefined stereochemistry is passed into this function.

Returns
moleculeopenforcefield.topology.Molecule
generate_conformers(molecule, n_conformers=1, rms_cutoff=None, clear_existing=True)[source]

Generate molecule conformers using OpenEye Omega.

Warning

This API is experimental and subject to change.

moleculea Molecule

The molecule to generate conformers for.

n_conformersint, default=1

The maximum number of conformers to generate.

rms_cutoffsimtk.Quantity-wrapped float, in units of distance, optional, default=None

The minimum RMS value at which two conformers are considered redundant and one is deleted. If None, the cutoff is set to 1 Angstrom

clear_existingbool, default=True

Whether to overwrite existing conformers for the molecule

assign_partial_charges(molecule, partial_charge_method=None, use_conformers=None, strict_n_conformers=False)[source]

Compute partial charges with OpenEye quacpac, and assign the new values to the partial_charges attribute.

Warning

This API is experimental and subject to change.

Parameters
moleculeopenforcefield.topology.Molecule

Molecule for which partial charges are to be computed

partial_charge_methodstr, optional, default=None

The charge model to use. One of [‘amberff94’, ‘mmff’, ‘mmff94’, am1-mulliken, ‘am1bcc’, ‘am1bccnosymspt’, ‘am1bccelf10’] If None, ‘am1-mulliken’ will be used.

use_conformersiterable of simtk.unit.Quantity-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_conformersbool, default=False

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.

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
compute_partial_charges_am1bcc(molecule, use_conformers=None, strict_n_conformers=False)[source]

Compute AM1BCC partial charges with OpenEye quacpac. This function will attempt to use the OEAM1BCCELF10 charge generation method, but may print a warning and fall back to normal OEAM1BCC if an error is encountered. This error is known to occur with some carboxylic acids, and is under investigation by OpenEye.

Warning

This API is experimental and subject to change.

Parameters
moleculeMolecule

Molecule for which partial charges are to be computed

use_conformersiterable of simtk.unit.Quantity-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_conformersbool, default=False

Whether to raise an exception if an invalid number of conformers is provided. If this is False and an invalid number of conformers is found, a warning will be raised instead of an Exception.

Returns
chargesnumpy.array of shape (natoms) of type float

The partial charges

assign_fractional_bond_orders(molecule, bond_order_model=None, use_conformers=None)[source]

Update and store list of bond orders this molecule. Bond orders are stored on each bond, in the bond.fractional_bond_order attribute.

Warning

This API is experimental and subject to change.

Parameters
moleculeopenforcefield.topology.molecule Molecule

The molecule to assign wiberg bond orders to

bond_order_modelstr, optional, default=None

The charge model to use. One of [‘am1-wiberg’, ‘pm3-wiberg’]. If None, ‘am1-wiberg’ will be used.

use_conformersiterable of simtk.unit.Quantity(np.array) with shape (n_atoms, 3) and dimension of distance, optional, default=None

The conformers to use for fractional bond order calculation. If None, an appropriate number of conformers will be generated by an available ToolkitWrapper.

get_tagged_smarts_connectivity(smarts)[source]

Returns a tuple of tuples indicating connectivity between tagged atoms in a SMARTS string. Does not return bond order.

Parameters
smartsstr

The tagged SMARTS to analyze

Returns
unique_tagstuple of int

A sorted tuple of all unique tagged atom map indices.

tagged_atom_connectivitytuple of tuples of int, shape n_tagged_bonds x 2

A tuple of tuples, where each inner tuple is a pair of tagged atoms (tag_idx_1, tag_idx_2) which are bonded. The inner tuples are ordered smallest-to-largest, and the tuple of tuples is ordered lexically. So the return value for an improper torsion would be ((1, 2), (2, 3), (2, 4)).

Raises
SMIRKSParsingError

If OpenEye toolkit was unable to parse the provided smirks/tagged smarts

find_smarts_matches(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.

Parameters
moleculeopenforcefield.topology.Molecule

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

smartsstr

SMARTS string with optional SMIRKS-style atom tagging

aromaticity_modelstr, optional, default=’OEAroModel_MDL’

Molecule is prepared with this aromaticity model prior to querying.

.. note :: Currently, the only supported ``aromaticity_model`` is ``OEAroModel_MDL``
property toolkit_file_read_formats

List of file formats that this toolkit can read.

property toolkit_file_write_formats

List of file formats that this toolkit can write.

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

property toolkit_name

Return the name of the toolkit wrapped by this class as a str

Warning

This API is experimental and subject to change.

Returns
toolkit_namestr

The name of the wrapped toolkit

property toolkit_version

Return the version of the wrapped toolkit as a str

Warning

This API is experimental and subject to change.

Returns
toolkit_versionstr

The version of the wrapped toolkit