.. _molprop_examples_molpropsddata:

Attach Molecular Properties as SD Data
======================================

The molecular properties calculated by :ref:`OEFilter <OEMolProp_OEFilter>` can be
attached as SD data to the molecule.  The 
:oe:meth:`OEMolProp::OEFilter::SetSDTag` method is used to attach the
calculated molecular properties to molecules passed to the filter object.

SD tag data corresponds to the
:ref:`tabular data <molprop_examples_molproptable>` functionality.
The SD data tag names are exactly the same as the names found in the table
header. The SD data values are exactly what is output in the data
table. The only exceptions are the "SMILES", "Name", and "Filter"
columns since this information can be obtained other ways. 

This example demonstrates how to set the table output to the ``oenul``
output stream to allow all properties to be attached as SD data, and  write
the tabular data to an output in the :oe:const:`OEChem::OEFormat::SDF`,
:oe:const:`OEChem::OEFormat::OEB`, or the :oe:const:`OEChem::OEFormat::CSV`
format. To specifically write to the :oe:const:`OEChem::OEFormat::CSV` 
format, also see the :ref:`MolPropCSV<molprop_examples_molpropcsv>` example.


.. warning:: 
   
   By default, only the properties up to the failing property will be attached
   to each molecule.  Use :oe:meth:`OEMolProp::OEFilter::SetTable` to force
   every property to be attached as SD data. The same rule applies to
   SD data as :ref:`tabular output data <molprop_examples_molproptable>`,
   only the properties specified in the :ref:`filter file<filter_files>` will
   be attached as SD data. 

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

.. oe:language:: python

   .. code-block:: console

      prompt> python molpropsddata.py --help

.. oe:language:: java

   .. code-block:: console

      prompt> java MolPropSDData --help

.. oe:language:: csharp

   .. code-block:: console

      prompt> MolPropSDData --help


will generate the following output:

.. code-block:: console

   Simple parameter list
    filter options :
      -filtertype : filter type

    input/output options :
      -in : Input filename
      -out : Output filename

    other options :
      -verbose : Error level of messages


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


.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

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


      .. admonition:: Download code

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

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

   .. only:: oepdf

      .. oe:source:: molpropsddata.py
         :language: python

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

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

.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: MolPropSDData.java
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: MolPropSDData.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> molpropsddata -in drugs.sdf -out out_mpsd.sdf -filtertype Lead

.. oe:language:: python

   .. code-block:: console

      prompt> python molpropsddata.py -in drugs.sdf -out out_mpsd.sdf -filtertype Lead

.. oe:language:: java

   .. code-block:: console

      prompt> java MolPropSDData -in drugs.sdf -out out_mpsd.sdf -filtertype Lead

.. oe:language:: csharp

   .. code-block:: console

      prompt> MolPropSDData -in drugs.sdf -out out_mpsd.sdf -filtertype Lead
