pymol
google-deepmind/science-skills
Visualize, analyze, and render protein and molecular structures using PyMOL.
What is pymol?
PyMOL is a molecular visualization tool for creating images of protein structures, performing structural alignments, measuring distances, and analyzing protein-ligand interactions. Use it when you need to visualize 3D protein structures, highlight binding sites, or color structures by properties like B-factor or pLDDT confidence scores.
- Create high-quality PNG renders of protein and molecular structures
- Perform structural alignments and superposition with RMSD calculation
- Measure distances and contacts between residues or atoms
- Highlight and visualize binding sites, active sites, and specific residues
- Color structures by B-factor, pLDDT confidence, secondary structure, or per-chain
- Render surfaces, electrostatic surfaces, and cavity/pocket visualizations
How to install pymol
npx skills add https://github.com/google-deepmind/science-skills --skill pymol- uv must be installed and on PATH (see uv skill)
- Structure file (PDB, CIF, or similar) must be downloaded to the host machine before running PyMOL
- PyMOL license check: if .licenses/pymol_LICENSE.txt does not exist, user must review the license at https://www.pymol.org/
How to use pymol
- 1.Download or obtain the protein structure file (PDB, CIF, or mmCIF format) and place it in your project directory
- 2.Write a PyMOL Python script with the PEP 0723 header and initialization boilerplate (see minimal example in skill documentation)
- 3.Verify the structure file exists on the host machine before running
- 4.Execute the script using `uv run script_name.py` from your project root directory
- 5.Check the output/ directory for generated PNG images and .pse session files
- 6.Open the .pse session file in local PyMOL for interactive exploration and further modifications
Use cases
- Render publication-quality images of AlphaFold predictions or experimental protein structures
- Visualize protein-ligand interactions and binding pockets for drug discovery analysis
- Compare two protein structures via superposition to identify structural differences
- Analyze protein flexibility by coloring by B-factor or displaying B-factor putty tubes
- Create multi-chain complex visualizations with automatic per-chain coloring
- Structural biologists and computational biologists
- Biochemists analyzing protein structures and interactions
- Drug discovery researchers visualizing binding sites
- Students learning protein structure visualization
- Researchers working with AlphaFold predictions or PDB structures
pymol FAQ
No. PyMOL runs headless on the host using OSMesa software rendering, requiring no GPU, X server, or display. Set PYOPENGL_PLATFORM=osmesa for headless rendering.
PyMOL supports PDB, CIF, mmCIF, and other standard molecular structure formats. Download the structure file to your project directory before running PyMOL.
No. PyMOL is for visualization and analysis only. Do not use it for docking, molecular dynamics simulations, or AlphaFold predictions—use other specialized tools for those tasks.
Save a .pse session file alongside PNG output. Load the .pse in a new PyMOL script, make modifications, and re-run to generate updated images.
Verify the file exists and is in a supported format. The skill includes a pre-flight file check and will verify the structure loaded by checking atom count. If atom count is 0, an error is printed and the script exits.
Full instructions (SKILL.md)
Source of truth, from google-deepmind/science-skills.
name: pymol description: > Visualize, analyze, and render protein and molecular structures using PyMOL. Use when the user wants to create images of protein structures, perform structural alignments or superposition, measure distances or contacts, highlight binding sites or active site residues, color by B-factor/pLDDT, or analyze protein-ligand interactions. Do not use for docking, molecular dynamics, or sequence-only analysis.
PyMOL
Prerequisites
uv: Read theuvskill and follow its Setup instructions to ensureuvis installed and on PATH.- User Notification: If .licenses/pymol_LICENSE.txt does not already exist in the workspace root 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 usecmd.draw()orcmd.ray()with hardware acceleration — OSMesa does not support it. Set environment variablePYOPENGL_PLATFORM=osmesafor headless rendering. - Always save a
.psesession 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 cmdmust come afterfinish_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 checkingcmd.count_atoms("all"). If the result is 0, print an error to stdout and callcmd.quit()immediately. - Auto-detect Alpha-Carbon Trace: For a cartoon representation your
PyMOL scripts should automatically detect if the structure is an
alpha-carbon trace (
cmd.count_atoms("name CA") == cmd.count_atoms("all")), then you MUST follow the Alpha carbon trace cartoon recipe. - 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
- Alpha carbon trace cartoon — force cartoon representation for CA-only structures
- 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
.psefile
Interpreting Output
- The
output/directory contains PNG images and a.psesession 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
.psefile in their local PyMOL to further explore, rotate, or modify the visualization. - If the user wants modifications, load the saved
.psein a new script and re-run. - Large sessions with surfaces can exceed the
--max_output_mblimit (default 500 MB). Increase it with--max_output_mb=1000if needed.
Related skills
More from google-deepmind/science-skills and the wider catalog.

quickgo-database
Query Gene Ontology and functional annotations via QuickGO REST API to map genes to biological processes and molecular functions.

reactome-database
Query Reactome pathway database for enrichment analysis, identifier mapping, and pathway navigation.

scienceskillscommon
>-

string-database
Query protein-protein interactions, functional enrichment, and homology from the STRING database.

ucsc-conservation-and-tfbs
Fetch evolutionary conservation scores and transcription factor binding sites from UCSC Genome Browser.

unibind-database
Query experimentally validated transcription factor binding sites across 9 species from the UniBind database.