.. _section_examples_summary_mols2img:

Depicting Molecules In a Grid
================================================================================

A program that converts molecular structures into an image with a grid layout.
By default the input molecules are depicted in a 3x2 grid.


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:: console

      prompt> mols2img --help

.. oe:language:: python

   .. code-block:: console

      prompt> python mols2img.py --help

.. oe:language:: java

   .. code-block:: console

      prompt> java Mols2Img --help

.. oe:language:: csharp

   .. code-block:: console

      prompt> Mols2Img --help


will generate the following output:

.. code-block:: console

   Simple parameter list
    -height : Height of output image
    -width : Width of output image

    image grid options :
      -cols : Number of columns
      -rows : Number of rows

    input/output options :
      -in : Input filename(s)
      -out : Output filename

    molecule display options :
      -aromstyle : Aromatic ring display style
      -atomcolor : Atom coloring style
      -atomlabelfontscale : Atom label font scale
      -atomprop : Atom property display
      -atomstereostyle : Atom stereo display style
      -bondcolor : Bond coloring style
      -bondprop : Bond property display
      -bondstereostyle : Bond stereo display style
      -hydrstyle : Hydrogen display style
      -linewidth : Default bond line width
      -protgroupdisp : Protective group display style
      -scale : Scaling of the depicted molecule
      -superdisp : Super atom display style
      -titleloc : Location of the molecule title

    prepare depiction options :
      -clearcoords : Clear and regenerate 2D coordinates of molecule(s)
      -orientation : Set the preferred orientation of 2D coordinates
      -suppressH : Suppress explicit hydrogens of molecule(s)


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

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

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

      with interface file

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

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

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

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


   .. only:: oepdf

      .. oe:source:: mols2img.py
         :language: python


.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: Mols2Img.java
         :language: java

      with interface file

      .. oe:source:: Mols2Img.txt
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: Mols2Img.cs
         :language: csharp


.. seealso::

   * :ref:`chapter_image_layout` chapter

   * :oe:func:`OEDepict::OEConfigureImageWidth` function
   * :oe:func:`OEDepict::OEConfigureImageHeight` function
   * :oe:func:`OEDepict::OEConfigureImageGridParams` function
   * :oe:func:`OEDepict::OEConfigurePrepareDepictionOptions` function
   * :oe:func:`OEDepict::OEConfigure2DMolDisplayOptions` function
   * :oe:func:`OEDepict::OEGetImageWidth` and :oe:func:`OEDepict::OEGetImageHeight` functions
   * :oe:func:`OEDepict::OEGetImageGridNumRows` and :oe:func:`OEDepict::OEGetImageGridNumColumns` functions
   * :ref:`OEImageGrid <OEDepict_OEImageGrid>` class
   * :ref:`OEPrepareDepictionOptions <OEDepict_OEPrepareDepictionOptions>` class
   * :oe:func:`OEDepict::OESetupPrepareDepictionOptions` function
   * :ref:`OE2DMolDisplayOptions <OEDepict_OE2DMolDisplayOptions>` class
   * :oe:func:`OEDepict::OESetup2DMolDisplayOptions` function
   * :oe:func:`OEDepict::OEPrepareDepiction` function
   * :oe:func:`OEDepict::OERenderMolecule` function
   * :oe:func:`OEDepict::OEWriteImage` function


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

.. oe:language:: c++

   .. code-block:: console

      prompt> mols2img -in amino.ism -out image.png

.. oe:language:: python

   .. code-block:: console

      prompt> python mols2img.py -in amino.ism -out image.png

.. oe:language:: java

   .. code-block:: console

      prompt> java Mols2Img -in amino.ism -out image.png

.. oe:language:: csharp

   .. code-block:: console

      prompt> Mols2Img -in amino.ism -out image.png

will generate the image shown in
:ref:`Figure: Example of using the program with default parameters <figure_mols2img_01>`.

.. _figure_mols2img_01:

.. figure:: images/mols2img-01.*
   :align:  center

   **Example of using the program with default parameters**

.. note::

   By default the program depicts molecules in a 3x2 grid

.. -----------------------------------------------------------------------------

.. oe:language:: c++

   .. code-block:: console

      prompt> mols2img -in amino.ism -out image.png -rows 2 -cols 3

.. oe:language:: python

   .. code-block:: console

      prompt> python mols2img.py -in amino.ism -out image.png -rows 2 -cols 3

.. oe:language:: java

   .. code-block:: console

      prompt> java Mols2Img -in amino.ism -out image.png -rows 2 -cols 3

.. oe:language:: csharp

   .. code-block:: console

      prompt> Mols2Img -in amino.ism -out image.png -rows 2 -cols 3

will generate the image shown in
:ref:`Figure: Example of using the program with user-defined number of rows and columns<figure_mols2img_02>`.

.. _figure_mols2img_02:

.. figure:: images/mols2img-02.*
   :align:  center

   **Example of using the program with user-defined number of rows and columns**


.. -----------------------------------------------------------------------------

.. oe:language:: c++

   .. code-block:: console

      prompt> mols2img -in amino.ism -out image.png  -rows 2 -cols 2 -titleloc Bottom

.. oe:language:: python

   .. code-block:: console

      prompt> python mols2img.py -in amino.ism -out image.png  -rows 2 -cols 2 -titleloc Bottom

.. oe:language:: java

   .. code-block:: console

      prompt> java Mols2Img -in amino.ism -out image.png  -rows 2 -cols 2 -titleloc Bottom

.. oe:language:: csharp

   .. code-block:: console

      prompt> Mols2Img -in amino.ism -out image.png  -rows 2 -cols 2 -titleloc Bottom

will generate the image shown in
:ref:`Figure: Example of using the program with molecule titles displayed at the bottom<figure_mols2img_03>`.

.. _figure_mols2img_03:

.. figure:: images/mols2img-03.*
   :align:  center

   **Example of using the program with molecule titles displayed at the bottom**

.. seealso::

   * :ref:`section_image_layout_grid` section
