.. oe:namespace:: OEBio

.. meta::
   :keywords: OEHierView, HierView


.. _OEBio_OEHierView:

.. oe:class:: OEHierView

   .. oe:api::


      class OEHierView

   The :ref:`OEHierView <OEBio_OEHierView>` class provides a convenient method for
   examining biological molecules as if they were hierarchical data.
   Hierarchical views can be fraught with inefficiencies. Despite this, they
   are such a common means of thinking about macromolecules that **OEChem**
   provides access to molecules in this manner.
   The :ref:`OEHierView <OEBio_OEHierView>` class takes a snapshot of an
   :ref:`OEMolBase <OEChem_OEMolBase>` and provides convenient access to a hierarchical
   view of the data.

   .. note::

      Unlike typical *OEChem* iterators that
      closely track changes to a molecule, the hierarchy view is based on
      a snapshot of the molecule. One should use the assignment operator
      to update the hierarchical view after any change to the molecule.

   .. oe:method:: Constructors

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

         .. oe:api::

            OEHierView()
            OEHierView(OEHierViewImpl* i)
            OEHierView(const OEHierView &)

      .. oe:language:: python

         .. oe:api:: python

            OEHierView(i: OEHierViewImpl) -> OEHierView
            OEHierView() -> OEHierView
            OEHierView(arg2: OEHierView) -> OEHierView

      Default and copy constructors.

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

         .. oe:api::

            OEHierView(OEChem::OEMolBase &,
                       unsigned assume = OEAssumption::Default)

      .. oe:language:: python

         .. oe:api:: python

            OEHierView(arg2: Union[OEGraphMol,OEMol,OEQMol], assume: int) -> OEHierView


      This constructor takes  an :ref:`OEMolBase <OEChem_OEMolBase>` as an argument
      and takes a snapshot of the molecule and sets up a hierarchical data
      view of the molecule. This allows hierarchical access to the
      molecule via the :ref:`OEIter <OESystem_OEIter>` class.

   .. note::

      Unlike typical *OEChem* iterators that track changes to a molecule,
      the hierarchy view is based on a snapshot of the molecule. One should
      use the assignment operator to update the hierarchical view after any
      change to the molecule.

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

      .. oe:api::

         OEHierView &operator=(const OEHierView &)
         OEHierView &operator=(OEChem::OEMolBase &)

      Assignment operator.


   .. oe:method:: GetAtom

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

         .. oe:api::

            const OEChem::OEAtomBase * GetAtom(char chainID,
                                               const char* resName, int resIdx,
                                               unsigned pdbAtomIdx)
            const OEChem::OEAtomBase* GetAtom(char chainID,
                                              const char* resName, int resIdx,
                                              unsigned pdbAtomIdx) const

      .. oe:language:: python

         .. oe:api:: python

            GetAtom(chainID: str, resName: str, resIdx: int, pdbAtomIdx: int) -> OEAtomBase

      Returns an atom specified by the chainID, residue name, residue
      number, and the PDB atom index.

      .. seealso::

         :ref:`OEGetPDBAtomIndex <OEChem_OEGetPDBAtomIndex>` function


   .. oe:method:: GetAtoms

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

         .. oe:api::

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

      .. oe:language:: python

         .. oe:api:: python

            GetAtoms() -> OEAtomIter
            GetAtoms() -> Iterable[OEAtomBase]

      Returns an iterator over all of the atoms in the hierarchical
      view.

   .. oe:method:: GetChains

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

         .. oe:api::

            OESystem::OEIterBase<OEHierChain>* GetChains()
            OESystem::OEIterBase<const OEHierChain>* GetChains() const

      .. oe:language:: python

         .. oe:api:: python

            GetChains() -> OEHierChainIter
            GetChains() -> Iterable[OEHierChain]

   .. oe:method:: GetFragments

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

         .. oe:api::

            OESystem::OEIterBase<OEHierFragment>* GetFragments()
            OESystem::OEIterBase<const OEHierFragment>* GetFragments() const

      .. oe:language:: python

         .. oe:api:: python

            GetFragments() -> OEHierFragmentIter
            GetFragments() -> Iterable[OEHierFragment]

      Returns an iterator over all of the fragments in the hierarchical
      view.

   .. oe:method:: GetResidue

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

         .. oe:api::

            OEHierResidue& GetResidue(char chainID, const char* resName,
                                      int resIdx)
            const OEHierResidue& GetResidue(char chainID, const char* resName,
                                            int resIdx) const

      .. oe:language:: python

         .. oe:api:: python

            GetResidue(chainID: str, resName: str, resIdx: int) -> OEHierResidue

      Gives direct access to a residue using the typical information that
      a user might know about a residue of interest (*e.g.* - ``THR242`` of
      chain ``'A'``).

   .. oe:method:: GetResidues

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

         .. oe:api::

            OESystem::OEIterBase<OEHierResidue>* GetResidues()
            OESystem::OEIterBase<const OEHierResidue>* GetResidues() const

      .. oe:language:: python

         .. oe:api:: python

            GetResidues() -> OEHierResidueIter
            GetResidues() -> Iterable[OEHierResidue]

      Returns an iterator over all of the residues in the hierarchical
      view.
