.. _section_example_oechem_sizefilter:

Filter molecules by weight or heavy atom count
================================================================================

A program that filters molecules by their weight and/or heavy atom
count. The program has four flags: ``-minhac``, the minimum heavy atom
count, ``-maxhac``, the maximum heavy atom count, ``-minwt``, the
minimum molecular weight and ``-maxwt`` the maximum molecular
weight. Any combination of the flags can be set. The program will
output the molecules to stdout as SMILES if no output file is set.

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

.. oe:language:: c++

   .. code-block:: console

      prompt> sizefilter -minhac 10 dbase.oeb.gz
      prompt> sizefilter -minhac 10 -maxwt 300 -i dbase.oeb.gz -o output.oeb.gz

.. oe:language:: python

   .. code-block:: console

      prompt> sizefilter.py -minhac 10 dbase.oeb.gz
      prompt> sizefilter.py -minhac 10 -maxwt 300 -i dbase.oeb.gz -o output.oeb.gz

.. oe:language:: java

   .. code-block:: console

      prompt> SizeFilter -minhac 10 dbase.oeb.gz
      prompt> SizeFilter -minhac 10 -maxwt 300 -i dbase.oeb.gz -o output.oeb.gz

.. oe:language:: csharp

   .. code-block:: console

      prompt> SizeFilter -minhac 10 dbase.oeb.gz
      prompt> SizeFilter -minhac 10 -maxwt 300 -i dbase.oeb.gz -o output.oeb.gz


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

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

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

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

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

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


   .. only:: oepdf

      .. oe:source:: sizefilter.py
         :language: python

.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: SizeFilter.java
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: SizeFilter.cs
         :language: csharp

.. seealso::

   * :ref:`OEIsHeavy <OEChem_OEIsHeavy>` functor
   * :oe:func:`OEChem::OECalculateMolecularWeight` function
