.. oe:namespace:: OEChem

.. meta::
   :keywords: OEMolBase, MolBase


.. _OEChem_OEMolBase:

.. oe:class:: OEMolBase

   .. oe:api::


      class OEMolBase : public OESystem::OEBase

   This class represents `OEMolBase`.

   The :ref:`OEMolBase <OEChem_OEMolBase>` class is the abstract interface for
   representing molecules within *OEChem*.

   The following methods are publicly inherited from :ref:`OEBase <OESystem_OEBase>`:

   ======================================================== ========================================================= =========================================================
   :oe:meth:`operator=<OESystem::OEBase::operator=>`        :oe:meth:`GetData<OESystem::OEBase::GetData>`             :oe:meth:`IsDataType<OESystem::OEBase::IsDataType>`      
   :oe:meth:`operator+=<OESystem::OEBase::operator+=>`      :oe:meth:`GetDataIter<OESystem::OEBase::GetDataIter>`     :oe:meth:`SetBaseData<OESystem::OEBase::SetBaseData>`    
   :oe:meth:`AddBaseData<OESystem::OEBase::AddBaseData>`    :oe:meth:`GetDataType<OESystem::OEBase::GetDataType>`     :oe:meth:`SetBoolData<OESystem::OEBase::SetBoolData>`    
   :oe:meth:`AddData<OESystem::OEBase::AddData>`            :oe:meth:`GetDoubleData<OESystem::OEBase::GetDoubleData>` :oe:meth:`SetData<OESystem::OEBase::SetData>`            
   :oe:meth:`Clear<OESystem::OEBase::Clear>`                :oe:meth:`GetFloatData<OESystem::OEBase::GetFloatData>`   :oe:meth:`SetDoubleData<OESystem::OEBase::SetDoubleData>`
   :oe:meth:`CreateCopy<OESystem::OEBase::CreateCopy>`      :oe:meth:`GetIntData<OESystem::OEBase::GetIntData>`       :oe:meth:`SetFloatData<OESystem::OEBase::SetFloatData>`  
   :oe:meth:`DeleteData<OESystem::OEBase::DeleteData>`      :oe:meth:`GetStringData<OESystem::OEBase::GetStringData>` :oe:meth:`SetIntData<OESystem::OEBase::SetIntData>`      
   :oe:meth:`GetBoolData<OESystem::OEBase::GetBoolData>`    :oe:meth:`HasData<OESystem::OEBase::HasData>`             :oe:meth:`SetStringData<OESystem::OEBase::SetStringData>`
   ======================================================== ========================================================= =========================================================


   The following classes derive from this class:
    * :ref:`OEConfBase <OEChem_OEConfBase>`
    * :ref:`OEMCMolBase <OEChem_OEMCMolBase>`
    * :ref:`OEQMolBase <OEChem_OEQMolBase>`


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

      .. oe:api::

         OEMolBase& operator=(const OEMolBase& m)

      Assignment operator.


   .. oe:method:: operator bool

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

         .. oe:api::

            operator bool() const

      .. oe:language:: python

         .. oe:api:: python

            IsValid() -> bool

      Determines whether the :ref:`OEMolBase <OEChem_OEMolBase>` object
      contains any atoms. This method is equivalent to
      :oe:meth:`OEChem::OEMolBase::NumAtoms()<OEChem::OEMolBase::NumAtoms>`
      != 0.

   .. oe:method:: Clear

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

         .. oe:api::

            void Clear()=0

      .. oe:language:: python

         .. oe:api:: python

            Clear() -> None

      Resets a molecule to its initial state. This method deletes all
      atoms (:ref:`OEAtomBase <OEChem_OEAtomBase>`) and bonds
      (:ref:`OEBondBase <OEChem_OEBondBase>`) that are part of the
      molecule. Following an :oe:meth:`OEChem::OEMolBase::Clear`, the
      atom and bond indices assigned to new atoms and bonds may not be
      unique with those assigned prior to the
      :oe:meth:`OEChem::OEMolBase::Clear`.

   .. oe:method:: ClearBase

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

         .. oe:api::

            void ClearBase()

      .. oe:language:: python

         .. oe:api:: python

            ClearBase() -> None

      Clear the generic data from the :ref:`OEBase <OESystem_OEBase>` base
      class of this object. Equivalent to just calling
      :oe:meth:`OESystem::OEBase::Clear` without actually clearing away
      molecule data like atoms and bonds.

   .. oe:method:: ClearCoords

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

         .. oe:api::

            void ClearCoords() =0

      .. oe:language:: python

         .. oe:api:: python

            ClearCoords() -> None

      Clears the coordinates, resets stereo perception flags and sets the coordinate
      dimension to ``0``

      .. seealso::

         * :oe:meth:`OEChem::OEMolBase::GetCoords`
         * :oe:meth:`OEChem::OEMolBase::SetCoords`

   .. oe:method:: Compress

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

         .. oe:api::

            bool Compress()

      .. oe:language:: python

         .. oe:api:: python

            Compress() -> bool

   .. seealso::

      .. oe:language:: c++

         * Example program :ref:`randomsample.cpp<section_example_oechem_randomsample>`

      .. oe:language:: python

         * Example program :ref:`randomsample.py<section_example_oechem_randomsample>`

      .. oe:language:: java

         * Example program :ref:`RandomSample.java<section_example_oechem_randomsample>`

      .. oe:language:: csharp

         * Example program :ref:`RandomSample.cs<section_example_oechem_randomsample>`

   .. oe:method:: Count

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

         .. oe:api::

            unsigned int Count(unsigned int) const = 0

      .. oe:language:: python

         .. oe:api:: python

            Count(arg2: int) -> int

   .. oe:method:: CreateCopy

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

         .. oe:api::

            OESystem::OEBase* CreateCopy() const

      .. oe:language:: python

         .. oe:api:: python

            CreateCopy() -> OEBase

   .. oe:method:: DeleteAtom

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

         .. oe:api::

            bool DeleteAtom(OEAtomBase* atom)=0

      .. oe:language:: python

         .. oe:api:: python

            DeleteAtom(arg2: OEAtomBase) -> bool

      Deletes an atom from a molecule. All bonds connected to the
      specified atom are also automatically deleted. Following an atom
      deletion, the specified :ref:`OEAtomBase <OEChem_OEAtomBase>` pointer, and
      the :ref:`OEBondBase <OEChem_OEBondBase>` pointers of any incident bonds,
      are no longer valid and should not be used. The atom index
      associated with the atom, and the bond indices of any incident
      bonds, are no longer recognized by the
      :ref:`OEMolBase <OEChem_OEMolBase>`, but the indices of all other atoms
      and bonds remain stable, and are unaffected by this call.

      .. note::

         After deleting atoms or bonds, it may be necessary to call the
         :oe:func:`OEChem::OEFindRingAtomsAndBonds` and
         :oe:func:`OEChem::OEAssignAromaticFlags` functions to update the
         'in ring' and 'aromatic' properties of the atoms and bonds in
         the modified molecule.

   .. oe:method:: DeleteBond

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

         .. oe:api::

            bool DeleteBond(OEBondBase* bond)=0

      .. oe:language:: python

         .. oe:api:: python

            DeleteBond(arg2: OEBondBase) -> bool

      Deletes a bond from a molecule. Following a bond deletion, the
      specified :ref:`OEBondBase <OEChem_OEBondBase>` pointer is no longer valid
      and should not be used. The bond index associated with the bond
      is no longer recognized by the :ref:`OEMolBase <OEChem_OEMolBase>`, but
      the indices of all other bonds remain stable, and are unaffected
      by this call.

      .. note::

         After deleting atoms or bonds, it may be necessary to call the
         :oe:func:`OEChem::OEFindRingAtomsAndBonds` and
         :oe:func:`OEChem::OEAssignAromaticFlags` functions to update the
         'in ring' and 'aromatic' properties of the atoms and bonds in
         the modified molecule.

   .. oe:method:: DeleteGroup

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

         .. oe:api::

            bool DeleteGroup(OEGroupBase* group)

      .. oe:language:: python

         .. oe:api:: python

            DeleteGroup(group: OEGroupBase) -> bool

      Deletes a group from a molecule. Following a group deletion, the
      specified :ref:`OEGroupBase <OEChem_OEGroupBase>` pointer is no longer valid
      and should not be used.

   .. oe:method:: GetAtom

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

         .. oe:api::

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

      .. oe:language:: python

         .. oe:api:: python

            GetAtom(arg2: OEUnaryAtomPred) -> OEAtomBase

      Retrieves the first atom of a molecule that matches the
      specified atom predicate
      (:ref:`OEUnaryPredicate <OESystem_OEUnaryPredicate>`). If the molecule does not
      contain an atom that matches, a NULL pointer,
      (:oe:cls:`OEChem::OEAtomBase*<OEChem::OEAtomBase>`)0, is returned.

   .. oe:method:: GetAtoms

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

         .. oe:api::

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

      .. oe:language:: python

         .. oe:api:: python

            GetAtoms() -> OEAtomIter

      Returns an iterator over all the atoms of a molecule. By
      default, this returns all the atoms of the molecule in the order
      they were created. The ordering of the atoms returned by
      :oe:meth:`OEChem::OEMolBase::GetAtoms` may be modified by
      :oe:meth:`OEChem::OEMolBase::OrderAtoms`.

      .. 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(arg2: OEUnaryAtomPred) -> OEAtomIter

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


   .. oe:language:: java

      .. oe:method:: GetAtomList

         .. oe:api:: java

            java.util.List<OEAtomBase> GetAtomList()

         Returns a List object containing all of the atoms in the order they were
         created.  Note that removing atoms from the list does not remove them from
         the molecule.

   .. oe:method:: GetBond

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

         .. oe:api::

            OEBondBase* GetBond(const OEAtomBase* src, const OEAtomBase* dst) const

      .. oe:language:: python

         .. oe:api:: python

            GetBond(arg2: OEAtomBase, arg3: OEAtomBase) -> OEBondBase

      Retrieves the bond of a molecule between two specified atoms. If
      the two atoms, 'src' and 'dst' are not bonded together, then a
      NULL pointer,
      (:oe:cls:`OEChem::OEBondBase*<OEChem::OEBondBase>`)0, is returned

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

         .. oe:api::

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

      .. oe:language:: python

         .. oe:api:: python

            GetBond(arg2: OEUnaryBondPred) -> OEBondBase

      Retrieves the first bond of a molecule that matches the
      specified bond predicate. If the molecule does not contain a
      bond that matches the predicate, a NULL pointer,
      (:oe:cls:`OEChem::OEBondBase*<OEChem::OEBondBase>`)0, is
      returned.

   .. oe:method:: GetBonds

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

         .. oe:api::

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

      .. oe:language:: python

         .. oe:api:: python

            GetBonds() -> OEBondIter

      Returns an iterator over all the bonds of a molecule. By
      default, this returns all the bonds of the molecule in the order
      they were created. The ordering of the bonds returned by
      :oe:meth:`OEChem::OEMolBase::GetBonds` may be modified by
      :oe:meth:`OEChem::OEMolBase::OrderBonds`.

      .. 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(arg2: OEUnaryBondPred) -> OEBondIter

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

   .. oe:language:: java

       .. oe:method:: GetBondList

          .. oe:api:: java

             java.util.List<OEBondBase> GetBondList()

          Returns a List object containing all of the bonds in the order they were
          created.  Note that removing bonds from the list does not remove them from
          the molecule.

   .. oe:method:: GetCoords

      .. oe:language:: python

         .. oe:api:: python

            GetCoords() -> {idx : (x_0, y_0, z_0), ... }

         Returns a Python dictionary of the coordinates of this
         molecule. The dictionary is keyed off the index of the
         :ref:`OEAtomBase <OEChem_OEAtomBase>` as returned by
         :oe:meth:`OEChem::OEAtomBase::GetIdx`. The values will always
         be a 3-element tuple of floating point values. Note, the
         dictionary will not contain entries for deleted atoms, making
         it significantly easier to use than the following
         ``OEFloatArray`` overloads. This also means the keys of the
         dictionary are not always guaranteed to be contiguous
         integers.

         .. note::

            The overload that returns a dictionary is for convenience
            over performance as it is significantly more
            pythonic. However, if the floating point values are not
            needed in Python and just being passed to another OpenEye
            toolkit function, using the following overloads with
            ``OEFloatArray`` objects will be significantly faster.

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

         .. oe:api::

            bool GetCoords(OEPlatform::OEHalfFloat *) const = 0
            bool GetCoords(float *) const = 0
            bool GetCoords(double *) const = 0
            bool GetCoords(long double *) const = 0

      .. oe:language:: python

         .. oe:api:: python

            GetCoords(arg2: OEAtomBase) -> bool
            GetCoords(crds: OEHalfFloat) -> bool
            GetCoords(arg2: OEFloatArray) -> bool
            GetCoords(arg2: OEDoubleArray) -> bool

      Fills the specified array of floating point values with the
      Cartesian coordinates of all of the atoms in the molecule. The
      array argument must point to an array of at least
      3* :oe:meth:`OEChem::OEMolBase::GetMaxAtomIdx()<OEChem::OEMolBase::GetMaxAtomIdx>`
      elements. The X, Y and Z coordinates for the atom with index 'i'
      will be placed at offsets ``3*i``, ``3*i+1`` and ``3*i+2``
      respectively.

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

         .. oe:api::

            bool GetCoords(const OEAtomBase *, OEPlatform::OEHalfFloat *) const = 0
            bool GetCoords(const OEAtomBase *, float *) const = 0
            bool GetCoords(const OEAtomBase *, double *) const = 0
            bool GetCoords(const OEAtomBase *, long double *) const = 0

      .. oe:language:: python

         .. oe:api:: python

            GetCoords(atom: OEAtomBase, crds: OEHalfFloat) -> bool
            GetCoords(arg2: OEAtomBase, arg3: OEFloatArray) -> bool
            GetCoords(arg2: OEAtomBase, arg3: OEDoubleArray) -> bool

      Fills the specified array of floating point values with the
      Cartesian coordinates of the specified atom. This array must be
      large enough to hold at least three values, corresponding to the
      X, Y and Z values for the given atom.

   .. oe:method:: GetDimension

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

         .. oe:api::

            unsigned int GetDimension() const = 0

      .. oe:language:: python

         .. oe:api:: python

            GetDimension() -> int

      Returns the 'dimensionality' property of a molecule. The default value is
      zero, for unknown or no coordinates, 2 for 2-dimensional
      coordinates (such as depictions) and 3 for 3-dimensional
      coordinates.
      The 'dimensionality' property of a molecule may be
      set using the :oe:meth:`OEChem::OEMolBase::SetDimension`
      method.

      This property is typically set by the appropriate
      molecular file format reader (``0`` for SMILES, ``3`` for MOL2 and ``2`` or
      ``3`` for MDL SD files *etc...*) or by calling the
      :oe:func:`OEChem::OESetDimensionFromCoords` function.

   .. oe:method:: GetEnergy

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

         .. oe:api::

            double GetEnergy() const = 0

      .. oe:language:: python

         .. oe:api:: python

            GetEnergy() -> float

      Returns the 'energy' property of a molecule. The default value is
      0.0. The 'energy' property of a molecule may be set using the
      :oe:meth:`OEChem::OEMolBase::SetEnergy` method. Higher values
      indicate higher energies and therefore less-favorable or
      more-strained structures.

   .. oe:method:: GetGroup

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

         .. oe:api::

            OEGroupBase* GetGroup(const OESystem::OEUnaryPredicate<OEChem::OEGroupBase>& pred) const

      .. oe:language:: python

         .. oe:api:: python

            GetGroup(pred: OEUnaryGroupPred) -> OEGroupBase

      Retrieves the first group of a molecule that matches the
      specified group predicate (:ref:`OEUnaryPredicate <OESystem_OEUnaryPredicate>`).
      If the molecule does not contain a group that matches, a NULL pointer,
      (:oe:cls:`OEChem::OEGroupBase*<OEChem::OEGroupBase>`)0, is returned.

      .. seealso::

         * :ref:`OEHasAtomInGroup <OEChem_OEHasAtomInGroup>` predicate
         * :ref:`OEHasBondInGroup <OEChem_OEHasBondInGroup>` predicate
         * :ref:`OEHasGroupType <OEChem_OEHasGroupType>` predicate
         * :ref:`OEIsMDLStereoGroup <OEChem_OEIsMDLStereoGroup>` predicate

   .. oe:method:: GetGroups

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

         .. oe:api::

            OESystem::OEIterBase<OEGroupBase>* GetGroups() const

      .. oe:language:: python

         .. oe:api:: python

            GetGroups() -> Iterable[OEGroupBase]

      Returns an iterator over all the groups of a molecule.

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

         .. oe:api::

            OESystem::OEIterBase<OEGroupBase>* GetGroups(const OESystem::OEUnaryPredicate<OEChem::OEGroupBase>& pred) const

      .. oe:language:: python

         .. oe:api:: python

            GetGroups(pred: OEUnaryGroupPred) -> Iterable[OEGroupBase]

      Returns an iterator over all of the groups of a molecule that
      match the specified group predicate
      (:ref:`OEUnaryPredicate <OESystem_OEUnaryPredicate>`).

      .. seealso::

         * :ref:`OEHasAtomInGroup <OEChem_OEHasAtomInGroup>` predicate
         * :ref:`OEHasBondInGroup <OEChem_OEHasBondInGroup>` predicate
         * :ref:`OEHasGroupType <OEChem_OEHasGroupType>` predicate
         * :ref:`OEIsMDLStereoGroup <OEChem_OEIsMDLStereoGroup>` predicate

   .. oe:language:: java

      .. oe:method:: GetGroupList

         .. oe:api:: java

            java.util.List<OEGroupBase> GetGroupList()

         Returns a List object containing all of the groups in the order they were
         created.  Note that removing groups from the list does not remove them from
         the molecule.

   .. oe:method:: GetMaxAtomIdx

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

         .. oe:api::

            unsigned int GetMaxAtomIdx() const = 0

      .. oe:language:: python

         .. oe:api:: python

            GetMaxAtomIdx() -> int

      For performance reasons, atom indices are not guaranteed to be contiguous.
      :oe:meth:`OEChem::OEMolBase::GetMaxAtomIdx` returns a lower bound for the maximum atom index
      i.e. all indices returned by :oe:meth:`OEChem::OEAtomBase::GetIdx` of the
      molecule will be less than this value.
      The value returned by :oe:meth:`OEChem::OEMolBase::GetMaxAtomIdx`
      is always at least as large as :oe:meth:`OEChem::OEMolBase::NumAtoms`.

      This method is useful for allocating temporary external data structures
      that need to be indexed by atom index, as returned by
      :oe:meth:`OEChem::OEAtomBase::GetIdx`.

   .. oe:method:: GetMaxBondIdx

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

         .. oe:api::

            unsigned int GetMaxBondIdx() const = 0

      .. oe:language:: python

         .. oe:api:: python

            GetMaxBondIdx() -> int

      For performance reasons, bond indices are not guaranteed to be contiguous.
      :oe:meth:`OEChem::OEMolBase::GetMaxBondIdx` returns a lower bound for the maximum bond index
      i.e. all indices returned by :oe:meth:`OEChem::OEBondBase::GetIdx` of the
      molecule will be less than this value.
      The value returned by :oe:meth:`OEChem::OEMolBase::GetMaxBondIdx`
      is always at least as large as :oe:meth:`OEChem::OEMolBase::NumBonds`.

      This method is useful for allocating temporary external data structures
      that need to be indexed by bond index, as returned by
      :oe:meth:`OEChem::OEBondBase::GetIdx`.

   .. oe:method:: GetTitle

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

         .. oe:api::

            const char* GetTitle() const

      .. oe:language:: python

         .. oe:api:: python

            GetTitle() -> str

      Returns the 'title' property of a molecule. The default value is
      the empty string. The title of a molecule may be set
      using the :oe:meth:`OEChem::OEMolBase::SetTitle` method.

      .. oe:language:: c++

         .. warning::

            Titles should be compared using **strcmp**:

            .. code-block:: c

               if (strcmp(mol1.GetTitle(), mol2.GetTitle()) == 0)
                 // do something if titles are the same

            The following code snippet compares the pointer of the titles **not** the titles themselves.

            .. code-block:: c

               if (mol1.GetTitle() == mol2.GetTitle())
                  // do something if titles are the same

      .. seealso::

         .. oe:language:: c++

            * Example programs :ref:`gettitles.cpp<section_example_oechem_gettitles>` and :ref:`molextract.cpp<section_example_oechem_molextract>`

         .. oe:language:: python

            * Example programs :ref:`gettitles.py<section_example_oechem_gettitles>` and :ref:`molextract.py<section_example_oechem_molextract>`

         .. oe:language:: java

            * Example programs :ref:`GetTitles.java<section_example_oechem_gettitles>` and :ref:`MolExtract.java<section_example_oechem_molextract>`

         .. oe:language:: csharp

            * Example programs :ref:`GetTitles.cs<section_example_oechem_gettitles>` and :ref:`MolExtract.cs<section_example_oechem_molextract>`


   .. oe:method:: HasPerceived

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

         .. oe:api::

            bool HasPerceived(unsigned int prop) const = 0

      .. oe:language:: python

         .. oe:api:: python

            HasPerceived(arg2: int) -> bool

      Returns whether a property is perceived for the given molecule.

      *property*
         This value has to be from the :oe:constns:`OEChem::OEPerceived`
         namespace.

      .. seealso::

         * :oe:meth:`OEChem::OEMolBase::ResetPerceived` method
         * :oe:meth:`OEChem::OEMolBase::SetPerceived` method


   .. oe:method:: IsDataType

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

         .. oe:api::

            bool IsDataType(const void *) const

      .. oe:language:: python

         .. oe:api:: python

            IsDataType(arg2: void) -> bool

   .. oe:method:: IsDeleted

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

         .. oe:api::

            bool IsDeleted(OEBondBase *) const = 0
            bool IsDeleted(OEAtomBase *) const = 0

      .. oe:language:: python

         .. oe:api:: python

            IsDeleted(arg2: OEBondBase) -> bool
            IsDeleted(arg2: OEAtomBase) -> bool

   .. oe:method:: IsRxn

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

         .. oe:api::

            bool IsRxn() const

      .. oe:language:: python

         .. oe:api:: python

            IsRxn() -> bool

      Determines whether the molecule represents a
      reaction/transform. A ``true`` returned value indicates that the
      molecule represents a reaction, while ``false`` indicates the
      molecule is a simple connection table. The default value is
      ``false``. The reaction property of a molecule may be set using
      the :oe:meth:`OEChem::OEMolBase::SetRxn` method.

   .. oe:method:: NewAtom

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

         .. oe:api::

            OEAtomBase* NewAtom(unsigned int)=0

      .. oe:language:: python

         .. oe:api:: python

            NewAtom(arg2: int) -> OEAtomBase

      Creates a new atom in the molecule by specifying the element
      number from the :oe:constns:`OEChem::OEElemNo` namespace.
      This method does not create any bonds, and the returned created
      atom is always disconnected.

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

         .. oe:api::

            OEAtomBase* NewAtom(const OEAtomBase &)=0

      .. oe:language:: python

         .. oe:api:: python

            NewAtom(arg2: OEAtomBase) -> OEAtomBase

      Creates a new atom in the molecule and copies the atomic
      properties of the specified atom (atomic number, formal charge,
      implicit hydrogen count, *etc...*)
      This method does not create any bonds, and the returned created
      atom is always disconnected.

   .. oe:method:: NewBond

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

         .. oe:api::

            OEBondBase* NewBond(OEAtomBase* src, OEAtomBase* dst,
                                unsigned int order = 0)=0

      .. oe:language:: python

         .. oe:api:: python

            NewBond(arg2: OEAtomBase, arg3: OEAtomBase, order: int = 0) -> OEBondBase

      Creates a new bond in the molecule. The 'src', 'dst' and 'order'
      arguments are used to specify the begin atom, the end atom and
      the bond order of the new bond.
      This method returns a pointer to the newly created
      :ref:`OEBondBase <OEChem_OEBondBase>` object.
      The atoms specified as 'src' and 'dst' atoms must belong to the
      current molecule.
      Additionally, a NULL pointer,
      (:oe:cls:`OEChem::OEAtomBase*<OEChem::OEAtomBase>`)0, may be
      passed as either the begin or end atom (but not both), allowing
      that atom to be specified later using
      :oe:meth:`OEChem::OEBondBase::SetBgn` or
      :oe:meth:`OEChem::OEBondBase::SetEnd` respectively.
      This helps when creating molecules for applications in which the
      ordering of atoms and/or bonds is significant.

      .. note::

         After creating new bonds, it may be necessary to call the
         :oe:func:`OEChem::OEFindRingAtomsAndBonds` and
         :oe:func:`OEChem::OEAssignAromaticFlags` functions to update the
         'in ring' and 'aromatic' properties of the atoms and bonds in
         the modified molecule.

   .. oe:method:: NewGroup

      .. oe:api::

         OEGroupBase *NewGroup(unsigned int type,
                               const std::vector<OEAtomBase *> &atoms)
         OEGroupBase *NewGroup(unsigned int type,
                               const std::vector<OEBondBase *> &bonds)
         OEGroupBase *NewGroup(unsigned int type,
                               const std::vector<OEAtomBase *> &atoms,
                               const std::vector<OEBondBase *> &bonds)
         OEGroupBase* NewGroup(unsigned int type, const OEAtomBondSet &abset)

      Creates a new group in the molecule with the given atoms or/and bonds.

      *type*
          The type associated with the created :ref:`OEGroupBase <OEChem_OEGroupBase>`
          object.

      *atoms*
          The pointer of the :ref:`OEAtomBase <OEChem_OEAtomBase>` objects that the group
          will hold.

      *bonds*
          The pointer of the :ref:`OEBondBase <OEChem_OEBondBase>` objects that the group
          will hold.

      *abset*
          The :ref:`OEAtomBondSet <OEChem_OEAtomBondSet>` container that holds atom and bond
          pointers.

      .. note::

         An empty group can not be created. If there is no valid atom or/and
         bond pointers given, then the :oe:meth:`OEChem::OEMolBase::NewGroup`
         will return a NULL pointer.

      .. seealso::

         * :oe:constns:`OEChem::OEGroupType` namespace

   .. oe:method:: NumAtoms

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

         .. oe:api::

            unsigned int NumAtoms() const = 0

      .. oe:language:: python

         .. oe:api:: python

            NumAtoms() -> int

      Returns the number of atoms in the molecule.

   .. oe:method:: NumBonds

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

         .. oe:api::

            unsigned int NumBonds() const = 0

      .. oe:language:: python

         .. oe:api:: python

            NumBonds() -> int

      Returns the number of bonds in the molecule.

   .. oe:method:: NumGroups

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

         .. oe:api::

            unsigned int NumGroups() const

      .. oe:language:: python

         .. oe:api:: python

            NumGroups() -> int

      Returns the number of groups in the molecule.

   .. oe:method:: OrderAtoms

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

         .. oe:api::

            bool OrderAtoms(const std::vector<OEAtomBase *> &)=0

      .. oe:language:: python

         .. oe:api:: python

            OrderAtoms(arg2: OEAtomVector) -> bool

      Reorders the atoms of the molecule.
      This method modifies the order in which the atoms are visited by
      the iterator returned by :oe:meth:`OEChem::OEMolBase::GetAtoms`.
      This method does not affect the atom indices of any of the atoms
      of the molecule.
      This method does not affect the ordering of any other iterator,
      including bonds over a molecule (:oe:meth:`OEChem::OEMolBase::GetBonds`) ,
      bonds over an atom (:oe:meth:`OEChem::OEAtomBase::GetBonds`) or
      neighboring atoms over an atom (:oe:meth:`OEChem::OEAtomBase::GetAtoms`).

   .. oe:method:: OrderBonds

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

         .. oe:api::

            bool OrderBonds(const std::vector<OEBondBase *> &)=0

      .. oe:language:: python

         .. oe:api:: python

            OrderBonds(arg2: OEBondVector) -> bool

      Reorders the bonds of a molecule.
      This method modifies the order in which the bonds are visited by
      the iterator returned by :oe:meth:`OEChem::OEMolBase::GetBonds`.
      This method does not affect the bond indices of any of the bonds
      of the molecule.
      This method does not affect the ordering of any other iterator,
      including atoms over a molecule (:oe:meth:`OEChem::OEMolBase::GetAtoms`),
      bonds over an atom (:oe:meth:`OEChem::OEAtomBase::GetBond`) or
      neighboring atoms over atom (:oe:meth:`OEChem::OEAtomBase::GetAtoms`).

   .. oe:method:: ResetPerceived

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

         .. oe:api::

            void ResetPerceived() = 0

      .. oe:language:: python

         .. oe:api:: python

            ResetPerceived() -> None

      Invalidates all previously perceived properties specified in the
      :oe:constns:`OEChem::OEPerceived` namespace.

      .. seealso::

         * :oe:meth:`OEChem::OEMolBase::HasPerceived` method
         * :oe:meth:`OEChem::OEMolBase::SetPerceived` method


   .. oe:method:: SetCoords

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

         .. oe:api::

            bool SetCoords(const OEPlatform::OEHalfFloat* coords)=0
            bool SetCoords(const float* coords)=0
            bool SetCoords(const double* coords)=0
            bool SetCoords(const long double* coords)=0

      .. oe:language:: python

         .. oe:api:: python

            SetCoords(arg2: OEAtomBase) -> bool
            SetCoords(crds: OEHalfFloat) -> bool
            SetCoords(arg2: OEFloatArray) -> bool
            SetCoords(arg2: OEDoubleArray) -> bool

      Sets the Cartesian coordinates for all of the atoms in a molecule.
      The array argument must point to an array of at least
      3* :oe:meth:`OEChem::OEMolBase::GetMaxAtomIdx()<OEChem::OEMolBase::GetMaxAtomIdx>`
      elements.
      The X, Y and Z coordinates for the atom with index 'i', should be
      placed at offsets ``3*i``, ``3*i+1`` and ``3*i+2`` respectively.

      .. seealso::

         * :oe:meth:`OEChem::OEMolBase::ClearCoords`

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

         .. oe:api::

            bool SetCoords(const OEAtomBase *, const OEPlatform::OEHalfFloat *)=0
            bool SetCoords(const OEAtomBase *, const float *)=0
            bool SetCoords(const OEAtomBase *, const double *)=0
            bool SetCoords(const OEAtomBase *, const long double *)=0

      .. oe:language:: python

         .. oe:api:: python

            SetCoords(atom: OEAtomBase, crds: OEHalfFloat) -> bool
            SetCoords(arg2: OEAtomBase, arg3: OEFloatArray) -> bool
            SetCoords(arg2: OEAtomBase, arg3: OEDoubleArray) -> bool

      Sets the Cartesian coordinates of the specified atom to the
      values specified by the floating point array.
      The array argument must point to array of at least three values,
      representing the X, Y and Z Cartesian coordinates of the atom,
      respectively.

   .. oe:method:: SetDimension

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

         .. oe:api::

            bool SetDimension(unsigned int)=0

      .. oe:language:: python

         .. oe:api:: python

            SetDimension(arg2: int) -> bool

      Sets the 'dimensionality' property of a molecule.
      The default value is zero.
      The 'dimensionality' property of a molecule may be retrieved using
      the :oe:meth:`OEChem::OEMolBase::GetDimension` method.
      This property is typically set by the appropriate molecular file
      format reader, or by calling the
      :oe:func:`OEChem::OESetDimensionFromCoords` function.

      The 'dimensionality' property represents the dimensionality of
      the coordinates.
      This has the default value zero, for unknown or no coordinates,
      2 for 2-dimensional coordinates (such as depictions) and 3 for
      3-dimensional coordinates.
      This property is typically set by the file format reader
      indicating the dimensionality of the input file (``0`` for
      SMILES, ``3`` for MOL2 and ``2`` or ``3`` for MDL SD files
      *etc...*)

   .. oe:method:: SetEnergy

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

         .. oe:api::

            bool SetEnergy(float)=0
            bool SetEnergy(double)=0

      .. oe:language:: python

         .. oe:api:: python

            SetEnergy(arg2: float) -> bool

      Sets the 'energy' property of a molecule. The default value is ``0.0``.
      The energy of a molecule may be retrieved using the
      :oe:meth:`OEChem::OEMolBase::GetEnergy` method.

   .. oe:method:: SetPerceived

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

         .. oe:api::

            bool SetPerceived(unsigned int property, bool perceived) = 0

      .. oe:language:: python

         .. oe:api:: python

            SetPerceived(arg2: int, arg3: bool) -> bool

      Sets whether a property is considered to be perceived for the
      given molecule.

      *property*
         This value has to be from the :oe:constns:`OEChem::OEPerceived`
         namespace.

      *perceived*
         A boolean value that determines whether the given property is
         perceived.

      .. warning::

         The perception flags are used for performance in order to avoid
         perceiving properties that have already been calculated.
         It should be set to be 'true' only by the function that
         calculates the given property.

      .. seealso::

         * :oe:meth:`OEChem::OEMolBase::HasPerceived` method
         * :oe:meth:`OEChem::OEMolBase::ResetPerceived` method


   .. oe:method:: SetRxn

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

         .. oe:api::

            bool SetRxn(bool)

      .. oe:language:: python

         .. oe:api:: python

            SetRxn(arg2: bool) -> bool

      Sets the 'reaction' property of a molecule.
      The 'reaction' property of a molecule may be retrieved using the
      :oe:meth:`OEChem::OEMolBase::IsRxn` method.

   .. oe:method:: SetTitle

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

         .. oe:api::

            bool SetTitle(const char *)=0
            bool SetTitle(const std::string &)=0

      .. oe:language:: python

         .. oe:api:: python

            SetTitle(arg2: str) -> bool

      Sets the 'title' property of a molecule.
      The default value is the empty string.
      The 'title' property of a molecule may be retrieved using the
      :oe:meth:`OEChem::OEMolBase::GetTitle` method.

   .. seealso::

      .. oe:language:: c++

         * Example program :ref:`sdfrename.cpp<section_example_oechem_sdfrename>`

      .. oe:language:: python

         * Example program :ref:`sdfrename.py<section_example_oechem_sdfrename>`

      .. oe:language:: java

         * Example program :ref:`SDFRename.java<section_example_oechem_sdfrename>`

      .. oe:language:: csharp

         * Example program :ref:`SDFRename.cs<section_example_oechem_sdfrename>`

   .. oe:method:: Sweep

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

         .. oe:api::

            bool Sweep()=0

      .. oe:language:: python

         .. oe:api:: python

            Sweep() -> bool

      Renumbers the atom and bond indices sequentially.
      This method invalidates the atom and bond indices of all atoms
      in a molecule.

      .. note::

         This method doesn't guarantee that all atom and bond indices
         are sequential upon completion (some molecule implementations
         may treat :oe:meth:`OEChem::OEMolBase::Sweep` as a no-op).

   .. oe:method:: UnCompress

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

         .. oe:api::

            bool UnCompress()

      .. oe:language:: python

         .. oe:api:: python

            UnCompress() -> bool

   .. seealso::

      .. oe:language:: c++

         * Example program :ref:`randomsample.cpp<section_example_oechem_randomsample>`

      .. oe:language:: python

         * Example program :ref:`randomsample.py<section_example_oechem_randomsample>`

      .. oe:language:: java

         * Example program :ref:`RandomSample.java<section_example_oechem_randomsample>`

      .. oe:language:: csharp

         * Example program :ref:`RandomSample.cs<section_example_oechem_randomsample>`
