.. oe:namespace:: OEChem


.. meta::
   :keywords: OEAtomBondSet, AtomBondSet


.. _OEChem_OEAtomBondSet:

.. oe:class:: OEAtomBondSet

   .. oe:api::

      class OEAtomBondSet : public OESystem::OERoleSet

   This class represents `OEAtomBondSet` that is a container that holds
   atom and bond pointers.

   The following methods are publicly inherited from :ref:`OERoleSet <OESystem_OERoleSet>`:

   ======================================================= ======================================================= =======================================================
   :oe:meth:`AddRole<OESystem::OERoleSet::AddRole>`        :oe:meth:`GetRoles<OESystem::OERoleSet::GetRoles>`
   :oe:meth:`ClearRoles<OESystem::OERoleSet::ClearRoles>`  :oe:meth:`HasRole<OESystem::OERoleSet::HasRole>`
   :oe:meth:`DeleteRole<OESystem::OERoleSet::DeleteRole>`  :oe:meth:`NumRoles<OESystem::OERoleSet::NumRoles>`
   ======================================================= ======================================================= =======================================================

   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEAtomBondSet()

      .. oe:language:: python

         .. oe:api:: python

            OEAtomBondSet() -> OEAtomBondSet

      Default constructor that generates an empty container.

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEAtomBondSet(rhs: OEAtomBondSet, amap: OEAtomBase = (OEAtomBase, bmap: OEBondBase = (OEBondBase) -> OEAtomBondSet

      .. oe:language:: python

         .. oe:api:: python

            OEAtomBondSet(rhs: OEAtomBondSet, amap: OEAtomBase = (OEAtomBase, bmap: OEBondBase = (OEBondBase) -> OEAtomBondSet

      Copy constructor.

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEAtomBondSet(OESystem::OEIter<OEChem::OEAtomBase>& atoms)
            OEAtomBondSet(OESystem::OEIter<OEChem::OEBondBase>& bonds)
            OEAtomBondSet(OESystem::OEIterBase<OEChem::OEAtomBase>* atoms)
            OEAtomBondSet(OESystem::OEIterBase<OEChem::OEBondBase>* bonds)
            OEAtomBondSet(OESystem::OEIter<OEChem::OEAtomBase>& atoms,
                          OESystem::OEIter<OEChem::OEBondBase>& bonds)
            OEAtomBondSet(OESystem::OEIterBase<OEChem::OEAtomBase>* atoms,
                          OESystem::OEIterBase<OEChem::OEBondBase>* bonds)

      .. oe:language:: python

         .. oe:api:: python

            OEAtomBondSet(atoms: OEAtomIter) -> OEAtomBondSet
            OEAtomBondSet(bonds: OEBondIter) -> OEAtomBondSet
            OEAtomBondSet(atoms: OEAtomIter, bonds: OEBondIter) -> OEAtomBondSet

      Constructors that generate an :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>`
      container with the given atoms and bonds.

   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OEAtomBondSet &operator=(const OEAtomBondSet &rhs)

      Assignment operator.

   .. oe:method:: Add

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool Add(const OEMolBase& mol,
                     const OESystem::OEUnaryPredicate<OEChem::OEAtomBase>& atompred)
            bool Add(const OEMolBase& mol,
                     const OESystem::OEUnaryPredicate<OEChem::OEBondBase>& bondpred)
            bool Add(const OEMolBase& mol,
                     const OESystem::OEUnaryPredicate<OEChem::OEAtomBase>& atompred,
                     const OESystem::OEUnaryPredicate<OEChem::OEBondBase>& bondpred)
            bool Add(const OEAtomBondSet& abset)

      .. oe:language:: python

         .. oe:api:: python

            Add(mol: Union[OEGraphMol,OEMol,OEQMol], atompred: OEUnaryAtomPred) -> bool
            Add(mol: Union[OEGraphMol,OEMol,OEQMol], bondpred: OEUnaryBondPred) -> bool
            Add(mol: Union[OEGraphMol,OEMol,OEQMol], atompred: OEUnaryAtomPred,
                bondpred: OEUnaryBondPred) -> bool
            Add(abset: OEAtomBondSet) -> bool

      Adds the atom and bond objects to the container. Returns ``false`` if given a null
      pointer or if the atoms or bonds being added do not belong to the same
      molecule previous objects in the set belong to.

      .. seealso::

         * :oe:meth:`OEChem::OEAtomBondSet::GetParent` method

   .. oe:method:: AddAtom

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool AddAtom(OEChem::OEAtomBase* atom)

      .. oe:language:: python

         .. oe:api:: python

            AddAtom(atom: OEAtomBase) -> bool

      Adds an atom to the container. Returns ``false`` if given a null
      pointer or if the atom being added does not belong to the same
      molecule previous atoms and bonds in the set belong to.

      .. seealso::

         * :oe:meth:`OEChem::OEAtomBondSet::GetParent` method

   .. oe:method:: AddAtoms

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool AddAtoms(const std::vector<OEChem::OEAtomBase *>& atoms)

      .. oe:language:: python

         .. oe:api:: python

            AddAtoms(atoms: OEAtomVector) -> bool

      Adds all the atoms to the container. Returns ``false`` if given a null
      pointer or if any atom being added does not belong to the same
      molecule previous atoms and bonds in the set belong to.

      .. seealso::

         * :oe:meth:`OEChem::OEAtomBondSet::GetParent` method

   .. oe:method:: AddBond

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool AddBond(OEChem::OEBondBase* bond)

      .. oe:language:: python

         .. oe:api:: python

            AddBond(bond: OEBondBase) -> bool

      Adds a bond to the container. Returns ``false`` if given a null
      pointer or if the bond being added does not belong to the same
      molecule previous atoms and bonds in the set belong to.

      .. seealso::

         * :oe:meth:`OEChem::OEAtomBondSet::GetParent` method

   .. oe:method:: AddBonds

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool AddBonds(const std::vector<OEChem::OEBondBase *>& bonds)

      .. oe:language:: python

         .. oe:api:: python

            AddBonds(bonds: OEBondVector) -> bool

      Adds all the bonds to the container. Returns ``false`` if given a null
      pointer or if any bond being added does not belong to the same
      molecule previous atoms and bonds in the set belong to.

      .. seealso::

         * :oe:meth:`OEChem::OEAtomBondSet::GetParent` method

   .. oe:method:: Clear

      .. oe:language:: c++ java csharp

         .. oe:api::

            void Clear()

      .. oe:language:: python

         .. oe:api:: python

            Clear() -> None

      Removes all atoms and bonds from the
      :oe:cls:`OEAtomBondSet<OEChem::OEAtomBondSet>`
      and clears the :ref:`OERoleSet <OESystem_OERoleSet>`.

   .. oe:method:: ClearAtoms

      .. oe:language:: c++ java csharp

         .. oe:api::

            void ClearAtoms()

      .. oe:language:: python

         .. oe:api:: python

            ClearAtoms() -> None

      Removes all atoms from the
      :oe:cls:`OEAtomBondSet<OEChem::OEAtomBondSet>`.

   .. oe:method:: ClearAtomsAndBonds

      .. oe:language:: c++ java csharp

         .. oe:api::

            void ClearAtomsAndBonds()

      .. oe:language:: python

         .. oe:api:: python

            ClearAtomsAndBonds() -> None

      Removes all atoms and bonds from the
      :oe:cls:`OEAtomBondSet<OEChem::OEAtomBondSet>` but retains
      the existing  :ref:`OERoleSet <OESystem_OERoleSet>`.

   .. oe:method:: ClearBonds

      .. oe:language:: c++ java csharp

         .. oe:api::

            void ClearBonds()

      .. oe:language:: python

         .. oe:api:: python

            ClearBonds() -> None

      Removes all bonds from the
      :oe:cls:`OEAtomBondSet<OEChem::OEAtomBondSet>`.

   .. oe:method:: CreateCopy

      .. oe:language:: c++ java csharp

         .. oe:api::

            OESystem::OEAtomBondSet* CreateCopy() const

      .. oe:language:: python

         .. oe:api:: python

            CreateCopy() -> OEAtomBondSet


      Deep copy constructor that returns a copy of the object.
      The memory for the returned object derived from
      :oe:cls:`OEAtomBondSet<OEChem::OEAtomBondSet>`
      is dynamically allocated and owned by the caller.

      .. oe:language:: c++

         The returned copy should be deallocated using C++
         delete operator in order to prevent a memory leak.

   .. oe:method:: HasAtom

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool HasAtom(const OEChem::OEAtomBase* atom) const

      .. oe:language:: python

         .. oe:api:: python

            HasAtom(atom: OEAtomBase) -> bool

      Returns whether ``atom`` already belongs to the set.

   .. oe:method:: HasBond

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool HasBond(const OEChem::OEBondBase* bond) const

      .. oe:language:: python

         .. oe:api:: python

            HasBond(bond: OEBondBase) -> bool

      Returns whether ``bond`` already belongs to the set.

   .. oe:method:: IsEmpty

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool IsEmpty() const

      .. oe:language:: python

         .. oe:api:: python

            IsEmpty() -> bool

      Returns whether the set contains any atoms or bonds.

   .. oe:method:: GetAtoms

      .. oe:language:: c++ java csharp

         .. oe:api::

            OESystem::OEIterBase<OEChem::OEAtomBase>* GetAtoms() const

      .. oe:language:: python

         .. oe:api:: python

            GetAtoms() -> OEAtomIter

      Returns an iterator over the atoms that are stored in the
      :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>` object.

      .. oe:language:: c++ java csharp

         .. oe:api::

            OESystem::OEIterBase<OEAtomBase>* GetAtoms(const OESystem::OEUnaryPredicate<OEChem::OEAtomBase> &) const = 0

      .. oe:language:: python

         .. oe:api:: python

            GetAtoms(atompred: OEUnaryAtomPred) -> OEAtomIter

      Returns an iterator over all of the atoms in the container that
      match the specified atom predicate
      (:ref:`OEUnaryPredicate <OESystem_OEUnaryPredicate>`).

   .. oe:method:: GetBonds

      .. oe:language:: c++ java csharp

         .. oe:api::

            OESystem::OEIterBase<OEChem::OEBondBase>* GetBonds() const

      .. oe:language:: python

         .. oe:api:: python

            GetBonds() -> OEBondIter

      Returns an iterator over the bonds that are stored in the
      :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>` object.

      .. oe:language:: c++ java csharp

         .. oe:api::

            OESystem::OEIterBase<OEBondBase>* GetBonds(const OESystem::OEUnaryPredicate<OEChem::OEBondBase> &) const = 0

      .. oe:language:: python

         .. oe:api:: python

            GetBonds(bondpred: OEUnaryBondPred) -> OEBondIter

      Returns an iterator over all of the bonds in the container that
      match the specified bond predicate
      (:ref:`OEUnaryPredicate <OESystem_OEUnaryPredicate>`).

   .. oe:method:: GetParent

      .. oe:language:: c++ java csharp

         .. oe:api::

            const OEMolBase* GetParent() const

      .. oe:language:: python

         .. oe:api:: python

            GetParent() -> OEGraphMol

      Returns the parent molecule of a :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>`
      object.
      This method can be used to determine the molecule of which atoms
      and bonds the container stores.
      The 'parent molecule' property of a :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>`
      object cannot be altered, as it is determined at the point the
      container is created.
      The :oe:meth:`OEChem::OEAtomBondSet::GetParent` method returns a
      null pointer if the container is empty.

   .. oe:method:: NumAtoms

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int NumAtoms() const

      .. oe:language:: python

         .. oe:api:: python

            NumAtoms() -> int

      Returns the number of atoms stored in the
      :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>` object.

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int NumAtoms(const OESystem::OEUnaryPredicate<OEChem::OEAtomBase>& atompred) const

      .. oe:language:: python

         .. oe:api:: python

            NumAtoms(atompred: OEUnaryAtomPred) -> int

      Returns the number of atoms stored in the
      :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>` object matching the provided predicate.

   .. oe:method:: NumBonds

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int NumBonds() const

      .. oe:language:: python

         .. oe:api:: python

            NumBonds() -> int

      Returns the number of bonds stored in the
      :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>` object.

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int NumBonds(const OESystem::OEUnaryPredicate<OEChem::OEBondBase>& bondpred) const

      .. oe:language:: python

         .. oe:api:: python

            NumBonds(bondpred: OEUnaryBondPred) -> int

      Returns the number of bonds stored in the
      :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>` object matching the provided predicate.

   .. oe:method:: Remove

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool Remove(const OEMolBase& mol,
                        const OESystem::OEUnaryPredicate<OEChem::OEAtomBase>& atompred)
            bool Remove(const OEMolBase& mol,
                        const OESystem::OEUnaryPredicate<OEChem::OEBondBase>& bondpred)
            bool Remove(const OEMolBase& mol,
                        const OESystem::OEUnaryPredicate<OEChem::OEAtomBase>& atompred,
                        const OESystem::OEUnaryPredicate<OEChem::OEBondBase>& bondpred)
            bool Remove(const OEAtomBondSet& abset)

      .. oe:language:: python

         .. oe:api:: python

            Remove(mol: Union[OEGraphMol,OEMol,OEQMol],
                   atompred: OEUnaryAtomPred) -> bool
            Remove(mol: Union[OEGraphMol,OEMol,OEQMol],
                   bondpred: OEUnaryBondPred) -> bool
            Remove(mol: Union[OEGraphMol,OEMol,OEQMol],
                   atompred: OEUnaryAtomPred, bondpred: OEUnaryBondPred) -> bool
            Remove(abset: OEAtomBondSet) -> bool

      Removes the objects from the container. Returns ``false`` if given a null
      pointer or if any of the objects being removed do not belong to the same
      molecule previous objects in the set belong to.

   .. oe:method:: RemoveAtom

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool RemoveAtom(OEChem::OEAtomBase* atom)

      .. oe:language:: python

         .. oe:api:: python

            RemoveAtom(atom: OEAtomBase) -> bool

      Removes an atom from the container. Returns ``false`` if given a null
      pointer or if the atom being removed does not belong to the same
      molecule previous atoms in the set belong to.

   .. oe:method:: RemoveAtoms

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool RemoveAtoms(const std::vector<OEChem::OEAtomBase *>& atoms)

      .. oe:language:: python

         .. oe:api:: python

            RemoveAtoms(atoms: OEAtomVector) -> bool

      Removes atoms from the container. Returns ``false`` if given a null
      pointer or if any atoms being removed do not belong to the same
      molecule previous atoms in the set belong to.

   .. oe:method:: RemoveBond

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool RemoveBond(OEChem::OEBondBase* bond)

      .. oe:language:: python

         .. oe:api:: python

            RemoveBond(bond: OEBondBase) -> bool

      Removes a bond from the container. Returns ``false`` if given a null
      pointer or if the bond being removed does not belong to the same
      molecule previous bonds in the set belong to.

   .. oe:method:: RemoveBonds

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool RemoveBonds(const std::vector<OEChem::OEBondBase *>& bonds)

      .. oe:language:: python

         .. oe:api:: python

            RemoveBonds(bonds: OEBondVector) -> bool

      Removes bonds from the container. Returns ``false`` if given a null
      pointer or if any bonds being removed do not belong to the same
      molecule previous bonds in the set belong to.

   .. oe:method:: Sweep

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool Sweep()

      .. oe:language:: python

         .. oe:api:: python

            Sweep() -> bool

      Removes deleted atoms and bonds from the container.

   .. oe:method:: Translate

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool Translate(OEAtomBase** amap, OEBondBase** bmap)

      .. oe:language:: python

         .. oe:api:: python

            Translate(amap: OEAtomBase, bmap: OEBondBase) -> bool

      Translates the pointers in the container based on the provided
      mapping between the atoms or bonds in the array arguments.
      This can be used to convert an existing :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>`
      container to refer to a copy of the molecule made from
      a subset operations.

      .. seealso::

         :oe:func:`OEChem::OESubsetMol`

