.. oe:namespace:: OEMolProp



.. meta::
   :keywords: OEFilter, Filter


.. _OEMolProp_OEFilter:

.. oe:class:: OEFilter

   .. oe:api::

      class OEFilter

   This class represents a set of filters as initialized from a
   :ref:`filter file <filter_files>`. The primary use of this class
   is :oe:meth:`OEMolProp::OEFilter::operator()` method which will
   return whether the molecule passes or fails the filter.

   .. _OEMolProp_OEFilter_Constructors:

   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEFilter(unsigned int type = OEFilterType::Default)

      .. oe:language:: python

         .. oe:api:: python

            OEFilter(type: int) -> OEFilter

      The :ref:`OEFilter <OEMolProp_OEFilter>` object is usually constructed
      from an ``unsigned integer`` from the
      :oe:constns:`OEMolProp::OEFilterType` constant namespace. The
      default constructor will initialize the object to the
      :oe:const:`OEMolProp::OEFilterType::Default` filter. The default
      filter is an alias for
      the :oe:const:`OEMolProp::OEFilterType::BlockBuster` filter.

      .. seealso::

         The :ref:`filter_theory_variations_of_filters` section.

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEFilter(OEPlatform::oeistream& filterstr)

      .. oe:language:: python

         .. oe:api:: python

            OEFilter(filterstr: oeistream) -> OEFilter

      Fine grained filter control is provided by allowing a custom
      filter file to be passed to the :ref:`OEFilter <OEMolProp_OEFilter>`
      object as the ``filterstr`` argument.

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEFilter(const OEFilter& filter)

      .. oe:language:: python

         .. oe:api:: python

            OEFilter(filter: OEFilter) -> OEFilter

      The :ref:`OEFilter <OEMolProp_OEFilter>` object can be copy constructed
      from another :ref:`OEFilter <OEMolProp_OEFilter>` object.

   .. _OEMolProp_OEFilter_operator_assign:

   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OEFilter &operator=(const OEFilter &filter)

      Assignment operator to allow copying a
      :ref:`OEFilter <OEMolProp_OEFilter>` object.

      Assignment operator.


   .. _OEMolProp_OEFilter_operator_call:

   .. oe:method:: operator()

      .. oe:language:: c++

         .. oe:api:: c++

            bool operator()(OEChem::OEMolBase& mol)
            bool operator()(OEChem::OEMCMolBase& mol)

      .. oe:language:: python

         .. oe:api:: python

            __call__(arg2: Union[OEGraphMol,OEQMol]) -> bool
            __call__(arg2: OEMol) -> bool

      .. oe:language:: java

         .. oe:api:: java

            boolean call(OEMolBase mol)

      Returns whether the molecule ``mol`` passes the
      :ref:`OEFilter <OEMolProp_OEFilter>` object's set of filter
      rules. This function has been optimized by applying the filter
      rules in order of how expensive they are to calculate. For
      example, molecular weight is much easier to calculate than any
      of the functional group rules.

      However, if an output stream has been specified using the
      :oe:meth:`OEMolProp::OEFilter::SetTable` method all the filter
      rules will be checked. This is the only way to ensure that all
      the fields are filled in the tabular data output to the stream
      specified in :oe:meth:`SetTable<OEMolProp::OEFilter::SetTable>`
      method.

      .. note::

         The molecule may be altered by the steps described in the
         :ref:`filter_process` chapter.

      .. seealso::

         This method will write logging data to
         :oe:constns:`OESystem::OEThrow` as described in this
         :ref:`example <molprop_examples_molfilter>`.

   .. _OEMolProp_OEFilter_operator_bool:

   .. oe:method:: operator bool

      .. oe:language:: c++

         .. oe:api:: c++

            operator bool() const

      .. oe:language:: python

         .. oe:api:: python

            IsValid() -> bool

      .. oe:language:: java

         .. oe:api:: java

            boolean IsValid()

      Returns whether the :ref:`OEFilter <OEMolProp_OEFilter>` object is in a
      valid state ready to accept molecules to its
      :oe:meth:`OEMolProp::OEFilter::operator()` method.

      .. note::

         It is nearly impossible for an end user to create an invalid
         filter. This method is here for future API design to allow
         for greater programmatic control of the
         :ref:`OEFilter <OEMolProp_OEFilter>` object.

   .. _OEMolProp_OEFilter_AddNormalizationRule:

   .. oe:method:: AddNormalizationRule

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool AddNormalizationRule(const OEChem::OEUniMolecularRxn& rxn)

      .. oe:language:: python

         .. oe:api:: python

            AddNormalizationRule(rxn: OEUniMolecularRxn) -> bool

      Add a :ref:`OEUniMolecularRxn <OEChem_OEUniMolecularRxn>` to apply to the
      molecule. Special note should be taken about what preprocessing
      has already occurred on the molecule before generic
      normalizations are applied as described by the
      :ref:`filter_process` chapter.

      .. seealso::

         The *OEChem* manual has a chapter devoted to reactions.

   .. _OEMolProp_OEFilter_ClearNormalizationRules:

   .. oe:method:: ClearNormalizationRules

      .. oe:language:: c++ java csharp

         .. oe:api::

            void ClearNormalizationRules()

      .. oe:language:: python

         .. oe:api:: python

            ClearNormalizationRules() -> None

      Remove all normalizations previously added with
      :oe:meth:`OEMolProp::OEFilter::AddNormalizationRule`.

   .. _OEMolProp_OEFilter_GetCanonOrder:

   .. oe:method:: GetCanonOrder

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool GetCanonOrder() const

      .. oe:language:: python

         .. oe:api:: python

            GetCanonOrder() -> bool

      Returns whether to canonicalize the atom and bond order after
      salt removal but before the molecule is altered into a neutral pH model.

      .. seealso::

         :oe:meth:`OEMolProp::OEFilter::SetCanonOrder`

   .. _OEMolProp_OEFilter_GetFilterType:

   .. oe:method:: GetFilterType

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int GetFilterType() const

      .. oe:language:: python

         .. oe:api:: python

            GetFilterType() -> int

      Return the ``unsigned integer`` constant from the
      :oe:constns:`OEMolProp::OEFilterType` namespace corresponding to
      the type of filter used to construct this object.

   .. _OEMolProp_OEFilter_GetFlagTableFailures:

   .. oe:method:: GetFlagTableFailures

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool GetFlagTableFailures() const

      .. oe:language:: python

         .. oe:api:: python

            GetFlagTableFailures() -> bool

      Return whether values in tabular data output are flagged with an
      asterisk marking them as outside the valid range for that filter
      rule. This is useful for figuring out why particular molecules
      have failed a given filter.

      .. seealso::

         * :ref:`molprop_examples_molproptable`
         * :oe:meth:`OEMolProp::OEFilter::SetFlagTableFailures`

   .. _OEMolProp_OEFilter_GetMessage:

   .. _OEMolProp_GetMessage:

   .. oe:method:: GetMessage

      .. oe:language:: c++ java csharp

         .. oe:api::

            std::string GetMessage(OEChem::OEMolBase &)
            std::string GetMessage(OEChem::OEMCMolBase &)

      .. oe:language:: python

         .. oe:api:: python

            GetMessage(arg2: Union[OEGraphMol,OEQMol]) -> str
            GetMessage(arg2: OEMol) -> str

      Return a message that is "Pass" if the molecule passes the filter, and
      a reason for failure if it does not.

   .. _OEMolProp_OEFilter_GetMMFFTypeCheck:

   .. oe:method:: GetMMFFTypeCheck

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool GetMMFFTypeCheck() const

      .. oe:language:: python

         .. oe:api:: python

            GetMMFFTypeCheck() -> bool

      Return whether molecules sent to
      :oe:meth:`OEMolProp::OEFilter::operator()` will be
      :ref:`MMFF atom type checked <filter_process_mmff_checking>` before any
      other filtering criteria are applied. The default is ``false``.

      .. seealso::

         * :ref:`filter_process_mmff_checking`
         * :oe:meth:`OEMolProp::OEFilter::SetMMFFTypeCheck`

   .. _OEMolProp_OEFilter_GetSDTag:

   .. oe:method:: GetSDTag

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool GetSDTag() const

      .. oe:language:: python

         .. oe:api:: python

            GetSDTag() -> bool

      Return whether to attach every molecular property checked by the
      filter as SD data to the molecule passed to the
      :oe:meth:`OEMolProp::OEFilter::operator()` method. By default the
      the :ref:`OEFilter <OEMolProp_OEFilter>` object will not attach SD data.

      .. seealso::

         :oe:meth:`OEMolProp::OEFilter::SetSDTag`

   .. _OEMolProp_OEFilter_GetTable:

   .. oe:method:: GetTable

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEPlatform::oeostream* GetTable() const

      .. oe:language:: python

         .. oe:api:: python

            GetTable() -> oeostream

      Return the :ref:`oeostream <OEPlatform_oeostream>` object that tabular
      data is sent to. Will return a zero-pointer, the default, if no
      output stream has been specified.

      .. seealso::

         * :ref:`molprop_examples_molproptable`
         * :oe:meth:`OEMolProp::OEFilter::SetTable`

   .. _OEMolProp_OEFilter_GetTypeCheck:

   .. oe:method:: GetTypeCheck

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool GetTypeCheck() const

      .. oe:language:: python

         .. oe:api:: python

            GetTypeCheck() -> bool

      Return whether molecules sent to
      :oe:meth:`OEMolProp::OEFilter::operator()` will be
      :ref:`type checked <filter_process_type_checking>` before any
      other filtering criteria are applied. The default is ``false``.

      .. seealso::

         * :ref:`filter_process_type_checking`
         * :oe:meth:`OEMolProp::OEFilter::SetTypeCheck`

   .. _OEMolProp_OEFilter_GetpKaNormalize:

   .. oe:method:: GetpKaNormalize

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool GetpKaNormalize() const

      .. oe:language:: python

         .. oe:api:: python

            GetpKaNormalize() -> bool

      Return whether the pKa state of molecules sent to
      :oe:meth:`OEMolProp::OEFilter::operator()` will be normalized to
      a neutral pH. The default is ``false``.

      .. seealso::

         * :ref:`filter_process_pka_normalization`
         * :oe:meth:`OEMolProp::OEFilter::SetpKaNormalize`

   .. _OEMolProp_OEFilter_ParseNewRules:

   .. oe:method:: ParseNewRules

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool ParseNewRules(OEPlatform::oeistream& rulefile)

      .. oe:language:: python

         .. oe:api:: python

            ParseNewRules(rulefile: oeistream) -> bool

      Parse the data from the ``rulefile``
      :ref:`oeistream <OEPlatform_oeistream>` as a ``NEWRULE`` file. These
      rules will override any rules specified by the :ref:`filter file
      <filter_files>` given to the :oe:meth:`OEFilter constructors
      <OEMolProp::OEFilter::Constructors>`.

      .. seealso::

         :ref:`filter_files_newrules`

   .. _OEMolProp_OEFilter_PrintConfig:

   .. oe:method:: PrintConfig

      .. oe:language:: c++ java csharp

         .. oe:api::

            void PrintConfig(OEPlatform::oeostream& log)

      .. oe:language:: python

         .. oe:api:: python

            PrintConfig(log: oeostream) -> None

      Print a human readable configuration of the object to the
      :ref:`oeostream <OEPlatform_oeostream>` ``log``.

   .. _OEMolProp_OEFilter_SetCanonOrder:

   .. oe:method:: SetCanonOrder

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetCanonOrder(bool b)

      .. oe:language:: python

         .. oe:api:: python

            SetCanonOrder(b: bool) -> None

      Specify whether the molecule atom and bond order should be
      canonicalized after salt removal but before the molecule is
      altered into a neutral pH model.

      .. seealso::

         :oe:meth:`OEMolProp::OEFilter::GetCanonOrder`

   .. _OEMolProp_OEFilter_SetErrorLevel:

   .. _OEMolProp_SetErrorLevel:

   .. oe:method:: SetErrorLevel

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetErrorLevel(unsigned int level)

      .. oe:language:: python

         .. oe:api:: python

            SetErrorLevel(level: int) -> None

      Sets the verbosity of warnings, using a level in the
      :oe:constns:`OESystem::OEErrorLevel` namespace, that
      are output when calling the operator
      :oe:meth:`OEMolProp::OEFilter::operator()` or the function
      :ref:`GetMessage <OEMolProp_GetMessage>` on the filter object.

   .. _OEMolProp_OEFilter_SetFlagTableFailures:

   .. oe:method:: SetFlagTableFailures

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetFlagTableFailures(bool b)

      .. oe:language:: python

         .. oe:api:: python

            SetFlagTableFailures(b: bool) -> None

      Specify whether tabular output data  should be marked with an
      asterisk if that value exceeds the limits specified by the filter.

      .. seealso::

         * :ref:`molprop_examples_molproptable`
         * :oe:meth:`OEMolProp::OEFilter::GetFlagTableFailures`

   .. _OEMolProp_OEFilter_SetMMFFTypeCheck:

   .. oe:method:: SetMMFFTypeCheck

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetMMFFTypeCheck(bool b)

      .. oe:language:: python

         .. oe:api:: python

            SetMMFFTypeCheck(b: bool) -> None

      Specify whether molecules sent to
      :oe:meth:`OEMolProp::OEFilter::operator()` will be
      :ref:`MMFF atom type checked <filter_process_mmff_checking>` before any
      other filtering criteria are applied.

      .. seealso::

         * :ref:`filter_process_mmff_checking`
         * :ref:`filter_files_typecheck` subsection describing filter files
         * :oe:meth:`OEMolProp::OEFilter::GetMMFFTypeCheck`

   .. _OEMolProp_OEFilter_SetSDTag:

   .. oe:method:: SetSDTag

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetSDTag(bool b)

      .. oe:language:: python

         .. oe:api:: python

            SetSDTag(b: bool) -> None

      Specify whether to attach every molecular property checked by the
      filter as SD data to the molecule passed to the
      :oe:meth:`OEMolProp::OEFilter::operator()` method.

      .. warning::

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

      .. seealso::

         * :ref:`molprop_examples_molpropsddata`
         * :oe:meth:`OEMolProp::OEFilter::GetSDTag`

   .. _OEMolProp_OEFilter_SetTable:

   .. oe:method:: SetTable

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetTable(OEPlatform::oeostream* table, bool owned)

      .. oe:language:: python

         .. oe:api:: python

            SetTable(table: oeostream, owned: bool) -> None

      Specify the :ref:`oeostream <OEPlatform_oeostream>` object that tabular
      data is sent to. The ``owned`` parameter specifies whether the
      :ref:`OEFilter <OEMolProp_OEFilter>` object should take ownership of the
      ``table`` pointer. If ``owned`` is ``true`` the
      :ref:`OEFilter <OEMolProp_OEFilter>` destructor will ``delete`` the
      ``table`` pointer, otherwise, it is the user's responsibility.

      Specifying a zero-pointer will effectively turn off
      tabular output data.

      .. oe:language:: python java

         .. note::

            The ``owned`` parameter must always be ``false`` for
            extension languages.

      .. seealso::

         * :ref:`molprop_examples_molproptable`
         * :oe:meth:`OEMolProp::OEFilter::GetTable`

   .. _OEMolProp_OEFilter_SetTypeCheck:

   .. oe:method:: SetTypeCheck

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetTypeCheck(bool b)

      .. oe:language:: python

         .. oe:api:: python

            SetTypeCheck(b: bool) -> None

      Specify whether molecules sent to
      :oe:meth:`OEMolProp::OEFilter::operator()` will be
      :ref:`type checked <filter_process_type_checking>` before any
      other filtering criteria are applied.

      .. seealso::

         * :ref:`filter_process_type_checking`
         * :ref:`filter_files_typecheck` subsection describing filter files
         * :oe:meth:`OEMolProp::OEFilter::GetTypeCheck`

   .. _OEMolProp_OEFilter_SetpKaNormalize:

   .. oe:method:: SetpKaNormalize

      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetpKaNormalize(bool b)

      .. oe:language:: python

         .. oe:api:: python

            SetpKaNormalize(b: bool) -> None

      Specify whether the pKa state of molecules sent to
      :oe:meth:`OEMolProp::OEFilter::operator()` will be normalized to
      a neutral pH.

      .. seealso::

         * :ref:`filter_process_pka_normalization`
         * :oe:meth:`OEMolProp::OEFilter::GetpKaNormalize`

