This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Agentic VMD Visualizer: a natural language interface for VMD (Visual Molecular Dynamics). A user uploads a PDB file and describes a visualization in plain English; an LLM converts that to a VMD Tcl script, VMD runs headlessly to render a snapshot, and the PNG is returned.
Two-process design:
-
FastAPI backend (
main.py) — exposes two endpoints:POST /vmd/run— accepts a natural languageprompt+pdb_file, calls the LLM to generate a Tcl script, runs VMD, returns an image URL.POST /vmd/run-tcl— accepts a rawtcl_script+pdb_file, skips the LLM, runs VMD directly.- Serves rendered PNGs from
./static/at/static.
-
Streamlit frontend (
streamlit_app.py) — sends multipart form requests to the FastAPI server athttp://127.0.0.1:8000. Shows the generated Tcl script in an editable text area so users can tweak and re-run without re-prompting.
LLM integration: Uses the Anthropic Python client with model claude-sonnet-4-6. API key is read from the ANTHROPIC_API_KEY environment variable.
VMD rendering pipeline:
- Write a
.tclfile to/tmp/that loads the PDB, appends the generated script, callsrender TachyonInternal <path>.tga, thenquit. - Execute
/Applications/VMD.app/Contents/vmd/vmd_MACOSXARM64 -dispdev text -e <script.tcl>. - Convert the
.tgaoutput to.pngvia Pillow (convert_tga_to_png). - Move the PNG to
./static/with a UUID filename.
Tcl script conventions (baked into the LLM system prompt):
- Always start with
delrep 0 topto remove the default representation. - Set
color Display Background white. - Turn off axes and depth cueing.
- Default drawing method is VDW; default coloring uses VMD numeric color codes (0=blue, 1=red, 2=gray, 3=orange, 4=yellow, 5=tan, 6=silver, 7=green, 8=white, 9=pink, 10=cyan).
Start the FastAPI backend:
uvicorn main:app --reloadStart the Streamlit frontend (in a separate terminal):
streamlit run streamlit_app.pyTest the backend directly:
# Natural language prompt endpoint
curl -X POST "http://127.0.0.1:8000/vmd/run" \
-F "prompt=Color chain A red in new ribbon representation and hide everything else" \
-F "pdb_file=@A1B1.pdb"ANTHROPIC_API_KEY— Anthropic API key (required)- VMD must be installed at
/Applications/VMD.app/(macOS ARM64 path hardcoded inmain.py:78)
main_app.py/app.py— older drafts;main.pyis the canonical backendtest_agent.ipynb— scratch notebook for exploring the OpenRouter APIA1B1.pdb— sample PDB file for manual testing