code wiki / (root) / nx_align_chain_stranded.nx

nx_align_chain_stranded.nx

buildroot/runtime/nx_align_chain_stranded.nx

6822 B162 linesdepth 3pulls 4 transitivereach 1 importersview sourcekind librarytopic align
docsdependenciesstructsconstsfunctions

about

nx_align_chain_stranded.nx -- strand-partitioned co-linear chain DP. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/li-2018-minimap2-section-2.2-strand-aware G1.3d of NISHI_GENOMICS_SUBSTRATE_ROADMAP.md. Closes the strand-aware-pipeline gap: nx_align_chain (G1.3) is strand-blind and would happily chain forward-strand seeds together with reverse-strand seeds, producing geometrically incoherent alignments. This primitive partitions seeds by strand tag, runs the strand-blind chain DP on each partition, and returns the LONGER of the two chains plus its strand orientation. Why partition not unified-DP: Forward and reverse alignments live in DIFFERENT coordinate systems on the query side (the reverse case uses revcomp-query coordinates). A single DP that mixed them would chain across strand boundaries and produce alignments that don't correspond to any real read placement. Partition + per-strand DP is the simplest correct primitive. Input contract: Caller provides pre-sorted (by r_pos asc) seed-pair arrays that come ALREADY PARTITIONED into a forward block then a reverse block, with the partition boundary count given by n_fwd (so seeds [0..n_fwd) are forward, [n_fwd..n_total) are reverse). This matches the output layout of nx_align_match_stranded after a per-block nx_seed_sort. Tie-break: When forward and reverse produce equal-length chains, the FORWARD chain wins. Deterministic and matches the "default to + strand on tie" convention used by minimap2. API: chain_pick_best_strand( q_arr, r_arr, n_fwd, n_total, out_chain_idx, out_strand, max_out ) -> i64 length of winning chain (>= 0); -1 on bad input

dependencies 3 imports · 1 importers

nx_syscalls.nx nx_const.nx nx_align_chain.nx nx_align_chain_stranded.nx nx_align_chain_stranded_test.nx

imports: nx_syscalls.nxnx_const.nxnx_align_chain.nx

imported by: nx_align_chain_stranded_test.nx

structs

none

consts

none

functions

91func chain_pick_best_strand(q_arr: *i64, r_arr: *i64,
called by 1: main calls 2: sys_mmapseed_chain