Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
google-deepmind avatar

Pymol

  • 1.3k installs
  • 2.6k repo stars
  • Updated July 7, 2026
  • google-deepmind/science-skills

pymol is a Google DeepMind agent skill that runs headless PyMOL scripts to render molecular structures and export PNG images for developers and researchers who need automated protein visualization without a GPU or GUI di

About

pymol is an agent skill providing PyMOL quick-reference patterns for headless molecular visualization. Every script must start with a mandatory initialization sequence—import pymol, set pymol_argv to ["pymol", "-cq"] for command-line quiet mode, then call pymol.finish_launching() before importing cmd; reversing this order crashes the session. PyMOL runs with OSMesa software rendering—no GPU or X display available. Use cmd.png(path, width, height, dpi) for standard output; cmd.ray() works for ray-traced quality but is slow. cmd.draw() must never be used because it requires hardware OpenGL. Researchers and computational biologists reach for pymol when agents need to programmatically render PDB structures, generate publication figures, or batch-export molecular images in CI or headless server environments.

  • Mandatory init sequence: import pymol, set pymol_argv to ["pymol", "-cq"], finish_launching(), then from pymol import cm
  • OSMesa software rendering — no GPU or X display; prefer cmd.png over cmd.draw or hardware OpenGL
  • Selection cheatsheet for chain, resi ranges/lists, resn, name CA, and ss h/s/l
  • Ray tracing via cmd.ray when quality matters; cmd.set ray_opaque_background for white backgrounds

Pymol by the numbers

  • 1,290 all-time installs (skills.sh)
  • +168 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #250 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/google-deepmind/science-skills --skill pymol

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.3k
repo stars2.6k
Security audit3 / 3 scanners passed
Last updatedJuly 7, 2026
Repositorygoogle-deepmind/science-skills

How do you render molecules headlessly with PyMOL?

Run headless PyMOL scripts from an agent to render molecular structures and export PNGs without a GPU or GUI.

Who is it for?

Computational biologists and researchers who need automated PyMOL molecular rendering on headless servers without GPU or X display.

Skip if: Interactive molecular modeling sessions requiring GUI manipulation or GPU-accelerated real-time OpenGL rendering with cmd.draw().

When should I use this skill?

An agent must render PDB structures, export molecular PNG figures, or run PyMOL scripts in headless CI or server environments.

What you get

PNG molecular structure images exported via cmd.png or cmd.ray from headless PyMOL scripts.

  • PNG molecular renders
  • Headless PyMOL scripts

Files

SKILL.mdMarkdownGitHub ↗

PyMOL

Prerequisites

1. `uv`: Read the uv skill and follow its Setup instructions to ensure uv is installed and on PATH. 2. User Notification: If LICENSE_NOTIFICATION.txt does not already exist in this skill directory then (1) prominently notify the user to check the license at https://www.pymol.org/, then (2) create the file recording the notification text and timestamp.

Overview

All PyMOL commands run on the host via uv with OSMesa software rendering — no GPU, display, or X server is needed. Structure files must be downloaded to the host before running PyMOL.

Do NOT use when:

  • The user wants to run AlphaFold predictions.
  • The user wants docking or molecular dynamics simulations.
  • The user only has a sequence and no structure file — fetch the structure

first. Check if any other installed skills can retrieve structures from the PDB or AlphaFold Database before proceeding.

Setup (Agent Instructions)

Ensure that uv is installed on the host system. The PyMOL scripts use PEP 0723 headers to declare their dependencies, and uv run will automatically handle installing them (including pymol-open-source-whl) when the script is executed.

Core Rules

  • Output paths must be absolute or relative to the user's project root.

Always run PyMOL scripts from the user's project directory.

  • Software rendering only. Use cmd.png() for output. Never use

cmd.draw() or cmd.ray() with hardware acceleration — OSMesa does not support it. Set environment variable PYOPENGL_PLATFORM=osmesa for headless rendering.

  • Always save a `.pse` session file alongside any PNG output. This lets

the user open the session in their local PyMOL for further inspection.

  • Always call `cmd.quit()` at the end of every PyMOL script. Omitting it

causes the process to stop responding.

  • Init boilerplate is mandatory. Every PyMOL script must begin with the

initialization sequence. from pymol import cmd must come after finish_launching(), not before.

  • See references/PYMOL_REFERENCE.md for

selection syntax, common commands, and gotchas.

  • Pre-Flight File Check: Before writing the PyMOL script or running it,

you MUST verify that the requested structure file actually exists on the host machine.

  • Verify Structure Load: After loading a structure with cmd.load(),

always verify it succeeded by checking cmd.count_atoms("all"). If the result is 0, print an error to stdout and call cmd.quit() immediately.

  • Notification: If this skill is used, ensure this is mentioned in the

output.

Quick Start

  • Ensure structure files are downloaded to a directory in the user's project.
  • Write a PyMOL Python script (e.g., render.py) with the required init

boilerplate and PEP 0723 header.

  • Run it via uv run: bash uv run render.py

Minimal example script (render.py)

# /// script
# requires-python = ">=3.10, <3.13"
# dependencies = [
#     "pymol-open-source-whl",
# ]
# ///

import os
import sys

# Set environment variable for headless rendering
os.environ["PYOPENGL_PLATFORM"] = "osmesa"

import pymol # pytype: disable=import-error
pymol.pymol_argv = ["pymol", "-cq"]
pymol.finish_launching()

from pymol import cmd # pytype: disable=import-error

cmd.load("AF-P00520-F1-model_v4.cif", "structure")
cmd.show("cartoon")
cmd.color("green", "ss h")
cmd.color("yellow", "ss s")
cmd.color("gray", "ss l+''")
cmd.orient()
cmd.set("ray_opaque_background", 1)
cmd.png("output/render.png", width=1200, height=900, dpi=150)
cmd.save("output/session.pse")
cmd.quit()

Common Recipes

See references/RECIPES.md for complete, copy-paste ready recipes. Available recipes:

  • Cartoon with secondary structure coloring — basic helix/sheet/loop

coloring

  • B-factor (pLDDT) coloring — continuous spectrum coloring by B-factor
  • AlphaFold pLDDT coloring — canonical threshold-based confidence colors
  • Highlight specific residues — show active site or key residues as sticks
  • Surface rendering — transparent surface over cartoon
  • Electrostatic surface rendering — vacuum electrostatics (qualitative)
  • Multi-chain complex colors — automatic per-chain coloring
  • B-factor putty analysis — tube width proportional to flexibility
  • Cavity and pocket visualization — surface cavity detection with ligand

focus

  • Multi-structure batch rendering — render a directory of structures
  • Measure distance between residues — CA–CA distance with labels
  • Zoom into binding pocket — simple pocket focus
  • Protein-ligand interaction — ligand isolation, styled rendering, polar

contacts

  • Two-structure superposition with RMSD — align/cealign with auto-fallback
  • In silico mutagenesis — mutate residues with the mutagenesis wizard
  • Load and modify an existing session — re-open a .pse file

Interpreting Output

  • The output/ directory contains PNG images and a .pse session file.
  • Any measurements or metrics (distances, RMSD, atom counts) are printed to

stdout by the PyMOL script. Report these values to the user.

  • Present PNG images to the user and describe the visualization.
  • Tell the user they can open the .pse file in their local PyMOL to further

explore, rotate, or modify the visualization.

  • If the user wants modifications, load the saved .pse in a new script and

re-run.

  • Large sessions with surfaces can exceed the --max_output_mb limit (default

500 MB). Increase it with --max_output_mb=1000 if needed.

Related skills

How it compares

Use pymol for scripted PyMOL PNG export on headless servers; use ChimeraX or interactive PyMOL GUI for manual molecular exploration.

FAQ

What is the required PyMOL headless initialization?

pymol requires every script to start with import pymol, set pymol_argv to ["pymol", "-cq"], call pymol.finish_launching(), then import cmd. Reversing import and finish_launching() crashes the session.

Can pymol use GPU rendering headlessly?

pymol runs PyMOL with OSMesa software rendering—no GPU or X display. Use cmd.png() for output or slow cmd.ray() for ray-traced quality. cmd.draw() requires hardware OpenGL and must not be used.

Is Pymol safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Data Science & MLresearchautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.