.. _section_examples_summary_smartsalign2D:

Aligning Molecules Based on Substructure Search
================================================================================

A program that aligns the molecules based on a substructure search
initialized with the given SMARTS pattern.


Command Line Interface
--------------------------------------------------------------------------------

A description of the command line interface can be obtained by
executing the program with the --help argument.

.. oe:language:: c++

   .. code-block:: bash

      prompt> smartsalign2D --help

.. oe:language:: python

   .. code-block:: bash

      prompt> python smartsalign2D.py --help

.. oe:language:: java

   .. code-block:: bash

      prompt> java SMARTSAlign2D --help

.. oe:language:: csharp

   .. code-block:: bash

      prompt> SMARTSAlign2D --help


Will generate the following output:

.. code-block:: console

   Simple parameter list
   input/output options :
      -in : Filename of input molecules
      -out : Output filename
      -smarts : SMARTS for alignment match


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

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

         :download:`smartsalign2D.cpp <../../../../sublibs/tklibs/depict/examples/smartsalign2D.cpp>`
         and
         :download:`smartsalign2D.txt <../../../../sublibs/tklibs/depict/examples/smartsalign2D.txt>`
         interface file

   .. only:: oepdf

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

      with interface file

      .. oe:source:: smartsalign2D.txt
         :language: c++

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

         :download:`smartsalign2D.py <../../../../wrappers/python/examples/depict/smartsalign2D.py>`

      .. literalinclude:: ../../../../wrappers/python/examples/depict/smartsalign2D.py


   .. only:: oepdf

      .. oe:source:: smartsalign2D.py
         :language: python


.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

         :download:`SMARTSAlign2D.java <../../../../wrappers/java/examples/openeye/examples/oedepict/SMARTSAlign2D.java>`
         and
         :download:`SMARTSAlign2D.txt <../../../../wrappers/java/examples/openeye/examples/oedepict/SMARTSAlign2D.txt>`
         interface file

   .. only:: oepdf

      .. oe:source:: SMARTSAlign2D.java
         :language: java

      with interface file

      .. oe:source:: SMARTSAlign2D.txt
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

         :download:`SMARTSAlign2D.cs <../../../../wrappers/csharp/Csharp-Examples/OEDepict/SMARTSAlign2D.cs>`

   .. only:: oepdf

      .. oe:source:: SMARTSAlign2D.cs
         :language: csharp


.. seealso::

   * :ref:`chapter_molalign` chapter

   * :ref:`OESubSearch <OEChem_OESubSearch>` class
   * :oe:func:`OEChem::OEGenerate2DCoordinates` function
   * :oe:func:`OEChem::OEIs2DFormat` function
   * :oe:func:`OEChem::OEPrepareSearch` function
   * :oe:func:`OEDepict::OEPrepareAlignedDepiction` function
   * :oe:func:`OEDepict::OEPrepareDepiction` function


Examples
--------------------------------------------------------------------------------

.. oe:language:: c++

   .. code-block:: console

       prompt> smartsalign2D -in test.sdf -out aligned.sdf -smarts "c1cc[c,n]c2c1ncc2"

.. oe:language:: python

   .. code-block:: console

      prompt> python smartsalign2D.py -in test.sdf -out aligned.sdf -smarts "c1cc[c,n]c2c1ncc2" -out out.mol

.. oe:language:: java

   .. code-block:: console

       prompt> java SMARTSAlign2D -in test.sdf -out aligned.sdf -smarts "c1cc[c,n]c2c1ncc2" -out out.mol

.. oe:language:: csharp

   .. code-block:: console

       prompt> SMARTSAlign2D -in test.sdf -out aligned.sdf -smarts "c1cc[c,n]c2c1ncc2" -out out.mol

Taking the output coordinates and generating the images with the
:ref:`mol2img<section_examples_summary_mol2img>` program will produce the images shown in
:ref:`Table: Example of using the program to align molecule<table_smartsalign2D>`

.. _table_smartsalign2D:

.. list-table:: **Example of using the program to align molecules**
   :widths: 100 100 100

   * - .. image:: images/smartsalign2D-out-1.*
         :align:  center
     - .. image:: images/smartsalign2D-out-2.*
         :align:  center
     - .. image:: images/smartsalign2D-out-3.*
         :align:  center

.. seealso::

   * :ref:`chapter_molalign` chapter
