Skip to main content

MR-TADF 二维结构绘图工具

mrtadf_depict 用于把 MR-TADF 分子的 SMILES 转成经过结构化排版的二维图,并可独立生成三维 XYZ 初始结构。

从 PyPI 安装

发布后,用户可以直接运行:

python -m pip install mrtadf-depict
mrtadf-depict --help

也可以在 Python 中使用:

from rdkit import Chem
from mrtadf_depict import optimize_mrtadf_layout

mol = Chem.MolFromSmiles("Brc1ccccc1")
result = optimize_mrtadf_layout(mol)
print(result.final_svg)

当前二维流程重点保证:

  • 螺芴及类似环系内部保持刚体,不拉伸芳环;
  • 螺环中心两根连接键可独立变化,不强制等长,且优先旋转后拉长;
  • 极端多螺环结构使用有界束搜索,不进行无限笛卡尔积;
  • BNN 核心最终统一为两个 N 水平、B 位于上方;
  • 简单卤素、CD3、叔丁基和小型支化基团使用确定性局部规则;
  • 最终用 SVG 几何检查报告键交叉和标签碰撞。

五分钟运行

以下命令都从项目根目录 mr_tadf_perf/ 执行。

第 1 步:创建环境

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e "production[dev]"

要求 Python 3.10 或更高版本。

第 2 步:运行测试

python -m pytest -q production/tests

当前预期结果:

9 passed, 3 subtests passed

第 3 步:批量生成二维图片

mrtadf-depict depict \
  --input production/examples/compound_smiles.csv \
  --output output_2d \
  --engine coordgen

如果没有使用命令行安装,也可以运行:

PYTHONPATH=production python -m mrtadf_depict.cli depict \
  --input production/examples/compound_smiles.csv \
  --output output_2d \
  --engine coordgen

第 4 步:检查结果

output_2d/
├── png/          # 预览图片
├── svg/          # 最终矢量图,也是碰撞验收依据
├── sdf/          # 带二维坐标的结构
└── report.csv    # 状态、碰撞结果、警告和算法元数据

重点检查 report.csv:

  1. status 应为 ok;
  2. final_svg 理想值为 (0, 0, 0);
  3. warnings 应为空;
  4. metadata 中若出现 "adaptive_status": "manual_review",必须人工复核。

第 5 步:生成 XYZ

mrtadf-depict xyz \
  --input production/examples/compound_smiles.csv \
  --output output_xyz \
  --seed 42

XYZ 使用独立的 ETKDGv3 + UFF 三维流程,不会把二维拉长的绘图键带入三维结构。

输入 CSV

必须包含两列:

compound_id,smiles
sample_001,Brc1ccc2...

其他列会被保留在输入中但不会参与计算。compound_id 用作输出文件名,因此应唯一且不含路径分隔符。

Python API

稳定公共 API 只有三个名字:

from mrtadf_depict import (
    PipelineConfig,
    PipelineResult,
    optimize_mrtadf_layout,
)

完整可运行示例见:

python production/examples/use_python_api.py

开发文档

开发原则

  1. 不再创建 v14.py、v15.py 之类的版本脚本。
  2. 新逻辑放进唯一对应模块,并增加回归测试。
  3. 螺芴搜索内层禁止反复渲染 SVG。
  4. 多臂搜索禁止直接构造完整笛卡尔积。
  5. 找不到可靠布局时返回 manual_review,不要破坏原始结构。
  6. 二维绘图与三维 XYZ 始终保持独立。

发布到 PyPI

发布者在 production/ 目录执行:

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
python -m twine upload dist/*

PyPI API token 不要写进代码、配置文件或命令历史。完整安全步骤见 docs/PUBLISHING.md。

Metadata

Release files for mrtadf-depict 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mrtadf-depict 0.2.0
File Size Uploaded
mrtadf_depict-0.2.0.tar.gz 61.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mrtadf-depict 0.2.0
File Interpreter ABI Platform
mrtadf_depict-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 114.9 kB

Release files / mrtadf_depict-0.2.0.tar.gz

Download URL mrtadf_depict-0.2.0.tar.gz
Size 61.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3480fe1b52ac9c15aada6060c8fd981e6d25fc0fb2db8a7a029be9b0c09a9b90
BLAKE2b-256 checksum
How to use checksums
1dfcb0ec8dcbc22e40c4832efbbe2d93736134086f1b24706cfb46c1b16ad7c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / mrtadf_depict-0.2.0-py3-none-any.whl

Download URL mrtadf_depict-0.2.0-py3-none-any.whl
Size 53.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3c646cd9201590c93cc0c0cb475c5df6e3334942d5926b043e8f77be6356d6d
BLAKE2b-256 checksum
How to use checksums
643780207350e2c70d26bc86c59f982fd319a68e9aade8753b5f2aa66e2c69ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release history Release notifications | RSS feed

0.2.1

2 release files

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page