Quickstart
This tutorial builds a complete optimization pipeline that designs a 100bp DNA sequence optimized for two properties simultaneously:- GC content between 60-70% (higher than the typical ~50%, useful for thermostable organisms)
- No homopolymer runs longer than 4bp (avoids synthesis errors and polymerase stalling)
Overview
The result is a 100bp DNA sequence with verified properties:Prerequisites
Proto must be installed first, including theproto-tools submodule that the examples import.
This tutorial uses only CPU-based constraints. No GPU required.
Step-by-Step
1
Define the sequence
Every design starts with Segments and Constructs. A Segment is a contiguous region to be designed. A Construct groups one or more Segments into a single design unit.
python
2
Set up the generator
A Generator proposes new candidate sequences at each optimization step.
RandomNucleotideGenerator introduces random point mutations; it is a baseline mutation generator for DNA/RNA sequence-level optimization.python
3
Define constraints
Constraints score how well each proposal sequence meets a requirement. By convention a constraint returns a score between 0.0 (perfect) and 1.0 (worst), and the optimizer minimizes these scores.
python
Weights vs. thresholds: two modes of constraint evaluation
weight(soft): The constraint score is multiplied by the weight and added to the total energy. Higher weight = more importance. The optimizer tries to minimize total energy.threshold(hard filter): Proposals with scores above the threshold are rejected outright. Use this for non-negotiable requirements. A constraint cannot have bothweightandthreshold.
4
Configure the optimizer
The Optimizer searches sequence space to minimize total constraint scores. MCMC (Markov Chain Monte Carlo) is a general-purpose default; it iteratively proposes mutations and accepts improvements.
python
5
Run the program
A Program orchestrates one or more optimizers. For this tutorial, we have a single stage. Call
run() and retrieve results from the construct.python
Complete Runnable Script
Copy this entire block and run it:python
Variations
- Tighter GC Range
- Multi-Segment Construct
- Multi-Stage Pipeline
Make GC content more precise by narrowing the target range and increasing optimization steps:
python
Key Concepts
Next Steps
Core Concepts
How segments, generators, constraints, and optimizers interact internally.
Symmetric Protein Design
Design proteins with structure prediction constraints using ESMFold, ESM2, and ProteinMPNN.
Available Constraints
Browse all 50+ built-in constraints: from GC content to protein folding to splice site prediction.
Worked Examples
Runnable example programs on GitHub: declarative specs in
examples/jsons/ (start with toy.json) and Python pipelines in examples/scripts/ (toy.py, protein_hunter.py, toy-multiple-optimizers.py).