Skip to content

graphchem.preprocessing.get_ring_size

determine whether rdkit.Chem.Atom or rdkit.Chem.Bond is in a ring, and of which size

Parameters:

Name Type Description Default
obj Union[rdkit.Chem.Atom, rdkit.Chem.Bond]

atom or bond

required
max_size int

maximum ring size to consider

12
Source code in graphchem/preprocessing/features.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def get_ring_size(obj: Union['rdkit.Chem.Atom', 'rdkit.Chem.Bond'],
                  max_size: int = 12):
    """ determine whether rdkit.Chem.Atom or rdkit.Chem.Bond is in a ring, and
    of which size

    Args:
        obj (Union[rdkit.Chem.Atom, rdkit.Chem.Bond]): atom or bond
        max_size (int): maximum ring size to consider
    """

    if not obj.IsInRing():
        return 0
    for i in range(max_size):
        if obj.IsInRingSize(i):
            return i
    return max_size + 1