Ling-MD/md-agent-skills / pymol-academic-figures
pymol-academic-figures
VerifiedUse when creating, improving, or troubleshooting publication-ready molecular structure figures with PyMOL: protein cartoons, ligand binding pockets, surfaces, electrostatic-style views, hydrogen bonds, labels, structure alignments, MD representative snapshots, transparent PNG export, ray tracing, journal-quality panels, PyMOL .pml scripts, or automated headless PyMOL rendering.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.3 KB |
| agents/openai.yaml | config | 219 B |
| references/figure-recipes.md | markdown | 2.2 KB |
| scripts/run_pymol_render.py | script | 3.4 KB |
scripts/run_pymol_render.py
View on GitHub#!/usr/bin/env python3
"""Run a PyMOL .pml script and optionally verify the rendered image."""
from __future__ import annotations
import argparse
import os
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
def find_pymol(explicit: str | None = None) -> str:
candidates = []
if explicit:
candidates.append(explicit)
if os.environ.get("PYMOL_EXE"):
candidates.append(os.environ["PYMOL_EXE"])
which = shutil.which("pymol")
if which:
candidates.append(which)
for candidate in candidates:
path = Path(candidate)
if path.exists():
return str(path)
raise FileNotFoundError("Could not find PyMOL. Set --pymol-exe or PYMOL_EXE.")
def write_self_test_pml(path: Path, output: Path) -> None:
path.write_text(
"\n".join(
[
"reinitialize",
"bg_color white",
"set ray_opaque_background, off",
"set antialias, 2",
"pseudoatom a, pos=[0,0,0]",
"pseudoatom b, pos=[2,0,0]",
"show spheres, a or b",
"color cyan, a",
"color orange, b",
"zoom all, 3",
"ray 900, 650",
f"png {output.as_posix()}, dpi=150",
"quit",
]
),
encoding="utf-8",
)
def main() -> int:
parser = argparse.ArgumentParser(description="Run a PyMOL .pml script headlessly.")
parser.add_argument("--pml", help="Path to the .pml script to run.")
parser.add_argument("--output", help="Expected image output path to verify.")
parser.add_argument("--pymol-exe", help="Explicit PyMOL executable path.")
parser.add_argument("--timeout", type=int, default=180, help="Timeout in seconds.")
parser.add_argument("--self-test", action="store_true", help="Render a tiny test image.")
args = parser.parse_args()
pymol = find_pymol(args.pymol_exe)
tempdir: tempfile.TemporaryDirectory[str] | None = None
if args.self_test:
tempdir = tempfile.TemporaryDirectory(prefix="pymol-render-test-")
root = Path(tempdir.name)
output = Path(args.output) if args.output else root / "self_test.png"
pml = root / "self_test.pml"
write_self_test_pml(pml, output)
else:
if not args.pml:
parser.error("--pml is required unless --self-test is used")
pml = Path(args.pml).resolve()
output = Path(args.output).resolve() if args.output else None
if not pml.exists():
raise FileNotFoundError(f"PML script not found: {pml}")
cmd = [pymol, "-cq", str(pml)]
result = subprocess.run(cmd, text=True, capture_output=True, timeout=args.timeout)
if result.stdout:
sys.stdout.write(result.stdout)
if result.stderr:
sys.stderr.write(result.stderr)
if result.returncode != 0:
return result.returncode
if output:
if not output.exists():
sys.stderr.write(f"Expected output was not created: {output}\n")
return 2
if output.stat().st_size == 0:
sys.stderr.write(f"Expected output is empty: {output}\n")
return 3
print(f"Rendered: {output} ({output.stat().st_size} bytes)")
if tempdir is not None:
tempdir.cleanup()
return 0
if __name__ == "__main__":
raise SystemExit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |