Supply motif models and a DNA length. Motif Balance searches for sequences that strengthen the weakest desired match while optionally limiting unwanted matches. Inspect the motif sites, collect different arrangements, and expand each layout into sequence alternatives.
Documentation · Supply motifs · Python API
Try a design
Fit the E. coli ArgR and Cra preferences into 25 bases. Their models span 25 and 14 positions, so their matches must overlap. The profiles come from the DAP-seq data in Baumgart et al. (2021), Supplementary Data 2.
1. Install and prepare the profiles
With uv installed:
# Create a project. The visualization extra adds PNG and video export.
uv init --python 3.12 my-project
cd my-project
uv add 'motif-balance[visualization]'
# Download and check the published data, then write editable inputs.
uv run motif-balance example argr-cra --out argr-cra
cd argr-cra
inputs/motifs/ contains the models, SOURCE.json records their origin, and
design.yaml sets the request. The download is cached for reuse.
Preparation details.
To see a model, start Python with uv run python and enter:
from motif_balance.formats import read_motif
cra = read_motif("inputs/motifs/cra.json")
print(cra) # Show nucleotide probabilities along the motif.
Cra (14 positions)
Background (A C G T): 0.25 0.25 0.25 0.25
Probabilities (3 significant digits)
Position A C G T
1 0.0227 0.0227 0.932 0.0227
2 0.0227 0.932 0.0227 0.0227
3 0.0227 0.0227 0.0227 0.932
... 9 positions omitted ...
13 0.0409 0.914 0.0227 0.0227
14 0.823 0.0227 0.0955 0.0591
Position 1 strongly favors G. Scoring compares these probabilities with the
background. Exit Python with exit() to continue in the terminal.
2. Design and inspect DNA
# Search 4,096 candidates and return four 25-base sequences.
uv run motif-balance design design.yaml --out result
# Draw the best sequence with its motif matches and scores.
uv run motif-balance inspect result --format png --out candidate.png
Each q is a motif's best match, rescaled to its own score range. Balance B is the weaker score, 0.855 here. Both strands are scanned. Other inspection formats include HTML score tables.
3. Collect different arrangements
# Choose up to two layouts that differ in motif order, strand, or overlap.
uv run motif-balance collect result --count 2 --out collection.json
uv run motif-balance inspect collection.json --format png --out arrangements.png
The first arrangement is the same duplex shown above, viewed from the opposite strand. Reversing the whole duplex does not create a different arrangement. Selection reports a shortfall if the retained pool cannot supply the requested count. Arrangement definitions.
4. Expand each arrangement into sequence alternatives
# Vary covered bases, keeping the selected motif positions and strands.
# Every returned sequence must have balance at least 0.8.
uv run motif-balance expand collection.json --all --min-balance 0.8 --out expanded
Each arrangement returns 256 sequences at the default output limit.
expanded/ contains FASTA sequences and per-motif score tables for each layout.
Other designs can yield fewer alternatives. See sequence expansion
to change the limits or inspect the checks.
Use new output names when repeating a step. The Python tutorial uses these same models throughout.
Design with more motifs
The same request can include more models. Prepare the twelve-model example, then use the ordinary design command:
uv run motif-balance example twelve-motifs --out twelve-motifs
# Edit this request to use your own motif files or change the DNA length.
uv run motif-balance design twelve-motifs/design.yaml --out twelve-result
uv run motif-balance inspect twelve-result --format png --out twelve-dna.png
This request uses 60 bases and 655,360 evaluations. The movie ends when the recorded run first reaches its best balance, 0.733, at evaluation 121,534. Gray windows show recorded search candidates; colored windows show the best sequence so far.
Exact replay checks the recorded inputs and winner. Use the editable request above for a new design.
Python 3.12–3.14 · Linux and macOS · MIT license · Contributing
For study data, reproduction, and citation, use the Motif Balance Study. Publication DOI: pending.
Metadata
Release files for motif-balance 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| motif_balance-0.9.1.tar.gz | 23.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| motif_balance-0.9.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.2 MB
Release files / motif_balance-0.9.1.tar.gz
| Download URL | motif_balance-0.9.1.tar.gz |
|---|---|
| Size | 23.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4339c95a75b59a6653c04ac9978483ebfd0facaafece3e73e5b777b7fff9b14
|
|
BLAKE2b-256 checksum How to use checksums |
43dedd6b1d437c3866770965dd5a7fddc3024231f7036f85e613fdd770e7f479
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency logRelease files / motif_balance-0.9.1-py3-none-any.whl
| Download URL | motif_balance-0.9.1-py3-none-any.whl |
|---|---|
| Size | 228.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c37af1cde12c2bd42003a9a1638df8cc4fa9e86f81b321d06ece547aded45775
|
|
BLAKE2b-256 checksum How to use checksums |
4fff69f737f307558807dda71ba3c9eb70a9d8459de1ff80cc85b85fd4b5716b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency log