Selectors

Selectors take advantage of rdkit and stk to provide access to specific subsets of a molecule for manipulation.

Examples:

To be nonspecific, you can use null or all selectors. And this taps into the stk functional group interface.

import stk
import bbprepared

bb = stk.BuildingBlock(
    smiles="C1=CC(=CC(=C1)C2=CN=CC=C2)C3=CN=CC=C3",
    functional_groups=stk.SmartsFunctionalGroupFactory(
        smarts="[#6]~[#7X2]~[#6]",
        bonders=(1,),
        deleters=(),
    ),
)
count_all = len(bbprepared.selectors.AllSelector().select_atoms(bb))
count_allnonh = len(bbprepared.selectors.AllNonHSelector().select_atoms(bb))
count_bind = len(bbprepared.selectors.BindersSelector().select_atoms(bb))
count_dele = len(bbprepared.selectors.DeletersSelector().select_atoms(bb))
count_null = len(bbprepared.selectors.NullSelector().select_atoms(bb))

Some selectors provide the atom positions only, when you are selecting based on a geometrical feature. X is often the binder positions in stk.BuildingBlock.

import stk
import bbprepared
import numpy as np

bb = stk.BuildingBlock(
    smiles="C1=CC(=CC(=C1)C2=CN=CC=C2)C3=CN=CC=C3",
    functional_groups=stk.SmartsFunctionalGroupFactory(
        smarts="[#6]~[#7X2]~[#6]",
        bonders=(1,),
        deleters=(),
    ),
)

selector = bbprepared.selectors.XCOMXSelector()
positions = selector.get_atomic_positions(bb)