Turn a JSON of SMILES into a paginated, property-annotated PDF grid with RDKit.
| 🌐 Website | marcdeller.com | ✉️ Contact | marc@marcdeller.com | 🐙 GitHub | bellcheddar/smiles2grid |
Render SMILES strings from a JSON file into a paginated PDF grid using RDKit.
Why it matters: after a generative or screening run you often have hundreds of SMILES and no fast way to actually look at them together, compare scaffolds, or pull a labelled subset for a slide. smiles_grid renders them into clean 5x5 PDF pages with structure labels tied to the original input order, computes a full property panel (MW, cLogP, HBD/HBA, TPSA, and more) into a companion CSV, and can highlight near-neighbours of a query structure in red. It is useful for medicinal chemists and computational scientists who need a quick, shareable visual of a compound set with the numbers attached: ideal for triage, SAR discussions, and decision-making meetings.
- Extracts SMILES strings from a nested JSON file.
- Preserves the original input order for labeling and selection.
- Renders molecules into a boxed 5x5 grid, 25 compounds per page.
- Supports optional similarity search against a query SMILES.
- Supports range-based selection such as
all,1-25,50-75, or1,5,10-20. - Writes a CSV summary for every rendered record.
- Highlights closely related structures within a page in red.
python smiles_grid.py scratch_Baricitinib_sim.out.20260530_0219.jsonThe script prompts by default. You can also run it non-interactively with --no-prompt and selection arguments.
- Single PDF output.
- 5x5 bordered panels per page.
- Structure labels based on original JSON order.
- Clean footer text with predicted properties.
- Structure drawing scaled to fit each panel.
A CSV file is written alongside the PDF and includes:
- output index.
- original index.
- source index.
- label.
- SMILES and canonical SMILES.
- formula.
- MW, cLogP, HBD, HBA, TPSA.
- rotatable bonds, rings, heavy atoms, fraction sp3, aromatic rings, hetero atoms.
- input JSON path.
- PDF filename.
- selection mode.
python smiles_grid.py input.jsonAt runtime the script prompts for:
- An optional query SMILES for similarity search.
- A similarity cutoff percentage.
- If no query is provided, a range selection such as
all,1-25, or50-75.
python smiles_grid.py input.json --query-smiles "CCO" --similarity 75python smiles_grid.py input.json --range 1-25
python smiles_grid.py input.json --range all
python smiles_grid.py input.json --range 1,5,10-20python smiles_grid.py input.json --no-prompt --range 1-25By default the script writes:
input_grid.pdfinput_summary.csv
You can override the PDF filename with --output.
- Python 3.9+
- RDKit
- ReportLab
- Pillow
- cairosvg, if your RDKit build does not include Cairo drawing support
conda install -c conda-forge rdkit reportlab pillow cairosvgIf you already have RDKit available in your environment:
pip install reportlab pillow cairosvg--query-smiles: similarity search query.--similarity: similarity cutoff as0-100or0-1.--range: selection by range or comma-separated ranges.--no-prompt: disable interactive prompting.--max-pages: render only the first N pages for debugging.--label-prefix: change the label prefix, defaultJ.--output: choose the PDF filename.
- Numbering is tied to the original JSON order, not to whether a SMILES can be rendered.
- Failed renderables are skipped visually but do not shift labels.
- The script keeps the input order for selection and CSV reporting.
- Similarity highlighting is page-local and uses red bond highlighting.
- Place the JSON file in your working directory.
- Run the script.
- Enter a query SMILES or press Enter.
- Enter a similarity cutoff or press Enter.
- Or press Enter again and provide a range such as
allor1-25. - Open the generated PDF and CSV.
Add your preferred license here.
Marc C. Deller, D.Phil.
Structural biologist & drug discovery scientist
| 🌐 | marcdeller.com | ✉️ | marc@marcdeller.com | 🐙 | github.com/bellcheddar/smiles2grid |