Skip to main content

Antigen Receptor Domain Annotation — fast TCR/BCR FR/CDR region annotation

Project description

arda

arda — Antigen Receptor Domain Annotation

PyPI CI docs python license

Versatile, fast, exact FR/CDR annotation of TCR and BCR sequences — mRNA and protein in FASTA, and reads in FASTQ from both amplicon and bulk RNA-seq — for nucleotide and amino-acid input, across all loci at once.

arda does the expensive IgBLAST work once, offline — building a pre-aligned reference database of every in-frame V·J germline scaffold with FR1–4 / CDR1–3 markup — then at runtime maps your sequences to that database with MMseqs2 and transfers the markup through the alignment in a small C++ hot path. The result is an AIRR-formatted annotation that matches IgBLAST (≈97% region concordance on real GenBank mRNA), from a plain CLI + Python library — no Docker, no workflow engine.

Why

IgBLAST is the gold standard but is slow to invoke per-batch and awkward to embed. arda keeps IgBLAST-quality region calls while being:

  • Fast & scalable — MMseqs2 search + a C++ projection step; multiprocessing and SLURM-friendly from small FASTA to large FASTQ.
  • Embeddableimport arda; arda.annotate_sequences(...).
  • Easy to install — conda for the mmseqs binary, pip install -e . for the package + C++ extension; IgBLAST is fetched into a gitignored bin/ and is only needed to (re)build the reference DB, not at runtime.

Install

pip install arda-mapper   # from PyPI (imports as `arda`); binary wheels ship the C++ extension

mmseqs2 (the search backend) is fetched/managed by arda at runtime. For development — and to get the committed germline references on disk — use setup.sh:

bash setup.sh            # creates conda env `arda`, fetches IgBLAST, pip install -e .
conda activate arda

Flags: --no-conda (use the active env), --build-db (rebuild references after install), --tests (run the fast suites). The committed database/vdj/<organism>/ references mean most users never need to build anything; a pip-only install builds them on first use (or set $ARDA_HOME to a checkout).

Supported organisms: human, mouse (full IG + TR), rat, rabbit, rhesus_monkey (IG only — IgBLAST ships no TR internal annotation for these).

CLI

arda info                                   # resolved paths + tool availability
arda annotate -i reads.fastq -o out.airr.tsv --organism human --seqtype nt
arda annotate -i prot.fasta  -o out.airr.tsv --organism human --seqtype aa
arda annotate -i reads.fastq -o out.airr.tsv --strand forward   # plus-strand only
arda build-db   --organism all              # rebuild references (needs IgBLAST)
arda build-index --organism all             # (re)build the precompiled mmseqs DBs
arda slurm -i big.fastq -o big.airr.tsv --shards 50 --partition cpu   # cluster scale

See examples/ for a runnable per-locus demo and benchmarks/RESULTS.md for measured speed/accuracy.

The reference database ships with precompiled MMseqs2 indexes (database/vdj/<organism>/mmseqs/), so annotation runs out of the box with no build step. They are used automatically when the local MMseqs2 version matches the shipped one; otherwise arda transparently rebuilds a private cache on first run (arda build-index regenerates the shipped DBs for your version).

Input may be FASTA or FASTQ, plain or gzipped. Nucleotide input is searched on both strands by default (reverse-complement reads are re-oriented and flagged rev_comp=T); a single search annotates a mixed bulk RNA-seq file across all loci.

Library

import arda

records = arda.annotate_sequences(
    ["GACGTGCAG...", ("clone7", "CAGGTG...")],  # strings or (id, seq) pairs
    seqtype="nt", organism="human",
)
# -> list of AIRR record dicts: v_call, d_call/d2_call, j_call, fwr1..fwr4,
#    cdr1..cdr3, *_start/*_end (1-based closed), *_aa, junction(_aa), np1/np2/np3,
#    v_sequence_end, j_sequence_start, productive, rev_comp, ...

Annotating bare germline segments

There is no coverage filter, so a V-only or J-only query maps to its scaffold and only the regions inside the query's coverage are returned. This lets you annotate isolated germline V or J alleles without synthesising a rearrangement — a bare V yields fwr1..fwr3, a bare J yields fwr4:

from arda.annotate.mapper import annotate_records

recs = annotate_records(
    [("TRBV9*01", v_germline_nt), ("TRBJ2-7*01", j_germline_nt)],
    organism="human", seqtype="nt", strand="forward", map_d=False,
)
# V record -> fwr1/cdr1/fwr2/cdr2/fwr3 (+ v_sequence_end = CDR3 start)
# J record -> fwr4 (+ j_sequence_start = CDR3 end / FR4 start)

(mirpy uses exactly this to bake per-allele FR/CDR subsequences into its gene library; see tests/synthetic/test_germline_segments.py.)

How it works

  1. Reference build (arda.refbuild, offline): download IMGT/V-QUEST germlines → enumerate deduplicated in-frame V×J scaffolds (D only affects CDR3 interior, so it isn't enumerated) → annotate with igblastn -outfmt 19 → translate → write database/vdj/<organism>/{alleles.fasta, alleles.aa.fasta, markup.tsv, markup.aa.tsv, combinations.tsv, build.log}.
  2. Runtime (arda.annotate): MMseqs2 search query→scaffolds → best hit → C++ transfer_regions projects scaffold region coordinates onto the query (handling indels, truncation, mid-codon alignment starts, reverse strand) → for VDJ loci a gapless C++ local alignment of the CDR3 interior against the D germlines adds d_call/d2_call + np* → AIRR TSV. Out-of-frame junctions are reported with an N-bridge (_) so FR4 still reads.

See memory/ for design rationale and gotchas. Fast sequence primitives (translate, detect_coding_frame, reverse_complement, back_translate) live in the C++ extension and are re-exported from arda.refbuild.translate — mirpy-API-compatible, so mirpy can import arda and reuse them.

Performance

Exact annotation that matches IgBLAST while being several times faster, scaling to large FASTQ. Synthetic human IGH, 16 threads (scripts/bench_vs_igblast.py):

sequences arda arda rate speedup vs IgBLAST region concordance
10,000 5.5s ~1.8k/s 4.4× 98.9%
50,000 16s ~3.0k/s 7.3×
100,000 30s ~3.3k/s 7.9×

On ~7.3k real GenBank mRNA records spanning all five organisms and their loci (committed, gzipped test fixtures), region concordance with IgBLAST on productive records is 98–99.7% per organism; junction_aa/cdr3_aa match IgBLAST ~99% and satisfy the AIRR invariants exactly. V-gene assignment agrees ~100%. (GenBank also contains genomic/partial/non-productive entries that confuse both tools; those are excluded from the comparison.)

Bulk RNA-seq is much faster than amplicon, because mmseqs prefilters by k-mer matching — reads with no receptor k-mer are rejected before alignment. At 150 nt reads, 16 threads (scripts/bench_prefilter.py):

receptor content throughput
100% (amplicon) ~5.7k reads/s
10% ~19k reads/s
1% (blood RNA-seq) ~25k reads/s

Extrapolated to a 32-core node, a 30M-read bulk RNA-seq library (~1% receptor) annotates in roughly 10–20 min — the same order of magnitude as a STAR genome alignment pass on the same data (STAR is faster per read, but arda maps only to a tiny germline DB and the non-receptor majority costs just prefilter rejection). Large FASTQ is streamed in bounded chunks (a background reader prefetches the next chunk while the current one is annotated), so memory stays flat regardless of input size — --chunk-size tunes it.

Roadmap / TODO

See ROADMAP.md. Done: V·J reference build (5 organisms), MMseqs2 mapping, C++ markup transfer, reverse-complement, all-loci querying, streaming I/O, out-of-frame junctions, D-segment mapping incl. D-D fusions, precompiled indexes, multi-node (SLURM) sharding. Next: full AIRR productivity.

Development

pip install -e .                                  # rebuilds the C++ ext on import
python -m pytest tests/unit tests/synthetic -q    # fast suite
env ARDA_REALWORLD=1 python -m pytest tests/realworld -s   # vs IgBLAST (network)
env RUN_BENCHMARK=1   python -m pytest tests/benchmark -s  # timing/memory/scaling

Layout: src/arda/{refbuild,annotate}, C++ in src/_markup/markup.cpp, references in database/, downloads in gitignored bin/ + data/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arda_mapper-2.0.3.tar.gz (9.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

arda_mapper-2.0.3-cp313-cp313-win_amd64.whl (140.4 kB view details)

Uploaded CPython 3.13Windows x86-64

arda_mapper-2.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (154.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

arda_mapper-2.0.3-cp313-cp313-macosx_11_0_arm64.whl (119.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

arda_mapper-2.0.3-cp312-cp312-win_amd64.whl (140.3 kB view details)

Uploaded CPython 3.12Windows x86-64

arda_mapper-2.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (154.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

arda_mapper-2.0.3-cp312-cp312-macosx_11_0_arm64.whl (119.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

arda_mapper-2.0.3-cp311-cp311-win_amd64.whl (138.5 kB view details)

Uploaded CPython 3.11Windows x86-64

arda_mapper-2.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (155.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

arda_mapper-2.0.3-cp311-cp311-macosx_11_0_arm64.whl (119.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

arda_mapper-2.0.3-cp310-cp310-win_amd64.whl (137.7 kB view details)

Uploaded CPython 3.10Windows x86-64

arda_mapper-2.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (153.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

arda_mapper-2.0.3-cp310-cp310-macosx_11_0_arm64.whl (118.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file arda_mapper-2.0.3.tar.gz.

File metadata

  • Download URL: arda_mapper-2.0.3.tar.gz
  • Upload date:
  • Size: 9.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arda_mapper-2.0.3.tar.gz
Algorithm Hash digest
SHA256 d77896b21b97fdca2df73f5209b3b6a71cc7ab7f9df1ccadfc688478fe879d78
MD5 50c2e84a215a55d58a347c02a8457bf0
BLAKE2b-256 38010d3d0a0a58fe08a291d5d3b327f1632b2d1a566989d9425d5df394b8c8dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3.tar.gz:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: arda_mapper-2.0.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 140.4 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arda_mapper-2.0.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ec055d032f42eb8deec9551c189569b527881ed0e972c1dbb783649f286dad0a
MD5 e004a2083b6bfcc533b8179e40825d02
BLAKE2b-256 caffc8efb5a2ac261e873360e74f83e4b94058f7d2da71b343a1f019f4993dc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for arda_mapper-2.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 226e0f860a2babb04962b5cd11bc54a6786146a0a8032a9bcf35bcafbf98b5dc
MD5 8d5800cfb10d8b74730a5b35ebcb949c
BLAKE2b-256 331b1733e0a6d80416d7f6efa2bc1ef40231deff76ed0e971f9cea18da8ee82b

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for arda_mapper-2.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 685647979e3e73939c71cb21cb84481d06fdd76ed755c177467dfcda4be83fe1
MD5 94708c8ebb65d718bd55507430641c56
BLAKE2b-256 0d1cc463be2575602990c591dd5b0d4e71e9938bb812b524fab14e434a9f8099

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: arda_mapper-2.0.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 140.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arda_mapper-2.0.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 94a26e2c63f94bcdcae690de006a378a7dd3ca204c122af0ac0ec0544c0cd973
MD5 1a0da314a168f3f86606b2ed68e9b95f
BLAKE2b-256 dfd5c6b4304cd9e129aecfe546d95c23071ce0feaa9ba581a3d1b48c12a53aa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for arda_mapper-2.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce56429923cfe38a0357b4aefad14ab5ebcd784204305d77fc0f577d8f49a3ee
MD5 fbe5f9d01cd2f092c86d9dca3e65425b
BLAKE2b-256 e9f274f619e5e4af2b4e21b69835e3790c08f6fa6b7dfddb294e9fa4654f5d0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for arda_mapper-2.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2860ca65495ac781b0385597bc47242088884b44b713cc4566582dc2432021f7
MD5 6feb300deb8caf20d37fef90399c94f2
BLAKE2b-256 90bf3c81985cf5a09a4cdb10e662b692e519b5e0e080e191a0fc578fa4a4b306

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: arda_mapper-2.0.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 138.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arda_mapper-2.0.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f24f5f42996b20017e0a7c52648c4a8782e5da9ca5b95c8e9d0272296b40f9c5
MD5 2051749db54176b3509e56a3bd7326f8
BLAKE2b-256 2cedc9f5401be7b0e730ba418ce6b243d30db0b767be5c44c7a25f9b219957af

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for arda_mapper-2.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8cae44ca9f4a83a7db30cf06900caf4677aca8331dd8d6c3913dd332da56f06
MD5 240e40471602e89c93a90771101340f7
BLAKE2b-256 b0681b109e6548dc62e9046e14e2ead7bd54491a45541bf6f022ed1f57a7b676

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for arda_mapper-2.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 353b389172ea798ddce99fde04fffe9d02df331a405ccbcebeaa313c7902268c
MD5 546c124d43cee7293855bcd751bd45d8
BLAKE2b-256 ff7b2ee19043ab1f5940c699f3b2b9f9316126613c224d6dbff0c757929aca17

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: arda_mapper-2.0.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 137.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arda_mapper-2.0.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 be85be2ad44ee609a500c1bc5c5cfa80b29717d2ff8f8686684d152a1862b574
MD5 42b728e46a563d621989a5c5cba1d764
BLAKE2b-256 82080b32a14be87a55ccf2b7bf776879f5a04041749d92f90fe22618b632944a

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp310-cp310-win_amd64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for arda_mapper-2.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5cc8f58f0ff3000fa3eea9504cd0f169b0a7496b136c73537ee3dd255eb54c5
MD5 580cd63f932c20ea96058d38e5fe3e3e
BLAKE2b-256 1059b15b1bdffd5950514ae7cca507ccdc3fd8d9485ec12f48c8588736622542

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arda_mapper-2.0.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for arda_mapper-2.0.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae1a5b103f90c67c14382c723a4680ebc3c48115f27c449417e09bfade443ece
MD5 6a4a6e31bab55152652750f11d5b35aa
BLAKE2b-256 6a87fc8447db113d342811bccaec54e61ea77a5bc81f2744bea0deb420ec5acd

See more details on using hashes here.

Provenance

The following attestation bundles were made for arda_mapper-2.0.3-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on antigenomics/arda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page