nx_align_score.nx
buildroot/runtime/nx_align_score.nx
about
nx_align_score.nx -- score chained alignment via Smith-Waterman.
license_tier: INDEPENDENT_REDERIVE
genealogy_id: international-research-sources/li-2018-minimap2-seed-and-extend
G1.4 of NISHI_GENOMICS_SUBSTRATE_ROADMAP.md. The integration
primitive that closes the seed-and-extend loop:
query+ref packed DNA
-> nx_align_minimizer (G1.1)
-> nx_align_match (G1.2)
-> caller pre-sort by r_pos
-> nx_align_chain (G1.3)
-> THIS PRIMITIVE (G1.4) -> alignment score + region
Given a chain (indices into the original seed arrays), extract the
implied alignment region:
q_start = seeds_q[chain[0]]
q_end = seeds_q[chain[chain_n-1]] + k // last seed spans k bases
r_start = seeds_r[chain[0]]
r_end = seeds_r[chain[chain_n-1]] + k
Then unpack the 2-bit DNA in [q_start, q_end) and [r_start, r_end)
into per-byte 2-bit codes and run Smith-Waterman over them. The
returned score is the local-alignment score for the implied
region; it is >= chain_n * k * match_score under exact match and
degrades with gaps + mismatches in the inter-seed regions.
Why not score the chain seeds alone:
- A chain proves co-linearity of seeds but says nothing about
the inter-seed gap quality. Two seeds 3bp apart in q and
50bp apart in r implies a large insertion that should drop
the alignment score. Only SW captures that geometry.
- Real BWA-MEM / minimap2 use the chain to GUIDE extension
(banded SW around chain diagonal) rather than re-aligning
the full region; that optimization is G1.5. For G1.4
reference correctness we re-align the full region.
What G1.4 does NOT do (deferred):
- Banded SW restricted to chain diagonal (G1.5 perf path)
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_sequence.nxnx_align.nx
imported by: nx_align_score_test.nx
structs
| none |
consts
| none |
functions
| 92 | func unpack_region_2bit(bases: *u8, start: i64, count: i64, out: *u8) -> i64 |
| 106 | func score_chained_alignment(q_bases: *u8, q_len: i64, |