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 identity, BLOSUM62, PAM250, PAM100, and structural (TeXshade sidechain volume + hydropathy), 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.1.0.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.1.0-cp313-cp313-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.13Windows x86-64

seqtree-0.1.0-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.1.0-cp313-cp313-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

seqtree-0.1.0-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.1.0-cp312-cp312-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

seqtree-0.1.0-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.1.0-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

seqtree-0.1.0-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.1.0-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.1.0.tar.gz.

File metadata

  • Download URL: seqtree-0.1.0.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.1.0.tar.gz
Algorithm Hash digest
SHA256 e2315faf81c14a0b56c43385a902216d195f53d8482815f9fb05ffffaa701382
MD5 87590b58c38636370147d24f7dda9a96
BLAKE2b-256 430b38c81f726d35d6527eb261d9b54806dc485af0f44912293edac2919d491c

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0.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.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: seqtree-0.1.0-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.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 81025746f40b4560b5164730be97f5827825995e33c92c6723956e9afda093fb
MD5 2e4b50811ad714bdb6bffd0f77d31629
BLAKE2b-256 39a5c3ae6e8e41d67700a05e86573aad8ac7f50b7fb1f744c2abeb6def5010ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqtree-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bd42df7841edc3628ae10cb676eb82b04229297d36f4d7bcf2b8a76064a7796
MD5 9df6557e69b9c8710e7e671c84f4d7b2
BLAKE2b-256 af003db364fa877b7b82fb51ad5f66b09863a3ab99ea2a437e483055f5671f65

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seqtree-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3686403867656c6e9a63d2749b545ee924283630799dd8e370cdb731bfd2fab2
MD5 cb4caa2032282157052b4d48eb5e1603
BLAKE2b-256 12a2bb2fb6886b256c1fce8233179e6740bcb7b69cdfdb98d08085ca9b2ff2a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: seqtree-0.1.0-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.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 24f6ef6034184d144cc80bb4271c680d0e0a42279cb6fca4a2096870fc625fd2
MD5 5f2f554c660f0402bb37411ab969db70
BLAKE2b-256 963871a24f424c6026ec593290b010cc44ea0281b10ef4ee90d3efa1eff46190

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqtree-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4bfb1e0e1901b37d1fee042b28f694549d9d799d80f09f7a3c85663ec86bd96c
MD5 50037a4dcae4aadfafb505549d24ef50
BLAKE2b-256 bfa95facf1cdefd00cbe0bd2b99033ca8f85c91b809e109a706858e9c3dbc0fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seqtree-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 338c8fa0aeef54e910e2a34c7e54e0db1715dfb21ddca23a9b0948245d9c5399
MD5 9c2a47f4494ae0a8080529b81f81d7a9
BLAKE2b-256 c8c00ffa93ed0d144f331bcd2811326e7f8b98c6e3da86e9e7f8a8dbec1d3475

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: seqtree-0.1.0-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.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4fbf7a3a6d3b035b8316bd20b00db4c0a3b632a4c3b9032172d199f9e6bb9425
MD5 dfb85167b449b18d0df195ad19e3f0c7
BLAKE2b-256 c3d00707273f3270818afddf059092ef95fb3aa824cf71f0500245f578b79a3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqtree-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5c8660f949505bcc1c3d1b958a0b5a843d3fe246a52d907baae24b16d33b93e0
MD5 b6a973ac11e1e587a9f37cdb9051013a
BLAKE2b-256 f2b4cfb70c0483cc175e0725360627ffa8a590a660b6a2003f87636a38d6bf10

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seqtree-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 65ecfb1427114d6c2eddcb811bf8b22d428218c5a4f06a3fdd417af313df9e8d
MD5 8b2566c7c85c55efe3f4a9bb06645b45
BLAKE2b-256 102cda114c99d854256b9be7e5c78def5824e7d7723c90b7152d972dc536c6b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: seqtree-0.1.0-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.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cdeb7623095e445bb3fb4c25bc80bd32c7714a3130404aad872d2efc83d3bfc4
MD5 9b4a320ab142ece96e06f461c0a0eedb
BLAKE2b-256 b65711928afd4b990cacc632c6c83f02609f9f2490b501ddeff7a217bd2a988a

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqtree-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bfa62cdbfbb4a435c22df46ca5364dc313fcd89561aa9b43e388dc3286519fa7
MD5 219999a7ec9d740b0f80783ad00abf24
BLAKE2b-256 337ef074270a1e562124d44d9a5e8fbfd2c7d90a1eed28e44d45c4fb6b104674

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for seqtree-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b8dd2ea2878f3e57450c0cb463df4c54d3e9eb99300163921bbfd7ef50c083c
MD5 10330bc0905c7dd9731ffbf5a641a019
BLAKE2b-256 d5fe817e782e76968fd30f4ca42541f6d444b525617983b5075b2b65c848cfa3

See more details on using hashes here.

Provenance

The following attestation bundles were made for seqtree-0.1.0-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