code wiki / (root) / nx_qc_svc_test.nx

nx_qc_svc_test.nx source

↩ module page · 369 lines · 19414 B

1// nx_qc_svc_test.nx -- gate for the QC/analytical facade. The decisive test is 2// T3: synthesise the doubly-charged peak a spiked BPC-157 sample really shows, 3// screen it, and prove the facade identifies it as prohibited -- the exact peak 4// a [M+H]+-only method reports as clean. Third facade, same base. 5// expect_exit: 0 license_tier: ORIGINAL 6import "nx_syscalls.nx" 7import "nx_service.nx" 8import "nx_peptide.nx" 9import "nx_supplement_screen.nx" 10import "nx_qc_svc.nx" 11 12func t_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 13func t_putn(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) } let t: *u8 = sys_mmap(28); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0 } 14 15func j_has(j: *NxJson, needle: *u8) -> i64 { 16 var nn: i64 = 0 17 while needle[nn] != (0 as u8) { nn = nn + 1 } 18 if nn == 0 { return 0 } 19 let b: *u8 = j.buf 20 let last: i64 = j.off - nn 21 var i: i64 = 0 22 var found: i64 = 0 23 while i <= last { 24 if found == 0 { 25 var m: i64 = 0 26 var ok: i64 = 1 27 while m < nn { if b[i + m] != needle[m] { ok = 0 } m = m + 1 } 28 if ok == 1 { found = 1 } 29 } 30 i = i + 1 31 } 32 return found 33} 34 35// Build an argv from up to 4 tokens (id in avX[1], args in [2..3]). 36func mk_argv(a0: *u8, a1: *u8, a2: *u8, a3: *u8) -> *i64 { 37 let av: *i64 = sys_mmap(64) 38 av[0] = a0 as i64 39 av[1] = a1 as i64 40 av[2] = a2 as i64 41 av[3] = a3 as i64 42 return av 43} 44 45// Decimal string of v into a fresh buffer (positive only; QC args are >=0). 46func numstr(v: i64) -> *u8 { 47 let b: *u8 = sys_mmap(24) 48 var m: i64 = v 49 if m == 0 { b[0] = 48 as u8; b[1] = 0 as u8; return b } 50 let t: *u8 = sys_mmap(24) 51 var k: i64 = 0 52 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 53 var i: i64 = 0 54 while i < k { b[i] = t[k - 1 - i]; i = i + 1 } 55 b[k] = 0 as u8 56 return b 57} 58 59func main() -> i64 { 60 var pass: i64 = 0 61 var total: i64 = 0 62 let NUL: *u8 = "\x00" as *u8 63 64 // --- T1 describe: third domain, same base --- 65 total = total + 1 66 let j1: *NxJson = nx_json_new(4096) 67 let av1: *i64 = mk_argv("nx_qc_svc" as *u8, "describe" as *u8, NUL, NUL) 68 qc_dispatch(2, av1, j1) 69 let d1: i64 = j_has(j1, "\"svc\":\"qc\"" as *u8) 70 let d2: i64 = j_has(j1, "21 CFR 111" as *u8) 71 let d3: i64 = j_has(j1, "\"catalog_size\":5" as *u8) 72 let d4: i64 = j_has(j1, "\"verb_count\":8" as *u8) 73 let d5: i64 = j_has(j1, "identify" as *u8) 74 let d6: i64 = j_has(j1, "denovo" as *u8) 75 t_puts("T1 qc describe: svc=" as *u8); t_putn(d1); t_puts(" cfr111=" as *u8); t_putn(d2); t_puts(" catalog5=" as *u8); t_putn(d3); t_puts(" verbs4=" as *u8); t_putn(d4); t_puts(" envelope=" as *u8); t_putn(d5); t_puts(": " as *u8) 76 var ok1: i64 = 1 77 if d1 != 1 { ok1 = 0 } 78 if d2 != 1 { ok1 = 0 } 79 if d3 != 1 { ok1 = 0 } 80 if d4 != 1 { ok1 = 0 } 81 if d5 != 1 { ok1 = 0 } 82 if d6 != 1 { ok1 = 0 } 83 if ok1 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 84 85 // --- T2 detect BPC-157: the blind-spot flag comes through --- 86 total = total + 1 87 let j2: *NxJson = nx_json_new(4096) 88 let av2: *i64 = mk_argv("nx_qc_svc" as *u8, "detect" as *u8, "0" as *u8, NUL) 89 qc_dispatch(3, av2, j2) 90 let mass_ok: i64 = j_has(j2, "\"monoisotopic_mass_q4\":14187044" as *u8) 91 let blind: i64 = j_has(j2, "\"single_charge_blind_spot\":true" as *u8) 92 let mh_out: i64 = j_has(j2, "\"mh_plus_in_scan_window\":false" as *u8) 93 let charges3: i64 = j_has(j2, "\"charges_in_window\":3" as *u8) 94 t_puts("T2 detect BPC-157: mass=" as *u8); t_putn(mass_ok); t_puts(" blindspot=" as *u8); t_putn(blind); t_puts(" MHout=" as *u8); t_putn(mh_out); t_puts(" 3charges=" as *u8); t_putn(charges3); t_puts(": " as *u8) 95 var ok2: i64 = 1 96 if mass_ok != 1 { ok2 = 0 } 97 if blind != 1 { ok2 = 0 } 98 if mh_out != 1 { ok2 = 0 } 99 if charges3 != 1 { ok2 = 0 } 100 if ok2 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 101 102 // --- T3 THE SPIKED-SAMPLE TEST: screen the z=2 peak BPC-157 really 103 // shows, and the facade names it as prohibited --- 104 total = total + 1 105 let obs: i64 = sup_mz_q4(SUP_BPC157, 2) 106 let j3: *NxJson = nx_json_new(4096) 107 let av3: *i64 = mk_argv("nx_qc_svc" as *u8, "screen" as *u8, numstr(obs), "200" as *u8) 108 qc_dispatch(4, av3, j3) 109 let matched: i64 = j_has(j3, "\"matched\":true" as *u8) 110 let entry0: i64 = j_has(j3, "\"matched_entry\":0" as *u8) 111 let z2: i64 = j_has(j3, "\"at_charge\":2" as *u8) 112 let prohibited: i64 = j_has(j3, "\"prohibited\":true" as *u8) 113 t_puts("T3 screen z=2 peak " as *u8); t_putn(obs); t_puts(": matched=" as *u8); t_putn(matched); t_puts(" entry0=" as *u8); t_putn(entry0); t_puts(" z2=" as *u8); t_putn(z2); t_puts(" prohibited=" as *u8); t_putn(prohibited); t_puts(": " as *u8) 114 var ok3: i64 = 1 115 if matched != 1 { ok3 = 0 } 116 if entry0 != 1 { ok3 = 0 } 117 if z2 != 1 { ok3 = 0 } 118 if prohibited != 1 { ok3 = 0 } 119 if ok3 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 120 121 // --- T4 a clean sample (unrelated peak) matches nothing -- and that is 122 // a first-class ok result, NOT an error --- 123 total = total + 1 124 let j4: *NxJson = nx_json_new(4096) 125 let av4: *i64 = mk_argv("nx_qc_svc" as *u8, "screen" as *u8, "5000000" as *u8, "200" as *u8) 126 qc_dispatch(4, av4, j4) 127 let ok_env: i64 = j_has(j4, "\"ok\":true" as *u8) 128 let no_match: i64 = j_has(j4, "\"matched\":false" as *u8) 129 let neg1: i64 = j_has(j4, "\"matched_entry\":-1" as *u8) 130 t_puts("T4 clean peak: ok=" as *u8); t_putn(ok_env); t_puts(" matched-false=" as *u8); t_putn(no_match); t_puts(" entry-1=" as *u8); t_putn(neg1); t_puts(": " as *u8) 131 var ok4: i64 = 1 132 if ok_env != 1 { ok4 = 0 } 133 if no_match != 1 { ok4 = 0 } 134 if neg1 != 1 { ok4 = 0 } 135 if ok4 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 136 137 // --- T5 label verify: on-claim, under, and superpotent --- 138 total = total + 1 139 let j5: *NxJson = nx_json_new(4096) 140 let av5: *i64 = mk_argv("nx_qc_svc" as *u8, "label" as *u8, "4750" as *u8, "5000" as *u8) 141 qc_dispatch(4, av5, j5) 142 let rec95: i64 = j_has(j5, "\"recovery_pct\":95" as *u8) 143 let comp: i64 = j_has(j5, "\"label_compliant\":true" as *u8) 144 let j5b: *NxJson = nx_json_new(4096) 145 let av5b: *i64 = mk_argv("nx_qc_svc" as *u8, "label" as *u8, "4000" as *u8, "5000" as *u8) 146 qc_dispatch(4, av5b, j5b) 147 let under: i64 = j_has(j5b, "\"dose_verdict\":-1" as *u8) 148 let j5c: *NxJson = nx_json_new(4096) 149 let av5c: *i64 = mk_argv("nx_qc_svc" as *u8, "label" as *u8, "6000" as *u8, "5000" as *u8) 150 qc_dispatch(4, av5c, j5c) 151 let over: i64 = j_has(j5c, "\"dose_verdict\":1" as *u8) 152 t_puts("T5 label 95%=" as *u8); t_putn(rec95); t_puts(" compliant=" as *u8); t_putn(comp); t_puts(" under=" as *u8); t_putn(under); t_puts(" over=" as *u8); t_putn(over); t_puts(": " as *u8) 153 var ok5: i64 = 1 154 if rec95 != 1 { ok5 = 0 } 155 if comp != 1 { ok5 = 0 } 156 if under != 1 { ok5 = 0 } 157 if over != 1 { ok5 = 0 } 158 if ok5 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 159 160 // --- T6 a SMALL peptide is NOT a blind spot (the control is specific) --- 161 total = total + 1 162 let j6: *NxJson = nx_json_new(4096) 163 let av6: *i64 = mk_argv("nx_qc_svc" as *u8, "detect" as *u8, "2" as *u8, NUL) 164 qc_dispatch(3, av6, j6) 165 let gh_notblind: i64 = j_has(j6, "\"single_charge_blind_spot\":false" as *u8) 166 let gh_mhin: i64 = j_has(j6, "\"mh_plus_in_scan_window\":true" as *u8) 167 t_puts("T6 GHRP-6 not-blind=" as *u8); t_putn(gh_notblind); t_puts(" MH-in-window=" as *u8); t_putn(gh_mhin); t_puts(": " as *u8) 168 if gh_notblind == 1 { if gh_mhin == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) } 169 170 // --- T7 structured errors: bad entry (404), bad dose (400) --- 171 total = total + 1 172 let j7: *NxJson = nx_json_new(4096) 173 let av7: *i64 = mk_argv("nx_qc_svc" as *u8, "detect" as *u8, "99" as *u8, NUL) 174 qc_dispatch(3, av7, j7) 175 let e404: i64 = j_has(j7, "\"status\":404" as *u8) 176 let j7b: *NxJson = nx_json_new(4096) 177 let av7b: *i64 = mk_argv("nx_qc_svc" as *u8, "label" as *u8, "100" as *u8, "0" as *u8) 178 qc_dispatch(4, av7b, j7b) 179 let e400: i64 = j_has(j7b, "\"status\":400" as *u8) 180 t_puts("T7 bad-entry 404=" as *u8); t_putn(e404); t_puts(" zero-declared 400=" as *u8); t_putn(e400); t_puts(": " as *u8) 181 if e404 == 1 { if e400 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) } 182 183 // --- T8 unknown verb -> 404 + non-zero exit --- 184 total = total + 1 185 let j8: *NxJson = nx_json_new(4096) 186 let av8: *i64 = mk_argv("nx_qc_svc" as *u8, "nope" as *u8, NUL, NUL) 187 let rc8: i64 = qc_dispatch(2, av8, j8) 188 let unk: i64 = j_has(j8, "\"code\":\"UNKNOWN_VERB\"" as *u8) 189 t_puts("T8 unknown verb: rc=" as *u8); t_putn(rc8); t_puts(" slug=" as *u8); t_putn(unk); t_puts(": " as *u8) 190 if rc8 != 0 { if unk == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) } 191 192 // --- T9 WORKFLOW: count how many catalog entries are blind spots by 193 // driving detect over the whole catalog (a QC audit sweep) --- 194 total = total + 1 195 var i9: i64 = 0 196 var blind_count: i64 = 0 197 while i9 < SUP_N_ENTRY { 198 let jx: *NxJson = nx_json_new(2048) 199 let avx: *i64 = mk_argv("nx_qc_svc" as *u8, "detect" as *u8, numstr(i9), NUL) 200 qc_dispatch(3, avx, jx) 201 if j_has(jx, "\"single_charge_blind_spot\":true" as *u8) == 1 { blind_count = blind_count + 1 } 202 i9 = i9 + 1 203 } 204 t_puts("T9 audit sweep: catalog blind spots to an [M+H]+-only method = " as *u8); t_putn(blind_count); t_puts("/5 want 3: " as *u8) 205 if blind_count == 3 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 206 207 // --- T10 envelope: the isotopic pattern, ANCHORED (verified:true), and 208 // the SOTA base-peak fact carried through the facade --- 209 total = total + 1 210 let j10: *NxJson = nx_json_new(4096) 211 let av10: *i64 = mk_argv("nx_qc_svc" as *u8, "envelope" as *u8, "DRVYIHPF" as *u8, NUL) 212 qc_dispatch(3, av10, j10) 213 let has_m1: i64 = j_has(j10, "\"m_plus_1_permil\":601" as *u8) 214 let mono_base: i64 = j_has(j10, "\"monoisotopic_is_base_peak\":true" as *u8) 215 let anchored: i64 = j_has(j10, "\"grounding\":\"ANCHORED\"" as *u8) 216 let verified: i64 = j_has(j10, "\"verified\":true" as *u8) 217 t_puts("T10 envelope angiotensin: M+1=601=" as *u8); t_putn(has_m1); t_puts(" mono-base=" as *u8); t_putn(mono_base); t_puts(" ANCHORED=" as *u8); t_putn(anchored); t_puts(" verified=" as *u8); t_putn(verified); t_puts(": " as *u8) 218 var ok10: i64 = 1 219 if has_m1 != 1 { ok10 = 0 } 220 if mono_base != 1 { ok10 = 0 } 221 if anchored != 1 { ok10 = 0 } 222 if verified != 1 { ok10 = 0 } 223 if ok10 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 224 225 // --- T11 the SAME facade reports DIFFERENT grounding per verb: screen 226 // is ASSERTED (regulatory status), envelope is ANCHORED (physics). 227 // The honesty is per-claim, not per-tool. --- 228 total = total + 1 229 let js: *NxJson = nx_json_new(4096) 230 let avs: *i64 = mk_argv("nx_qc_svc" as *u8, "detect" as *u8, "0" as *u8, NUL) 231 qc_dispatch(3, avs, js) 232 let screen_asserted: i64 = j_has(js, "\"grounding\":\"ASSERTED\"" as *u8) 233 let screen_unverified: i64 = j_has(js, "\"verified\":false" as *u8) 234 t_puts("T11 detect(regulatory)=ASSERTED/unverified " as *u8); t_putn(screen_asserted); t_putn(screen_unverified); t_puts(" vs envelope(physics)=ANCHORED/verified: honest per-verb: " as *u8) 235 if screen_asserted == 1 { if screen_unverified == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) } 236 237 // --- T12 msms: the theoretical fragment ladder, ANCHORED, with the b2 238 // and y6 ions that nx_peptide's own gate verified --- 239 total = total + 1 240 let j12: *NxJson = nx_json_new(4096) 241 let av12: *i64 = mk_argv("nx_qc_svc" as *u8, "msms" as *u8, "DRVYIHPF" as *u8, NUL) 242 qc_dispatch(3, av12, j12) 243 let has_nfrag: i64 = j_has(j12, "\"n_fragments\":14" as *u8) 244 let has_b2: i64 = j_has(j12, "2721353" as *u8) 245 let has_y6: i64 = j_has(j12, "7754138" as *u8) 246 let msms_anchored: i64 = j_has(j12, "\"grounding\":\"ANCHORED\"" as *u8) 247 t_puts("T12 msms angiotensin: 14 frags=" as *u8); t_putn(has_nfrag); t_puts(" b2=" as *u8); t_putn(has_b2); t_puts(" y6=" as *u8); t_putn(has_y6); t_puts(" ANCHORED=" as *u8); t_putn(msms_anchored); t_puts(": " as *u8) 248 var ok12: i64 = 1 249 if has_nfrag != 1 { ok12 = 0 } 250 if has_b2 != 1 { ok12 = 0 } 251 if has_y6 != 1 { ok12 = 0 } 252 if msms_anchored != 1 { ok12 = 0 } 253 if ok12 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 254 255 // --- T13 deconv: recover BPC-157's neutral mass from its z=2/z=3 peaks 256 // BLIND, ANCHORED, through the facade --- 257 total = total + 1 258 let j13: *NxJson = nx_json_new(4096) 259 let av13: *i64 = mk_argv("nx_qc_svc" as *u8, "deconv" as *u8, "4739087" as *u8, "7103595" as *u8) 260 qc_dispatch(4, av13, j13) 261 let has_mass: i64 = j_has(j13, "\"neutral_mass_q4\":14187044" as *u8) 262 let has_z2: i64 = j_has(j13, "\"charge_of_mz_hi\":2" as *u8) 263 let consistent: i64 = j_has(j13, "\"pair_consistent\":true" as *u8) 264 let dec_anchored: i64 = j_has(j13, "\"grounding\":\"ANCHORED\"" as *u8) 265 t_puts("T13 deconv z3/z2 -> mass 14187044=" as *u8); t_putn(has_mass); t_puts(" charge2=" as *u8); t_putn(has_z2); t_puts(" consistent=" as *u8); t_putn(consistent); t_puts(" ANCHORED=" as *u8); t_putn(dec_anchored); t_puts(": " as *u8) 266 var ok13: i64 = 1 267 if has_mass != 1 { ok13 = 0 } 268 if has_z2 != 1 { ok13 = 0 } 269 if consistent != 1 { ok13 = 0 } 270 if dec_anchored != 1 { ok13 = 0 } 271 if ok13 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 272 273 // --- T14 deconv rejects a misordered pair as a structured 400 --- 274 total = total + 1 275 let j14: *NxJson = nx_json_new(4096) 276 let av14: *i64 = mk_argv("nx_qc_svc" as *u8, "deconv" as *u8, "7103595" as *u8, "4739087" as *u8) 277 qc_dispatch(4, av14, j14) 278 let e400: i64 = j_has(j14, "\"status\":400" as *u8) 279 t_puts("T14 deconv misordered (mz_hi<mz_lo) -> 400=" as *u8); t_putn(e400); t_puts(": " as *u8) 280 if e400 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 281 282 // --- T15 THE FLAGSHIP: identify a raw BPC-157 spectrum (3 peaks, unsorted) 283 // end to end -> confident, prohibited, correct sequence --- 284 total = total + 1 285 let av15: *i64 = sys_mmap(64) 286 av15[0] = "nx_qc_svc" as i64 287 av15[1] = "identify" as i64 288 av15[2] = "7103595" as i64 // z=2 (deliberately out of order) 289 av15[3] = "4739087" as i64 // z=3 290 av15[4] = "3556834" as i64 // z=4 291 let j15: *NxJson = nx_json_new(4096) 292 qc_dispatch(5, av15, j15) 293 let id_conf: i64 = j_has(j15, "\"confident\":true" as *u8) 294 let id_seq: i64 = j_has(j15, "\"identified_sequence\":\"GEPPPGKPADDAGLV\"" as *u8) 295 let id_proh: i64 = j_has(j15, "\"prohibited\":true" as *u8) 296 let id_mass: i64 = j_has(j15, "\"mass_grounding\":\"ANCHORED\"" as *u8) 297 t_puts("T15 identify raw BPC-157 spectrum: confident=" as *u8); t_putn(id_conf); t_puts(" seq=" as *u8); t_putn(id_seq); t_puts(" prohibited=" as *u8); t_putn(id_proh); t_puts(" mass-anchored=" as *u8); t_putn(id_mass); t_puts(": " as *u8) 298 var ok15: i64 = 1 299 if id_conf != 1 { ok15 = 0 } 300 if id_seq != 1 { ok15 = 0 } 301 if id_proh != 1 { ok15 = 0 } 302 if id_mass != 1 { ok15 = 0 } 303 if ok15 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 304 305 // --- T16 identify REFUSES noise: no confident ID through the facade --- 306 total = total + 1 307 let av16: *i64 = sys_mmap(64) 308 av16[0] = "nx_qc_svc" as i64 309 av16[1] = "identify" as i64 310 av16[2] = "3210000" as i64 311 av16[3] = "5550000" as i64 312 av16[4] = "8880000" as i64 313 let j16: *NxJson = nx_json_new(4096) 314 qc_dispatch(5, av16, j16) 315 let noise_conf: i64 = j_has(j16, "\"confident\":false" as *u8) 316 let noise_unid: i64 = j_has(j16, "\"identified_sequence\":\"UNIDENTIFIED\"" as *u8) 317 t_puts("T16 identify NOISE: confident-false=" as *u8); t_putn(noise_conf); t_puts(" UNIDENTIFIED=" as *u8); t_putn(noise_unid); t_puts(" (names nothing): " as *u8) 318 if noise_conf == 1 { if noise_unid == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) } 319 320 // --- T17 THE CROWN JEWEL: de novo sequence bradykinin from its b-ion 321 // ladder through the facade, ANCHORED, no database --- 322 total = total + 1 323 let bkseq: *u8 = "RPPGFSPFR" as *u8 324 let bkM: i64 = pep_mass_mono_q4(bkseq) 325 // b1..b8 of bradykinin 326 let av17: *i64 = sys_mmap(128) 327 av17[0] = "nx_qc_svc" as i64 328 av17[1] = "denovo" as i64 329 let pm: *u8 = sys_mmap(24) 330 var pmm: i64 = bkM 331 var pk: i64 = 0 332 while pmm > 0 { pm[pk] = (48 + (pmm % 10)) as u8; pmm = pmm / 10; pk = pk + 1 } 333 let pmr: *u8 = sys_mmap(24) 334 var pj: i64 = 0 335 while pj < pk { pmr[pj] = pm[pk - 1 - pj]; pj = pj + 1 } 336 pmr[pk] = 0 as u8 337 av17[2] = pmr as i64 338 var bi: i64 = 1 339 while bi < 9 { 340 let ion: i64 = pep_b_ion_q4(bkseq, bi) 341 let ib: *u8 = sys_mmap(24) 342 var im: i64 = ion 343 var ik: i64 = 0 344 while im > 0 { ib[ik] = (48 + (im % 10)) as u8; im = im / 10; ik = ik + 1 } 345 let ir: *u8 = sys_mmap(24) 346 var ij: i64 = 0 347 while ij < ik { ir[ij] = ib[ik - 1 - ij]; ij = ij + 1 } 348 ir[ik] = 0 as u8 349 av17[2 + bi] = ir as i64 350 bi = bi + 1 351 } 352 let j17: *NxJson = nx_json_new(4096) 353 qc_dispatch(11, av17, j17) 354 let dn_seq: i64 = j_has(j17, "\"sequence\":\"RPPGFSPFR\"" as *u8) 355 let dn_len: i64 = j_has(j17, "\"length\":9" as *u8) 356 let dn_amb: i64 = j_has(j17, "\"leu_ile_ambiguous_positions\":0" as *u8) 357 let dn_anchored: i64 = j_has(j17, "\"grounding\":\"ANCHORED\"" as *u8) 358 t_puts("T17 de novo bradykinin via facade: seq=" as *u8); t_putn(dn_seq); t_puts(" len9=" as *u8); t_putn(dn_len); t_puts(" 0-ambiguous=" as *u8); t_putn(dn_amb); t_puts(" ANCHORED=" as *u8); t_putn(dn_anchored); t_puts(": " as *u8) 359 var ok17: i64 = 1 360 if dn_seq != 1 { ok17 = 0 } 361 if dn_len != 1 { ok17 = 0 } 362 if dn_amb != 1 { ok17 = 0 } 363 if dn_anchored != 1 { ok17 = 0 } 364 if ok17 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 365 366 t_puts("QC-SVC-GATE passed " as *u8); t_putn(pass); t_puts("/" as *u8); t_putn(total) 367 if pass == total { t_puts(" verdict=GREEN\n" as *u8); sys_exit(0); return 0 } 368 t_puts(" verdict=RED\n" as *u8); sys_exit(1); return 1 369}