Skip to main content

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)
It demonstrates the core Proto workflow end to end.

Overview

The result is a 100bp DNA sequence with verified properties:
The exact sequence will differ because the process is stochastic, but the properties will be within the target ranges.

Prerequisites

Proto must be installed first, including the proto-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
Why Constructs? Real genetic designs often have multiple parts: a promoter, a coding sequence, a terminator. Each part is a Segment with its own generator and constraints. The Construct joins them for the optimizer.
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
Choosing num_mutations: Lower values (1-2) make small, conservative changes, good for fine-tuning. Higher values (5-10) make bigger jumps, good for escaping local optima. For a 100bp sequence, 3 mutations per step is a reasonable starting point.
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 both weight and threshold.
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
MCMC uses simulated annealing. It starts at high temperature (accepting worse solutions to escape local optima) and gradually cools (becoming greedy). The num_results parameter runs multiple independent trajectories in parallel, increasing the chance of finding good solutions.
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

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).