12.2 Number of Ring Bonds to an Atom

To provide an example of how one might use the above functions, the code below returns the number of ring bonds attached to an atom. This is useful for identifying ring fusion atoms (ring bond count = 3) and potential spiro-atoms (ring bond count $\ge$ 4).

def MyAtomRingBondCount(atom):
    count = 0;
    for bond in atom.GetBonds():
    	if bond.IsInRing():
            count += 1
    return count