.. _section_example_oechem_sdfilter:

Filter molecules by SD data
================================================================================

A program that can filter a database of molecules based on SD
tags. Any SD tag that contains numerical data can be used. Flags are:
``-tag``, the SD tag to use, ``-min``, the minimum value of the tag,
``-max``, the maximum value of the tag. The program formats are
limited to those that can have SD data ``i.e.`` SDF, OEB, and CSV.

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

.. oe:language:: c++

   .. code-block:: console

      prompt > sdfilter -tag LOGD -min -2 -max 5 -i input.sdf -o output.oeb.gz

.. oe:language:: python

   .. code-block:: console

      prompt > sdfilter.py -tag LOGD -min -2 -max 5 -i input.sdf -o output.oeb.gz

.. oe:language:: java

   .. code-block:: console

      prompt > SDFilter -tag LOGD -min -2 -max 5 -i input.sdf -o output.oeb.gz

.. oe:language:: csharp

   .. code-block:: console

      prompt > SDFilter -tag LOGD -min -2 -max 5 -i input.sdf -o output.oeb.gz

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

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

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

.. oe:language:: python

   .. only:: oehtml


      .. admonition:: Download code

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

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


   .. only:: oepdf

      .. oe:source:: sdfilter.py
         :language: python

.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: SDFilter.java
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: SDFilter.cs
         :language: csharp

.. seealso::

   * :oe:func:`OEChem::OEHasSDData` function
   * :oe:func:`OEChem::OEGetSDData` function
   * :oe:func:`OESystem::OEStringToNumber` function

