chemprop.featurizers.bond
=========================

.. py:module:: chemprop.featurizers.bond


Classes
-------

.. autoapisummary::

   chemprop.featurizers.bond.MultiHotBondFeaturizer
   chemprop.featurizers.bond.RIGRBondFeaturizer


Module Contents
---------------

.. py:class:: MultiHotBondFeaturizer(bond_types = None, stereos = None)

   Bases: :py:obj:`chemprop.featurizers.base.VectorFeaturizer`\ [\ :py:obj:`rdkit.Chem.rdchem.Bond`\ ]


   A :class:`MultiHotBondFeaturizer` feauturizes bonds based on the following attributes:

   * ``null``-ity (i.e., is the bond ``None``?)
   * bond type
   * conjugated?
   * in ring?
   * stereochemistry

   The feature vectors produced by this featurizer have the following (general) signature:

   +---------------------+-----------------+--------------+
   | slice [start, stop) | subfeature      | unknown pad? |
   +=====================+=================+==============+
   | 0-1                 | null?           | N            |
   +---------------------+-----------------+--------------+
   | 1-5                 | bond type       | N            |
   +---------------------+-----------------+--------------+
   | 5-6                 | conjugated?     | N            |
   +---------------------+-----------------+--------------+
   | 6-8                 | in ring?        | N            |
   +---------------------+-----------------+--------------+
   | 7-14                | stereochemistry | Y            |
   +---------------------+-----------------+--------------+

   **NOTE**: the above signature only applies for the default arguments, as the bond type and
   sterochemistry slices can increase in size depending on the input arguments.

   :param bond_types: the known bond types
   :type bond_types: Sequence[BondType] | None, default=[SINGLE, DOUBLE, TRIPLE, AROMATIC]
   :param stereos: the known bond stereochemistries. See [1]_ for more details
   :type stereos: Sequence[int] | None, default=[0, 1, 2, 3, 4, 5]

   .. rubric:: References

   .. [1] https://www.rdkit.org/docs/source/rdkit.Chem.rdchem.html#rdkit.Chem.rdchem.BondStereo.values


   .. py:attribute:: bond_types


   .. py:attribute:: stereo


   .. py:method:: __len__()


   .. py:method:: __call__(b)


   .. py:method:: one_hot_index(x, xs)
      :classmethod:


      Returns a tuple of the index of ``x`` in ``xs`` and ``len(xs) + 1`` if ``x`` is in ``xs``.
      Otherwise, returns a tuple with ``len(xs)`` and ``len(xs) + 1``.



.. py:class:: RIGRBondFeaturizer

   Bases: :py:obj:`chemprop.featurizers.base.VectorFeaturizer`\ [\ :py:obj:`rdkit.Chem.rdchem.Bond`\ ]


   A :class:`RIGRBondFeaturizer` featurizes bonds using resonance-invariant features [1]_.

   The generated bond features include:
   * ``null``-ity (i.e., whether the bond is ``None``)
   * in ring?

   .. rubric:: References

   .. [1] Zalte, A. S.; Pang, H.-W.; Doner, A. C.; Green, W. H.
       "RIGR: Resonance-Invariant Graph Representation for Molecular Property Prediction."
       J. Chem. Inf. Model. 2025, 65 (20), 10832–10843.
       https://doi.org/10.1021/acs.jcim.5c00495


   .. py:method:: __len__()


   .. py:method:: __call__(b)


   .. py:method:: one_hot_index(x, xs)
      :classmethod:


      Returns a tuple of the index of ``x`` in ``xs`` and ``len(xs) + 1`` if ``x`` is in ``xs``.
      Otherwise, returns a tuple with ``len(xs)`` and ``len(xs) + 1``.



