.. _molprop_examples_molproptable:

Molecular Property Table
========================

The :ref:`OEFilter <OEMolProp_OEFilter>` object allows for the calculation of
all the molecular properties it uses during the filtering process
without actually applying the filter. This may be useful for
caching the :ref:`OEFilter <OEMolProp_OEFilter>` object results into a
database. The :oe:meth:`OEMolProp::OEFilter::SetTable` method can be
used to specify where to write a tab-delimited table of every property
in the associated :ref:`filter file <filter_files>`.  This example
demonstrates how to write the tabular output to standard out.

.. note:: 

   A tab-delimited file format was chosen to integrate better with
   Unix commandline utilities. For example, this allows for quick and
   easy filter experimentation with the `awk
   <http://en.wikipedia.org/wiki/AWK>`_ command line utility. The
   following snippet will print the number of molecules (plus one for
   the header) with a molecular weight greater than 200.
   
   .. oe:language:: c++

      .. code-block:: console

         > molproptable -in drugs.sdf -filtertype Lead > drugs.txt
         > cat drugs.txt | awk -F\t '{if ($12 > 200) { print $12 }}' | wc -l

   .. oe:language:: python

      .. code-block:: console

         > python molproptable.py -in drugs.sdf -filtertype Lead > drugs.txt
         > cat drugs.txt | awk -F\t '{if ($12 > 200) { print $12 }}' | wc -l

   .. oe:language:: java

      .. code-block:: console

         > java MolPropTable -in drugs.sdf -filtertype Lead > drugs.txt
         > cat drugs.txt | awk -F\t '{if ($12 > 200) { print $12 }}' | wc -l

   .. oe:language:: csharp

      .. code-block:: console

         > MolPropTable -in drugs.sdf -filtertype Lead > drugs.txt
         > cat drugs.txt | awk -F\t '{if ($12 > 200) { print $12 }}' | wc -l

   Furthermore, all database programs have utilities for importing
   tab-delimited files. Loading the filter results into a third-party
   database would provide very speedy filter experimentation since the
   properties would only have to be calculated once and then cached in
   the database.

..   [[ We would be the coolest company ever if we provided the SQL
..   schema to associate with the tabular output. ]]


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> molproptable --help

.. oe:language:: python

   .. code-block:: console

      prompt> python molproptable.py --help

.. oe:language:: java

   .. code-block:: console

      prompt> java MolPropTable --help

.. oe:language:: csharp

   .. code-block:: console

      prompt> MolPropTable --help


will generate the following output:

.. code-block:: console

   Simple parameter list
    filter options :
      -filtertype : filter type

    input/output options :
      -in : Input filename

    other options :
      -verbose : Error level of messages


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

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

         :download:`molproptable.py <../../../../wrappers/python/examples/molprop/molproptable.py>`

      ..    literalinclude:: ../../../../wrappers/python/examples/molprop/molproptable.py

   .. only:: oepdf

      .. oe:source:: molproptable.py
         :language: python


.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

         :download:`molproptable.cpp <../../../../sublibs/tklibs/molprop/examples/molproptable.cpp>`

   .. only:: oepdf

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

.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

         :download:`MolPropTable.java <../../../../wrappers/java/examples/openeye/examples/oemolprop/MolPropTable.java>`

   .. only:: oepdf

      .. oe:source:: MolPropTable.java
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

         :download:`MolPropTable.cs <../../../../wrappers/csharp/Csharp-Examples/OEMolProp/MolPropTable.cs>`

   .. only:: oepdf

      .. oe:source:: MolPropTable.cs
         :language: csharp

.. seealso::

   * :oe:func:`OEMolProp::OEFilter` class
   * :oe:func:`OEMolProp::OEConfigureFilterParams` and :oe:func:`OEMolProp::OEConfigureFilterType` functions
   * :oe:func:`OEMolProp::OEGetFilterType` function

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

.. oe:language:: c++

   .. code-block:: console

      prompt> molpropsdtable -in drugs.sdf -filtertype Lead

.. oe:language:: python

   .. code-block:: console

      prompt> python molpropsdtable.py -in drugs.sdf -filtertype Lead

.. oe:language:: java

   .. code-block:: console

      prompt> java MolPropTable -in drugs.sdf -filtertype Lead

.. oe:language:: csharp

   .. code-block:: console

      prompt> MolPropTable -in drugs.sdf -filtertype Lead
