
This constraint is open source. Any third-party models, product names, or trademarks referenced are the property of their respective owners, and Proto is not affiliated with them.
API Reference
Configuration for sequence length constraint.This class defines configuration parameters for evaluating sequence length
in DNA, RNA, or protein sequences. The constraint supports two modes:
range mode (specify acceptable length range) and target mode (specify exact
target length).Supports two mutually exclusive modes:
- Range mode: Specify both min_length and max_length to define an acceptable length range. Sequences within this range receive score 0.0, while those outside are penalized based on distance from the range.
- Target mode: Specify target_length for exact length matching. Sequences exactly matching the target receive score 0.0, while deviations are penalized based on proportional distance from the target.
Minimum acceptable length (use with max_length for range mode)
Maximum acceptable length (use with min_length for range mode)
Target length for exact matching (alternative to min/max range)
ReturnsConstraintOutput
One result per sequence. A score of 0.0 indicates
the sequence meets the length requirement (within range or at target).
Higher scores indicate greater deviation:- Range mode: Linear penalty based on distance outside [min, max]. Score = 0.0 if within range, else proportional to deviation distance.
- Target mode: Normalized penalty as |actual - target| / target. For example, 10% deviation from target yields score ~0.1.
metadata carries:For range mode:length: Integer actual sequence lengthlength_mode: String “range”length_min: Integer minimum acceptable lengthlength_max: Integer maximum acceptable length
length: Integer actual sequence lengthlength_mode: String “target”length_target: Integer target length
Usage
Range mode (protein):python
python
Metadata
| Property | Value |
|---|---|
| Key | sequence-length |
| Function | sequence_length_constraint |
| Category | sequence_composition |
| Mode | discrete |
| Uses GPU | False |
| Supported Types | dna, rna, protein |