Skip to main content

RDKit molecule drawing with Depth of Field (DOF) effects.

Project description

rdkit-dof

license PyPI version PyPI status Python versions CI/CD Typing Code style: Ruff

简体中文

rdkit-dof is a lightweight Python package for rendering RDKit molecules with a depth-of-field (DOF) or fog effect. It uses 3D conformer depth to fade distant atoms and bonds, producing clearer visual depth in 2D molecular depictions.

Highlights

  • Single-molecule and grid rendering with RDKit-compatible APIs.
  • SVG and PNG output, including direct file saving.
  • Atom and bond highlighting with saturated colors while the rest keeps DOF fading.
  • Preset styles: default, nature, jacs, and dark.
  • Local or global configuration through standard-library dataclasses.
  • Optional Jupyter/IPython integration for RDKit Mol display.

Comparison

Single Molecule

Default RDKit rdkit-dof Effect
Paclitaxel Default Paclitaxel DOF

Grid Mode

Default RDKit rdkit-dof Effect
Grid Default Grid DOF

Highlighting

Single Highlighting Grid Highlighting
Highlight Single Highlight Grid

Installation

pip install rdkit-dof

Quick Start

from rdkit import Chem
from rdkit.Chem.rdDistGeom import EmbedMolecule
from rdkit.Chem.rdForceFieldHelpers import MMFFOptimizeMolecule
from rdkit_dof import MolToDofImage, dofconfig

mol = Chem.MolFromSmiles("CCO")
mol = Chem.AddHs(mol)
EmbedMolecule(mol, randomSeed=42)
MMFFOptimizeMolecule(mol)

dofconfig.use_style("nature")

MolToDofImage(
    mol,
    size=(600, 500),
    legend="Ethanol",
    filename="ethanol.svg",
)

Examples

Open the executed notebook for concrete examples with rendered output:

  • Quickstart Notebook: single molecule, style presets, highlighting, grid rendering, configuration, notebook integration, and raw SVG/PNG output.
  • 中文 Notebook: Chinese version with the same runnable examples.

Molecules with 3D conformers get true depth-based fading. Molecules without conformers are still supported; 2D coordinates are computed automatically and the depth effect is flat.

Documentation

  • Usage Guide: workflow notes for single molecules, grids, highlighting, notebook integration, and custom RDKit drawing.
  • API Reference: signatures and parameter behavior for MolToDofImage, MolsToGridDofImage, and DofDrawSettings.
  • Configuration: global config, local settings, .env, environment variables, and style presets.

Compatibility

  • Python 3.8+
  • RDKit 2023.09+
  • Linux, macOS, and Windows

Python 3.8 installs are constrained to the last compatible RDKit line (<2024.3.6).

Development

uv sync --all-extras --dev
uv run pytest
uv run ruff check .
uv run mypy src
uv run pyright

To open the notebook examples:

uv run notebook examples/rdkit_dof_quickstart.en.ipynb

To regenerate README showcase images:

python scripts/_generate_comparison_images.py

License

This project is distributed under the MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdkit_dof-0.2.0.tar.gz (878.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rdkit_dof-0.2.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file rdkit_dof-0.2.0.tar.gz.

File metadata

  • Download URL: rdkit_dof-0.2.0.tar.gz
  • Upload date:
  • Size: 878.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rdkit_dof-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d19fdd06eb3fcc87859514dd248e42cc799c2c6364989221acefb35c9d2d9f65
MD5 6524f9a367f8b446326b48cd185e3ef1
BLAKE2b-256 45bcdfbd8b6bf934ded085d41c216d031b22742f2f964fb65553b4a8df3091da

See more details on using hashes here.

File details

Details for the file rdkit_dof-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rdkit_dof-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rdkit_dof-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a2c74422a2c80a5ffbce5e2063465811cfb3d2415a27c928eb5e2cf453f4191
MD5 071dd4677d821a29f571b56881b54e2e
BLAKE2b-256 ec5ccea0d945eb7011bfc2606e2ebd7766e1d84abe8bd5451eeb840fe4fb46ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page