CReM

June 17, 2026 · View on GitHub

CReM

CReM — chemically reasonable mutations

PyPI version Documentation License: BSD-3-Clause

CReM is an open-source Python framework to generate chemical structures using a fragment-based approach.

The idea is similar to matched molecular pairs: fragments that occur in the same context are considered interchangeable. CReM stores such context–fragment relationships in a database and uses them to generate chemically valid structures.

Features

  • Four generation modesmutate, grow, link, and make_cycle (ring closure / macrocyclization).
  • Custom fragment databases built in one step with cremdb_create, or downloaded as precompiled ChEMBL databases.
  • Multiple fragment sets per database — switch between them at generation time with set_names and a frequency threshold (min_freq).
  • Fine control — context radius, fragment-size windows, replaceable/protected atoms, and replace_cycles for partial-ring replacement.
  • Custom selection — bias or restrict fragments with filter_func / sample_func, or with molecular-property columns.
  • Reproducible and parallelseed for deterministic sampling; ncores and picklable *_mol2 wrappers for multiprocessing.

Installation

pip install crem

From source:

git clone https://github.com/DrrDom/crem
cd crem
pip install .

CReM requires rdkit>=2025.3.5. Optional extras: guacamol (to run the benchmark) and zstandard (to read .zst-compressed input when building databases).

Quick start

All examples assume a fragment database fragments.dbbuild one or download a precompiled ChEMBL database.

from rdkit import Chem
from crem.crem import mutate_mol, grow_mol, link_mols, make_cycle

m = Chem.MolFromSmiles('c1cc(OC)ccc1C')          # methoxytoluene

# replace an existing fragment
mutants = list(mutate_mol(m, db_name='fragments.db', max_size=1))

# decorate by replacing a hydrogen
grown = list(grow_mol(m, db_name='fragments.db'))

# link two molecules with a linker
m2 = Chem.MolFromSmiles('NCC(=O)O')              # glycine
linked = list(link_mols(m, m2, db_name='fragments.db'))

# form a new ring
cyclic = list(make_cycle(m, db_name='fragments.db', ring_size=(5, 7)))

All four are generators (wrap in list(...)) and share many options — radius, size windows, min_freq / set_names, replace_ids / protected_ids, filter_func / sample_func, max_replacements, seed, and ncores. See Mutate, grow, link, Advanced fragment selection, and the API reference.

Build a fragment database

Build a database directly from a SMILES file in one step:

cremdb_create -i input.smi -o fragments.db -s chembl

This produces the current database format with fragment-set support and ring-closure fragments. For multiple sets, property columns, sharded/parallel builds, conversion of older databases, and the programmatic crem.db API, see Fragment databases.

Benchmarks

GuacaMol goal-directed benchmark (scores marked * are from the original GuacaMol publication):

taskSMILES LSTM*SMILES GA*Graph GA*Graph MCTS*CReM
Celecoxib rediscovery1.0000.7321.0000.3551.000
Troglitazone rediscovery1.0000.5151.0000.3111.000
Thiothixene rediscovery1.0000.5981.0000.3111.000
Aripiprazole similarity1.0000.8341.0000.3801.000
Albuterol similarity1.0000.9071.0000.7491.000
Mestranol similarity1.0000.791.0000.4021.000
C11H240.9930.8290.9710.4100.966
C9H10N2O2PF2Cl0.8790.8890.9820.6310.940
Median molecules 10.4380.3340.4060.2250.371
Median molecules 20.4220.380.4320.1700.434
Osimertinib MPO0.9070.8860.9530.7840.995
Fexofenadine MPO0.9590.9310.9980.6951.000
Ranolazine MPO0.8550.8810.920.6160.969
Perindopril MPO0.8080.6610.7920.3850.815
Amlodipine MPO0.8940.7220.8940.5330.902
Sitagliptin MPO0.5450.6890.8910.4580.763
Zaleplon MPO0.6690.4130.7540.4880.770
Valsartan SMARTS0.9780.5520.9900.040.994
Deco Hop0.9960.9701.0000.5901.000
Scaffold Hop0.9980.8851.0000.4781.000
total score17.34114.39817.9839.01117.919

Limitations

  • CReM builds structures only from fragments present in the database, so the ring systems that can appear depend on the database. make_cycle and replace_cycles form or replace rings using fragments observed in the database rather than inventing entirely new ring systems.
  • Very large molecules are skipped in some workflows: a molecule with more than 30 non-ring single bonds is not mutated, and one with more than 100 hydrogen atoms is not grown or linked.
  • Context canonicalization relies on RDKit's SMILES output. A database is best used with the RDKit version it was built with (no incompatibilities observed so far); pin RDKit when sharing databases across machines.

License

BSD-3-Clause. See LICENSE.txt.

Citation

CReM: chemically reasonable mutations framework for structure generation Pavel Polishchuk Journal of Cheminformatics 2020, 12, (1), 28 https://doi.org/10.1186/s13321-020-00431-w

Control of Synthetic Feasibility of Compounds Generated with CReM Pavel Polishchuk Journal of Chemical Information and Modeling 2020, 60, 6074-6080 https://dx.doi.org/10.1021/acs.jcim.0c00792