Skip to main content

GenAIRR

GenAIRR

Adaptive Immune Receptor Repertoire sequence simulator
Generate realistic BCR & TCR repertoires in a single line of Python.

PyPI version


📑 Table of Contents

  1. Why GenAIRR?
  2. Key Features
  3. Installation
  4. Quick Start
  5. Examples
  6. Mutation Models
  7. Roadmap
  8. Contributing
  9. Citing GenAIRR
  10. License
  11. Acknowledgements

🧐 Why GenAIRR?

Click to expand

Benchmarking modern aligners, exploring somatic-hypermutation, or stress-testing novel ML pipelines requires large, perfectly-annotated repertoires—not snippets of real data peppered with sequencing error.
GenAIRR fills that gap with a plug-and-play, fully-extensible simulation engine that produces sequences while giving you full ground-truth labels.


✨ Key Features

Category Highlights
Realistic Simulation Context-aware S5F mutations, indels, allele-specific trimming, NP-region modelling
Composable Pipelines Chain together built-in & custom AugmentationSteps into simulation pipelines
Multi-Chain Support Heavy & light BCRs plus TCR-β out of the box
Research-ready Output JSON / pandas export, built-in plotting stubs, deterministic seeds
Docs & Tutorials Rich API docs, Jupyter notebooks, step-by-step guides

⚡ Installation

# Python ≥ 3.9
pip install GenAIRR
# or the bleeding edge
pip install git+https://github.com/your-org/GenAIRR.git

🚀 Quick Start

Below is a 60-second tour. See /examples for notebooks and CLI usages.

from GenAIRR.pipeline import AugmentationPipeline
from GenAIRR.parameters import ChainType,CHAIN_TYPE_INFO
from GenAIRR.steps import SimulateSequence, FixVPositionAfterTrimmingIndexAmbiguity
from GenAIRR.mutation import S5F
from GenAIRR.data import builtin_heavy_chain_data_config
from GenAIRR.steps.StepBase import AugmentationStep

# 1️⃣  Configure built-in germline & chain type
data_cfg = builtin_heavy_chain_data_config()
AugmentationStep.set_dataconfig(config = data_cfg,
                                chain_type=ChainType.BCR_HEAVY)

# 2️⃣  Build a minimal pipeline
pipeline = AugmentationPipeline([
    SimulateSequence(mutation_model=S5F(min_mutation_rate=0.003, max_mutation_rate=0.25), productive=True),
    FixVPositionAfterTrimmingIndexAmbiguity()
])

# 3️⃣  Simulate!
sim = pipeline.execute()
print(sim.get_dict())

🧑‍💻 Examples

1. Full Heavy-Chain Pipeline

from GenAIRR.steps import (
    FixDPositionAfterTrimmingIndexAmbiguity, FixJPositionAfterTrimmingIndexAmbiguity,
    CorrectForVEndCut, CorrectForDTrims, CorruptSequenceBeginning,
    InsertNs, InsertIndels, ShortDValidation, DistillMutationRate
)

pipeline = AugmentationPipeline([
    SimulateSequence(mutation_model=S5F(min_mutation_rate=0.003, max_mutation_rate=0.25), productive=True),
    FixVPositionAfterTrimmingIndexAmbiguity(),
    FixDPositionAfterTrimmingIndexAmbiguity(),
    FixJPositionAfterTrimmingIndexAmbiguity(),
    CorrectForVEndCut(),
    CorrectForDTrims(),
    CorruptSequenceBeginning(
        corruption_probability=0.7,
        corrupt_events_proba=[0.4, 0.4, 0.2],
        max_sequence_length=576,
        nucleotide_add_coefficient=210,
        nucleotide_remove_coefficient=310,
        nucleotide_add_after_remove_coefficient=50,
        random_sequence_add_proba=1
    ),
    InsertNs(n_ratio=0.02, proba=0.5),
    ShortDValidation(short_d_length=5),
    InsertIndels(indel_probability=0.5, max_indels=5, insertion_proba=0.5, deletion_proba=0.5),
    DistillMutationRate()
])
result = pipeline.execute()

2. Naïve Sequence (no SHM)

from GenAIRR.mutation import Uniform
naive_step = SimulateSequence(mutation_model=Uniform(0, 0), productive=True)
pipeline = AugmentationPipeline([naive_step])
naive_seq = pipeline.execute()
print(naive_seq.sequence)

3. Custom Allele Combination

custom_step = SimulateSequence(
    mutation_model=S5F(0.003, 0.25),
    productive=True,
    specific_v=data_cfg.allele_list('v')[0],# specific V allele (as Allele object)
    specific_d=data_cfg.allele_list('d')[0],# specific D allele (as Allele object)
    specific_j=data_cfg.allele_list('j')[0] # specific J allele (as Allele object)
)
pipeline = AugmentationPipeline([custom_step])
print(pipeline.execute().get_dict())

🔬 Mutation Models

Model Description When to use
S5F Context-specific somatic hyper-mutation Antibody maturation studies
Uniform Evenly random mutations Baselines / ablation
Your Model ➕ Implement BaseMutationModel Custom evolutionary scenarios
from GenAIRR.mutation import S5F
s5f = S5F(min_mutation_rate=0.01, max_mutation_rate=0.05)
mut_seq, muts, rate = s5f.apply_mutation(naive_seq)

🗺️ Roadmap

  • 🚧 More Complex Mutation Model (With Selection)
  • 🚧 More Built-in Data Configs (e.g., TCR, custom germlines)
  • 🚧 More Built-in Steps (e.g., more mutation models, more data augmentation)
  • 🚧 Deeper Docs (e.g., more examples, more tutorials)

See the open issues. Feel something’s missing? Open a feature request.


🤝 Contributing

Contributions are welcome! 💙 Please read our contributing guide and check the good first issue label.


✏️ Citing GenAIRR

If GenAIRR helps your research, please cite:

Konstantinovsky T, Peres A, Polak P, Yaari G.  
An unbiased comparison of immunoglobulin sequence aligners.
Briefings in Bioinformatics. 2024 Sep 23; 25(6): bbae556.  
https://doi.org/10.1093/bib/bbae556  
PMID: 39489605 | PMCID: PMC11531861

📜 License

Distributed under the MIT License. See LICENSE for details.


🙏 Acknowledgements

GenAIRR is inspired by and builds upon amazing work from the immunoinformatics community—especially AIRRship.

Metadata

Release files for GenAIRR 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GenAIRR 0.4
File Size Uploaded Provenance Actions
GenAIRR-0.4.tar.gz 101.6 kB Without provenance Details for GenAIRR-0.4.tar.gz

Release files / GenAIRR-0.4.tar.gz

Download URL GenAIRR-0.4.tar.gz
Size 101.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ca4c4ce2b2eadb2d6920846a80f6b637a06cb302c2ca9f05e6441586336e533e
BLAKE2b-256 checksum
How to use checksums
eef3ada8add05a9c5793aa2969ded0bca608d32286e7367b20b5439a3bad77d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Security for GenAIRR 0.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page