Skip to main content

Segments

A Segment is a region of biological sequence to be designed or optimized. It is analogous to a gene annotation on a genome map: a bounded region with a specific function (a promoter, a coding sequence, a linker domain) that the framework fills with an optimal sequence. Each Segment maintains two pools of sequences that the optimization loop uses: one for exploring proposals, and one for preserving the best results found so far.

Creating Segments

Creates an entirely new sequence for a region from scratch. The framework fills it during optimization.
python
The Segment starts with an empty sequence. The Generator will populate it with proposals at the start of optimization.
Either length or sequence must be provided, but not both. If a sequence is provided, the length is inferred automatically.

Sequence Types

Ligand segments must be initialized with a sequence (SMILES string), not just a length. This is because SMILES syntax cannot be randomly generated; the molecule must be chemically valid.

The Dual Pool Model

Each Segment maintains two separate lists of Sequence objects that serve different purposes during optimization:
SEGMENTGeneratorConstraintsproposal_sequencesWorking spaceMany proposals being exploredresult_sequencesResults spaceBest sequences found so farfills withnew proposalsscored byoptimizer selectsbest proposalsseeds nextgeneration
SEGMENTGeneratorConstraintsproposal_sequencesWorking spaceMany proposals being exploredresult_sequencesResults spaceBest sequences found so farfills withnew proposalsscored byoptimizer selectsbest proposalsseeds nextgeneration

proposal_sequences

The working space. Generators fill this pool with new proposals each step. Constraints score every proposal. The Optimizer ranks them and decides which survive.
  • Rebuilt every optimization step
  • Can contain many sequences (e.g., 100 proposals)
  • Internal to the optimization loop

result_sequences

The results space. The Optimizer promotes the best proposals here. This pool persists across optimization steps, and when using multi-stage Programs, carries results from one stage to the next.
  • Persists across steps and stages
  • Contains the top-K best sequences
  • User-facing output after optimization
python

Properties Reference


Labels

Labels identify segments in multi-segment designs and appear in constraint metadata, so per-segment results are attributable to a named region.
python
If a label is not provided, segments are auto-labeled based on their position in the Construct: segment_0, segment_1, etc.

Custom Valid Characters

Restrict the allowed characters for specialized applications:
python
The valid_chars constraint is enforced during validation and used by Generators to only propose valid characters.

Iteration and Indexing

Segments support direct iteration and indexing into the result pool (results):
python

Creation Patterns


Serialization

Segments serialize to dictionaries, preserving both pools and all metadata:

Next Steps

Constructs

Combine Segments into complete biological designs

Generators

How Generators propose new sequences for Segments

Sequences

The data model underlying each pool entry

Overview

See how Segments fit into the full architecture