agentsclimarketplace

Chem skill

Skill ghutchis/chem-skill

An experiment with Claude Skills

Install
npx -y skills add ghutchis/chem-skill

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Generate 2D structure images and interactive 3D viewers from chemical names or SMILES. Supports PNG/SVG output for 2D and 3Dmol.js HTML viewers for 3D conformers.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.3 KB, as published. Nobody here has run it

Chemical Visualization Skill

Overview

Generate publication-quality 2D molecular structure images and interactive 3D conformer viewers from chemical names, SMILES, or InChI strings.

Needs network access to *.nih.gov servers to access PubChem for common names like caffeine, testosterone, estrogen, etc.

Much of the code was generated by Claude, with careful validation, error fixing, and OPSIN integration by Geoff Hutchison.

Quick Start

# 2D structure image
python scripts/chem_2d.py "caffeine" --output caffeine.png

# 3D interactive viewer
python scripts/chem_3d.py "caffeine" --output caffeine.html

# Both at once
python scripts/chem_vis.py "caffeine" --both --output-dir ./caffeine/

Dependencies

pip install rdkit pubchempy py2opsin --break-system-packages

Scripts

ScriptPurpose
chem_2d.pyGenerate 2D structure images (PNG/SVG)
chem_3d.pyGenerate 3D conformer viewers (HTML)
chem_vis.pyUnified CLI for both
common.pyShared utilities (name resolution, etc.)

2D Structure Images

Generate static images of molecular structures.

Usage

python scripts/chem_2d.py "aspirin" --output aspirin.png
python scripts/chem_2d.py "CCO" --input-type smiles --output ethanol.svg --format svg
python scripts/chem_2d.py "glucose" --width 400 --height 400 --output glucose.png

Options

OptionDescriptionDefault
--input-type, -tInput: name, smiles, inchiname
--output, -oOutput file pathmolecule.png
--format, -fOutput: png, svgpng
--width, -WWidth in pixels300
--height, -HHeight in pixels300
--kekulize, -kShow Kekulé structureFalse
--show-atom-numbers, -nDisplay atom indicesFalse
--highlight-atomsAtom indices to highlightNone

Python API

from scripts.chem_2d import chemical_to_image, batch_convert

# Single molecule
chemical_to_image("caffeine", "caffeine.png", width=400, height=400)

# Batch conversion
chemicals = ["aspirin", "ibuprofen", "acetaminophen"]
results = batch_convert(chemicals, output_dir="./structures/", format="svg")

3D Conformer Viewers

Generate interactive HTML viewers with 3Dmol.js.

Usage

python scripts/chem_3d.py "dopamine" --output dopamine.html
python scripts/chem_3d.py "CCO" --input-type smiles --style ballstick --output ethanol.html
python scripts/chem_3d.py "serotonin" --embed --output serotonin_widget.html

Options

OptionDescriptionDefault
--input-type, -tInput: name, smilesname
--output, -oOutput file pathmolecule_3d.html
--width, -WViewer width (px)500
--height, -HViewer height (px)400
--style, -sStyle: stick, sphere, line, ballstickstick
--conformers, -cConformers to sample10
--no-optimizeSkip MMFF optimizationFalse
--no-controlsHide interactive buttonsFalse
--embedOutput snippet without HTML wrapperFalse

Embed Mode

Use --embed to generate a snippet for inserting into existing web pages:

python scripts/chem_3d.py "aspirin" --embed --output aspirin_widget.html

The parent page must load 3Dmol.js:

<script src="https://3dmol.org/build/3Dmol-min.js"></script>

Each viewer gets a unique ID, so multiple molecules can coexist on one page.

Python API

from scripts.chem_3d import chemical_to_3d, generate_conformer, generate_html_viewer

# Full pipeline
chemical_to_3d("caffeine", "caffeine.html")

# Step by step
from scripts.common import get_smiles
smiles = get_smiles("caffeine", "name")
mol_block = generate_conformer(smiles, num_conformers=20)
html = generate_html_viewer(mol_block, title="Caffeine", width=600, height=500)

# Embeddable snippet
snippet = generate_html_viewer(mol_block, title="Caffeine", embed=True)

Unified CLI

Generate both 2D and 3D outputs with one command.

# 2D only
python scripts/chem_vis.py "caffeine" --2d --output caffeine.png

# 3D only
python scripts/chem_vis.py "caffeine" --3d --output caffeine.html

# Both
python scripts/chem_vis.py "caffeine" --both --output-dir ./caffeine/

Examples

Generate structures for a lecture

from scripts.chem_2d import batch_convert

neurotransmitters = ["dopamine", "serotonin", "acetylcholine", "GABA", "glutamate"]
batch_convert(neurotransmitters, output_dir="./lecture_slides/", width=400, height=400)

Comparison page with multiple 3D viewers

from scripts.chem_3d import generate_conformer, generate_html_viewer
from scripts.common import get_smiles

molecules = ["aspirin", "ibuprofen", "naproxen"]

page = '''<!DOCTYPE html>
<html>
<head>
    <script src="https://3dmol.org/build/3Dmol-min.js"></script>
    <style>
        .container { display: flex; gap: 20px; flex-wrap: wrap; padding: 20px; }
    </style>
</head>
<body>
<h1>NSAID Comparison</h1>
<div class="container">
'''

for mol_name in molecules:
    smiles = get_smiles(mol_name, "name")
    mol_block = generate_conformer(smiles)
    page += generate_html_viewer(mol_block, title=mol_name.title(), 
                                  width=350, height=300, embed=True)

page += '</div></body></html>'

with open("nsaid_comparison.html", "w") as f:
    f.write(page)

Troubleshooting

"Could not find chemical"

  • Check if network access is enabled to *.nih.gov sites for PubChem use.
  • Check spelling
  • Try alternative names (IUPAC vs common)
  • Use SMILES directly: --input-type smiles

"Could not generate 3D conformer"

  • Try --no-optimize flag
  • Increase --conformers count
  • Some structures (metals, unusual bonding) may not embed well

Poor 2D layout

  • RDKit's 2D coordinate generation works best for typical organic molecules
  • Very large or unusual structures may need manual adjustment

3D viewer doesn't load

  • Check internet connection (3Dmol.js loads from CDN)
  • Check browser console for errors
  • For embed mode, ensure parent page loads 3Dmol.js first

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.