# Rfdiffusion

> Skill for de novo protein backbone generation with RFdiffusion from the Baker Lab (Institute for Protein Design). Use this skill when a user wants to design a new protein backbone from scratch, scaffold a functional motif into a new protein, design a protein binder against a target, generate symmetric oligomers (cyclic, dihedral, tetrahedral), redesign part of an existing structure via partial di…

- **Type:** Skill
- **Install:** `agentstack add skill-naity-fm4life-rfdiffusion`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [naity](https://agentstack.voostack.com/s/naity)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [naity](https://github.com/naity)
- **Source:** https://github.com/naity/FM4Life/tree/main/skills/rfdiffusion

## Install

```sh
agentstack add skill-naity-fm4life-rfdiffusion
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# RFdiffusion: De Novo Protein Backbone Generation

## Overview

RFdiffusion generates protein backbones via a denoising diffusion process. It starts from random noise and iteratively refines toward a plausible protein structure. It is the backbone generation half of the modern protein design pipeline:

```
RFdiffusion (backbone) → ProteinMPNN (sequence) → AlphaFold2 (validation)
```

**Core design modes:**
- **Unconditional generation** — design monomers of specified length
- **Motif scaffolding** — build a new protein around a fixed functional motif
- **Binder design** — create proteins that bind a target surface
- **Symmetric oligomers** — cyclic (Cn), dihedral (Dn), tetrahedral, octahedral, icosahedral
- **Partial diffusion** — diversify an existing backbone (keep fold, vary details)
- **Active site scaffolding** — design enzymes around catalytic residues
- **Cyclic peptides** — macrocyclic monomers and binders
- **Sequence inpainting** — redesign selected residues in context

## Installation

```bash
git clone https://github.com/RosettaCommons/RFdiffusion.git
cd RFdiffusion

# Create environment
conda env create -f env/SE3nv.yml
conda activate SE3nv

# Install SE3-Transformer
cd env/SE3Transformer
pip install --no-cache-dir -r requirements.txt
python setup.py install
cd ../..

# Install RFdiffusion
pip install -e .
```

### Download model weights

```bash
mkdir models && cd models
# Base (unconditional + motif scaffolding)
wget http://files.ipd.uw.edu/pub/RFdiffusion/6f5902ac237024bdd0c176cb93063dc4/Base_ckpt.pt
# Binder / PPI design
wget http://files.ipd.uw.edu/pub/RFdiffusion/e29311f6f1bf1af907f9ef9f44b8328b/Complex_base_ckpt.pt
# Active site scaffolding
wget http://files.ipd.uw.edu/pub/RFdiffusion/5532d2e1f3a4738decd58b19d633b3c3/ActiveSite_ckpt.pt
# Sequence inpainting
wget http://files.ipd.uw.edu/pub/RFdiffusion/74f51cfb8b440f50d70878e05361d8f0/InpaintSeq_ckpt.pt
# Epoch 8 (metal binding, symmetric oligomers)
wget http://files.ipd.uw.edu/pub/RFdiffusion/12fc204edeae5b57713c5ad7dcb97d39/Base_epoch8_ckpt.pt
```

Requirements: NVIDIA GPU with CUDA 11.1+, ~8 GB VRAM recommended.

## Model Checkpoints

| Checkpoint | Use case |
|---|---|
| `Base_ckpt.pt` | Unconditional monomers, motif scaffolding |
| `Complex_base_ckpt.pt` | Binder / PPI design |
| `Complex_Fold_base_ckpt.pt` | Binder design with fold conditioning |
| `InpaintSeq_ckpt.pt` | Sequence inpainting / redesign |
| `InpaintSeq_Fold_ckpt.pt` | Sequence inpainting with fold conditioning |
| `ActiveSite_ckpt.pt` | Enzyme active site scaffolding |
| `Base_epoch8_ckpt.pt` | Metal binding, symmetric oligomers |

## Contig Syntax (Critical)

The **contig string** tells RFdiffusion what to design and what to keep fixed. This is the most important concept.

- **Bare numbers** = residues to **design** (variable length range)
- **Chain-prefixed residues** = residues to **keep** from the input PDB
- `/` separates segments within a chain
- `/0` separates different chains

```
[150-150]                    ← unconditional: design exactly 150 residues
[100-200]                    ← unconditional: random length 100–200
[10-40/A10-25/30-40]         ← motif scaffolding: design, keep A10-25, design
[B1-100/0 70-100]            ← binder: keep target B1-100, design 70-100aa binder
[480-480]                    ← symmetric: total residues for C6 (480/6 = 80 per subunit)
```

## Core Workflows

### 1. Unconditional monomer

```bash
./scripts/run_inference.py \
  'contigmap.contigs=[100-200]' \
  inference.output_prefix=outputs/monomer \
  inference.num_designs=10
```

### 2. Motif scaffolding

Build a new protein around residues A163-181 from a known structure:

```bash
./scripts/run_inference.py \
  'contigmap.contigs=[10-40/A163-181/10-40]' \
  inference.input_pdb=input_pdbs/5TPN.pdb \
  inference.output_prefix=outputs/motif_scaffold \
  inference.num_designs=10
```

### 3. Binder design

Design a protein that binds to target chain A (keeping residues A1-150), with hotspot guidance:

```bash
./scripts/run_inference.py \
  'contigmap.contigs=[A1-150/0 70-100]' \
  inference.input_pdb=target.pdb \
  'ppi.hotspot_res=[A59,A83,A91]' \
  inference.output_prefix=outputs/binder \
  inference.num_designs=1000 \
  denoiser.noise_scale_ca=0 \
  denoiser.noise_scale_frame=0
```

**Binder design tips:**
- Generate 1,000–10,000 backbones
- Select 3–6 hotspot residues on the target surface
- Truncate large targets to ~200 residues around the interface
- Set noise scales to 0 for better quality
- Filter downstream with AF2: keep designs where `pAE_interaction < 10`

### 4. Partial diffusion (backbone diversification)

Add controlled noise to an existing structure, then denoise to generate variants:

```bash
./scripts/run_inference.py \
  'contigmap.contigs=[79-79]' \
  inference.input_pdb=input_pdbs/2KL8.pdb \
  diffuser.partial_T=10 \
  inference.output_prefix=outputs/partial_diff \
  inference.num_designs=10
```

**Important:** Contig length must exactly match the input PDB length for partial diffusion.

### 5. Symmetric oligomers

```bash
# C6 cyclic symmetry (80 residues per subunit × 6 = 480 total)
./scripts/run_inference.py --config-name=symmetry \
  inference.symmetry="C6" \
  'contigmap.contigs=[480-480]' \
  'potentials.guiding_potentials=["type:olig_contacts,weight_intra:1,weight_inter:0.1"]' \
  potentials.olig_intra_all=True \
  potentials.olig_inter_all=True \
  potentials.guide_scale=2.0 \
  potentials.guide_decay="quadratic" \
  inference.num_designs=10
```

Supported symmetries: `C2`–`C6`, `D2`–`D6`, `tetrahedral`, `octahedral`, `icosahedral`.

### 6. Active site scaffolding

```bash
./scripts/run_inference.py \
  'contigmap.contigs=[10-100/A1083/10-100/A1051/10-100/A1180/10-100]' \
  inference.input_pdb=input_pdbs/5an7.pdb \
  'potentials.guiding_potentials=["substrate_contacts:s=1,r_0=8,rep_r_0=5.0,rep_s=2,rep_r_min=1"]' \
  potentials.substrate=LLK \
  potentials.guide_scale=1 \
  inference.ckpt_override_path=models/ActiveSite_ckpt.pt \
  inference.num_designs=10
```

### 7. Cyclic peptides

```bash
./scripts/run_inference.py \
  'contigmap.contigs=[12-18]' \
  inference.cyclic=True \
  inference.cyc_chains=a \
  inference.output_prefix=outputs/cyclic_peptide \
  inference.num_designs=10
```

## Key Parameters

| Parameter | Default | Description |
|---|---|---|
| `inference.num_designs` | 10 | Number of backbones to generate |
| `inference.input_pdb` | null | Input PDB (null for unconditional) |
| `inference.output_prefix` | samples/design | Output path prefix |
| `inference.ckpt_override_path` | — | Override model checkpoint |
| `diffuser.T` | 50 | Diffusion timesteps (200 for max quality, 20 for speed) |
| `diffuser.partial_T` | null | Timesteps for partial diffusion |
| `denoiser.noise_scale_ca` | varies | Cα noise (0 for zero-noise inference) |
| `denoiser.noise_scale_frame` | varies | Frame noise (0 for zero-noise inference) |
| `ppi.hotspot_res` | null | Target residues for binding `[A30,A33,A34]` |
| `potentials.guide_scale` | 1.0 | Strength of guiding potentials |
| `potentials.guide_decay` | null | `"quadratic"` or linear decay |
| `inference.symmetry` | null | Symmetry type (`C3`, `D2`, `tetrahedral`, etc.) |
| `inference.cyclic` | false | Enable cyclization |

## Output Format

```
outputs/
├── design_0.pdb     ← backbone PDB (Cα, N, C, O atoms only — no sidechains)
├── design_0.trb     ← metadata pickle (config, contig mapping, scores)
├── design_1.pdb
└── ...
```

The output PDBs are **backbone-only** — they have no sequence or sidechains. The next step is always ProteinMPNN for sequence design.

## The Full Design Pipeline

```
1. RFdiffusion    → backbone PDB (no sequence)
2. ProteinMPNN    → sequences for the backbone (FASTA)
3. AlphaFold2     → validate: does the designed sequence fold to the intended structure?
```

For binder design, filter AF2 predictions by `pAE_interaction < 10`. For monomers, check that AF2's predicted structure matches the RFdiffusion backbone (low RMSD).

## Performance

- ~20 diffusion steps produces equivalent quality to 200 steps (10× speedup)
- Runtime scales O(N²) with residue count
- First run caches IGSO3 calculations (~30 min); subsequent runs are faster
- Generate many designs (100–10,000) and filter downstream — RFdiffusion is fast, validation is the bottleneck

## Resources

- **GitHub:** https://github.com/RosettaCommons/RFdiffusion
- **Paper:** Watson et al., Nature 2023 — https://doi.org/10.1038/s41586-023-06415-8
- **Binder design protocol:** https://github.com/nrbennet/dl_binder_design
- **Docker:** `rosettacommons/rfdiffusion` on Docker Hub

## References

- `references/design-modes.md` — all design modes with full command examples, contig syntax reference, guiding potentials, fold conditioning

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [naity](https://github.com/naity)
- **Source:** [naity/FM4Life](https://github.com/naity/FM4Life)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-naity-fm4life-rfdiffusion
- Seller: https://agentstack.voostack.com/s/naity
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
