Pymol

From MarceloClaro/OpenCode_Ecosystem · View interactive version

Pymol is an AI agent skill from the GitHub repository MarceloClaro/OpenCode_Ecosystem. 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 ana

How to use this skill

Skill file

PyMOL

Prerequisites

  1. uv: Read the uv skill and follow its Setup instructions to ensure

uv is installed and on PATH.

  1. 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:

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

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

cmd.draw() or cmd.ray() with hardware acceleration — OSMesa does not

support it. Set environment variable PYOPENGL_PLATFORM=osmesa for headless

rendering.

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

causes the process to stop responding.

initialization sequence. from pymol import cmd must come after

finish_launching(), not before.

selection syntax, common commands, and gotchas.

you MUST verify that the requested structure file actually exists on the

host machine.

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.

output.

Quick Start

boilerplate and PEP 0723 header.

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:

coloring

focus

contacts

Interpreting Output

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

explore, rotate, or modify the visualization.

re-run.

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.