vdjtools 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vdjtools-2.0.0/.gitignore +44 -0
- vdjtools-2.0.0/CLAUDE.md +64 -0
- vdjtools-2.0.0/CMakeLists.txt +41 -0
- vdjtools-2.0.0/LICENSE +674 -0
- vdjtools-2.0.0/PKG-INFO +95 -0
- vdjtools-2.0.0/README.md +43 -0
- vdjtools-2.0.0/ROADMAP.md +23 -0
- vdjtools-2.0.0/SOURCES.md +26 -0
- vdjtools-2.0.0/environment.yml +23 -0
- vdjtools-2.0.0/include/vdjtools/core.hpp +14 -0
- vdjtools-2.0.0/include/vdjtools/inext.hpp +59 -0
- vdjtools-2.0.0/pyproject.toml +67 -0
- vdjtools-2.0.0/python/vdjtools/__init__.py +17 -0
- vdjtools-2.0.0/python/vdjtools/biomarker/__init__.py +1 -0
- vdjtools-2.0.0/python/vdjtools/cli/__init__.py +1 -0
- vdjtools-2.0.0/python/vdjtools/features/__init__.py +11 -0
- vdjtools-2.0.0/python/vdjtools/features/kmer.py +86 -0
- vdjtools-2.0.0/python/vdjtools/features/physchem.py +132 -0
- vdjtools-2.0.0/python/vdjtools/io/__init__.py +49 -0
- vdjtools-2.0.0/python/vdjtools/io/batch.py +136 -0
- vdjtools-2.0.0/python/vdjtools/io/read.py +162 -0
- vdjtools-2.0.0/python/vdjtools/io/schema.py +160 -0
- vdjtools-2.0.0/python/vdjtools/model/__init__.py +1 -0
- vdjtools-2.0.0/python/vdjtools/overlap/__init__.py +9 -0
- vdjtools-2.0.0/python/vdjtools/overlap/metrics.py +96 -0
- vdjtools-2.0.0/python/vdjtools/preprocess/__init__.py +1 -0
- vdjtools-2.0.0/python/vdjtools/py.typed +0 -0
- vdjtools-2.0.0/python/vdjtools/resources/.gitkeep +0 -0
- vdjtools-2.0.0/python/vdjtools/resources/aa_property_table.txt +1 -0
- vdjtools-2.0.0/python/vdjtools/sc/__init__.py +1 -0
- vdjtools-2.0.0/python/vdjtools/stats/__init__.py +50 -0
- vdjtools-2.0.0/python/vdjtools/stats/diversity.py +239 -0
- vdjtools-2.0.0/python/vdjtools/stats/inext.py +716 -0
- vdjtools-2.0.0/python/vdjtools/stats/rarefaction.py +77 -0
- vdjtools-2.0.0/python/vdjtools/stats/spectratype.py +84 -0
- vdjtools-2.0.0/python/vdjtools/stats/usage.py +87 -0
- vdjtools-2.0.0/src/_bindings.cpp +50 -0
- vdjtools-2.0.0/src/core.cpp +16 -0
- vdjtools-2.0.0/src/inext.cpp +386 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
.ruff_cache/
|
|
8
|
+
.mypy_cache/
|
|
9
|
+
|
|
10
|
+
# venv / conda
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
|
|
15
|
+
# build artifacts (scikit-build-core / CMake / wheels)
|
|
16
|
+
build/
|
|
17
|
+
dist/
|
|
18
|
+
wheelhouse/
|
|
19
|
+
_skbuild/
|
|
20
|
+
*.so
|
|
21
|
+
*.dylib
|
|
22
|
+
*.pyd
|
|
23
|
+
|
|
24
|
+
# C++
|
|
25
|
+
*.o
|
|
26
|
+
*.a
|
|
27
|
+
|
|
28
|
+
# docs
|
|
29
|
+
docs/_build/
|
|
30
|
+
|
|
31
|
+
# editor / OS
|
|
32
|
+
.idea/
|
|
33
|
+
.vscode/
|
|
34
|
+
*.iml
|
|
35
|
+
.DS_Store
|
|
36
|
+
|
|
37
|
+
# scratch
|
|
38
|
+
tmp/
|
|
39
|
+
|
|
40
|
+
# example-notebook data (fetched from HuggingFace, md5-cached; never committed)
|
|
41
|
+
examples/.data/
|
|
42
|
+
|
|
43
|
+
# marimo session/run cache
|
|
44
|
+
__marimo__/
|
vdjtools-2.0.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# CLAUDE.md — vdjtools v2
|
|
2
|
+
|
|
3
|
+
## What this is
|
|
4
|
+
Clean-room **Python + C++** rewrite (v2.0.0, GPL-3.0) of the legacy Groovy/Java vdjtools.
|
|
5
|
+
TCR/BCR repertoire analysis on the **AIRR schema + polars**, minimal OO, built on the
|
|
6
|
+
antigenomics ecosystem: **seqtree** (fuzzy search / e-value engine), **vdjmatch** (overlap +
|
|
7
|
+
TCRnet), **arda** (AIRR annotation + markup repair; brings conda/mmseqs2).
|
|
8
|
+
|
|
9
|
+
## Layout
|
|
10
|
+
- `python/vdjtools/` — package (src-layout via `wheel.packages`). Subpackages: `io model stats
|
|
11
|
+
features overlap preprocess biomarker sc cli` (lazy-loaded; `import vdjtools` pulls no heavy deps).
|
|
12
|
+
- `src/`, `include/vdjtools/` — C++ core; `src/_bindings.cpp` → the `vdjtools._core` pybind11 ext.
|
|
13
|
+
**Native only for Pgen DP, generation sampler, EM E-step** (Python-first everywhere else).
|
|
14
|
+
- `tests/{cpp,python}/`, `docs/` (Sphinx + pydata, gh-pages), `.github/workflows/{ci,docs,publish}.yml`.
|
|
15
|
+
- `CMakeLists.txt` (scikit-build-core + pybind11, C++20), `environment.yml` (conda), `setup.sh`.
|
|
16
|
+
|
|
17
|
+
## Build / test / run
|
|
18
|
+
```bash
|
|
19
|
+
conda env create -f environment.yml && conda activate vdjtools # or reuse .venv
|
|
20
|
+
pip install -e ".[dev,test]" # builds _core
|
|
21
|
+
pytest tests/python -q
|
|
22
|
+
cmake -S . -B build -DVDJTOOLS_TESTS=ON && cmake --build build && ctest --test-dir build
|
|
23
|
+
sphinx-build -W --keep-going -b html docs docs/_build/html # docs gate (zero warnings)
|
|
24
|
+
```
|
|
25
|
+
Co-developed parents are early-alpha: `bash setup.sh --dev-parents` editable-installs
|
|
26
|
+
`../seqtree ../arda ../vdjmatch` if present (else PyPI: `seqtree`, `arda-mapper`, `vdjmatch`).
|
|
27
|
+
Deps trace to real imports — `arda-mapper`/`vdjmatch` live in the `[model]`/`[overlap]` extras
|
|
28
|
+
until the phase that imports them promotes them to base deps.
|
|
29
|
+
|
|
30
|
+
## Git model
|
|
31
|
+
`master` = v2 (tagged releases) ← `dev` (integration) ← `feature/*` (one per phase).
|
|
32
|
+
**Legacy v1.x is on the `legacy-1.x` branch and under tags `v0.0.1`..`1.2.1`** — do not disturb.
|
|
33
|
+
The v2 history is an orphan root (no shared ancestry with legacy). Carried-over legacy resource
|
|
34
|
+
files (`aa_property_table.txt`, `cdr3contact.txt`, `vj_families.txt`) and format-conversion test
|
|
35
|
+
fixtures live on `legacy-1.x` (`src/test/resources/samples/`), pull them over when a phase needs them.
|
|
36
|
+
|
|
37
|
+
## Conventions
|
|
38
|
+
- AIRR Rearrangement/Cell + polars `pl.DataFrame` in and out; minimal OO (thin index classes only).
|
|
39
|
+
- Delegate rather than reimplement: overlap/TCRnet → vdjmatch (`cluster.overlap`,
|
|
40
|
+
`evalue.query_evalues`); annotation/markup/scenarios → arda; search/e-value → seqtree.
|
|
41
|
+
- Native code goes through the single `_core` ext. Flip `editable.rebuild=true` in pyproject
|
|
42
|
+
during C++-heavy work for recompile-on-import (needs the `build-dir` already set).
|
|
43
|
+
|
|
44
|
+
## Open loops / next steps
|
|
45
|
+
Phase 0 (scaffold, git surgery, CI) is **done and pushed**. See `ROADMAP.md` for all phases and
|
|
46
|
+
`SOURCES.md` for data provenance. The full approved design lives in the session plan file
|
|
47
|
+
(`~/.claude/plans/i-want-to-complenely-gleaming-snail.md`).
|
|
48
|
+
|
|
49
|
+
**Next: Phase 1 — `feature/model-engine`** (native V(D)J recombination model, supersedes OLGA+IGoR):
|
|
50
|
+
- `python/vdjtools/model/`: `events schema reference io model scenario stitch pgen generate infer validate`.
|
|
51
|
+
- Model = directory of **long-format polars parquet** marginal tables + `manifest.json` (Bayes net
|
|
52
|
+
declared as data via `events{}.given`). **D-D capable**: `p_nd(n_d∈{0,1,2})`, `p_d1`, `p_d2`, `DD`
|
|
53
|
+
insertion junction. VJ loci degrade cleanly (no D tables).
|
|
54
|
+
- Scenario enumeration from **arda** best alignment → plausible set (slide V3'/J5' over a window;
|
|
55
|
+
seed D via `arda.map_d_junction`; emit n_D∈{0,1,2}). `stitch_contig` rebuilds full nt reads from
|
|
56
|
+
OLGA's (V,J,CDR3) output so synthetic + real reads share the arda→scenarios→EM path.
|
|
57
|
+
- **C++ (`_core`)**: Pgen DP (OLGA transfer-matrix factorization + D-D term; one DP for nt & aa),
|
|
58
|
+
generation sampler, EM E-step. Python/polars: I/O, marginals, EM driver, validation.
|
|
59
|
+
- Bootstrap data: mirpy's OLGA models (7 loci) + ~100k OLGA-synthetic out-of-frame seqs/chain
|
|
60
|
+
(`mirpy/mir/resources/olga/default_models/`, reference only). **No tandem D in bootstrap** — build
|
|
61
|
+
D-D but unit-test it structurally; closed-loop oracle: EM must recover OLGA marginals, Pgen must
|
|
62
|
+
match OLGA. Real out-of-frame data (all 7 loci) ships later from the owner.
|
|
63
|
+
- Watch: arda↔OLGA coordinate convention (1-based junction vs 0-based CDR3 grid) — one authoritative
|
|
64
|
+
converter in `reference.py` with fixtures both ways; Pgen float64 underflow on long aa-CDR3.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20)
|
|
2
|
+
project(vdjtools LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
7
|
+
if(NOT CMAKE_BUILD_TYPE)
|
|
8
|
+
set(CMAKE_BUILD_TYPE Release)
|
|
9
|
+
endif()
|
|
10
|
+
if(NOT MSVC)
|
|
11
|
+
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
|
12
|
+
endif() # MSVC Release already uses /O2; -O3 is not a valid MSVC flag
|
|
13
|
+
|
|
14
|
+
option(VDJTOOLS_TESTS "Build C++ tests" OFF)
|
|
15
|
+
option(VDJTOOLS_PYTHON "Build the pybind11 module" OFF)
|
|
16
|
+
|
|
17
|
+
# Native core: Pgen DP, generation sampler, EM E-step inner loop land here (Phase 1).
|
|
18
|
+
# hamming is a minimal hot-path primitive; inext.cpp is the iNEXT size-based
|
|
19
|
+
# diversity kernel (curve + bootstrap + parallel batch).
|
|
20
|
+
add_library(vdjtools_core STATIC
|
|
21
|
+
src/core.cpp
|
|
22
|
+
src/inext.cpp
|
|
23
|
+
)
|
|
24
|
+
target_include_directories(vdjtools_core PUBLIC include PRIVATE src)
|
|
25
|
+
|
|
26
|
+
find_package(Threads REQUIRED)
|
|
27
|
+
target_link_libraries(vdjtools_core PUBLIC Threads::Threads)
|
|
28
|
+
|
|
29
|
+
if(VDJTOOLS_PYTHON)
|
|
30
|
+
find_package(pybind11 CONFIG REQUIRED)
|
|
31
|
+
pybind11_add_module(_core src/_bindings.cpp)
|
|
32
|
+
target_link_libraries(_core PRIVATE vdjtools_core)
|
|
33
|
+
install(TARGETS _core DESTINATION vdjtools)
|
|
34
|
+
endif()
|
|
35
|
+
|
|
36
|
+
if(VDJTOOLS_TESTS)
|
|
37
|
+
enable_testing()
|
|
38
|
+
add_executable(vdjtools_tests tests/cpp/test_core.cpp)
|
|
39
|
+
target_link_libraries(vdjtools_tests PRIVATE vdjtools_core)
|
|
40
|
+
add_test(NAME vdjtools_tests COMMAND vdjtools_tests)
|
|
41
|
+
endif()
|