Mol 3d Viewer logo

Mol 3d Viewer

Organization
InternScience
mol-3d-viewer

将 SMILES 或化学名称转换为分子 3D 结构。支持生成 SDF 文件、3D 分子图片和可交互 HTML 网页(可旋转观察)。

Overview

PublisherInternScience
RepositoryChemClaw
Skill namemol-3d-viewer
Stars
53
Forks
13
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by InternScience on GitHub. Read the source before you install it.

Installation

Install the Mol 3d Viewer AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/InternScience/ChemClaw/tree/main/skills/mol-3d-viewer
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/InternScience/ChemClaw.git /tmp/ChemClaw
mkdir -p .claude/skills
cp -r /tmp/ChemClaw/skills/mol-3d-viewer .claude/skills/mol-3d-viewer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Mol 3d Viewer in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Mol 3d Viewer on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Mol 3d Viewer is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Molecular 3D Viewer

将 SMILES 字符串或化学名称转换为分子 3D 结构,支持生成 SDF 文件、3D 分子图片和 可交互 HTML 网页(可用鼠标旋转观察)。

触发条件

  • 用户提供 SMILES 并要求 3D 可视化
  • 提到"3D 分子"、"分子 3D"、"3D 结构"
  • 说"3D visualization"、"rotate molecule"、"交互分子"
  • 要求生成可旋转的分子模型
  • 提供分子文件(SDF、MOL、PDB 等)

功能

  • ✅ SMILES → 3D 分子结构
  • ✅ IUPAC 名称 → 3D 结构(自动通过 OPSIN 转 SMILES)
  • ✅ 分子文件支持 - SDF、MOL、PDB 格式
  • ✅ 3D 优化 - 使用 RDKit MMFF94 力场优化几何结构
  • ✅ SDF 文件输出 - 标准分子结构文件格式
  • ✅ 真正的 3D 渲染图片 - 基于 3D 坐标渲染,不是 2D 结构图
  • ✅ 可交互 HTML - 生成 WebGL 网页,支持鼠标旋转、缩放
  • ✅ 多种渲染样式 - 球棍模型、棍状模型、空间填充模型
  • ✅ 聚合物支持 - 正确渲染聚合物 3D 结构
  • ✅ 批量生成 - 支持多个分子同时处理
  • ✅ 分子信息展示 - HTML 中显示分子式、分子量

三种输出格式

1. SDF 文件 (.sdf)

  • 格式: Structure Data File
  • 用途: 标准分子结构交换格式
  • 内容: 3D 坐标、原子、键信息
  • 兼容: 支持所有化学软件(ChemDraw、PyMOL 等)

2. 3D 图片 (.png)

  • 格式: PNG 位图
  • 渲染: 基于真实 3D 坐标渲染
  • 样式: 默认球棍模型(ball_stick)
  • 尺寸: 800x600(可自定义)
  • 用途: 快速预览、文档插入

3. 可交互 HTML (.html)

  • 渲染: 3Dmol.js WebGL
  • 功能:
    • 🖱️ 鼠标旋转、平移、缩放
    • 🎨 多种显示模式切换
    • 📊 分子式、分子量展示
    • 💾 截图保存功能
    • 🔄 自动旋转开关
  • 特点: 分子自动居中,打开即可见

使用方法

对话框中使用

生成 ethanol 的 3D 分子结构
SMILES: CCO,创建 3D 可交互网页
可视化 aspirin 的 3D 结构,保存为 HTML
poly[oxy(1-methylethylene)] 生成 3D 模型
从文件 molecule.sdf 生成 3D 展示
批量生成 3D:CCO,C1=CC=CC=C1

命令行使用

bash
# 生成全部三种输出(SDF + 3D 图片 + HTML)
python3 scripts/mol_3d_viewer.py --smiles "CCO" --output ethanol

# 只生成 SDF 文件
python3 scripts/mol_3d_viewer.py --smiles "CCO" --output ethanol --sdf-only

# 只生成 3D 图片
python3 scripts/mol_3d_viewer.py --smiles "CCO" --output ethanol --image-only

# 只生成 HTML
python3 scripts/mol_3d_viewer.py --smiles "CCO" --output ethanol --html-only

# 从名称生成
python3 scripts/mol_3d_viewer.py --name "aspirin" --output aspirin

# 自定义渲染样式
python3 scripts/mol_3d_viewer.py --smiles "CCO" --output ethanol --style ball_stick

# 批量生成
python3 scripts/mol_3d_viewer.py --smiles "CCO,C1=CC=CC=C1" --output-dir ./3d_molecules

参数说明

参数简写说明默认值
--smiles-sSMILES 字符串(可多个)-
--name-nIUPAC 名称-
--input-i输入分子文件-
--output-o输出文件基础路径自动生成
--output-dir-d输出目录(批量模式)~/.openclaw/media/mol-3d-viewer
--sdf-only只生成 SDF 文件false
--image-only只生成 3D 图片false
--html-only只生成 HTMLfalse
--style-S渲染样式ball_stick
--width-W宽度(像素)800
--height-H高度(像素)600
--bg-color-b背景颜色white
--show-labels-l显示原子标签true
--hide-labels隐藏原子标签false
--auto-rotate-rHTML 自动旋转false
--force-field力场类型mmff94
--max-steps优化最大步数200

渲染样式

样式说明适用场景
stick棍状模型清晰展示化学键
sphere空间填充模型展示分子体积和形状
ball_stick球棍模型(默认)平衡结构和原子
surface分子表面展示静电势、疏水性
line线状模型快速预览大分子

输出示例

生成全部三种输出

bash
$ python3 mol_3d_viewer.py -s "CCO" -o ethanol
✓ 已生成 3D 优化结构
  📄 SDF: ethanol.sdf
  🖼️  3D 图片:ethanol_3d.png
  🌐 HTML: ethanol.html (可交互,支持旋转)

从名称生成

bash
$ python3 mol_3d_viewer.py -n "caffeine" -o caffeine
✓ 已生成 3D 优化结构
  📄 SDF: caffeine.sdf
  🖼️  3D 图片:caffeine_3d.png
  🌐 HTML: caffeine.html (可交互,支持旋转)

聚合物 3D 结构

bash
$ python3 mol_3d_viewer.py -s "*OCC*" -o peo
✓ 已生成 3D 优化结构 [聚合物]
  📄 SDF: peo.sdf
  🖼️  3D 图片:peo_3d.png
  🌐 HTML: peo.html (可交互,支持旋转)

批量生成

bash
$ python3 mol_3d_viewer.py -s "CCO,C1=CC=CC=C1,CC(=O)O" -d ./3d_molecules
✓ 已生成:./3d_molecules/mol_1/ (3 files)
✓ 已生成:./3d_molecules/mol_2/ (3 files)
✓ 已生成:./3d_molecules/mol_3/ (3 files)
完成:3/3 成功

可交互 HTML 功能

生成的 HTML 网页支持:

鼠标控制

  • 左键拖动 - 旋转分子
  • 右键拖动 - 平移分子
  • 滚轮 - 缩放
  • 双击 - 重置视角

显示模式切换

  • 棍状模型(Stick)
  • 球棍模型(Ball & Stick)
  • 空间填充(Space Fill)
  • 分子表面(Surface)

信息展示

  • 分子式 - 醒目显示在顶部
  • 分子量 - 精确到小数点后两位
  • SMILES - 可滚动查看完整结构
  • 输入名称 - 如果从名称生成

其他功能

  • 原子标签显示/隐藏
  • 自动旋转开关
  • 截图保存(一键下载 PNG)
  • 响应式设计(适配桌面和移动设备)

依赖

bash
pip install rdkit requests numpy

可选依赖(用于更高级的 3D 优化):

bash
pip install openbabel  # 支持更多文件格式

OPSIN API 说明

  • 来源: 剑桥大学(重定向至欧洲生物信息学研究所 EBI)
  • 网址: https://opsin.ch.cam.ac.uk/
  • 优势:
    • 支持复杂 IUPAC 名称解析
    • 无需 API 密钥
    • 自动跟随重定向
  • 限制:
    • 需要网络连接
    • 某些商品名可能无法识别

3D 优化流程

  1. 从 SMILES 生成 2D 结构 - RDKit
  2. 添加氢原子 - 补全分子
  3. 生成 3D 坐标 - ETKDG 算法
  4. 力场优化 - MMFF94 或 UFF
  5. 能量最小化 - 最多 200 步迭代
  6. 渲染输出 - 3Dmol.js(HTML)或 RDKit(图片)

完整工作流程示例

示例 1: 从 IUPAC 名称到三种输出

bash
# 一键生成(自动转换名称 + 3D 优化 + 三种输出)
python3 scripts/mol_3d_viewer.py --name "aspirin" --output aspirin

示例 2: 从分子文件到 3D 展示

bash
# 从 SDF 文件生成
python3 scripts/mol_3d_viewer.py --input molecule.sdf --output molecule_3d

# 从 PDB 文件生成(蛋白质等生物大分子)
python3 scripts/mol_3d_viewer.py --input protein.pdb --output protein_3d --style surface

示例 3: 批量处理聚合物

bash
# 创建聚合物列表
cat > polymers.txt << EOF
poly[oxyethylene]
poly[methyl methacrylate]
poly[styrene]
EOF

# 批量转换并生成 3D
python3 scripts/iupac_to_smiles.py --input polymers.txt --output polymers.json

# 提取 SMILES 并批量生成 3D
python3 scripts/mol_3d_viewer.py --smiles "*OCC*,*CC(C)(C(=O)OC)*,*CC(C1=CC=CC=C1)*" \
  --output-dir ./polymer_3d

与其他化学技能配合

与 iupac_to_smiles 配合

bash
# 1. 转换名称为 SMILES
python3 scripts/iupac_to_smiles.py --name "poly[oxy(1-methylethylene)]" -o result.json

# 2. 生成 3D 三种输出
SMILES=$(cat result.json | jq -r '.results[0].polymer_smiles')
python3 scripts/mol_3d_viewer.py --smiles "$SMILES" --output ppo_3d

与 mol_visualizer 配合

bash
# 2D 结构图 + 3D 可交互模型一起生成
python3 scripts/mol_visualizer.py --smiles "CCO" --output ethanol_2d.png
python3 scripts/mol_3d_viewer.py --smiles "CCO" --output ethanol_3d

支持的分子文件格式

格式扩展名说明
SDF.sdf, .sdStructure Data File,支持多个分子
MOL.molMDL Molfile,单个分子
PDB.pdbProtein Data Bank,生物大分子
XYZ.xyz简单坐标格式

注意事项

  • ✅ 三种输出 - 默认生成 SDF + 3D 图片 + HTML
  • ✅ 3D 优化 - 所有结构都经过力场优化,接近真实几何
  • ✅ 聚合物支持 - 正确处理聚合物连接点
  • ✅ 自动加氢 - 自动补充氢原子确保价态正确
  • ✅ 交互友好 - HTML 分子自动居中,打开即可见
  • ✅ 信息完整 - HTML 显示分子式、分子量
  • ⚠️ 大分子优化时间 - 超过 100 个原子的分子可能需要数秒优化
  • ⚠️ 构象异构体 - 生成的是单一构象,可能存在多种稳定构象
  • ⚠️ 需要网络连接 - IUPAC 名称转换需要 OPSIN API
  • ⚠️ HTML 需要浏览器 - 可交互网页需要现代浏览器(支持 WebGL)

错误处理

错误说明解决方案
Invalid SMILESSMILES 格式错误检查语法,确保括号匹配
3D generation failed3D 坐标生成失败简化分子或检查价态
Force field error力场优化失败尝试 UFF 力场(--force-field uff)
Name not found名称无法识别OPSIN 无法识别,使用 SMILES 直接输入
File format error文件格式不支持检查文件格式,转换为 SDF/MOL

技术实现

3D 坐标生成

  • 算法: ETKDG (Experimental-Torsion Knowledge Distance Geometry)
  • 库: RDKit
  • 精度: 接近实验晶体结构

力场优化

  • 默认: MMFF94 (Merck Molecular Force Field)
  • 备选: UFF (Universal Force Field)
  • 迭代: 最多 200 步能量最小化

3D 图片渲染

  • 库: RDKit MolDraw2D (Cairo/SVG)
  • 类型: 真正的 3D 坐标渲染(不是 2D 结构图)
  • 默认样式: 球棍模型(ball_stick)

HTML 渲染

  • 库: 3Dmol.js (v2.x)
  • 渲染器: WebGL
  • 兼容性: 所有现代浏览器

性能参考

分子大小3D 生成时间HTML 生成时间
小分子 (<20 原子)<0.5s<0.1s
中等分子 (20-50 原子)0.5-2s<0.1s
大分子 (50-100 原子)2-5s<0.2s
聚合物/蛋白 (>100 原子)5-20s0.2-1s

输出文件位置

默认输出目录:~/.openclaw/media/mol-3d-viewer/

可以在技能目录创建输出目录:

bash
mkdir -p ~/.openclaw/media/mol-3d-viewer

高级选项

自定义力场

bash
# 使用 UFF 力场(适合含金属的分子)
python3 mol_3d_viewer.py -s "CCO" -o ethanol --force-field uff

自定义优化步数

bash
# 增加优化步数(更精确但更慢)
python3 mol_3d_viewer.py -s "CCO" -o ethanol --max-steps 500

自定义样式

bash
# 球棍模型
python3 mol_3d_viewer.py -s "CCO" -o ethanol --style ball_stick

# 空间填充模型
python3 mol_3d_viewer.py -s "CCO" -o ethanol --style sphere

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Mol 3d Viewer AI skill do?

将 SMILES 或化学名称转换为分子 3D 结构。支持生成 SDF 文件、3D 分子图片和可交互 HTML 网页(可旋转观察)。

Why use Mol 3d Viewer on TypingMind?

Because you install it once and use it with any model. Mol 3d Viewer is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Mol 3d Viewer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/InternScience/ChemClaw/tree/main/skills/mol-3d-viewer. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Mol 3d Viewer?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Mol 3d Viewer?

As many as you like. As long as a model supports skills, you can use Mol 3d Viewer with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Mol 3d Viewer AI skill free?

Yes. It is published on GitHub by InternScience under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇