code wiki / (root) / nx_align_minimizer.nx

nx_align_minimizer.nx

buildroot/runtime/nx_align_minimizer.nx

6008 B154 linesdepth 3pulls 4 transitivereach 4 importersview sourcekind librarytopic align
docsdependenciesstructsconstsfunctions

about

nx_align_minimizer.nx -- canonical k-mer minimizer extraction. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/roberts-hunt-2004-schleimer-2003 G1.1 of NISHI_GENOMICS_SUBSTRATE_ROADMAP.md. Composes the existing nx_sequence k-mer + canonical-k-mer primitives. Roberts/Schleimer minimizer scheme: - Slide a window of w consecutive k-mers along the sequence. - For each window, the minimizer is the leftmost canonical k-mer with the smallest value. - As the window slides, emit a new (value, position) pair only when it differs from the previous window's pair. This deduplicates the common case of one minimizer persisting across many overlapping windows. Why this scheme: - Any two sequences sharing a substring of length k + w - 1 share at least one minimizer (the "window guarantee"). This makes minimizers a correct seeding primitive for read alignment. - Sub-samples ~2/(w+1) of the k-mers, vastly reducing index size vs. storing every k-mer (minimap2: ~0.2x reference size with k=15 w=10 vs ~6x with all-kmers). - Composable: same scheme for indexing a reference + for extracting query seeds; matching is just (value, refpos) lookup. Tie-break: When multiple k-mers in a window have the same min value, the LEFTMOST one wins. This matches minimap2's convention and is stable across hosts. Naive complexity: O((n - k - w + 2) * w) -- one full scan per window. Fine for the G1.1 reference impl + KAT. The deque-based O(n) variant lives in nx_align_minimizer_fast.nx (G1.5). API: minimizer_count_windows(n, k, w) -> i64 minimizer_extract(bases, n, k, w,

dependencies 2 imports · 4 importers

nx_syscalls.nx nx_sequence.nx nx_align_minimizer.nx nx_align_match_stranded_test.nx nx_align_match_test.nx nx_align_minimizer_test.nx nx_align_score_test.nx

imports: nx_syscalls.nxnx_sequence.nx

imported by: nx_align_match_stranded_test.nxnx_align_match_test.nxnx_align_minimizer_test.nxnx_align_score_test.nx

structs

none

consts

none

functions

80func minimizer_count_windows(n: i64, k: i64, w: i64) -> i64
96func minimizer_extract(bases: *u8, n: i64, k: i64, w: i64,