OpenEyeToolkitWrapper
- class openff.toolkit.utils.toolkits.OpenEyeToolkitWrapper[source]
OpenEye toolkit wrapper
Warning
This API is experimental and subject to change.
- __init__()[source]
Methods
__init__
()apply_elf_conformer_selection
(molecule[, ...])Applies the ELF method to select a set of diverse conformers which have minimal electrostatically strongly interacting functional groups from a molecules conformers.
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.
atom_is_in_ring
(atom)Return whether or not an atom is in a ring.
bond_is_in_ring
(bond)Return whether or not a bond is in a ring.
canonical_order_atoms
(molecule)Canonical order the atoms in the molecule using the OpenEye toolkit.
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 openff.toolkit.topology.Molecule from a file using this toolkit.
from_file_obj
(file_obj, file_format[, ...])Return an openff.toolkit.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[, ...])Construct a Molecule from an IUPAC name
from_object
(obj[, allow_undefined_stereo, _cls])Convert an OEMol (or OEMol-derived object) into an openff.toolkit.topology.molecule
from_openeye
(oemol[, ...])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.
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 OpenEye OEChem Toolkit.
to_inchikey
(molecule[, fixed_hydrogens])Create an InChIKey for the molecule using the OpenEye OEChem 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
to_openeye_cache
List of file formats that this toolkit can read.
List of file formats that this toolkit can write.
Instructions on how to install the wrapped toolkit.
Return the name of the toolkit wrapped by this class as a str
Return the version of the wrapped toolkit as a str
- classmethod is_available() bool [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 required toolkits ,
False
is returned.- Returns:
all_installed (bool) –
True
if all required OpenEye tools are installed and licensed,False
otherwise
- from_object(obj, allow_undefined_stereo: bool = False, _cls=None) Molecule [source]
Convert an OEMol (or OEMol-derived object) into an openff.toolkit.topology.molecule
- Parameters:
obj (A molecule-like object) – An object to by type-checked.
allow_undefined_stereo (bool, 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.
_cls (class) – Molecule constructor
- Returns:
Molecule – An openff.toolkit.topology.molecule Molecule.
- Raises:
NotImplementedError – If the object could not be converted into a Molecule.
- from_file(file_path: str, file_format: str, allow_undefined_stereo: bool = False, _cls=None) List[Molecule] [source]
Return an openff.toolkit.topology.Molecule from a file using this toolkit.
- Parameters:
file_path (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.
_cls (class) – Molecule constructor
- Returns:
molecules (List[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 openff.toolkit.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: str, allow_undefined_stereo: bool = False, _cls=None) List[Molecule] [source]
Return an openff.toolkit.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit.
- 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.
_cls (class) – Molecule constructor
- Returns:
molecules (List[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: Molecule, file_obj, file_format: str)[source]
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
file_format – The format for writing the molecule data
- to_file(molecule: Molecule, file_path: str, file_format: str)[source]
Writes an OpenFF Molecule to a file-like object
- Parameters:
molecule (an 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: Molecule, max_states: int = 10) List[Molecule] [source]
Enumerate the formal charges of a molecule to generate different protomoers.
- Parameters:
molecule (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[openff.toolkit.topology.Molecule],) – A list of the protomers of the input molecules not including the input.
- enumerate_stereoisomers(molecule: Molecule, undefined_only: bool = False, max_isomers: int = 20, rationalise: bool = True) List[Molecule] [source]
Enumerate the stereocenters and bonds of the current molecule.
- Parameters:
molecule (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[openff.toolkit.topology.Molecule]) – A list of openff.toolkit.topology.Molecule instances
- enumerate_tautomers(molecule: Molecule, max_states: int = 20) List[Molecule] [source]
Enumerate the possible tautomers of the current molecule
- Parameters:
molecule (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[openff.toolkit.topology.Molecule]) – A list of openff.toolkit.topology.Molecule instances excluding the input molecule.
- static from_openeye(oemol, allow_undefined_stereo: bool = False, _cls=None) Molecule [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 thanopenff.toolkit.topology.Molecule
s. In the OpenEye toolkits, partial charges are stored on individualOEAtom
s, and their values are initialized to0.0
. In the Open Force Field Toolkit, anopenff.toolkit.topology.Molecule
’spartial_charges
attribute is initialized toNone
and can be set to a unit-wrapped numpy array with units of elementary charge. The Open Force Field Toolkit considers anOEMol
where everyOEAtom
has a partial charge offloat('nan')
to be equivalent to an Open Force Field Toolkit Molecule’spartial_charges = None
. This assumption is made in bothto_openeye
andfrom_openeye
.Warning
This API is experimental and subject to change.
- Parameters:
oemol (openeye.oechem.OEMol) – An OpenEye molecule
allow_undefined_stereo (bool, default=False) – If false, raises an exception if oemol contains undefined stereochemistry.
_cls (class) – Molecule constructor
- Returns:
molecule (openff.toolkit.topology.Molecule) – An OpenFF molecule
Examples
Create a Molecule from an OpenEye OEMol
>>> from openeye import oechem >>> from openff.toolkit._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])
- to_openeye(molecule: Molecule, aromaticity_model: str = DEFAULT_AROMATICITY_MODEL)[source]
Create an OpenEye molecule using the specified aromaticity model
OEAtom
s have a different set of allowed value for partial charges thanopenff.toolkit.topology.Molecule
s. In the OpenEye toolkits, partial charges are stored on individualOEAtom
s, and their values are initialized to0.0
. In the Open Force Field Toolkit, an``openff.toolkit.topology.Molecule``’spartial_charges
attribute is initialized toNone
and can be set to a unit-wrapped numpy array with units of elementary charge. The Open Force Field Toolkit considers anOEMol
where everyOEAtom
has a partial charge offloat('nan')
to be equivalent to an Open Force Field ToolkitMolecule
’spartial_charges = None
. This assumption is made in bothto_openeye
andfrom_openeye
.Warning
This API is experimental and subject to change.
- Parameters:
molecule (openff.toolkit.topology.molecule.Molecule object) – The molecule to convert to an OEMol
aromaticity_model (str, optional, default=DEFAULT_AROMATICITY_MODEL) – The aromaticity model to use
- Returns:
oemol (openeye.oechem.OEMol) – An OpenEye molecule
Examples
Create an OpenEye molecule from a Molecule
>>> from openff.toolkit import Molecule >>> toolkit_wrapper = OpenEyeToolkitWrapper() >>> molecule = Molecule.from_smiles('CC') >>> oemol = toolkit_wrapper.to_openeye(molecule)
- atom_is_in_ring(atom: Atom) bool [source]
Return whether or not an atom is in a ring.
It is assumed that this atom is in molecule.
- Parameters:
atom (Atom) – The molecule containing the atom of interest
- Returns:
is_in_ring (bool) – Whether or not the atom is in a ring.
- Raises:
- bond_is_in_ring(bond: Bond) bool [source]
Return whether or not a bond is in a ring.
It is assumed that this atom is in molecule.
- Parameters:
bond (Bond) – The molecule containing the atom of interest
- Returns:
is_in_ring (bool) – Whether or not the bond of index bond_index is in a ring
- Raises:
- to_smiles(molecule: Molecule, isomeric: bool = True, explicit_hydrogens: bool = True, mapped: bool = False) str [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:
molecule (An openff.toolkit.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:
smiles (str) – The SMILES of the input molecule.
- to_inchi(molecule: Molecule, fixed_hydrogens: bool = False) str [source]
Create an InChI string for the molecule using the OpenEye OEChem 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:
molecule (An openff.toolkit.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: Molecule, fixed_hydrogens: bool = False) str [source]
Create an InChIKey for the molecule using the OpenEye OEChem 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:
molecule (An openff.toolkit.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: Molecule) str [source]
Generate IUPAC name from Molecule
- Parameters:
molecule (An openff.toolkit.topology.Molecule) – The molecule to convert into a SMILES.
- Returns:
iupac_name (str) – IUPAC name of the molecule
Examples
>>> from openff.toolkit import Molecule >>> from openff.toolkit.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: Molecule) Molecule [source]
Canonical order the atoms in the molecule using the OpenEye toolkit.
- Parameters:
molecule (Molecule) –
The input molecule
Returns
------- –
molecule – The input molecule, with canonically-indexed atoms and bonds.
- from_smiles(smiles: str, hydrogens_are_explicit: bool = False, allow_undefined_stereo: bool = False, _cls=None, name: str = '') Molecule [source]
Create a Molecule from a SMILES string using the OpenEye 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, OE will perform hydrogen addition using OEAddExplicitHydrogens
allow_undefined_stereo (bool, 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.
_cls (class) – Molecule constructor
name (str, default="") – An optional name for the output molecule
- Returns:
molecule (openff.toolkit.topology.Molecule) – An OpenFF style molecule.
:raises RadicalsNotSupportedError : If any atoms in the OpenEye molecule contain radical electrons.:
- from_inchi(inchi: str, allow_undefined_stereo: bool = False, _cls=None, name: str = '') Molecule [source]
Construct a Molecule from a InChI representation
- Parameters:
inchi (str) – The InChI representation of the molecule.
allow_undefined_stereo (bool, 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.
_cls (class) – Molecule constructor
name (str, default="") – An optional name for the output molecule
- Returns:
molecule (openff.toolkit.topology.Molecule)
- from_iupac(iupac_name: str, allow_undefined_stereo: bool = False, _cls=None, **kwargs) Molecule [source]
Construct a Molecule from an IUPAC name
- Parameters:
iupac_name (str) – The IUPAC or common name of the molecule.
allow_undefined_stereo (bool, 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.
_cls (class) – Molecule constructor
- Returns:
molecule (openff.toolkit.topology.Molecule)
- generate_conformers(molecule: Molecule, n_conformers: int = 1, rms_cutoff: Optional[Quantity] = None, clear_existing: bool = True, make_carboxylic_acids_cis: bool = False)[source]
Generate molecule conformers using OpenEye Omega.
Warning
This API is experimental and subject to change.
- Parameters:
molecule (a
Molecule
) – The molecule to generate conformers for.n_conformers (int, default=1) – The maximum number of conformers to generate.
rms_cutoff (unit-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_existing (bool, default=True) – Whether to overwrite existing conformers for the molecule
make_carboxylic_acids_cis (bool, default=False) – Guarantee all conformers have exclusively cis carboxylic acid groups (COOH) by rotating the proton in any trans carboxylic acids 180 degrees around the C-O bond.
- apply_elf_conformer_selection(molecule: Molecule, percentage: float = 2.0, limit: int = 10)[source]
Applies the ELF method to select a set of diverse conformers which have minimal electrostatically strongly interacting functional groups from a molecules conformers.
Notes
The input molecule should have a large set of conformers already generated to select the ELF conformers from.
The selected conformers will be retained in the
molecule.conformers
list while unselected conformers will be discarded.Conformers generated with the OpenEye toolkit often include trans carboxylic acids (COOH). These are unphysical and will be rejected by
apply_elf_conformer_selection
. If no conformers are selected, try re-runninggenerate_conformers
with themake_carboxylic_acids_cis
argument set toTrue
- Parameters:
molecule – The molecule which contains the set of conformers to select from.
percentage – The percentage of conformers with the lowest electrostatic interaction energies to greedily select from.
limit – The maximum number of conformers to select.
- assign_partial_charges(molecule: Molecule, partial_charge_method: Optional[str] = None, use_conformers: Optional[List[Quantity]] = None, strict_n_conformers: bool = False, normalize_partial_charges: bool = True, _cls=None)[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:
molecule (Molecule) – Molecule for which partial charges are to be computed
partial_charge_method (str, optional, default=None) – The charge model to use. One of [‘amberff94’, ‘mmff’, ‘mmff94’, ‘am1-mulliken’, ‘am1bcc’, ‘am1bccnosymspt’, ‘am1bccelf10’, ‘gasteiger’] If None, ‘am1-mulliken’ will be used.
use_conformers (iterable of unit-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, 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.
normalize_partial_charges (bool, default=True) – 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 –
- assign_fractional_bond_orders(molecule: Molecule, bond_order_model: Optional[str] = None, use_conformers: Optional[List[Quantity]] = None, _cls=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:
molecule (openff.toolkit.topology.molecule Molecule) – The molecule to assign wiberg bond orders to
bond_order_model (str, optional, default=None) – The charge model to use. One of [‘am1-wiberg’, ‘am1-wiberg-elf10’, ‘pm3-wiberg’, ‘pm3-wiberg-elf10’]. If None, ‘am1-wiberg’ will be used.
use_conformers (iterable of unit-wrapped 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. If the chosen
bond_order_model
is an ELF variant, the ELF conformer selection method will be applied to the provided conformers._cls (class) – Molecule constructor
- get_tagged_smarts_connectivity(smarts: str) Tuple[Tuple[Tuple[Any, ...], ...], ...] [source]
Returns a tuple of tuples indicating connectivity between tagged atoms in a SMARTS string. Does not return bond order.
- Parameters:
smarts (str) – The tagged SMARTS to analyze
- Returns:
unique_tags (tuple of int) – A sorted tuple of all unique tagged atom map indices.
tagged_atom_connectivity (tuple 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. 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: Molecule, smarts: str, aromaticity_model=DEFAULT_AROMATICITY_MODEL, unique=False) List[Tuple[int, ...]] [source]
Find all SMARTS matches for the specified molecule, using the specified aromaticity model.
Warning
This API is experimental and subject to change.
- Parameters:
molecule (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") – The aromaticity model to use. Only OEAroModel_MDL is supported.
unique (bool, default=False) – If True, only return unique matches. If False, return all matches.
: (.. note) – Currently:
OEAroModel_MDL (the only supported aromaticity_model is) –