code wiki / (root) / nx_const.nx

nx_const.nx

buildroot/runtime/nx_const.nx

10724 B250 linesdepth 0pulls 0 transitivereach 42 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_const.nx -- meta source of truth for universal constants. license_tier: ORIGINAL genealogy_id: nishi-substrate/constant-registry CARDINAL: constants that are SHARED across multiple modules and are UNIVERSAL (not algorithm-specific or application-tunable) live in ONE place. Per user 2026-05-19: "lets get a meta source of truth or whatever its called for values that should be like pi and calculations and all that as we build bits up so that these values arent scattered everywhere" What belongs HERE (in nx_const.nx): - Mathematical constants: pi, e, ln(2), sqrt(2), golden ratio - Alphabet encodings: DNA 2-bit codes, ASCII for nucleotides - Universal sentinels: NEG_INF, POS_INF, sentinel bytes - Common ASCII: digits, whitespace, punctuation What stays LOCAL to its module (NOT in nx_const): - Algorithm-spec constants: SHA-256 K[64], ChaCha20 sigma, AES S-box, P-256 curve params. These are PART OF the algorithm spec; moving them away from the implementation obscures provenance (license_tier + genealogy_id audit). See feedback-defer-ethics + Cardinal 11. - Application-tunable values: default gap penalties, k-mer sizes, window widths. These are user choices per workload, not universals. - File-format magic: opcode tables, struct offsets, ISA codes. Floating-point policy: The substrate is no-float (Cardinal 6 + crypto modules). Math constants are stored at fixed-point scale 1e18 (suffix _x1e18). Callers divide by NX_FIXED_SCALE_1E18 or use the integer-arithmetic helpers to be added in nx_fixed_point (G3+). Scale 1e18 fits in i64 (max ~9.2e18) and preserves all 18 decimal digits of the underlying transcendental, which exceeds IEEE-754 double precision. Discovery: docs/NISHI_CONSTANT_REGISTRY.md explains the policy + how to propose new entries. Any new constant that appears in two modules belongs here; refactor pull both into an import of this

dependencies 0 imports · 35 importers

nx_const.nx nx_align_affine.nx nx_align_backtrace.nx nx_align_backtrace_test.nx nx_align_chain_stranded.nx nx_align_chain_stranded_test.nx nx_align_match_stranded.nx nx_align_match_stranded_test.nx nx_alignment.nx nx_alignment_test.nx nx_bam.nx

diagram shows first 10 each side; +0 more imports, +25 more importers in the complete lists below.

imports: none

imported by: nx_align_affine.nxnx_align_backtrace.nxnx_align_backtrace_test.nxnx_align_chain_stranded.nxnx_align_chain_stranded_test.nxnx_align_match_stranded.nxnx_align_match_stranded_test.nxnx_alignment.nxnx_alignment_test.nxnx_bam.nxnx_bam_file_compose_test.nxnx_bam_test.nxnx_bgzf.nxnx_bgzf_test.nxnx_cigar.nxnx_cigar_test.nxnx_fasta.nxnx_fasta_test.nxnx_fastq.nxnx_fastq_test.nxnx_phred.nxnx_phred_test.nxnx_pileup.nxnx_pileup_test.nxnx_sam.nxnx_sam_test.nxnx_sequence.nxnx_sequence_ambig.nxnx_sequence_ambig_test.nxnx_sequence_fm.nxnx_sequence_kat_test.nxnx_variant.nxnx_variant_test.nxnx_vcf.nxnx_vcf_test.nx

structs

none

consts

48const NX_FIXED_SCALE_1E18: i64 = 1000000000000000000
51const NX_PI_X1E18: i64 = 3141592653589793238
54const NX_E_X1E18: i64 = 2718281828459045235
57const NX_LN2_X1E18: i64 = 693147180559945309
60const NX_LOG2E_X1E18: i64 = 1442695040888963407
63const NX_SQRT2_X1E18: i64 = 1414213562373095049
66const NX_GOLDEN_X1E18: i64 = 1618033988749894848
69const NX_GAMMA_X1E18: i64 = 577215664901532861
76const NX_DNA_A: i64 = 0
77const NX_DNA_C: i64 = 1
78const NX_DNA_G: i64 = 2
79const NX_DNA_T: i64 = 3
81const NX_DNA_COMPLEMENT_MASK: i64 = 3
88const NX_ASCII_NULL: i64 = 0x00
89const NX_ASCII_TAB: i64 = 0x09
90const NX_ASCII_LF: i64 = 0x0A
91const NX_ASCII_CR: i64 = 0x0D
92const NX_ASCII_SPACE: i64 = 0x20
93const NX_ASCII_DOLLAR: i64 = 0x24
94const NX_ASCII_PLUS: i64 = 0x2B
95const NX_ASCII_HYPHEN: i64 = 0x2D
96const NX_ASCII_DOT: i64 = 0x2E
97const NX_ASCII_SLASH: i64 = 0x2F
98const NX_ASCII_DIGIT_0: i64 = 0x30
99const NX_ASCII_DIGIT_9: i64 = 0x39
100const NX_ASCII_COLON: i64 = 0x3A
101const NX_ASCII_GT: i64 = 0x3E
102const NX_ASCII_AT: i64 = 0x40
105const NX_ASCII_DNA_A: i64 = 0x41
106const NX_ASCII_DNA_B: i64 = 0x42
107const NX_ASCII_DNA_C: i64 = 0x43
108const NX_ASCII_DNA_D: i64 = 0x44
109const NX_ASCII_DNA_G: i64 = 0x47
110const NX_ASCII_DNA_H: i64 = 0x48
111const NX_ASCII_DNA_K: i64 = 0x4B
112const NX_ASCII_DNA_M: i64 = 0x4D
113const NX_ASCII_DNA_N: i64 = 0x4E
114const NX_ASCII_DNA_R: i64 = 0x52
115const NX_ASCII_DNA_S: i64 = 0x53
116const NX_ASCII_DNA_T: i64 = 0x54
117const NX_ASCII_DNA_U: i64 = 0x55
118const NX_ASCII_DNA_V: i64 = 0x56
119const NX_ASCII_DNA_W: i64 = 0x57
120const NX_ASCII_DNA_Y: i64 = 0x59
123const NX_ASCII_DNA_a: i64 = 0x61
124const NX_ASCII_DNA_c: i64 = 0x63
125const NX_ASCII_DNA_g: i64 = 0x67
126const NX_ASCII_DNA_t: i64 = 0x74
136const NX_NEG_INF_I64: i64 = -1000000000
137const NX_POS_INF_I64: i64 = 1000000000
141const NX_INDEX_NONE: i64 = -1
147const NX_FM_SENTINEL_BYTE: i64 = 0x24 // '$'
155const NX_STRAND_FWD: i64 = 1 // forward / + / sense
156const NX_STRAND_REV: i64 = -1 // reverse-complement / - / antisense
157const NX_STRAND_UNKNOWN: i64 = 0
165const NX_VARIANT_NONE: i64 = 0 // no variant -- matches reference
166const NX_VARIANT_HET: i64 = 1 // heterozygous variant (0/1)
167const NX_VARIANT_HOM: i64 = 2 // homozygous variant (1/1)
176const NX_INDEL_NONE: i64 = 0
177const NX_INDEL_INS: i64 = 1
178const NX_INDEL_DEL: i64 = 2
186const NX_PHRED33_OFFSET: i64 = 33
187const NX_PHRED64_OFFSET: i64 = 64
188const NX_PHRED_MIN_Q: i64 = 0
189const NX_PHRED_MAX_Q: i64 = 93 // upper Phred+33 ASCII cap (126 - 33)
199const NX_CIGAR_M: i64 = 0 // alignment match (consume query + ref); M
200const NX_CIGAR_I: i64 = 1 // insertion to ref (consume query only); I
201const NX_CIGAR_D: i64 = 2 // deletion from ref (consume ref only); D
202const NX_CIGAR_N: i64 = 3 // skipped region (intron-style large gap); N
203const NX_CIGAR_S: i64 = 4 // soft clip (query bases not aligned); S
204const NX_CIGAR_H: i64 = 5 // hard clip (query bases not stored); H
205const NX_CIGAR_P: i64 = 6 // padding (silent deletion vs padded ref);P
206const NX_CIGAR_EQ: i64 = 7 // sequence match (explicit); =
207const NX_CIGAR_X: i64 = 8 // sequence mismatch (explicit); X
216const NX_BAM_NT_EQ: i64 = 0 // '=' equals reference
217const NX_BAM_NT_A: i64 = 1
218const NX_BAM_NT_C: i64 = 2
219const NX_BAM_NT_M: i64 = 3 // A or C
220const NX_BAM_NT_G: i64 = 4
221const NX_BAM_NT_R: i64 = 5 // A or G
222const NX_BAM_NT_S: i64 = 6 // C or G
223const NX_BAM_NT_V: i64 = 7 // A or C or G
224const NX_BAM_NT_T: i64 = 8
225const NX_BAM_NT_W: i64 = 9 // A or T
226const NX_BAM_NT_Y: i64 = 10 // C or T
227const NX_BAM_NT_H: i64 = 11 // A or C or T
228const NX_BAM_NT_K: i64 = 12 // G or T
229const NX_BAM_NT_D: i64 = 13 // A or G or T
230const NX_BAM_NT_B: i64 = 14 // C or G or T
231const NX_BAM_NT_N: i64 = 15 // any (default for unknown)
234const NX_BAM_MAGIC_B: i64 = 0x42 // 'B'
235const NX_BAM_MAGIC_A: i64 = 0x41 // 'A'
236const NX_BAM_MAGIC_M: i64 = 0x4D // 'M'
237const NX_BAM_MAGIC_1: i64 = 0x01 // BAM v1
240const NX_BAM_UNMAPPED: i64 = -1
241const NX_BAM_NO_QUAL_BYTE: i64 = 0xFF // per spec: all 0xFF if quals absent
247const NX_BYTE_BITS: i64 = 8
248const NX_I64_BYTES: i64 = 8
249const NX_I64_BITS: i64 = 64
250const NX_PAGE_BYTES: i64 = 4096

functions

none