.. _section_example_oechem_minpath:

Find minimum path in a molecule
================================================================================

A program that finds and outputs the minimum path in a molecule. The
input can be two specific named atoms or two SMARTS matches. As SMARTS
matches could hit more than one atom this could result in multiple
different paths. To use atom names a helper program, printatomnames,
is provided (see below).  If ``-o`` is set then the atoms in the path
will be output to a molecule file, otherwise just the length of the
path is reported. ``-verbose`` outputs more details on the
path.

Example
--------------------------------------------------------------------------------

.. oe:language:: c++

   .. code-block:: console

      prompt> minpath -i input.oeb.gz -atom1 'N1' -atom2 'S1'
      prompt> minpath -i input.oeb.gz -smarts1 'c1cccs1' -smarts2 'OC(=O)C' -o output.smi

.. oe:language:: python

   .. code-block:: console

      prompt> minpath.py -i input.oeb.gz -atom1 'N1' -atom2 'S1'
      prompt> minpath.py -i input.oeb.gz -smarts1 'c1cccs1' -smarts2 'OC(=O)C' -o output.smi

.. oe:language:: java

   .. code-block:: console

      prompt> MinPath -i input.oeb.gz -atom1 'N1' -atom2 'S1'
      prompt> MinPath -i input.oeb.gz -smarts1 'c1cccs1' -smarts2 'OC(=O)C' -o output.smi

.. oe:language:: csharp

   .. code-block:: console

      prompt> MinPath -i input.oeb.gz -atom1 'N1' -atom2 'S1'
      prompt> MinPath -i input.oeb.gz -smarts1 'c1cccs1' -smarts2 'OC(=O)C' -o output.smi


Code
--------------------------------------------------------------------------------

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

         :download:`minpath.cpp <../../../../../sublibs/tklibs/oechem/examples/minpath.cpp>`

   .. only:: oepdf

      .. oe:source:: minpath.cpp
         :language: c++

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

         :download:`minpath.py <../../../../../wrappers/python/examples/oechem/minpath.py>`

      .. literalinclude:: ../../../../../wrappers/python/examples/oechem/minpath.py


   .. only:: oepdf

      .. oe:source:: minpath.py
         :language: python


.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

         :download:`MinPath.java <../../../../../wrappers/java/examples/openeye/examples/oechem/MinPath.java>`

   .. only:: oepdf

      .. oe:source:: MinPath.java
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

         :download:`MinPath.cs <../../../../../wrappers/csharp/Csharp-Examples/OEChem/MinPath.cs>`

   .. only:: oepdf

      .. oe:source:: MinPath.cs
         :language: csharp


.. seealso::

   * :ref:`OEIsMemberPtr <OEChem_OEIsMemberPtr>` specialized functor `OEIsAtomMember`
   * :oe:func:`OEChem::OEGetPathLength` function
   * :oe:func:`OEChem::OEShortestPath` function
   * :oe:func:`OEChem::OEPrepareSearch` function
