CyclingOptimizer coordinates the two, using Boltz2 for structure prediction and
ProteinMPNN for inverse folding.
This designs a 100-residue protein over five cycles. It requires a GPU and downloads the Boltz2
and ProteinMPNN weights on first use.
Open as a runnable notebook
View as a Python script
Runtime: this walkthrough runs real models on a GPU and takes several minutes to complete. The first run is slower because it builds the tool environment and downloads model weights.
The design target
ASegment is the stretch of sequence being designed; a Construct groups the segments that make up one molecule. Here a single designed_protein segment is seeded with "X" * DESIGN_LENGTH, an all-X (unknown) sequence of 100 residues that the cycle fills in. The ProteinMPNNGenerator performs the inverse-folding step, designing sequences predicted to fold into a given backbone structure. temperature=0.1 sets near-deterministic sampling that favors the most likely residues, excluded_amino_acids=["C"] forbids cysteine, and generator.assign(protein) binds the generator to the segment it writes into.
python
The conditioning function
CyclingOptimizer calls a conditioning function once per cycle with the current sequences and feeds its output into the generator’s sample(). This one wraps each sequence in a Complex, predicts a fold for it with predict_structures(complexes, "boltz2", {}), and stashes the predicted PDB on each sequence under _metadata["designed_structure_pdb"] so it can be retrieved later. It returns the list of predicted structures, which the optimizer then passes to ProteinMPNN for the inverse-folding step.
python
Run the cycle
CyclingOptimizer alternates the conditioning function and the generator for num_steps cycles: each cycle conditions on the current result_sequences, generates proposals, and (with no constraints here) accepts every proposal as the next cycle’s input. The config sets num_steps=5 cycles and num_results=2 independent proposal trajectories, with verbose=True to print per-cycle progress. target_segment names the segment being optimized, conditioning_fn supplies the structure-prediction step defined above, and the custom_logging callback (track) records each cycle’s sequence into trajectory. The Program runs the optimizer and collects the results.
python
Inspect the result
protein.result_sequences[0] is the first trajectory’s final design. The recorded trajectory shows the sequence after each cycle, redesigned for its predicted fold each time, so the all-X start has been replaced by a concrete amino acid sequence whose length matches DESIGN_LENGTH.
python
Next Steps
Symmetric Protein Design
Structure-constrained protein design with MCMC.
Using Optimizers
The cycling optimizer and its siblings.