Combinatorial library design constructs many unique compounds by systematically combining predefined molecular fragments. A fragment may be a scaffold, or core, or an R-group attached to that scaffold. Keeping the scaffold fixed while varying R-groups creates analogs for exploring how structural changes affect activity, such as through a QSAR model. section 7.2.2
A practical design workflow can:
- Extract Murcko scaffolds and R-groups from molecular structures. section 7.2.2
- Combine fragments through reaction rules while limiting expansion and retaining chemically valid molecules. section 7.2.2
- Use scaffold decoration for optimization, or scaffold hopping when the original core has toxicity, patentability, or other fundamental limitations. section 7.2.2
Listing 7.5 Combinatorial Library Construction
from rdkit.Chem.Scaffolds import MurckoScaffold
from rdkit.Chem import AllChem
import random
cores, frags = [], []
data['mols'] = data['SMILES'].apply(Chem.MolFromSmiles)
for mol in data['mols']:
if mol is None:
continue
bms = MurckoScaffold.GetScaffoldForMol(mol) #A
core = Chem.ReplaceSidechains(mol, bms)
rgroups = Chem.ReplaceCore(mol, bms) #A
if core is None:
continue
cores.append(Chem.MolToSmiles(core))
if rgroups:
frags.extend(Chem.MolToSmiles(rgroups).split('.'))
reaction_smarts = "[*:1][#0].[#0][*:2]>>[*:1][*:2]"
rxn = AllChem.ReactionFromSmarts(reaction_smarts)
new_mols = []
EXPANSION_FACTOR = 5
MAX_STEPS = 20
for core_smi in cores: #B
for _ in range(EXPANSION_FACTOR):
current_smi = core_smi
steps = 0
while "[*]" in current_smi and steps < MAX_STEPS:
steps += 1
random_index = random.randint(0, len(frags) - 1)
products = rxn.RunReactants((
Chem.MolFromSmiles(current_smi),
Chem.MolFromSmiles(frags[random_index]),
))
if len(products) == 0: #C
break #C
product_index = random.randint(0, len(products) - 1)
current_smi = Chem.MolToSmiles(products[product_index][0])
mol = Chem.MolFromSmiles(current_smi)
if mol:
AllChem.Compute2DCoords(mol)
new_mols.append(mol)The RDKit listing demonstrates scaffold extraction, R-group collection, reaction-based assembly, expansion controls, and molecule validation. section 7.2.2
Figure 7.8 Scaffold hopping requires identifying a new scaffold that can bear the required R-groups in the appropriate relative positions. Replacement of the benzene ring with a pyridine ring would give a similar structure, but a pyrimidine scaffold would not work since the two nitrogens won’t accommodate the necessary R-group orientation.

The scaffold-hopping figure shows why replacement cores must preserve the required R-group orientation: pyridine can work where pyrimidine cannot. section 7.2.2
