Skip to main content

Fast fuzzy search over biological sequences (C++ core, Python bindings)

Project description

seqtree

PyPI Python License CI Docs

Fast fuzzy search over biological sequences (amino-acid or nucleotide), as a C++ core with a minimal Python binding. Build an immutable index once, then search single queries or massive batches in parallel.

Two search engines over one trie:

  • seqtm — branch-and-bound enumeration. Exact per-type edit caps (max_subs / max_ins / max_dels) and a fast Hamming-only path. Best for small edit distances (UMI collapse, error correction, CDR3/epitope matching).
  • seqtrie — banded edit-distance DP. Matrix-weighted score budgets (BLOSUM62 + gap costs), cost independent of edit count. Best for similarity-scored searches.

engine="auto" picks one per query. Results are payload-agnostic: (ref_id, score, n_subs, n_ins, n_dels). Downstream libraries map ref_id back to their own payloads (V gene, MHC, counts) and filter.

Beyond search, seqtree ships:

  • Substitution matrices — built-in BLOSUM62 and PAM50, plus custom matrices via SubstitutionMatrix.from_similarity (Gram-distance penalty s(a,a)+s(b,b)−2·s(a,b)).
  • E-values / significance — calibrate hit counts against a background control repertoire (load_control + evalues), the TCRNET approach on a finite-sample footing. See the E-value guide.

Install

pip install seqtree       # prebuilt wheels for CPython 3.10–3.13

Prebuilt wheels cover Linux x86-64, macOS arm64 (Apple Silicon), and Windows x86-64. There are no Intel/x86-64 macOS wheels — Intel Macs build from source (see below), which just needs a C++17 compiler and CMake (pulled in automatically by the build).

Build from source

bash setup.sh            # repo-local .venv + editable install
bash setup.sh --tests    # + pytest
bash setup.sh --bench     # + benchmark deps (huggingface_hub, pandas, psutil)

Quickstart

import seqtree

idx = seqtree.Index.build(["CASSLAPGATNEKLFF", "CASSLELGATNEKLFF"], alphabet="aa")

p = seqtree.SearchParams(max_subs=2, engine="seqtm")
for hit in idx.search("CASSLAPGATNEKLFF", p):
    print(hit.ref_id, hit.score, hit.n_subs)

# parallel batch (releases the GIL)
results = idx.search_batch(queries, p, threads=0)   # 0 = all cores

# matrix-weighted budget
pm = seqtree.SearchParams(matrix="BLOSUM62", max_penalty=12, engine="seqtrie")
top = idx.search_top("CASSLAPGATNEKLFF", pm, k=5)

# alignment on demand
aln = idx.align(0, "CASSLELGATNEKLFF", p)
print(aln.aligned_query, aln.aligned_ref, aln.ops)

# batch-vs-batch (auto-indexes the larger set)
pairs = seqtree.pairwise_batch(query_set, db_set, p, alphabet="aa")

# E-values against a background control repertoire (TCRNET-style significance)
control = seqtree.load_control("human_trb_aa", size=1_000_000)
target = seqtree.Index.build(vdjdb_cdr3s, alphabet="aa")
for q, r in zip(queries, seqtree.evalues(target, control, queries, p)):
    if r["p_enrichment"] < 1e-3:
        print(q, r["E"], r["n_target"], r["n_control"])

Tests

cmake -S . -B build -G Ninja -DSEQTREE_TESTS=ON
cmake --build build
ctest --test-dir build           # C++ unit tests
pytest tests/python              # Python tests

Benchmarks

python bench/bench_gnuplot.py        # throughput / scaling / matrix / collisions → SVG (needs gnuplot)
python bench/bench.py                # recall vs ground truth (real VDJdb data)
python bench/bench_evalue.py         # true E-value benchmark (target vs background control)
python bench/bench_evalue_matrix.py  # significance across reference/control/query/scope grid
python bench/bench_epitope.py        # epitope detection-complexity (GIL vs NLV)

Figures (throughput, scaling, matrix-scoring overhead, collisions, E-value matrix, epitope detection) and the full methodology are in the benchmarks docs. Set RUN_BENCHMARK=1 for the large tiers.

Development

This repo follows git-flow:

  • master — stable, release-ready; CI + docs deploy run here.
  • dev — integration branch for day-to-day work.
  • feature branches branch off dev and merge back via PR; releases merge devmaster.

Roadmap (affine gaps, position-specific matrices, succinct memory packing) lives in docs/roadmap.rst. Control-set E-values already ship — see the E-value guide.

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

seqtree-0.0.3.tar.gz (1.5 MB view details)

Uploaded Source

Built Distributions

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

seqtree-0.0.3-cp313-cp313-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.13Windows x86-64

seqtree-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

seqtree-0.0.3-cp313-cp313-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

seqtree-0.0.3-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12Windows x86-64

seqtree-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

seqtree-0.0.3-cp312-cp312-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

seqtree-0.0.3-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11Windows x86-64

seqtree-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

seqtree-0.0.3-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

seqtree-0.0.3-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10Windows x86-64

seqtree-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

seqtree-0.0.3-cp310-cp310-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file seqtree-0.0.3.tar.gz.

File metadata

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

File hashes

Hashes for seqtree-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ba6f3f68e8ea0bee4b46ab93a3d074b1f811036d8fa45818ee01be926ea49dfe
MD5 6b80de0e4935f67ef61a78f8e085a395
BLAKE2b-256 2af43099298233da24109645421200bd1b9e64c30b5ac679f3f26b9439ec0a2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3.tar.gz:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: seqtree-0.0.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • 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 seqtree-0.0.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 84ab74c0ff56bf2cb0f8774d81daf5560eaaec1a9609d2011c8d24b86acd3c7c
MD5 8cd4c0a6d4227dee503fe8ec4dae4d91
BLAKE2b-256 6d20c90e99f84eb76d8b9a9963c44a04df536d2791c15d346a9c501e7a920996

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqtree-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 70d30f7a7dd7c9b459d4d26050f4a5c566d338ddd4b8fac8fd8489d0c4d5ece3
MD5 b155e5577745cf908375e912ac72fb97
BLAKE2b-256 a9065a0c355c2e9c72c8c6789ff0e55b3cfc97a8a114b143e75cd63ddf7ffc0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seqtree-0.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06d6c8496cafd1ef730501c66d7f8f7a95a720d5e3bf66dc39536b3844bc365c
MD5 4713224ab3a985a3efb24d6a921f96a4
BLAKE2b-256 b225b49d0af542db9a2957b653a710f03475b8338d8825a8efb00cf7fce9d5bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: seqtree-0.0.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • 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 seqtree-0.0.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f71dd1ef63c98c86dc20df168bcecc48fa1c17fc783527ffda6fe7441cd21038
MD5 28a6d08d5193a99942e91963c79efafc
BLAKE2b-256 b3e13f84eab1b889ca7884ebc2fface3be72e63e15cdd97c49223923746329e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqtree-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 76ea79ad22613295fc0b588e0868d88fdc873aaab65bcf37d60d262a74494a87
MD5 690792e385361f2bd3ee584f2598dd8c
BLAKE2b-256 d62d822cb3a19a42d0b67dee88ad22fba8da3d3feea6235cefdffcd643f34265

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seqtree-0.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1179b52165a9f4e42feef88b8f0b23fbf8352a114ca8f3161328bc5798cec4cc
MD5 06a17c21b364a54a8bc271bab35b451d
BLAKE2b-256 961dd7982a9b40a34bd1409d289fc48db915d46f29a2d96c4595212c433aeb5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: seqtree-0.0.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • 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 seqtree-0.0.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 48ecaa848e1095211ad56cc086748f16b7532c9e91f6f3a52e6f26c49bd1d632
MD5 02c09e5b731bc8ac03802c64e3a04128
BLAKE2b-256 6d9e513e1afab0f64079d7a077137a8b0ea7607d202780eb015e7493986e1b62

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqtree-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa981857d7daf774837007dcf0855394206f6bc2a6e360f973793b1c6b3d0fd9
MD5 92acb06ee5f65590d18e30d79016a29f
BLAKE2b-256 bc3266ce555cfb2e817913264efa94e3475c3362f4a06b7e4993aba5e9a68990

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seqtree-0.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb5efaa9975753449fbe37ef9be6597e8cfdf03cc0821892550f45f18a3f132d
MD5 070a7df3dcb7f4e3a86b214c9093dcf8
BLAKE2b-256 cf169c4abd8c8b1a5cca51e9428251a42ce4186e8b3ccb6b26bafc241ebb759a

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: seqtree-0.0.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • 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 seqtree-0.0.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4a391b21f5d345e6b0be21373bbb1995d024c2f2b60c02a16fa321b8c153a8b7
MD5 5e4c89ef0c64b1d7b3b3984a49da20a0
BLAKE2b-256 b76f4ee6d05dc1fc2e6736a420fd26a0917e0176bd583f5e9e7ab73162f70f51

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp310-cp310-win_amd64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqtree-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8cd105a7af13c06a507e8a3df1f1f1ecc88b56535ef0803530d05ad516886a5e
MD5 4e587c021fa7457a67acb9657c8061f3
BLAKE2b-256 2d389b25c28c3f0b2ee02a744371ff59553581f580f52211d8978784f77da100

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on antigenomics/seqtree

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

File details

Details for the file seqtree-0.0.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seqtree-0.0.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bb8e1249d6cbee427d989cb37f8e9f7bc9bde13c5ef6ac2f5e86e49fbff1540
MD5 997460e847f5b575e68ba9500d9586f3
BLAKE2b-256 68551745a8af16bc0e5a6a2a07e1d7060e9d424c3fef8b3c84dd039f36e9e1db

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.0.3-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on antigenomics/seqtree

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