Skip to content

Bond featurizers

RingFeaturizer

Bases: BaseBondFeaturizer

Class for featurizing bond its ring membership.

Source code in bionemo/geometric/bond_featurizers.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class RingFeaturizer(BaseBondFeaturizer):
    """Class for featurizing bond its ring membership."""

    def __init__(self, n_ring_sizes=7) -> None:
        """Initializes RingFeaturizer class."""
        self.n_ring_sizes = n_ring_sizes  # ring size 3 - 8 and UNK

    @property
    def n_dim(self) -> int:
        """Returns dimensionality of the computed features."""
        return self.n_ring_sizes

    def get_bond_features(self, mol: Mol, bond_indices: Optional[Iterable]) -> list[tuple[int]]:
        """Computes ring sizes a bonds of the molecule are present in.

        Args:
            mol: An RDkit Chem.Mol object
            bond_indices: Indices of bonds for feature computation. By default, features for all bonds is computed.

        Returns:
            An list of tuples indicating the size of ring(s) the bonds are present in.
        """
        _bond_indices = bond_indices if bond_indices else range(mol.GetNumBonds())

        ri = mol.GetRingInfo()
        return [ri.BondRingSizes(bidx) for bidx in _bond_indices]

n_dim: int property

Returns dimensionality of the computed features.

__init__(n_ring_sizes=7)

Initializes RingFeaturizer class.

Source code in bionemo/geometric/bond_featurizers.py
30
31
32
def __init__(self, n_ring_sizes=7) -> None:
    """Initializes RingFeaturizer class."""
    self.n_ring_sizes = n_ring_sizes  # ring size 3 - 8 and UNK

get_bond_features(mol, bond_indices)

Computes ring sizes a bonds of the molecule are present in.

Parameters:

Name Type Description Default
mol Mol

An RDkit Chem.Mol object

required
bond_indices Optional[Iterable]

Indices of bonds for feature computation. By default, features for all bonds is computed.

required

Returns:

Type Description
list[tuple[int]]

An list of tuples indicating the size of ring(s) the bonds are present in.

Source code in bionemo/geometric/bond_featurizers.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def get_bond_features(self, mol: Mol, bond_indices: Optional[Iterable]) -> list[tuple[int]]:
    """Computes ring sizes a bonds of the molecule are present in.

    Args:
        mol: An RDkit Chem.Mol object
        bond_indices: Indices of bonds for feature computation. By default, features for all bonds is computed.

    Returns:
        An list of tuples indicating the size of ring(s) the bonds are present in.
    """
    _bond_indices = bond_indices if bond_indices else range(mol.GetNumBonds())

    ri = mol.GetRingInfo()
    return [ri.BondRingSizes(bidx) for bidx in _bond_indices]