Rdkit conf

From jinzhezenggroup/computational-chemistry-agent-skills · View interactive version

Rdkit conf is an AI agent skill from the GitHub repository jinzhezenggroup/computational-chemistry-agent-skills. A standardized CLI wrapper for RDKit 3D/2D conformer generation that samples multiple conformers per molecule (ETKDGv3, default 10), optimizes each with a force field (MMFF94s/UFF), keeps the lowest-energy conformer, automatically falls back to 2D layout on total embedding failure with a printed war

How to use this skill

Skill file

RDKit Conformer Generation

This skill provides practical command patterns for RDKit 3D/2D conformer generation

using the standardized CLI wrapper: <skill_path>/scripts/rdkit_conf_helper.py.

Key behaviors (important for Agents):

via EmbedMultipleConfs, optimizes each with the chosen force field, and keeps the

lowest-energy one. Set --num-confs 1 to revert to single-conformer behavior.

and a [WARN] line is printed to stderr for that molecule.

Quick Start

Check CLI help:

uv run <skill_path>/scripts/rdkit_conf_helper.py --help
uv run <skill_path>/scripts/rdkit_conf_helper.py conf --help

Disable environment printing (optional):

uv run <skill_path>/scripts/rdkit_conf_helper.py --no-env conf --smiles "CCO" --output out.sdf

Core Tasks

1) Generate 3D conformers (SDF output, default)

Single SMILES:

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --smiles "CCO" \
    --output /tmp/CCO.sdf

Single SMILES with a custom molecule name:

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --smiles "c1ccccc1" \
    --name benzene \
    --output /tmp/benzene.sdf

From CSV (default SMILES column: smiles):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv \
    --smiles-col smiles \
    --output data.sdf

From CSV with a name column:

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv \
    --smiles-col smiles \
    --name-col compound_id \
    --output data.sdf

From SMI (second token per line is used as name automatically):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file molecules.smi \
    --output molecules.sdf

2) Control conformer sampling count

Default (10 conformers sampled, lowest-energy kept):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --output data.sdf

Single conformer (fastest, least thorough):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --num-confs 1 --output data.sdf

Increase sampling for flexible or macrocyclic molecules:

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --num-confs 50 --output data.sdf

3) Choose force-field minimization

MMFF94s (default, falls back to UFF if unavailable):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --ff mmff94s --output data.mmff.sdf

UFF (universal force field):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --ff uff --output data.uff.sdf

Skip force-field optimization (raw ETKDG geometry only):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --ff none --output data.etkdg_raw.sdf

4) XYZ output

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv \
    --format xyz \
    --output data.xyz

5) Tuning embedding for difficult molecules

Large or macrocyclic molecules sometimes fail standard ETKDG; try random initial coordinates:

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file macrocycles.csv \
    --use-random-coords \
    --max-attempts 500 \
    --output macrocycles.sdf

Use a different random seed (reproducibility):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --seed 123 --output data.seed123.sdf

Non-deterministic embedding (seed = -1):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --seed -1 --output data.sdf

6) Suppress hydrogen addition

By default explicit H atoms are added before embedding for more accurate 3D geometry.

Use --no-hs to keep the molecule as-is (heavy atoms only):

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv --no-hs --output data.noh.sdf

7) Custom log file paths

uv run <skill_path>/scripts/rdkit_conf_helper.py conf \
    --file data.csv \
    --output data.sdf \
    --error-log logs/skipped.csv \
    --fallback-log logs/used_2d.csv

3D Embedding Pipeline Details

For each molecule, the script runs the following steps in order:

  1. Parse SMILES via Chem.MolFromSmiles.
  2. Add hydrogens (Chem.AddHs) -- skipped with --no-hs.
  3. Multi-conformer 3D embedding (EmbedMultipleConfs, --num-confs candidates,

default 10): tries ETKDGv3, then ETKDGv2, then ETDG, then ETDG+useRandomCoords

as a fallback chain until at least one conformer is embedded.

  1. Force-field minimization (if --ff is not none): each successfully embedded

conformer is individually optimized. MMFF94s transparently falls back to UFF if

parameters are unavailable for that molecule.

  1. Lowest-energy selection: the conformer with the minimum post-optimization energy

is retained; all others are discarded. If --ff none, the first embedded conformer

is kept without energy ranking.

  1. 2D fallback (if all 3D attempts yield zero conformers): generates a flat 2D layout

via Compute2DCoords (Z=0 for all atoms), prints a [WARN] to stderr, and records

the molecule in the fallback log.


Output Format Notes

SDF output (--format sdf, default):

written to the SDF header line.

XYZ output (--format xyz):

Fallback log (*.fallback.csv):

Skipped log (*.skipped.csv):


Agent Checklist

When using this skill for users:

  1. Confirm input format:
  1. Quote SMILES containing special shell characters (brackets/parentheses):
  1. For CSV workflows, verify column names:
  1. Check the [INFO] Done: summary line for the 3D/2D/skip breakdown.
  2. If 2D fallbacks occurred, inspect *.fallback.csv:
  1. Always capture absolute output paths:
  1. If debugging is needed, enable full traceback:

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.