fastaModeller
Generate random DNA, RNA or protein sequences in FASTA format from a JSON configuration file.
fastaModeller is a command-line tool, but the same engine is available as a
small Python library.
Features
- Random sequences with a final length between
min_lenandmax_len(inserts and repeats are included in the final length). - Configurable residue composition for DNA, RNA and protein alphabets.
- IUPAC ambiguity symbols (
N,R,Y, ...) and proteinB,Z,X,J. - Tandem repeat motifs with per-sequence likelihood.
- Inserts that can be split into fragments, separated by random gaps and mutated.
- Reproducible generation from a seed. Each batch derives an independent RNG from the master seed, so adding or reordering batches does not alter others.
- Streaming FASTA output (sequences are not retained in memory) and an incremental report.
- Reports include composition, GC content for nucleic acids, ambiguous fraction, insert mutations/gaps and repeat counts.
Installation
python -m pip install fastamodeller
Or install it as an isolated command-line application:
pipx install fastamodeller
Python 3.10 or newer is required.
Command line
# Write FASTA to stdout; the seed notice goes to stderr.
fastamodeller generate config.json
# Write files explicitly.
fastamodeller generate config.json -o output.fasta -r report.txt
# Only print the report.
fastamodeller generate config.json --only-report
# Override the seed (0 is a valid seed).
fastamodeller generate config.json --seed 0
# Read the configuration from stdin.
fastamodeller generate - -o output.fasta -r report.txt -q < config.json
# Validate without generating.
fastamodeller validate config.json
# Create a template.
fastamodeller template ./examples
python -m fastamodeller is equivalent to the fastamodeller command.
The alias fastaModeller is also installed for backwards compatibility.
Use -q/--quiet to suppress the seed notice. The seed is always included in
the report.
Configuration format
{
"molecule": "dna",
"id_padding": 4,
"seq_wrap": 70,
"seed": false,
"sequences": [
{
"base_id": "TEST",
"generate": 10,
"min_len": 500,
"max_len": 1000,
"proportion": {"A": 0.20, "T": 0.25, "C": 0.20, "G": 0.35},
"repeats": [
{
"likelihood": 0.5,
"pattern": "ATCATT",
"pattern_min_reps": 10,
"pattern_max_reps": 50
}
],
"inserts": [
{
"total": 4,
"min_split": 0,
"max_split": 5,
"ave_gap": 5,
"sd_gap": 2,
"mutation_rate": 0.05,
"sequence": "CCCCCCTTAAACACTTATACGGTAG"
}
]
}
]
}
Top-level fields
| Field | Meaning |
|---|---|
molecule |
dna (default), rna or protein. One molecule per file. |
id_padding |
Width of the numeric suffix in FASTA identifiers. |
seq_wrap |
Line width. false or 0 disables wrapping. |
seed |
Optional integer for reproducibility. Omit or use false for a random seed. |
sequences |
List of sequence groups (batches). Required and non-empty. |
Sequence fields
base_id: unique prefix for FASTA identifiers (TEST0001, ...).generate: number of sequences in the batch.min_len/max_len: bounds for the final sequence length. If the inserts and repeats of a given sequence exceedmax_len, generation raises a clear error rather than silently exceeding the limit.proportion: relative weight per residue. If omitted, a uniform composition over the canonical alphabet is used.repeats: for each sequence, the repeat is included with probabilitylikelihood; its tandem copy count is sampled betweenpattern_min_repsandpattern_max_reps.inserts:totalcopies are distributed across the batch, so every requested copy is used. Each copy may be split into fragments (min_split/max_split), separated by normally distributed gaps (ave_gap/sd_gap) and mutated per residue (mutation_rate).
Alphabets
- DNA:
A C G T, plus IUPAC ambiguityR Y S W K M B D H V N. - RNA:
A C G U, plus the same ambiguity codes. - Protein: the 20 standard amino acids, plus
B Z X J U O.
Ambiguity symbols are accepted in inserts, repeats and compositions. To emit
them in the random filler, include them in proportion.
Python API
from fastamodeller import ConfigLoader, generate_to_files
config = ConfigLoader("config.json").load()
result = generate_to_files(
config,
fasta_path="output.fasta",
report_path="report.txt",
)
print(result.seed)
The CLI is the recommended integration path for other applications.
Integration with SeqModeller
SeqModeller can invoke the CLI without depending on the old libs/ package:
import json
import subprocess
import sys
result = subprocess.run(
[
sys.executable,
"-m",
"fastamodeller",
"generate",
"-",
"-o",
str(fasta_path),
"-r",
str(report_path),
"-q",
],
input=json.dumps(config),
text=True,
capture_output=True,
)
if result.returncode != 0:
raise RuntimeError(result.stderr.strip())
Exit codes: 0 success, 1 configuration or generation error, 2 command
usage error. Errors are written to stderr. FASTA, report and configuration
files are written atomically.
Architecture
fastamodeller/
config/ # immutable models, alphabets, composition, loader, validation
generation/ # RNG, mutation, repeats, inserts, assembly, service
reporting/ # incremental statistics and text formatting
output/ # atomic FASTA/report/config writers
cli.py # Click commands
Generation depends on small protocols (composition sampling, mutation,
sequence types) and receives them from the configuration. Adding a new molecule
is a matter of registering a SequenceType and its composition; the generation
and reporting code contains no DNA-specific conditions.
Development
python -m pip install -e ".[dev]"
python -m pytest
python -m ruff check fastamodeller tests fastaModeller.py deploy.py
python -m mypy fastamodeller/config fastamodeller/generation fastamodeller/reporting fastamodeller/output fastamodeller/cli.py
To build and inspect a release locally:
python -m build
python -m twine check dist/*
Releases are published to PyPI from GitHub Actions when a GitHub release is
created. The workflow uses PyPI trusted publishing and requires the pypi
environment configured in the repository.
License
MIT. See LICENSE.
Metadata
Release files for fastamodeller 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastamodeller-1.0.0.tar.gz | 28.0 kB | Without provenance | Details for fastamodeller-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastamodeller-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for fastamodeller-1.0.0-py3-none-any.whl |
Total release size: 55.1 kB
Release files / fastamodeller-1.0.0.tar.gz
| Download URL | fastamodeller-1.0.0.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f581c98e6424c5f35a4df510a5db2ff1d8f262fe057780304d2dbfdf1e0e87c6
|
|
BLAKE2b-256 checksum How to use checksums |
caff6aac6bb9688aed27a8f576a86156a1533b4d4dd37d1fff95799dbd6e2078
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.11
|
Release files / fastamodeller-1.0.0-py3-none-any.whl
| Download URL | fastamodeller-1.0.0-py3-none-any.whl |
|---|---|
| Size | 27.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8bd951adeccf68381d01830ce179e40b911adec33b0512b05df7eb108d0f5ff
|
|
BLAKE2b-256 checksum How to use checksums |
001897adf5b3c750b4fe009fa318b8ad16736bc2c4781bad99ed86e35311ae65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.11
|
Security for fastamodeller 1.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.