Mol 2d Viewer logo

Mol 2d Viewer

Organization
InternScience
mol-2d-viewer

将 SMILES 或化学名称转换为分子 2D 结构图。支持普通分子和聚合物 2D 结构绘制。

Overview

PublisherInternScience
RepositoryChemClaw
Skill namemol-2d-viewer
Stars
53
Forks
13
Bundled files
2
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.

  • 2 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 2d 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-2d-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-2d-viewer .claude/skills/mol-2d-viewer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Mol 2d 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 2d 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 2d 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 Structure Visualizer

将 SMILES 字符串或化学名称转换为分子结构图,支持聚合物 2D 结构绘制。

触发条件

  • 用户提供 SMILES 并要求可视化
  • 提到"分子结构"、"可视化"、"draw molecule"
  • 说"SMILES 转图片"、"显示结构"
  • 提供聚合物名称或 SMILES

功能

  • ✅ SMILES → 分子结构图
  • ✅ IUPAC 名称 → 结构图(自动通过 OPSIN 转 SMILES)
  • ✅ 聚合物支持 - 正确渲染聚合物重复单元
  • ✅ 输出 PNG 或 SVG 格式
  • ✅ 可自定义尺寸、样式
  • ✅ 批量生成
  • ✅ 聚合物标题 - 自动添加化合物名称作为标题

聚合物渲染

对于聚合物 SMILES(包含 * 连接点标记):

  • 自动识别聚合物标记
  • 清理 SMILES 以便正确渲染
  • 添加"Polymer Structure"标题
  • 使用增强的渲染选项(更粗的键、更大的原子标签)

聚合物 SMILES 格式

*monomer*          # 简单聚合物
*[linker]monomer*  # 带连接基团的聚合物
*CC*               # 聚乙烯
*OCC*              # 聚环氧乙烷
*OCC(C)*           # 聚环氧丙烷

使用方法

对话框中使用

画出 ethanol 的分子结构
SMILES: CCO,生成结构图
可视化 aspirin,保存为 SVG
poly[oxy(1-methylethylene)] 画结构图
批量生成:CCO,C1=CC=CC=C1

命令行使用

bash
# 从 SMILES 生成
python3 scripts/mol_2d_viewer.py --smiles "CCO" --output ethanol.png

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

# 聚合物 SMILES
python3 scripts/mol_2d_viewer.py --smiles "*OCC*" --output peo.png

# 聚合物名称
python3 scripts/mol_2d_viewer.py --name "poly[oxy(1-methylethylene)]" --output ppo.png

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

# 自定义尺寸
python3 scripts/mol_2d_viewer.py --smiles "CCO" --width 400 --height 300

参数说明

参数简写说明默认值
--smiles-sSMILES 字符串(可多个)-
--name-nIUPAC 名称-
--output-o输出文件路径自动生成
--output-dir-d输出目录(批量模式)~/.openclaw/media/mol-2d-viewer
--format-f输出格式:png/svgpng
--width-W图片宽度(像素)400
--height-H图片高度(像素)300
--kekulize-k凯库勒化(显示双键)false
--quiet-q安静模式false
--stdout输出 base64 到 stdoutfalse

输出示例

单个分子

bash
$ python3 mol_2d_viewer.py -s "CCO" -o ethanol.png
✓ 已生成:ethanol.png (400x300, PNG)

聚合物

bash
$ python3 mol_2d_viewer.py -s "*OCC*" -o peo.png
✓ 已生成:peo.png (400x300, PNG) [聚合物]

$ python3 mol_2d_viewer.py -n "poly[oxy(1-methylethylene)]" -o ppo.png
✓ 已生成:ppo.png (400x300, PNG) [聚合物]

批量生成

bash
$ python3 mol_2d_viewer.py -s "CCO,C1=CC=CC=C1" -d ./output
✓ 已生成:./output/mol_1.png
✓ 已生成:./output/mol_2.png
完成:2/2 成功

依赖

bash
pip install rdkit Pillow requests

输出格式

PNG

  • 位图格式
  • 适合网页展示
  • 文件较小
  • 聚合物使用增强的 Cairo 渲染

SVG

  • 矢量格式
  • 无限缩放不失真
  • 适合出版物
  • 支持标题嵌入

聚合物渲染选项

选项说明默认
键宽度化学键线宽2
原子标签字体元素符号大小14
高亮键宽倍数高亮显示倍数3
标题化合物名称自动

完整工作流程示例

示例 1: 从 IUPAC 名称到结构图

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

# 输出:
# {
#   "polymer_smiles": "*OCC(C)*",
#   "explanation": "连接基团:oxy | 单体 SMILES: CC(C)"
# }

# 2. 绘制结构图
python3 scripts/mol_2d_viewer.py --smiles "*OCC(C)*" --output ppo.png --title "PPO"

示例 2: 批量处理

bash
# 创建输入文件
cat > polymers.txt << EOF
poly[oxyethylene]
poly[methyl methacrylate]
poly[styrene]
EOF

# 批量转换
python3 scripts/iupac_to_smiles.py --input polymers.txt --output polymers.json

# 提取 SMILES 并批量绘制
python3 scripts/mol_2d_viewer.py --smiles "*OCC*,*CC(C)(C(=O)OC)*,*CC(C1=CC=CC=C1)*" \
  --output-dir ./polymers --format png

注意事项

  • ✅ 聚合物自动识别 - 包含 * 的 SMILES 自动按聚合物渲染
  • ✅ 名称转结构 - IUPAC 名称自动通过 OPSIN 转换
  • ✅ 增强渲染 - 聚合物使用更大的字体和更粗的键
  • ⚠️ 复杂聚合物可能渲染不完整 - RDKit 对某些复杂重复单元支持有限
  • ⚠️ 需要网络连接 - IUPAC 名称转换需要 OPSIN API
  • ⚠️ SVG 文件通常比 PNG 大

错误处理

错误说明解决方案
Invalid SMILESSMILES 格式错误检查语法,确保括号匹配
Cannot parse无法解析结构简化 SMILES 或检查聚合物标记
Name not found名称无法识别OPSIN 无法识别,使用 SMILES 直接输入

与 iupac_to_smiles 技能配合使用

这两个技能可以完美配合:

  1. iupac_to_smiles: 将 IUPAC 名称(包括聚合物)转换为 SMILES
  2. mol_2d_viewer: 将 SMILES 转换为可视化的 2D 结构图
bash
# 完整流程示例
# 1. 转换
python3 scripts/iupac_to_smiles.py -n "poly[oxy(1-methylethylene)]" -o result.json

# 2. 从结果提取 SMILES 并绘制
SMILES=$(cat result.json | jq -r '.results[0].polymer_smiles')
python3 scripts/mol_2d_viewer.py -s "$SMILES" -o structure.png

支持的聚合物类型

聚合物SMILES 示例说明
聚乙烯*CC*最简单的碳链聚合物
聚环氧乙烷*OCC*含氧连接基团
聚环氧丙烷*OCC(C)*带侧链的聚醚
聚苯乙烯*CC(C1=CC=CC=C1)*含苯环侧链
PMMA*CC(C)(C(=O)OC)*聚甲基丙烯酸甲酯

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 2d Viewer AI skill do?

将 SMILES 或化学名称转换为分子 2D 结构图。支持普通分子和聚合物 2D 结构绘制。

Why use Mol 2d Viewer on TypingMind?

Because you install it once and use it with any model. Mol 2d 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 2d Viewer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/InternScience/ChemClaw/tree/main/skills/mol-2d-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 2d 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 2d Viewer?

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

Is the Mol 2d 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 👇