# openforcefield.typing.chemistry.ChemicalEnvironment

class `openforcefield.typing.chemistry.``ChemicalEnvironment`(smirks=None, label=None, replacements=None, toolkit='openeye')

  Chemical environment abstract base class that matches an atom, bond, angle, etc.

  Warning

  This class is largely redundant with the same one in the Chemper package, and will likely be removed.

  Methods

  `Atom`([ORtypes, ANDtypes, index, ring]) | Atom representation, which may have some ORtypes and ANDtypes properties.
  `Bond`([ORtypes, ANDtypes]) | Bond representation, which may have ORtype and ANDtype descriptors.
  `addAtom`(bondToAtom[, bondORtypes, …]) | Add an atom to the specified target atom.
  `asSMIRKS`([smarts]) | Returns a SMIRKS representation of the chemical environment
  `getAlphaAtoms`() | Returns a list of atoms alpha to any indexed atom
  `getAlphaBonds`() | Returns a list of Bond objects that connect

  `getAtoms`()

  Returns

  `getBetaAtoms`() | Returns a list of atoms beta to any indexed atom
  `getBetaBonds`() | Returns a list of Bond objects that connect
  `getBond`(atom1, atom2) | Get bond betwen two atoms
  `getBondOrder`(atom) | Returns minimum bond order around a given atom 0 if atom has no neighbors aromatic bonds count as 1.5 any bond counts as 1.0

  `getBonds`([atom])

  Parameters

  `getComponentList`(component_type[, descriptor]) | Returns a list of atoms or bonds matching the descriptor
  `getIndexedAtoms`() | returns the list of Atom objects with an index
  `getIndexedBonds`() | Returns a list of Bond objects that connect two indexed atoms
  `getNeighbors`(atom) | Returns atoms that are bound to the given atom in the form of a list of Atom objects
  `getType`() | Uses number of indexed atoms and bond connectivity to determine the type of chemical environment
  `getUnindexedAtoms`() | returns a list of Atom objects that are not indexed
  `getUnindexedBonds`() | Returns a list of Bond objects that connect
  `getValence`(atom) | Returns the valence (number of neighboring atoms) around the given atom
  `isAlpha`(component) | Takes an atom or bond are returns True if it is alpha to an indexed atom
  `isBeta`(component) | Takes an atom or bond are returns True if it is beta to an indexed atom
  `isIndexed`(component) | returns True if the atom or bond is indexed
  `isUnindexed`(component) | returns True if the atom or bond is not indexed
  `isValid`([smirks]) | Returns if the environment is valid, that is if it creates a parseable SMIRKS string.
  `removeAtom`(atom[, onlyEmpty]) | Remove the specified atom from the chemical environment.
  `selectAtom`([descriptor]) | Select a random atom fitting the descriptor.
  `selectBond`([descriptor]) | Select a random bond fitting the descriptor.
  `validate`(smirks[, ensure_valence_type, toolkit]) | Validate the provided SMIRKS string is valid, and if requested, tags atoms appropriate to the specified valence type.

  `__init__`(smirks=None, label=None, replacements=None, toolkit='openeye')

    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

    replacements = list of lists, optional,

      [substitution, smarts] form for parsing SMIRKS

  Methods

  `__init__`([smirks, label, replacements, toolkit]) | Initialize a chemical environment abstract base class.
  `addAtom`(bondToAtom[, bondORtypes, …]) | Add an atom to the specified target atom.
  `asSMIRKS`([smarts]) | Returns a SMIRKS representation of the chemical environment
  `getAlphaAtoms`() | Returns a list of atoms alpha to any indexed atom
  `getAlphaBonds`() | Returns a list of Bond objects that connect

  `getAtoms`()

  Returns

  `getBetaAtoms`() | Returns a list of atoms beta to any indexed atom
  `getBetaBonds`() | Returns a list of Bond objects that connect
  `getBond`(atom1, atom2) | Get bond betwen two atoms
  `getBondOrder`(atom) | Returns minimum bond order around a given atom 0 if atom has no neighbors aromatic bonds count as 1.5 any bond counts as 1.0

  `getBonds`([atom])

  Parameters

  `getComponentList`(component_type[, descriptor]) | Returns a list of atoms or bonds matching the descriptor
  `getIndexedAtoms`() | returns the list of Atom objects with an index
  `getIndexedBonds`() | Returns a list of Bond objects that connect two indexed atoms
  `getNeighbors`(atom) | Returns atoms that are bound to the given atom in the form of a list of Atom objects
  `getType`() | Uses number of indexed atoms and bond connectivity to determine the type of chemical environment
  `getUnindexedAtoms`() | returns a list of Atom objects that are not indexed
  `getUnindexedBonds`() | Returns a list of Bond objects that connect
  `getValence`(atom) | Returns the valence (number of neighboring atoms) around the given atom
  `isAlpha`(component) | Takes an atom or bond are returns True if it is alpha to an indexed atom
  `isBeta`(component) | Takes an atom or bond are returns True if it is beta to an indexed atom
  `isIndexed`(component) | returns True if the atom or bond is indexed
  `isUnindexed`(component) | returns True if the atom or bond is not indexed
  `isValid`([smirks]) | Returns if the environment is valid, that is if it creates a parseable SMIRKS string.
  `removeAtom`(atom[, onlyEmpty]) | Remove the specified atom from the chemical environment.
  `selectAtom`([descriptor]) | Select a random atom fitting the descriptor.
  `selectBond`([descriptor]) | Select a random bond fitting the descriptor.
  `validate`(smirks[, ensure_valence_type, toolkit]) | Validate the provided SMIRKS string is valid, and if requested, tags atoms appropriate to the specified valence type.

  class `Atom`(ORtypes=None, ANDtypes=None, index=None, ring=None)

    Atom representation, which may have some ORtypes and ANDtypes properties.

    Attributes
      ORtypes list of tuples in the form (base, [list of decorators])

        where bases and decorators are both strings The descriptor types that will be combined with logical OR

      ANDtypes list of string

        The descriptor types that will be combined with logical AND

    Methods

    `addANDtype`(ANDtype) | Adds ANDtype to the set for this atom.
    `addORtype`(ORbase, ORdecorators) | Adds ORtype to the set for this atom.
    `asSMARTS`() | Return the atom representation as SMARTS.
    `asSMIRKS`() | Return the atom representation as SMIRKS.
    `getANDtypes`() | returns a copy of the list of ANDtypes for this atom
    `getORtypes`() | returns a copy of the dictionary of ORtypes for this atom
    `setANDtypes`(newANDtypes) | sets new ANDtypes for this atom
    `setORtypes`(newORtypes) | sets new ORtypes for this atom

    `asSMARTS`()

      Return the atom representation as SMARTS.

      Returns
        smarts str
        The SMARTS string for this atom
    `asSMIRKS`()

      Return the atom representation as SMIRKS.

      Returns
        smirks str
        The SMIRKS string for this atom
    `addORtype`(ORbase, ORdecorators)

      Adds ORtype to the set for this atom.

      Parameters
        ORbase: string, such as ‘#6’
        ORdecorators: list of strings, such as [‘X4’,’+0’]
    `addANDtype`(ANDtype)

      Adds ANDtype to the set for this atom.

      Parameters
        ANDtype: string

          added to the list of ANDtypes for this atom

    `getORtypes`()

      returns a copy of the dictionary of ORtypes for this atom

    `setORtypes`(newORtypes)

      sets new ORtypes for this atom

      Parameters
        newORtypes: list of tuples in the form (base, [ORdecorators])

          for example: (‘#6’, [‘X4’,’H0’,’+0’]) –> ‘#6X4H0+0’

    `getANDtypes`()

      returns a copy of the list of ANDtypes for this atom

    `setANDtypes`(newANDtypes)

      sets new ANDtypes for this atom

      Parameters
        newANDtypes: list of strings

          strings that will be AND’d together in a SMARTS

  class `Bond`(ORtypes=None, ANDtypes=None)

    Bond representation, which may have ORtype and ANDtype descriptors.

    Attributes
      ORtypes list of tuples of ORbases and ORdecorators

        in form (base: [list of decorators]) The ORtype types that will be combined with logical OR

      ANDtypes list of string

        The ANDtypes that will be combined with logical AND

    Methods

    `addANDtype`(ANDtype) | Adds ANDtype to the set for this atom.
    `addORtype`(ORbase, ORdecorators) | Adds ORtype to the set for this atom.
    `asSMARTS`() | Return the atom representation as SMARTS.

    `asSMIRKS`()

    Returns

    `getANDtypes`() | returns a copy of the list of ANDtypes for this atom
    `getORtypes`() | returns a copy of the dictionary of ORtypes for this atom
    `getOrder`() | Returns a float for the order of this bond for multiple ORtypes or ~ it returns the minimum possible order the intended application is for checking valence around a given atom
    `setANDtypes`(newANDtypes) | sets new ANDtypes for this atom
    `setORtypes`(newORtypes) | sets new ORtypes for this atom

    `asSMARTS`()

      Return the atom representation as SMARTS.

      Returns
        smarts str

          The SMARTS string for just this atom

    `asSMIRKS`()
      Returns
        smarts str

          The SMIRKS string for just this bond

    `getOrder`()

      Returns a float for the order of this bond for multiple ORtypes or ~ it returns the minimum possible order the intended application is for checking valence around a given atom

    `addANDtype`(ANDtype)

      Adds ANDtype to the set for this atom.

      Parameters
        ANDtype: string

          added to the list of ANDtypes for this atom

    `addORtype`(ORbase, ORdecorators)

      Adds ORtype to the set for this atom.

      Parameters
        ORbase: string, such as ‘#6’
        ORdecorators: list of strings, such as [‘X4’,’+0’]
    `getANDtypes`()

      returns a copy of the list of ANDtypes for this atom

    `getORtypes`()

      returns a copy of the dictionary of ORtypes for this atom

    `setANDtypes`(newANDtypes)

      sets new ANDtypes for this atom

      Parameters
        newANDtypes: list of strings

          strings that will be AND’d together in a SMARTS

    `setORtypes`(newORtypes)

      sets new ORtypes for this atom

      Parameters
        newORtypes: list of tuples in the form (base, [ORdecorators])

          for example: (‘#6’, [‘X4’,’H0’,’+0’]) –> ‘#6X4H0+0’

  static `validate`(smirks, ensure_valence_type=None, toolkit='openeye')

    Validate 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

      ensure_valence_type str, optional, default=None

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

      This method will raise a :class:`SMIRKSParsingError` if the provided SMIRKS string is not valid.
  `isValid`(smirks=None)

    Returns if the environment is valid, that is if it creates a parseable SMIRKS string.

  `asSMIRKS`(smarts=False)

    Returns a SMIRKS representation of the chemical environment

    Parameters
      smarts: optional, boolean

        if True, returns a SMARTS instead of SMIRKS without index labels

  `selectAtom`(descriptor=None)

    Select a random atom fitting the descriptor.

    Parameters
      descriptor: optional, None

        None - returns any atom with equal probability int - will return an atom with that index ‘Indexed’ - returns a random indexed atom ‘Unindexed’ - returns a random unindexed atom ‘Alpha’ - returns a random alpha atom ‘Beta’ - returns a random beta atom

    Returns
      a single Atom object fitting the description
      or None if no such atom exists
  `getComponentList`(component_type, descriptor=None)

    Returns a list of atoms or bonds matching the descriptor

    Parameters
      component_type: string: ‘atom’ or ‘bond’
      descriptor: string, optional

        ‘all’, ‘Indexed’, ‘Unindexed’, ‘Alpha’, ‘Beta’

  `selectBond`(descriptor=None)

    Select a random bond fitting the descriptor.

    Parameters
      descriptor: optional, None

        None - returns any bond with equal probability int - will return an bond with that index ‘Indexed’ - returns a random indexed bond ‘Unindexed’ - returns a random unindexed bond ‘Alpha’ - returns a random alpha bond ‘Beta’ - returns a random beta bond

    Returns
      a single Bond object fitting the description
      or None if no such atom exists
  `addAtom`(bondToAtom, bondORtypes=None, bondANDtypes=None, newORtypes=None, newANDtypes=None, newAtomIndex=None, newAtomRing=None, beyondBeta=False)

    Add an atom to the specified target atom.

    Parameters
      bondToAtom: atom object, required

        atom the new atom will be bound to

      bondORtypes: list of tuples, optional

        strings that will be used for the ORtypes for the new bond

      bondANDtypes: list of strings, optional

        strings that will be used for the ANDtypes for the new bond

      newORtypes: list of strings, optional

        strings that will be used for the ORtypes for the new atom

      newANDtypes: list of strings, optional

        strings that will be used for the ANDtypes for the new atom

      newAtomIndex: int, optional

        integer label that could be used to index the atom in a SMIRKS string

      beyondBeta: boolean, optional

        if True, allows bonding beyond beta position

    Returns
      newAtom: atom object for the newly created atom
  `removeAtom`(atom, onlyEmpty=False)

    Remove the specified atom from the chemical environment. if the atom is not indexed for the SMIRKS string or used to connect two other atoms.

    Parameters
      atom: atom object, required

        atom to be removed if it meets the conditions.

      onlyEmpty: boolean, optional

        True only an atom with no ANDtypes and 1 ORtype can be removed

    Returns
      Boolean True: atom was removed, False: atom was not removed
  `getAtoms`()
    Returns
      list of atoms in the environment
  `getBonds`(atom=None)
    Parameters
      atom: Atom object, optional, returns bonds connected to atom
      returns all bonds in fragment if atom is None
    Returns
      a complete list of bonds in the fragment
  `getBond`(atom1, atom2)

    Get bond betwen two atoms

    Parameters
      atom1 and atom2: atom objects
    Returns
      bond object between the atoms or None if no bond there
  `getIndexedAtoms`()

    returns the list of Atom objects with an index

  `getUnindexedAtoms`()

    returns a list of Atom objects that are not indexed

  `getAlphaAtoms`()
    Returns a list of atoms alpha to any indexed atom

      that are not also indexed

  `getBetaAtoms`()
    Returns a list of atoms beta to any indexed atom

      that are not alpha or indexed atoms

  `getIndexedBonds`()

    Returns a list of Bond objects that connect two indexed atoms

  `getUnindexedBonds`()
    Returns a list of Bond objects that connect

      an indexed atom to an unindexed atom two unindexed atoms

  `getAlphaBonds`()
    Returns a list of Bond objects that connect

      an indexed atom to alpha atoms

  `getBetaBonds`()
    Returns a list of Bond objects that connect

      alpha atoms to beta atoms

  `isAlpha`(component)

    Takes an atom or bond are returns True if it is alpha to an indexed atom

  `isUnindexed`(component)

    returns True if the atom or bond is not indexed

  `isIndexed`(component)

    returns True if the atom or bond is indexed

  `isBeta`(component)

    Takes an atom or bond are returns True if it is beta to an indexed atom

  `getType`()

    Uses number of indexed atoms and bond connectivity to determine the type of chemical environment

    Returns
      chemical environemnt type:

        ‘Atom’, ‘Bond’, ‘Angle’, ‘ProperTorsion’, ‘ImproperTorsion’ None if number of indexed atoms is 0 or > 4

  `getNeighbors`(atom)

    Returns atoms that are bound to the given atom in the form of a list of Atom objects

  `getValence`(atom)

    Returns the valence (number of neighboring atoms) around the given atom

  `getBondOrder`(atom)

    Returns minimum bond order around a given atom 0 if atom has no neighbors aromatic bonds count as 1.5 any bond counts as 1.0