openff.toolkit.typing.chemistry.ChemicalEnvironment

class openff.toolkit.typing.chemistry.ChemicalEnvironment(smirks=None, label=None, validate_parsable=True, validate_valence_type=True, toolkit_registry=None)[source]

Chemical environment abstract base class used for validating SMIRKS

__init__(smirks=None, label=None, validate_parsable=True, validate_valence_type=True, toolkit_registry=None)[source]

Initialize a chemical environment abstract base class.

smirks = string, optional

if smirks is not None, a chemical environment is built from the provided SMIRKS string

label = anything, optional

intended to be used to label this chemical environment could be a string, int, or float, or anything

validate_parsable: bool, optional, default=True

If specified, ensure the provided smirks is parsable

validate_valence_typebool, optional, default=True

If specified, ensure the tagged atoms are appropriate to the specified valence type

toolkit_registry = string or ToolkitWrapper or ToolkitRegistry. Default = None

Either a ToolkitRegistry, ToolkitWrapper, or the strings ‘openeye’ or ‘rdkit’, indicating the backend to use for validating the correct connectivity of the SMIRKS during initialization. If None, this function will use the GLOBAL_TOOLKIT_REGISTRY

Raises
  • SMIRKSParsingError – if smirks was unparsable

  • SMIRKSMismatchError – if smirks did not have expected connectivity between tagged atoms and validate_valence_type=True

Methods

__init__([smirks, label, validate_parsable, ...])

Initialize a chemical environment abstract base class.

get_type([toolkit_registry])

Return the valence type implied by the connectivity of the bound atoms in this ChemicalEnvironment.

validate([validate_valence_type, ...])

Returns True if the underlying smirks is the correct valence type, False otherwise.

validate_smirks(smirks[, validate_parsable, ...])

Check the provided SMIRKS string is valid, and if requested, tags atoms appropriate to the specified valence type.

validate(validate_valence_type=True, toolkit_registry=None)[source]

Returns True if the underlying smirks is the correct valence type, False otherwise. If the expected type is None, this method always returns True.

validate_valence_typebool, optional, default=True

If specified, ensure the tagged atoms are appropriate to the specified valence type

toolkit_registry = ToolkitWrapper or ToolkitRegistry. Default = None

Either a ToolkitRegistry or ToolkitWrapper, indicating the backend to use for validating the correct connectivity of the SMIRKS during initialization. If None, this function will use the GLOBAL_TOOLKIT_REGISTRY

Raises
  • SMIRKSParsingError – if smirks was unparsable

  • SMIRKSMismatchError – if smirks did not have expected connectivity between tagged atoms and validate_valence_type=True

classmethod validate_smirks(smirks, validate_parsable=True, validate_valence_type=True, toolkit_registry=None)[source]

Check the provided SMIRKS string is valid, and if requested, tags atoms appropriate to the specified valence type.

Parameters
  • smirks (str) – The SMIRKS expression to validate

  • validate_parsable (bool, optional, default=True) – If specified, ensure the provided smirks is parsable

  • validate_valence_type (bool, optional, default=True) – If specified, ensure the tagged atoms are appropriate to the specified valence type

  • None (toolkit_registry = string or ToolkitWrapper or ToolkitRegistry. Default =) – Either a ToolkitRegistry, ToolkitWrapper, or the strings ‘openeye’ or ‘rdkit’, indicating the backend to use for validating the correct connectivity of the SMIRKS during initialization. If None, this function will use the GLOBAL_TOOLKIT_REGISTRY

Raises
  • SMIRKSParsingError – if smirks was unparsable

  • SMIRKSMismatchError – if smirks did not have expected connectivity between tagged atoms and validate_valence_type=True

get_type(toolkit_registry=None)[source]

Return the valence type implied by the connectivity of the bound atoms in this ChemicalEnvironment.

Parameters

toolkit_registry (openff.toolkit.utils.ToolkitRegistry or openff.toolkit.utils.ToolkitWrapper) – The cheminformatics toolkit to use for parsing the smirks

Returns

valence_type (str) – One of “Atom”, “Bond”, “Angle”, “ProperTorsion”, “ImproperTorsion”, or None. If tagged atoms are not connected in a known pattern this method will return None.

Raises

SMIRKSParsingError – if smirks was unparsable