From cbdb84cb4b3c4d3e04f4143dc13e68748a33b2eb Mon Sep 17 00:00:00 2001 From: jvogan <6239693+jvogan@users.noreply.github.com> Date: Fri, 17 Jul 2026 12:42:50 -0700 Subject: [PATCH] Add reproducible structural visualization workflows --- .github/workflows/ci.yml | 4 + CHANGELOG.md | 9 + CONTRIBUTING.md | 1 + Makefile | 7 +- README.md | 37 + SKILL.md | 722 +++++------------- references/chimerax.md | 14 +- references/workflows.md | 224 ++++++ scripts/annotation_figure.py | 197 +++++ scripts/assembly_explorer.py | 132 ++++ scripts/chemical_site.py | 226 ++++++ scripts/chimerax_rest.py | 6 +- scripts/cryoem_workflow.py | 221 ++++++ scripts/electrostatics_workflow.py | 113 +++ scripts/ensemble_report.py | 210 +++++ scripts/interface_story.py | 192 +++++ scripts/model_quality.py | 150 +++- scripts/pae_report.py | 75 +- scripts/pocket_tunnel.py | 210 +++++ scripts/proteus.py | 66 ++ scripts/proteus_batch.py | 23 + scripts/proteus_common.py | 345 +++++++++ scripts/proteus_doctor.py | 32 + scripts/residue_story.py | 167 ++++ scripts/restraint_report.py | 217 ++++++ scripts/scene_figure.py | 296 +++++++ scripts/state_compare.py | 173 +++++ scripts/structure_info.py | 37 +- scripts/structure_qc.py | 486 ++++++++++++ scripts/sync_skill_package.py | 78 ++ scripts/visual_common.py | 248 ++++++ skills/proteus/SKILL.md | 722 +++++------------- skills/proteus/agents/openai.yaml | 7 +- skills/proteus/references/chimerax.md | 14 +- skills/proteus/references/workflows.md | 224 ++++++ skills/proteus/scripts/annotation_figure.py | 197 +++++ skills/proteus/scripts/assembly_explorer.py | 132 ++++ skills/proteus/scripts/chemical_site.py | 226 ++++++ skills/proteus/scripts/chimerax_rest.py | 6 +- skills/proteus/scripts/cryoem_workflow.py | 221 ++++++ .../scripts/electrostatics_workflow.py | 113 +++ skills/proteus/scripts/ensemble_report.py | 210 +++++ skills/proteus/scripts/interface_story.py | 192 +++++ skills/proteus/scripts/model_quality.py | 150 +++- skills/proteus/scripts/pae_report.py | 75 +- skills/proteus/scripts/pocket_tunnel.py | 210 +++++ skills/proteus/scripts/proteus.py | 66 ++ skills/proteus/scripts/proteus_batch.py | 23 + skills/proteus/scripts/proteus_common.py | 345 +++++++++ skills/proteus/scripts/proteus_doctor.py | 32 + skills/proteus/scripts/residue_story.py | 167 ++++ skills/proteus/scripts/restraint_report.py | 217 ++++++ skills/proteus/scripts/scene_figure.py | 296 +++++++ skills/proteus/scripts/state_compare.py | 173 +++++ skills/proteus/scripts/structure_info.py | 37 +- skills/proteus/scripts/structure_qc.py | 486 ++++++++++++ skills/proteus/scripts/visual_common.py | 248 ++++++ tests/test_workflows.py | 220 ++++++ 58 files changed, 8802 insertions(+), 1125 deletions(-) create mode 100644 references/workflows.md create mode 100644 scripts/annotation_figure.py create mode 100644 scripts/assembly_explorer.py create mode 100644 scripts/chemical_site.py create mode 100644 scripts/cryoem_workflow.py create mode 100644 scripts/electrostatics_workflow.py create mode 100644 scripts/ensemble_report.py create mode 100644 scripts/interface_story.py create mode 100644 scripts/pocket_tunnel.py create mode 100644 scripts/proteus.py create mode 100644 scripts/proteus_common.py create mode 100644 scripts/residue_story.py create mode 100644 scripts/restraint_report.py create mode 100644 scripts/scene_figure.py create mode 100644 scripts/state_compare.py create mode 100644 scripts/structure_qc.py create mode 100644 scripts/sync_skill_package.py create mode 100644 scripts/visual_common.py create mode 100644 skills/proteus/references/workflows.md create mode 100644 skills/proteus/scripts/annotation_figure.py create mode 100644 skills/proteus/scripts/assembly_explorer.py create mode 100644 skills/proteus/scripts/chemical_site.py create mode 100644 skills/proteus/scripts/cryoem_workflow.py create mode 100644 skills/proteus/scripts/electrostatics_workflow.py create mode 100644 skills/proteus/scripts/ensemble_report.py create mode 100644 skills/proteus/scripts/interface_story.py create mode 100644 skills/proteus/scripts/pocket_tunnel.py create mode 100644 skills/proteus/scripts/proteus.py create mode 100644 skills/proteus/scripts/proteus_common.py create mode 100644 skills/proteus/scripts/residue_story.py create mode 100644 skills/proteus/scripts/restraint_report.py create mode 100644 skills/proteus/scripts/scene_figure.py create mode 100644 skills/proteus/scripts/state_compare.py create mode 100644 skills/proteus/scripts/structure_qc.py create mode 100644 skills/proteus/scripts/visual_common.py create mode 100644 tests/test_workflows.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd4029c..2c83c82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,9 +31,13 @@ jobs: - name: Run tests run: python -m unittest -v + - name: Verify installable skill package parity + run: python scripts/sync_skill_package.py --check --json + - name: JSON smoke checks run: | python scripts/proteus_doctor.py --json | python -m json.tool >/dev/null python scripts/resolve_structure.py tests/fixtures/tiny.pdb --json | python -m json.tool >/dev/null python scripts/pae_report.py tests/fixtures/tiny_pae.json --json | python -m json.tool >/dev/null python scripts/pocket_report.py tests/fixtures/tiny.pdb --json | python -m json.tool >/dev/null + python scripts/proteus.py qc tests/fixtures/tiny.pdb --json | python -m json.tool >/dev/null diff --git a/CHANGELOG.md b/CHANGELOG.md index acf99d6..83483b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## Unreleased +- Added a unified `proteus.py` interface for coordinate QC, declarative + PyMOL/ChimeraX figures, state and interface comparisons, residue stories, + annotation overlays, distance restraints, assemblies, cryo-EM review, + ensembles, electrostatics, pocket detection, and chemical-site triage. +- Added replayable script/session artifacts, privacy-safe provenance and + execution summaries, package-parity checks, and representative real-tool + validation for PyMOL and ChimeraX workflows. +- Added chain-aware PAE summaries, per-residue AlphaFold confidence reporting, + and optional local DockQ and Foldseek adapters. - Added a `density` subcommand to `pymol_agent.py`: render a model in cryo-EM density (real `--map` or `--simulate`d gaussian density), with the mesh carved around the model or a `--residue` selection and the contour level taken from diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4cb3db0..1f49342 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,6 +15,7 @@ small tests that keep agents from repeating common mistakes. ```bash make test +make package-check python3 scripts/proteus_doctor.py --json ``` diff --git a/Makefile b/Makefile index 66395dd..012fe03 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,13 @@ -.PHONY: test release-check +.PHONY: test package-check verify release-check test: python3 -m unittest -v +package-check: + python3 scripts/sync_skill_package.py --check --json + +verify: test package-check release-check + # Pre-publish hygiene sweep: no tracked structures/maps/media/secrets, no large # files, no obvious secret strings. Run before pushing public changes. release-check: diff --git a/README.md b/README.md index 6c43b64..09b1e3f 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,9 @@ Rosetta-oriented protein design guidance without building a custom plugin. cryo-EM workflows. - **Produces outputs agents can chain.** Reports use machine-readable JSON for parallel runs, CI checks, notebooks, and downstream analysis. +- **Keeps local research local by default.** Coordinate files, maps, annotations, + and restraints are processed on the machine unless a public identifier is + explicitly resolved through a public data source. ## What It Provides @@ -79,6 +82,14 @@ Rosetta-oriented protein design guidance without building a custom plugin. - Rosetta/PyRosetta patterns plus ML alternatives (ProteinMPNN, ESM2) - Zero-dependency PDB file inspector (`pdb_info.py` — stdlib only) - Structured JSON output from analysis helper scripts, safe for parallel runs +- A unified `proteus.py` workflow interface with coordinate preflight, declarative + PyMOL/ChimeraX figures, state comparisons, residue and interface stories, + annotation overlays, restraint checks, assembly exploration, cryo-EM review, + ensemble analysis, electrostatics, pocket detection, and chemical-site triage +- Replayable `.pml`/`.cxc` scripts and saved `.pse`/`.cxs` sessions for audit and + human handoff +- Optional local DockQ, Foldseek, fpocket, P2Rank, PDB2PQR, and APBS capability + detection without automatic installation or structure uploads ## Agent Prompts That Work @@ -91,6 +102,8 @@ Render the 1HSG binding pocket around indinavir in PyMOL and save a clean PNG. Compare AF-P04637-F1 against an experimental p53 structure and report RMSD plus high-deviation residues. Run a ChimeraX hydrogen-bond and SASA analysis for this protein-protein interface. Check whether 4HHB has validation red flags before using it as a reference structure. +Build an apo/holo comparison with aligned PyMOL views and report contacts gained or lost. +Inspect this cryo-EM model/map pair at several contour levels and save a ChimeraX session. ``` ## Capabilities Matrix @@ -104,6 +117,9 @@ Check whether 4HHB has validation red flags before using it as a reference struc | Headless structure rendering | no | yes | limited | no | no | | SASA, H-bonds, contacts, alignment | partial | partial | yes | no | optional | | Protein design/scoring guidance | docs | optional | optional | optional | yes | +| Reproducible figure/scene manifests | scripts | yes | yes | no | no | +| Cryo-EM map/model review | map stats | limited | yes | EMDB optional | no | +| Ensemble, restraint, and annotation reports | yes | optional | optional | no | no | ## Generated Outputs @@ -127,6 +143,7 @@ make test python3 scripts/proteus_doctor.py --json python3 scripts/resolve_structure.py TP53 --no-download --json python3 scripts/pocket_report.py tests/fixtures/tiny.pdb --json +python3 scripts/proteus.py qc tests/fixtures/tiny.pdb --json ``` These commands require only Python 3.10+. Install PyMOL or ChimeraX later when @@ -174,6 +191,20 @@ Analyze the hydrogen bonds at a protein-protein interface in ChimeraX. The helper scripts also work standalone: ```bash +python3 scripts/proteus.py --help # unified workflow entry point +python3 scripts/proteus.py qc structure.cif --json # coordinate preflight/QC +python3 scripts/proteus.py figure scene.json --execute # manifest -> figure + session +python3 scripts/proteus.py compare apo.pdb holo.pdb --ligand ATP # aligned state comparison +python3 scripts/proteus.py residue model.cif A:42 --execute # residue-centered story +python3 scripts/proteus.py interface complex.cif --chains A,B # interface analysis + figures +python3 scripts/proteus.py annotate model.pdb scores.csv # residue score overlay +python3 scripts/proteus.py restraints model.pdb restraints.csv # distance-restraint report +python3 scripts/proteus.py assembly 4HHB --assembly 1 # ASU/assembly/crystal views +python3 scripts/proteus.py cryoem model.cif map.mrc --resolution 3.2 # contour sweep/map review +python3 scripts/proteus.py ensemble models.pdb # multi-model RMSF summary +python3 scripts/proteus.py electrostatics model.pdb # qualitative Coulombic surface +python3 scripts/proteus.py pockets model.pdb --detector auto # local fpocket/P2Rank workflow +python3 scripts/proteus.py chemical-site complex.cif --component ZN:A:501 python3 scripts/pdb_info.py structure.pdb # zero-dep PDB inspection python3 scripts/structure_info.py structure.cif --json # PDB/mmCIF inspection python3 scripts/fetch_pdb.py 4HHB --json # RCSB PDB fetch @@ -202,6 +233,8 @@ python3 scripts/validation_report.py 4HHB --json # wwPDB valid python3 scripts/pocket_report.py tests/fixtures/tiny.cif --json # ligand-pocket contacts python3 scripts/interface_report.py 1BRS --chains A,D --json # protein-protein interface residues python3 scripts/model_quality.py detect --json # optional quality tool detection +python3 scripts/model_quality.py dockq model.pdb native.pdb --json # DockQ when installed +python3 scripts/model_quality.py foldseek query.pdb targets --json # local Foldseek search python3 scripts/resolve_structure.py TP53 --json # one-command resolver python3 scripts/pymol_agent.py render structure.pdb output.png # headless render python3 scripts/pymol_agent.py pocket 1HSG.pdb pocket.png --label # annotated binding-pocket figure @@ -231,6 +264,7 @@ proteus/ │ ├── file-formats.md │ ├── prediction-models.md │ ├── pymol.md +│ ├── workflows.md │ └── rosetta.md └── scripts/ # Agent helper scripts (all stdlib-only) ├── add_helix_records.py @@ -250,6 +284,9 @@ proteus/ ├── ligand_extract.py ├── map_info.py ├── model_quality.py + ├── proteus.py + ├── structure_qc.py + ├── scene_figure.py ├── mutation_triage.py ├── pae_report.py ├── pdb_info.py diff --git a/SKILL.md b/SKILL.md index 60bb956..2cb37f9 100644 --- a/SKILL.md +++ b/SKILL.md @@ -2,553 +2,213 @@ name: proteus description: > Use this skill when the user asks you to work with protein structures, - molecular visualization, or structural biology tools. TRIGGER when: - the user mentions PyMOL, ChimeraX, AlphaFold, Rosetta, PyRosetta, - UniProt, RCSB PDB, PDBe, PDB files, protein structures, molecular - rendering, pLDDT, RMSD, structure alignment, binding pockets, - drug-target analysis, cryo-EM density maps, homology modeling, or - protein design. Also trigger when the user opens/loads .pdb, .cif, - .mmcif, .sdf, or .mol2 files, or .mrc density maps (see - references/chimerax.md for cryo-EM workflows). - DO NOT TRIGGER for: general biology questions with no structural component, - bioinformatics sequence-only tasks (BLAST, MSA), or genomics/transcriptomics. + molecular visualization, or structural biology tools. Trigger for PyMOL, + ChimeraX, AlphaFold, Rosetta/PyRosetta, UniProt, RCSB PDB, PDBe, PDB/mmCIF + files, molecular rendering, pLDDT, PAE, RMSD, structure alignment, binding + pockets, interfaces, variants, docking context, cryo-EM maps, ensembles, + restraints, or protein design. Also trigger when the user opens .pdb, .cif, + .mmcif, .sdf, .mol2, .mrc, .map, or .ccp4 files. Do not trigger for general + biology with no structural component, sequence-only bioinformatics, genomics, + or transcriptomics. --- # Proteus — Structural Biology Agent Skill -You are an AI agent driving structural biology tools programmatically. -This skill teaches you how to control PyMOL, ChimeraX, AlphaFold DB, -and Rosetta/PyRosetta from the command line — including the non-obvious -gotchas that will otherwise cost hours of debugging. - -## Tool Detection - -Before doing anything, detect what's installed: - -```python -import shutil, subprocess - -PYMOL = shutil.which("pymol") -if not PYMOL: - # macOS common locations - import os - for p in ["/Applications/PyMOL.app/Contents/bin/pymol", - os.path.expanduser("~/Applications/PyMOL.app/Contents/bin/pymol")]: - if os.path.isfile(p): - PYMOL = p - break - -CHIMERAX = shutil.which("ChimeraX") or shutil.which("chimerax") -if not CHIMERAX: - import glob - hits = glob.glob("/Applications/ChimeraX*.app/Contents/bin/ChimeraX") - if hits: - CHIMERAX = sorted(hits)[-1] # latest version -``` - -If neither is found, do not guess paths. Continue with zero-dependency workflows -(`scripts/pdb_info.py`, AlphaFold metadata fetches, file inspection) when they -fit the task; otherwise tell the user what to install and stop. - -Run helper scripts from the repo or skill root with Python 3.10+: +Use Proteus to turn structural-biology questions into inspectable analyses, +figures, sessions, and replayable PyMOL (`.pml`) or ChimeraX (`.cxc`) commands. +Prefer the included helper workflows over improvised command strings. + +## Safety and Scientific Ground Rules + +- Treat local structures, maps, annotations, sequences, and restraints as private + unless the user identifies them as public. Do not upload private or unpublished + inputs to a web service without explicit authorization. +- Public identifiers such as PDB, EMDB, UniProt, and AlphaFold DB accessions may + be resolved through their public APIs when network access is needed. Say which + source was used and preserve provenance. +- Keep secrets, credentials, arbitrary absolute paths, raw private data, and + machine-specific details out of reports, logs, manifests, and repository files. +- Never use a protein-structure result as the sole basis for a clinical, safety, + efficacy, or patient-specific decision. Flag medical or biosafety implications + and recommend appropriate expert review. +- Separate observation from inference. A short distance is a geometric contact, + not proof of a hydrogen bond, energetic hotspot, catalytic role, binding + affinity, biological assembly, or causal variant effect. +- State uncertainty from resolution, missing atoms/residues, alternate + conformers, occupancy, protonation, tautomerism, model confidence, chain + mapping, alignment coverage, map processing, and assembly choice when relevant. +- Do not overwrite source coordinates. Write generated artifacts to a dedicated + output directory and keep scripts/sessions so the result can be audited. + +## Start Here + +Run scripts from the skill or repository root with Python 3.10+. ```bash -cd -python3 scripts/proteus_doctor.py --network --json +python3 scripts/proteus.py --help +python3 scripts/proteus.py qc structure.cif --json ``` -On macOS, `/usr/bin/python3` may be 3.9 and too old for several helpers. Use a -Homebrew, conda, pyenv, or system Python 3.10+ interpreter when the doctor marks -Python as too old. Hardened launchers that set `PYTHONSAFEPATH=1` are supported: -the helper entrypoints add their bundled `scripts/` directory before importing -sibling modules. +Do not run network checks merely because the skill was invoked. Use +`scripts/proteus_doctor.py --json` for local readiness, and add `--network` only +when the task actually needs public APIs. -If PyMOL or ChimeraX are installed as macOS apps, the doctor can often find their -app-bundle binaries even when they are not on `PATH`. For direct shell use, add -the actual app `Contents/bin` directory to `PATH`. Install `ffmpeg` for spin -movies. Confirm PyMOL is licensed before publishing renders because evaluation -builds can watermark output. +Before using a helper, run its `--help`. Treat helpers as black boxes unless +debugging or changing the implementation. -## Tool Selection — When to Use What - -| Task | Best Tool | Why | -|---|---|---| -| Headless rendering (no display) | **PyMOL** | Software ray tracer works fully headless | -| Interactive demo with live GUI | **ChimeraX REST API** | HTTP control of running GUI session | -| H-bonds, SASA, clashes, contacts | **ChimeraX** | Built-in analysis commands, even in `--nogui` | -| Structure alignment + RMSD | **Either** | PyMOL `cealign` or ChimeraX `matchmaker` | -| AlphaFold confidence analysis | **PyMOL** + AlphaFold API | Fetch prediction, color by pLDDT, render headless | -| Experimental PDB download | **`fetch_pdb.py`** | RCSB metadata + coordinates | -| Structure landscape search | **`pdb_search.py`** | Enumerate PDB hits by text and/or UniProt accession | -| Structure candidate ranking | **`pdb_select.py`** | Rank hits by method, resolution, validation, assemblies, and ligands | -| Protein name -> accession | **`uniprot_lookup.py`** | Resolve names/genes before AlphaFold fetch | -| PDB/mmCIF preflight | **`structure_info.py`** | Zero-dependency file inspection | -| Target dossier/report | **`target_dossier.py`** | Markdown + JSON provenance for targets, with opt-in local analyses | -| Structural mutation triage | **`mutation_triage.py`** | Local variant proximity to ligands, interfaces, contacts, and PAE context | -| Docking box prep | **`docking_box.py`** | Ligand-centered Vina box plus optional docking-tool detection | -| Cryo-EM density map visualization | **ChimeraX REST API** | Volume rendering requires GPU/display | -| Quick legacy PDB inspection | **`pdb_info.py` script** | Backward-compatible PDB-only inspector | -| KRAS G12C dossier | **`kras_dossier.py`** | End-to-end workflow with public structures, analyses, and figures | -| Protein design / scoring | **Rosetta/PyRosetta** | Or ML alternatives (ProteinMPNN, RFdiffusion) | - -**Key architectural insight:** ChimeraX `--nogui` mode has NO OpenGL context on macOS. -It can run analysis commands (H-bonds, SASA, matchmaker, info) but CANNOT render images. -For ChimeraX rendering, you must use the REST API approach with a running GUI instance. +## Workflow Routing -## Reading Guide - -Load reference files on demand — don't read all of them upfront: - -| Working with... | Read this file | +| User goal | Preferred workflow | |---|---| -| PyMOL (any task) | `references/pymol.md` | -| ChimeraX (any task) | `references/chimerax.md` | -| AlphaFold DB predictions | `references/alphafold.md` | -| PDB/UniProt/PDBe/RCSB data lookup | `references/data-sources.md` | -| File format choices (.pdb, .cif, .sdf, .mrc) | `references/file-formats.md` | -| Prediction models beyond AlphaFold DB | `references/prediction-models.md` | -| Rosetta / protein design | `references/rosetta.md` | - -## Agent Helper Scripts - -These scripts handle the hard parts of tool communication. - -**IMPORTANT: Always run `python3 scripts/