@genobank/biofs 3.1.0 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (499) hide show
  1. package/CHANGELOG.md +663 -462
  2. package/dist/abi/USDC.json +33 -0
  3. package/dist/abi/sequentia/BioAgentRegistry.json +20 -0
  4. package/dist/abi/sequentia/BioCIDRegistry.json +139 -0
  5. package/dist/abi/sequentia/BioPIL.json +130 -0
  6. package/dist/abi/sequentia/ConsentManager.json +620 -0
  7. package/dist/abi/sequentia/OpenCravatJobs.json +988 -0
  8. package/dist/abi/sequentia/PaymentRouter.json +638 -0
  9. package/dist/commands/agent/list-sequentia.d.ts +17 -0
  10. package/dist/commands/agent/list-sequentia.d.ts.map +1 -0
  11. package/dist/commands/agent/list-sequentia.js +87 -0
  12. package/dist/commands/agent/list-sequentia.js.map +1 -0
  13. package/dist/commands/agent/register-sequentia.d.ts +33 -0
  14. package/dist/commands/agent/register-sequentia.d.ts.map +1 -0
  15. package/dist/commands/agent/register-sequentia.js +145 -0
  16. package/dist/commands/agent/register-sequentia.js.map +1 -0
  17. package/dist/commands/align-shard/exec.d.ts +45 -0
  18. package/dist/commands/align-shard/exec.d.ts.map +1 -0
  19. package/dist/commands/align-shard/exec.js +549 -0
  20. package/dist/commands/align-shard/exec.js.map +1 -0
  21. package/dist/commands/align-shard/submit.d.ts +37 -0
  22. package/dist/commands/align-shard/submit.d.ts.map +1 -0
  23. package/dist/commands/align-shard/submit.js +117 -0
  24. package/dist/commands/align-shard/submit.js.map +1 -0
  25. package/dist/commands/ancestry/ingest.d.ts +34 -0
  26. package/dist/commands/ancestry/ingest.d.ts.map +1 -0
  27. package/dist/commands/ancestry/ingest.js +175 -0
  28. package/dist/commands/ancestry/ingest.js.map +1 -0
  29. package/dist/commands/ancestry/share.d.ts +33 -0
  30. package/dist/commands/ancestry/share.d.ts.map +1 -0
  31. package/dist/commands/ancestry/share.js +154 -0
  32. package/dist/commands/ancestry/share.js.map +1 -0
  33. package/dist/commands/ancestry/somos.d.ts +34 -0
  34. package/dist/commands/ancestry/somos.d.ts.map +1 -0
  35. package/dist/commands/ancestry/somos.js +151 -0
  36. package/dist/commands/ancestry/somos.js.map +1 -0
  37. package/dist/commands/ancestry/status.d.ts +14 -0
  38. package/dist/commands/ancestry/status.d.ts.map +1 -0
  39. package/dist/commands/ancestry/status.js +74 -0
  40. package/dist/commands/ancestry/status.js.map +1 -0
  41. package/dist/commands/annotate/status.d.ts +11 -4
  42. package/dist/commands/annotate/status.d.ts.map +1 -1
  43. package/dist/commands/annotate/status.js +66 -99
  44. package/dist/commands/annotate/status.js.map +1 -1
  45. package/dist/commands/annotate/submit.d.ts +15 -5
  46. package/dist/commands/annotate/submit.d.ts.map +1 -1
  47. package/dist/commands/annotate/submit.js +86 -266
  48. package/dist/commands/annotate/submit.js.map +1 -1
  49. package/dist/commands/benchmark.d.ts +50 -0
  50. package/dist/commands/benchmark.d.ts.map +1 -0
  51. package/dist/commands/benchmark.js +608 -0
  52. package/dist/commands/benchmark.js.map +1 -0
  53. package/dist/commands/biofiles.d.ts +1 -0
  54. package/dist/commands/biofiles.d.ts.map +1 -1
  55. package/dist/commands/biofiles.js +19 -6
  56. package/dist/commands/biofiles.js.map +1 -1
  57. package/dist/commands/biowallet/bind.d.ts +12 -0
  58. package/dist/commands/biowallet/bind.d.ts.map +1 -0
  59. package/dist/commands/biowallet/bind.js +85 -0
  60. package/dist/commands/biowallet/bind.js.map +1 -0
  61. package/dist/commands/biowallet/create.d.ts +40 -0
  62. package/dist/commands/biowallet/create.d.ts.map +1 -0
  63. package/dist/commands/biowallet/create.js +191 -0
  64. package/dist/commands/biowallet/create.js.map +1 -0
  65. package/dist/commands/biowallet/family.d.ts +48 -0
  66. package/dist/commands/biowallet/family.d.ts.map +1 -0
  67. package/dist/commands/biowallet/family.js +310 -0
  68. package/dist/commands/biowallet/family.js.map +1 -0
  69. package/dist/commands/biowallet/list.d.ts +15 -0
  70. package/dist/commands/biowallet/list.d.ts.map +1 -0
  71. package/dist/commands/biowallet/list.js +81 -0
  72. package/dist/commands/biowallet/list.js.map +1 -0
  73. package/dist/commands/bode.d.ts +34 -0
  74. package/dist/commands/bode.d.ts.map +1 -0
  75. package/dist/commands/bode.js +257 -0
  76. package/dist/commands/bode.js.map +1 -0
  77. package/dist/commands/claim.d.ts +32 -0
  78. package/dist/commands/claim.d.ts.map +1 -0
  79. package/dist/commands/claim.js +138 -0
  80. package/dist/commands/claim.js.map +1 -0
  81. package/dist/commands/clinical.d.ts +49 -0
  82. package/dist/commands/clinical.d.ts.map +1 -0
  83. package/dist/commands/clinical.js +273 -0
  84. package/dist/commands/clinical.js.map +1 -0
  85. package/dist/commands/cohort-acmg.d.ts +42 -0
  86. package/dist/commands/cohort-acmg.d.ts.map +1 -0
  87. package/dist/commands/cohort-acmg.js +319 -0
  88. package/dist/commands/cohort-acmg.js.map +1 -0
  89. package/dist/commands/cohort-fourier-score.d.ts +57 -0
  90. package/dist/commands/cohort-fourier-score.d.ts.map +1 -0
  91. package/dist/commands/cohort-fourier-score.js +390 -0
  92. package/dist/commands/cohort-fourier-score.js.map +1 -0
  93. package/dist/commands/cohort-pipeline.d.ts +49 -0
  94. package/dist/commands/cohort-pipeline.d.ts.map +1 -0
  95. package/dist/commands/cohort-pipeline.js +308 -0
  96. package/dist/commands/cohort-pipeline.js.map +1 -0
  97. package/dist/commands/cohort-train.d.ts +45 -0
  98. package/dist/commands/cohort-train.d.ts.map +1 -0
  99. package/dist/commands/cohort-train.js +308 -0
  100. package/dist/commands/cohort-train.js.map +1 -0
  101. package/dist/commands/comethyl/exec.d.ts +40 -0
  102. package/dist/commands/comethyl/exec.d.ts.map +1 -0
  103. package/dist/commands/comethyl/exec.js +493 -0
  104. package/dist/commands/comethyl/exec.js.map +1 -0
  105. package/dist/commands/comethyl/submit.d.ts +35 -0
  106. package/dist/commands/comethyl/submit.d.ts.map +1 -0
  107. package/dist/commands/comethyl/submit.js +98 -0
  108. package/dist/commands/comethyl/submit.js.map +1 -0
  109. package/dist/commands/consent.d.ts +10 -0
  110. package/dist/commands/consent.d.ts.map +1 -0
  111. package/dist/commands/consent.js +114 -0
  112. package/dist/commands/consent.js.map +1 -0
  113. package/dist/commands/dipcall/exec.d.ts +25 -0
  114. package/dist/commands/dipcall/exec.d.ts.map +1 -0
  115. package/dist/commands/dipcall/exec.js +207 -0
  116. package/dist/commands/dipcall/exec.js.map +1 -0
  117. package/dist/commands/dipcall/submit.d.ts +22 -0
  118. package/dist/commands/dipcall/submit.d.ts.map +1 -0
  119. package/dist/commands/dipcall/submit.js +81 -0
  120. package/dist/commands/dipcall/submit.js.map +1 -0
  121. package/dist/commands/download-with-consent.d.ts +1 -0
  122. package/dist/commands/download-with-consent.d.ts.map +1 -1
  123. package/dist/commands/download-with-consent.js +32 -0
  124. package/dist/commands/download-with-consent.js.map +1 -1
  125. package/dist/commands/download.d.ts +2 -0
  126. package/dist/commands/download.d.ts.map +1 -1
  127. package/dist/commands/download.js +31 -0
  128. package/dist/commands/download.js.map +1 -1
  129. package/dist/commands/duet.d.ts +39 -0
  130. package/dist/commands/duet.d.ts.map +1 -0
  131. package/dist/commands/duet.js +323 -0
  132. package/dist/commands/duet.js.map +1 -0
  133. package/dist/commands/erase.d.ts +29 -0
  134. package/dist/commands/erase.d.ts.map +1 -0
  135. package/dist/commands/erase.js +136 -0
  136. package/dist/commands/erase.js.map +1 -0
  137. package/dist/commands/family-status.d.ts +3 -0
  138. package/dist/commands/family-status.d.ts.map +1 -1
  139. package/dist/commands/family-status.js +279 -166
  140. package/dist/commands/family-status.js.map +1 -1
  141. package/dist/commands/fingerprint.d.ts +2 -0
  142. package/dist/commands/fingerprint.d.ts.map +1 -1
  143. package/dist/commands/fingerprint.js +4 -0
  144. package/dist/commands/fingerprint.js.map +1 -1
  145. package/dist/commands/fluency/index.d.ts +7 -0
  146. package/dist/commands/fluency/index.d.ts.map +1 -0
  147. package/dist/commands/fluency/index.js +122 -0
  148. package/dist/commands/fluency/index.js.map +1 -0
  149. package/dist/commands/fourier-score.d.ts +36 -0
  150. package/dist/commands/fourier-score.d.ts.map +1 -0
  151. package/dist/commands/fourier-score.js +713 -0
  152. package/dist/commands/fourier-score.js.map +1 -0
  153. package/dist/commands/fuse.d.ts.map +1 -1
  154. package/dist/commands/fuse.js +29 -7
  155. package/dist/commands/fuse.js.map +1 -1
  156. package/dist/commands/hifi-align/exec.d.ts +23 -0
  157. package/dist/commands/hifi-align/exec.d.ts.map +1 -0
  158. package/dist/commands/hifi-align/exec.js +224 -0
  159. package/dist/commands/hifi-align/exec.js.map +1 -0
  160. package/dist/commands/hifi-align/submit.d.ts +22 -0
  161. package/dist/commands/hifi-align/submit.d.ts.map +1 -0
  162. package/dist/commands/hifi-align/submit.js +82 -0
  163. package/dist/commands/hifi-align/submit.js.map +1 -0
  164. package/dist/commands/hifi-deepvariant/exec.d.ts +29 -0
  165. package/dist/commands/hifi-deepvariant/exec.d.ts.map +1 -0
  166. package/dist/commands/hifi-deepvariant/exec.js +280 -0
  167. package/dist/commands/hifi-deepvariant/exec.js.map +1 -0
  168. package/dist/commands/hifi-deepvariant/submit.d.ts +23 -0
  169. package/dist/commands/hifi-deepvariant/submit.d.ts.map +1 -0
  170. package/dist/commands/hifi-deepvariant/submit.js +80 -0
  171. package/dist/commands/hifi-deepvariant/submit.js.map +1 -0
  172. package/dist/commands/hifi-methyl/exec.d.ts +25 -0
  173. package/dist/commands/hifi-methyl/exec.d.ts.map +1 -0
  174. package/dist/commands/hifi-methyl/exec.js +243 -0
  175. package/dist/commands/hifi-methyl/exec.js.map +1 -0
  176. package/dist/commands/hifi-methyl/submit.d.ts +22 -0
  177. package/dist/commands/hifi-methyl/submit.d.ts.map +1 -0
  178. package/dist/commands/hifi-methyl/submit.js +78 -0
  179. package/dist/commands/hifi-methyl/submit.js.map +1 -0
  180. package/dist/commands/htsget.d.ts +6 -0
  181. package/dist/commands/htsget.d.ts.map +1 -1
  182. package/dist/commands/htsget.js +31 -6
  183. package/dist/commands/htsget.js.map +1 -1
  184. package/dist/commands/imaging/attribute.d.ts +19 -0
  185. package/dist/commands/imaging/attribute.d.ts.map +1 -0
  186. package/dist/commands/imaging/attribute.js +102 -0
  187. package/dist/commands/imaging/attribute.js.map +1 -0
  188. package/dist/commands/imaging/characterize.d.ts +20 -0
  189. package/dist/commands/imaging/characterize.d.ts.map +1 -0
  190. package/dist/commands/imaging/characterize.js +105 -0
  191. package/dist/commands/imaging/characterize.js.map +1 -0
  192. package/dist/commands/imaging/compare.d.ts +33 -0
  193. package/dist/commands/imaging/compare.d.ts.map +1 -0
  194. package/dist/commands/imaging/compare.js +129 -0
  195. package/dist/commands/imaging/compare.js.map +1 -0
  196. package/dist/commands/imaging/enrich.d.ts +28 -0
  197. package/dist/commands/imaging/enrich.d.ts.map +1 -0
  198. package/dist/commands/imaging/enrich.js +130 -0
  199. package/dist/commands/imaging/enrich.js.map +1 -0
  200. package/dist/commands/imaging/findings.d.ts +21 -0
  201. package/dist/commands/imaging/findings.d.ts.map +1 -0
  202. package/dist/commands/imaging/findings.js +134 -0
  203. package/dist/commands/imaging/findings.js.map +1 -0
  204. package/dist/commands/imaging/lesions.d.ts +21 -0
  205. package/dist/commands/imaging/lesions.d.ts.map +1 -0
  206. package/dist/commands/imaging/lesions.js +131 -0
  207. package/dist/commands/imaging/lesions.js.map +1 -0
  208. package/dist/commands/imaging/submit.d.ts +32 -0
  209. package/dist/commands/imaging/submit.d.ts.map +1 -0
  210. package/dist/commands/imaging/submit.js +118 -0
  211. package/dist/commands/imaging/submit.js.map +1 -0
  212. package/dist/commands/imaging/trajectory.d.ts +23 -0
  213. package/dist/commands/imaging/trajectory.d.ts.map +1 -0
  214. package/dist/commands/imaging/trajectory.js +134 -0
  215. package/dist/commands/imaging/trajectory.js.map +1 -0
  216. package/dist/commands/imaging/twin.d.ts +32 -0
  217. package/dist/commands/imaging/twin.d.ts.map +1 -0
  218. package/dist/commands/imaging/twin.js +168 -0
  219. package/dist/commands/imaging/twin.js.map +1 -0
  220. package/dist/commands/ingest-rna-tpm.d.ts +33 -0
  221. package/dist/commands/ingest-rna-tpm.d.ts.map +1 -0
  222. package/dist/commands/ingest-rna-tpm.js +104 -0
  223. package/dist/commands/ingest-rna-tpm.js.map +1 -0
  224. package/dist/commands/interpret/status.d.ts +14 -0
  225. package/dist/commands/interpret/status.d.ts.map +1 -0
  226. package/dist/commands/interpret/status.js +83 -0
  227. package/dist/commands/interpret/status.js.map +1 -0
  228. package/dist/commands/interpret/submit.d.ts +22 -0
  229. package/dist/commands/interpret/submit.d.ts.map +1 -0
  230. package/dist/commands/interpret/submit.js +103 -0
  231. package/dist/commands/interpret/submit.js.map +1 -0
  232. package/dist/commands/inventory/cohort.d.ts +29 -0
  233. package/dist/commands/inventory/cohort.d.ts.map +1 -0
  234. package/dist/commands/inventory/cohort.js +136 -0
  235. package/dist/commands/inventory/cohort.js.map +1 -0
  236. package/dist/commands/inventory-register-sqlite.d.ts +36 -0
  237. package/dist/commands/inventory-register-sqlite.d.ts.map +1 -0
  238. package/dist/commands/inventory-register-sqlite.js +178 -0
  239. package/dist/commands/inventory-register-sqlite.js.map +1 -0
  240. package/dist/commands/job/recall.d.ts +6 -0
  241. package/dist/commands/job/recall.d.ts.map +1 -0
  242. package/dist/commands/job/recall.js +59 -0
  243. package/dist/commands/job/recall.js.map +1 -0
  244. package/dist/commands/job/reconcile.d.ts +19 -0
  245. package/dist/commands/job/reconcile.d.ts.map +1 -0
  246. package/dist/commands/job/reconcile.js +67 -0
  247. package/dist/commands/job/reconcile.js.map +1 -0
  248. package/dist/commands/lab/refreshCoverage.d.ts +53 -0
  249. package/dist/commands/lab/refreshCoverage.d.ts.map +1 -0
  250. package/dist/commands/lab/refreshCoverage.js +244 -0
  251. package/dist/commands/lab/refreshCoverage.js.map +1 -0
  252. package/dist/commands/liftover/exec.d.ts +27 -0
  253. package/dist/commands/liftover/exec.d.ts.map +1 -0
  254. package/dist/commands/liftover/exec.js +258 -0
  255. package/dist/commands/liftover/exec.js.map +1 -0
  256. package/dist/commands/liftover/submit.d.ts +22 -0
  257. package/dist/commands/liftover/submit.d.ts.map +1 -0
  258. package/dist/commands/liftover/submit.js +79 -0
  259. package/dist/commands/liftover/submit.js.map +1 -0
  260. package/dist/commands/lineage.d.ts +6 -0
  261. package/dist/commands/lineage.d.ts.map +1 -0
  262. package/dist/commands/lineage.js +126 -0
  263. package/dist/commands/lineage.js.map +1 -0
  264. package/dist/commands/methyl/exec.d.ts +47 -0
  265. package/dist/commands/methyl/exec.d.ts.map +1 -0
  266. package/dist/commands/methyl/exec.js +565 -0
  267. package/dist/commands/methyl/exec.js.map +1 -0
  268. package/dist/commands/methyl/submit.d.ts +25 -0
  269. package/dist/commands/methyl/submit.d.ts.map +1 -0
  270. package/dist/commands/methyl/submit.js +98 -0
  271. package/dist/commands/methyl/submit.js.map +1 -0
  272. package/dist/commands/mount.d.ts +17 -2
  273. package/dist/commands/mount.d.ts.map +1 -1
  274. package/dist/commands/mount.js +158 -6
  275. package/dist/commands/mount.js.map +1 -1
  276. package/dist/commands/myvariant.d.ts +60 -0
  277. package/dist/commands/myvariant.d.ts.map +1 -0
  278. package/dist/commands/myvariant.js +433 -0
  279. package/dist/commands/myvariant.js.map +1 -0
  280. package/dist/commands/ont-variants/exec.d.ts +24 -0
  281. package/dist/commands/ont-variants/exec.d.ts.map +1 -0
  282. package/dist/commands/ont-variants/exec.js +230 -0
  283. package/dist/commands/ont-variants/exec.js.map +1 -0
  284. package/dist/commands/ont-variants/submit.d.ts +22 -0
  285. package/dist/commands/ont-variants/submit.d.ts.map +1 -0
  286. package/dist/commands/ont-variants/submit.js +78 -0
  287. package/dist/commands/ont-variants/submit.js.map +1 -0
  288. package/dist/commands/pbsv/exec.d.ts +24 -0
  289. package/dist/commands/pbsv/exec.d.ts.map +1 -0
  290. package/dist/commands/pbsv/exec.js +231 -0
  291. package/dist/commands/pbsv/exec.js.map +1 -0
  292. package/dist/commands/pbsv/submit.d.ts +22 -0
  293. package/dist/commands/pbsv/submit.d.ts.map +1 -0
  294. package/dist/commands/pbsv/submit.js +78 -0
  295. package/dist/commands/pbsv/submit.js.map +1 -0
  296. package/dist/commands/phase/exec.d.ts +26 -0
  297. package/dist/commands/phase/exec.d.ts.map +1 -0
  298. package/dist/commands/phase/exec.js +246 -0
  299. package/dist/commands/phase/exec.js.map +1 -0
  300. package/dist/commands/phase/submit.d.ts +24 -0
  301. package/dist/commands/phase/submit.d.ts.map +1 -0
  302. package/dist/commands/phase/submit.js +83 -0
  303. package/dist/commands/phase/submit.js.map +1 -0
  304. package/dist/commands/pipe.d.ts +4 -2
  305. package/dist/commands/pipe.d.ts.map +1 -1
  306. package/dist/commands/pipe.js +55 -50
  307. package/dist/commands/pipe.js.map +1 -1
  308. package/dist/commands/pipeline/runWes.d.ts +28 -0
  309. package/dist/commands/pipeline/runWes.d.ts.map +1 -0
  310. package/dist/commands/pipeline/runWes.js +276 -0
  311. package/dist/commands/pipeline/runWes.js.map +1 -0
  312. package/dist/commands/profile.d.ts +8 -0
  313. package/dist/commands/profile.d.ts.map +1 -0
  314. package/dist/commands/profile.js +193 -0
  315. package/dist/commands/profile.js.map +1 -0
  316. package/dist/commands/psm-consensus.d.ts +72 -0
  317. package/dist/commands/psm-consensus.d.ts.map +1 -0
  318. package/dist/commands/psm-consensus.js +338 -0
  319. package/dist/commands/psm-consensus.js.map +1 -0
  320. package/dist/commands/qc/exec.d.ts +32 -0
  321. package/dist/commands/qc/exec.d.ts.map +1 -0
  322. package/dist/commands/qc/exec.js +350 -0
  323. package/dist/commands/qc/exec.js.map +1 -0
  324. package/dist/commands/qc/submit.d.ts +23 -0
  325. package/dist/commands/qc/submit.d.ts.map +1 -0
  326. package/dist/commands/qc/submit.js +88 -0
  327. package/dist/commands/qc/submit.js.map +1 -0
  328. package/dist/commands/query.d.ts +37 -0
  329. package/dist/commands/query.d.ts.map +1 -0
  330. package/dist/commands/query.js +170 -0
  331. package/dist/commands/query.js.map +1 -0
  332. package/dist/commands/repeat-genotype/exec.d.ts +26 -0
  333. package/dist/commands/repeat-genotype/exec.d.ts.map +1 -0
  334. package/dist/commands/repeat-genotype/exec.js +245 -0
  335. package/dist/commands/repeat-genotype/exec.js.map +1 -0
  336. package/dist/commands/repeat-genotype/submit.d.ts +23 -0
  337. package/dist/commands/repeat-genotype/submit.d.ts.map +1 -0
  338. package/dist/commands/repeat-genotype/submit.js +82 -0
  339. package/dist/commands/repeat-genotype/submit.js.map +1 -0
  340. package/dist/commands/researcher/passport.d.ts +15 -0
  341. package/dist/commands/researcher/passport.d.ts.map +1 -0
  342. package/dist/commands/researcher/passport.js +98 -0
  343. package/dist/commands/researcher/passport.js.map +1 -0
  344. package/dist/commands/researcher/register.d.ts +18 -0
  345. package/dist/commands/researcher/register.d.ts.map +1 -0
  346. package/dist/commands/researcher/register.js +277 -0
  347. package/dist/commands/researcher/register.js.map +1 -0
  348. package/dist/commands/researcher/status.d.ts +6 -0
  349. package/dist/commands/researcher/status.d.ts.map +1 -0
  350. package/dist/commands/researcher/status.js +111 -0
  351. package/dist/commands/researcher/status.js.map +1 -0
  352. package/dist/commands/room.d.ts +31 -0
  353. package/dist/commands/room.d.ts.map +1 -0
  354. package/dist/commands/room.js +486 -0
  355. package/dist/commands/room.js.map +1 -0
  356. package/dist/commands/route/anchor.d.ts +42 -0
  357. package/dist/commands/route/anchor.d.ts.map +1 -0
  358. package/dist/commands/route/anchor.js +213 -0
  359. package/dist/commands/route/anchor.js.map +1 -0
  360. package/dist/commands/route/index.d.ts +27 -0
  361. package/dist/commands/route/index.d.ts.map +1 -0
  362. package/dist/commands/route/index.js +82 -0
  363. package/dist/commands/route/index.js.map +1 -0
  364. package/dist/commands/rrm-consensus.d.ts +74 -0
  365. package/dist/commands/rrm-consensus.d.ts.map +1 -0
  366. package/dist/commands/rrm-consensus.js +334 -0
  367. package/dist/commands/rrm-consensus.js.map +1 -0
  368. package/dist/commands/rrm-distribution.d.ts +34 -0
  369. package/dist/commands/rrm-distribution.d.ts.map +1 -0
  370. package/dist/commands/rrm-distribution.js +743 -0
  371. package/dist/commands/rrm-distribution.js.map +1 -0
  372. package/dist/commands/rrm-train.d.ts +33 -0
  373. package/dist/commands/rrm-train.d.ts.map +1 -0
  374. package/dist/commands/rrm-train.js +549 -0
  375. package/dist/commands/rrm-train.js.map +1 -0
  376. package/dist/commands/samples.d.ts +25 -0
  377. package/dist/commands/samples.d.ts.map +1 -0
  378. package/dist/commands/samples.js +184 -0
  379. package/dist/commands/samples.js.map +1 -0
  380. package/dist/commands/score-protein.d.ts +13 -0
  381. package/dist/commands/score-protein.d.ts.map +1 -0
  382. package/dist/commands/score-protein.js +360 -0
  383. package/dist/commands/score-protein.js.map +1 -0
  384. package/dist/commands/stream.d.ts +7 -0
  385. package/dist/commands/stream.d.ts.map +1 -1
  386. package/dist/commands/stream.js +26 -41
  387. package/dist/commands/stream.js.map +1 -1
  388. package/dist/commands/sv-call/exec.d.ts +23 -0
  389. package/dist/commands/sv-call/exec.d.ts.map +1 -0
  390. package/dist/commands/sv-call/exec.js +233 -0
  391. package/dist/commands/sv-call/exec.js.map +1 -0
  392. package/dist/commands/sv-call/submit.d.ts +21 -0
  393. package/dist/commands/sv-call/submit.d.ts.map +1 -0
  394. package/dist/commands/sv-call/submit.js +77 -0
  395. package/dist/commands/sv-call/submit.js.map +1 -0
  396. package/dist/commands/tele.d.ts +42 -0
  397. package/dist/commands/tele.d.ts.map +1 -0
  398. package/dist/commands/tele.js +559 -0
  399. package/dist/commands/tele.js.map +1 -0
  400. package/dist/commands/tokenize-spectrum.d.ts +58 -0
  401. package/dist/commands/tokenize-spectrum.d.ts.map +1 -0
  402. package/dist/commands/tokenize-spectrum.js +297 -0
  403. package/dist/commands/tokenize-spectrum.js.map +1 -0
  404. package/dist/commands/umount.d.ts.map +1 -1
  405. package/dist/commands/umount.js +42 -1
  406. package/dist/commands/umount.js.map +1 -1
  407. package/dist/commands/variants.d.ts +42 -0
  408. package/dist/commands/variants.d.ts.map +1 -0
  409. package/dist/commands/variants.js +237 -0
  410. package/dist/commands/variants.js.map +1 -0
  411. package/dist/commands/verkko/exec.d.ts +27 -0
  412. package/dist/commands/verkko/exec.d.ts.map +1 -0
  413. package/dist/commands/verkko/exec.js +223 -0
  414. package/dist/commands/verkko/exec.js.map +1 -0
  415. package/dist/commands/verkko/submit.d.ts +24 -0
  416. package/dist/commands/verkko/submit.d.ts.map +1 -0
  417. package/dist/commands/verkko/submit.js +96 -0
  418. package/dist/commands/verkko/submit.js.map +1 -0
  419. package/dist/commands/wavelet-consensus.d.ts +69 -0
  420. package/dist/commands/wavelet-consensus.d.ts.map +1 -0
  421. package/dist/commands/wavelet-consensus.js +338 -0
  422. package/dist/commands/wavelet-consensus.js.map +1 -0
  423. package/dist/commands/workspace.d.ts +59 -0
  424. package/dist/commands/workspace.d.ts.map +1 -0
  425. package/dist/commands/workspace.js +419 -0
  426. package/dist/commands/workspace.js.map +1 -0
  427. package/dist/commands/x402/index.d.ts +8 -0
  428. package/dist/commands/x402/index.d.ts.map +1 -1
  429. package/dist/commands/x402/index.js +100 -2
  430. package/dist/commands/x402/index.js.map +1 -1
  431. package/dist/commands/x402/pipeline-cancer-twin.d.ts +119 -0
  432. package/dist/commands/x402/pipeline-cancer-twin.d.ts.map +1 -0
  433. package/dist/commands/x402/pipeline-cancer-twin.js +326 -0
  434. package/dist/commands/x402/pipeline-cancer-twin.js.map +1 -0
  435. package/dist/commands/x402/submit.d.ts +72 -0
  436. package/dist/commands/x402/submit.d.ts.map +1 -0
  437. package/dist/commands/x402/submit.js +227 -0
  438. package/dist/commands/x402/submit.js.map +1 -0
  439. package/dist/commands/x402/verify-payment.d.ts +24 -0
  440. package/dist/commands/x402/verify-payment.d.ts.map +1 -0
  441. package/dist/commands/x402/verify-payment.js +113 -0
  442. package/dist/commands/x402/verify-payment.js.map +1 -0
  443. package/dist/index.js +2804 -196
  444. package/dist/index.js.map +1 -1
  445. package/dist/lib/api/client.d.ts +1 -0
  446. package/dist/lib/api/client.d.ts.map +1 -1
  447. package/dist/lib/api/client.js +22 -0
  448. package/dist/lib/api/client.js.map +1 -1
  449. package/dist/lib/api/fuse-client.d.ts +281 -0
  450. package/dist/lib/api/fuse-client.d.ts.map +1 -1
  451. package/dist/lib/api/fuse-client.js +428 -0
  452. package/dist/lib/api/fuse-client.js.map +1 -1
  453. package/dist/lib/biofiles/resolver.d.ts +1 -1
  454. package/dist/lib/biofiles/resolver.d.ts.map +1 -1
  455. package/dist/lib/biofiles/resolver.js +173 -138
  456. package/dist/lib/biofiles/resolver.js.map +1 -1
  457. package/dist/lib/config/constants.d.ts +1 -0
  458. package/dist/lib/config/constants.d.ts.map +1 -1
  459. package/dist/lib/config/constants.js +1 -0
  460. package/dist/lib/config/constants.js.map +1 -1
  461. package/dist/lib/config/paths.d.ts +6 -6
  462. package/dist/lib/config/paths.d.ts.map +1 -1
  463. package/dist/lib/config/paths.js +56 -17
  464. package/dist/lib/config/paths.js.map +1 -1
  465. package/dist/lib/gene-map.d.ts +24 -0
  466. package/dist/lib/gene-map.d.ts.map +1 -0
  467. package/dist/lib/gene-map.js +114 -0
  468. package/dist/lib/gene-map.js.map +1 -0
  469. package/dist/lib/htsget/client.d.ts +28 -5
  470. package/dist/lib/htsget/client.d.ts.map +1 -1
  471. package/dist/lib/htsget/client.js +96 -18
  472. package/dist/lib/htsget/client.js.map +1 -1
  473. package/dist/lib/sequentia/BioAgentRegistry.d.ts +98 -0
  474. package/dist/lib/sequentia/BioAgentRegistry.d.ts.map +1 -0
  475. package/dist/lib/sequentia/BioAgentRegistry.js +209 -0
  476. package/dist/lib/sequentia/BioAgentRegistry.js.map +1 -0
  477. package/dist/lib/tele/core.d.ts +71 -0
  478. package/dist/lib/tele/core.d.ts.map +1 -0
  479. package/dist/lib/tele/core.js +387 -0
  480. package/dist/lib/tele/core.js.map +1 -0
  481. package/dist/lib/x402/cancer-twin-agents.d.ts +65 -0
  482. package/dist/lib/x402/cancer-twin-agents.d.ts.map +1 -0
  483. package/dist/lib/x402/cancer-twin-agents.js +114 -0
  484. package/dist/lib/x402/cancer-twin-agents.js.map +1 -0
  485. package/dist/lib/x402/sequentia-pay.d.ts +51 -0
  486. package/dist/lib/x402/sequentia-pay.d.ts.map +1 -0
  487. package/dist/lib/x402/sequentia-pay.js +186 -0
  488. package/dist/lib/x402/sequentia-pay.js.map +1 -0
  489. package/dist/types/biofiles.d.ts +1 -1
  490. package/dist/types/biofiles.d.ts.map +1 -1
  491. package/dist/utils/errorReporter.d.ts +1 -0
  492. package/dist/utils/errorReporter.d.ts.map +1 -1
  493. package/dist/utils/errorReporter.js +39 -1
  494. package/dist/utils/errorReporter.js.map +1 -1
  495. package/dist/version.d.ts +2 -0
  496. package/dist/version.d.ts.map +1 -0
  497. package/dist/version.js +20 -0
  498. package/dist/version.js.map +1 -0
  499. package/package.json +5 -4
@@ -0,0 +1,743 @@
1
+ "use strict";
2
+ /**
3
+ * biofs rrm-distribution <gene>
4
+ *
5
+ * Pull ClinVar-classified missense variants for a gene and compute Cosic-RRM
6
+ * features for each, producing the empirical distribution that lets us rank
7
+ * individual patient variants against known pathogenic vs known benign.
8
+ *
9
+ * Pipeline:
10
+ * 1. NCBI E-utils esearch for ClinVar IDs in <gene> with germline missense
11
+ * classifications (P, LP, VUS, LB, B).
12
+ * 2. esummary on each id for canonical_spdi + classification + HGVS.
13
+ * 3. For each missense variant: pull WT residue from the cached UniProt
14
+ * FASTA, build MT sequence by single-residue swap, compute Cosic features
15
+ * (windowed Σ|ΔF|, full-protein L1 spectral distance, multi-peak
16
+ * weighted aggregate, ratio at primary f_c).
17
+ * 4. Save to ~/.biofs/cache/rrm/<gene>-distribution.json.
18
+ * 5. If --highlight is passed, render distribution plot with the highlighted
19
+ * variants marked, separated by classification class.
20
+ *
21
+ * Use case: validate that Cosic features discriminate pathogenic from benign,
22
+ * and report the ranking percentile for n-of-1 variants.
23
+ */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || (function () {
41
+ var ownKeys = function(o) {
42
+ ownKeys = Object.getOwnPropertyNames || function (o) {
43
+ var ar = [];
44
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
45
+ return ar;
46
+ };
47
+ return ownKeys(o);
48
+ };
49
+ return function (mod) {
50
+ if (mod && mod.__esModule) return mod;
51
+ var result = {};
52
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
53
+ __setModuleDefault(result, mod);
54
+ return result;
55
+ };
56
+ })();
57
+ var __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.rrmDistributionCommand = rrmDistributionCommand;
62
+ const child_process_1 = require("child_process");
63
+ const fs = __importStar(require("fs"));
64
+ const path = __importStar(require("path"));
65
+ const os = __importStar(require("os"));
66
+ const chalk_1 = __importDefault(require("chalk"));
67
+ const ora_1 = __importDefault(require("ora"));
68
+ const RRM_CACHE_DIR = path.join(os.homedir(), '.biofs', 'cache', 'rrm');
69
+ const UNIPROT_CACHE_DIR = path.join(os.homedir(), '.biofs', 'cache', 'uniprot');
70
+ const gene_map_1 = require("../lib/gene-map");
71
+ const HGVS_3_TO_1 = {
72
+ Ala: 'A', Arg: 'R', Asn: 'N', Asp: 'D', Cys: 'C',
73
+ Glu: 'E', Gln: 'Q', Gly: 'G', His: 'H', Ile: 'I',
74
+ Leu: 'L', Lys: 'K', Met: 'M', Phe: 'F', Pro: 'P',
75
+ Ser: 'S', Thr: 'T', Trp: 'W', Tyr: 'Y', Val: 'V',
76
+ Ter: '*',
77
+ };
78
+ function simplifyClassification(s) {
79
+ const t = (s || '').toLowerCase();
80
+ if (t.includes('conflicting'))
81
+ return 'conflicting';
82
+ if (t.includes('likely pathogenic'))
83
+ return 'likely_pathogenic';
84
+ if (t.includes('pathogenic'))
85
+ return 'pathogenic';
86
+ if (t.includes('likely benign'))
87
+ return 'likely_benign';
88
+ if (t.includes('benign'))
89
+ return 'benign';
90
+ if (t.includes('uncertain'))
91
+ return 'vus';
92
+ return 'other';
93
+ }
94
+ const SINGLE_AA = 'ACDEFGHIKLMNPQRSTVWY';
95
+ function parseProteinHgvs(s) {
96
+ if (!s)
97
+ return null;
98
+ // 3-letter form: p.Leu225Arg, NP_000410.2:p.Leu225Arg
99
+ const m3 = s.match(/p\.([A-Z][a-z]{2})(\d+)([A-Z][a-z]{2})/);
100
+ if (m3) {
101
+ const ref = HGVS_3_TO_1[m3[1]];
102
+ const alt = HGVS_3_TO_1[m3[3]];
103
+ if (ref && alt)
104
+ return { pos: parseInt(m3[2], 10), ref, alt };
105
+ }
106
+ // Single-letter form: V779A (ClinVar esummary's protein_change field)
107
+ const m1 = s.match(/^([A-Z])(\d+)([A-Z*])$/);
108
+ if (m1 && SINGLE_AA.includes(m1[1]) && (SINGLE_AA.includes(m1[3]) || m1[3] === '*')) {
109
+ return { pos: parseInt(m1[2], 10), ref: m1[1], alt: m1[3] };
110
+ }
111
+ // Multi-variant compound (e.g. "V779A;K989N") — take first
112
+ if (s.includes(';') || s.includes(',')) {
113
+ for (const part of s.split(/[;,]/)) {
114
+ const r = parseProteinHgvs(part.trim());
115
+ if (r)
116
+ return r;
117
+ }
118
+ }
119
+ return null;
120
+ }
121
+ function fetchClinVarIds(gene, retmax, quiet) {
122
+ // ClinVar E-utils search with VUS / Conflicting EXCLUDED at server side. The
123
+ // earlier version of this function pulled the default-ordered first 996
124
+ // entries which are dominated by Uncertain Significance and Conflicting
125
+ // Classification submissions, leaving 1-12 trainable variants on heavily-
126
+ // curated cancer genes like BRCA1 / BRCA2. The corrected query restricts
127
+ // to clinsig_pathogenic, clinsig_likely_pathogenic, clinsig_benign, and
128
+ // clinsig_likely_benign at the index level. We paginate via the retstart
129
+ // parameter so all matching variants are retrieved, capped at retmax.
130
+ // Reference: https://www.ncbi.nlm.nih.gov/clinvar/docs/api_search/
131
+ const sigTerms = encodeURIComponent('(clinsig_pathogenic[Properties] OR clinsig_likely_pathogenic[Properties] OR ' +
132
+ 'clinsig_benign[Properties] OR clinsig_likely_benign[Properties])');
133
+ const gene_term = encodeURIComponent(`${gene}[gene]`);
134
+ const missense_term = encodeURIComponent('missense_variant[molecular consequence]');
135
+ const term = `${gene_term}+AND+${sigTerms}+AND+${missense_term}`;
136
+ const pageSize = Math.min(retmax, 5000);
137
+ const allIds = [];
138
+ let retstart = 0;
139
+ while (allIds.length < retmax) {
140
+ const url = `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=clinvar&term=${term}&retmax=${pageSize}&retstart=${retstart}&retmode=json`;
141
+ const r = (0, child_process_1.spawnSync)('curl', ['-sS', '-A', 'biofs/3.2.0', '--max-time', '60', url], {
142
+ encoding: 'utf8',
143
+ maxBuffer: 50 * 1024 * 1024,
144
+ });
145
+ if (r.status !== 0)
146
+ throw new Error(`E-utils esearch failed: ${r.stderr}`);
147
+ const data = JSON.parse(r.stdout);
148
+ const idlist = data?.esearchresult?.idlist || [];
149
+ if (idlist.length === 0)
150
+ break;
151
+ allIds.push(...idlist);
152
+ const totalAvailable = parseInt(data?.esearchresult?.count || '0', 10);
153
+ if (!quiet) {
154
+ process.stderr.write(` ClinVar esearch page: retstart=${retstart}, got ${idlist.length}, cumulative ${allIds.length}/${totalAvailable}\n`);
155
+ }
156
+ if (allIds.length >= totalAvailable)
157
+ break;
158
+ retstart += idlist.length;
159
+ if (idlist.length < pageSize)
160
+ break;
161
+ // polite NCBI throttle (3 req/sec without API key)
162
+ (0, child_process_1.spawnSync)('sleep', ['0.4']);
163
+ }
164
+ return allIds.slice(0, retmax);
165
+ }
166
+ function fetchClinVarSummaries(ids, quiet) {
167
+ // Batch in chunks of 200 ids per esummary call
168
+ const summaries = [];
169
+ const chunkSize = 200;
170
+ for (let i = 0; i < ids.length; i += chunkSize) {
171
+ const chunk = ids.slice(i, i + chunkSize);
172
+ const url = `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=clinvar&id=${chunk.join(',')}&retmode=json`;
173
+ const r = (0, child_process_1.spawnSync)('curl', ['-sS', '-A', 'biofs/3.2.0', '--max-time', '120', url], {
174
+ encoding: 'utf8',
175
+ maxBuffer: 200 * 1024 * 1024,
176
+ });
177
+ if (r.status !== 0)
178
+ throw new Error(`E-utils esummary failed: ${r.stderr}`);
179
+ const data = JSON.parse(r.stdout);
180
+ const result = data?.result || {};
181
+ for (const id of chunk) {
182
+ if (result[id])
183
+ summaries.push(result[id]);
184
+ }
185
+ }
186
+ return summaries;
187
+ }
188
+ function extractMissenseFromSummary(summary) {
189
+ // ClinVar esummary places single-letter form in summary.protein_change (e.g. "V779A")
190
+ // and 3-letter HGVS in variation_set[*].variation_name (e.g. "...(ITGA2B):c.2336T>C (p.Val779Ala)").
191
+ const singleLetter = summary?.protein_change || '';
192
+ const variationName = (summary?.variation_set || [])[0]?.variation_name || '';
193
+ const proteinDescr = ((summary?.variation_set || [])[0]?.variation_loc || [])
194
+ .map((l) => l?.protein_descr)
195
+ .find(Boolean) || '';
196
+ const parsed = parseProteinHgvs(singleLetter) ||
197
+ parseProteinHgvs(variationName) ||
198
+ parseProteinHgvs(proteinDescr);
199
+ if (!parsed)
200
+ return null;
201
+ // Reject anything that isn't a single-residue substitution (e.g. nonsense / stop)
202
+ if (parsed.alt === '*')
203
+ return null;
204
+ const cls = summary?.germline_classification?.description ||
205
+ summary?.classification?.germline_classification?.description ||
206
+ summary?.clinical_significance?.description ||
207
+ '';
208
+ // Genomic coordinates + dbSNP cross-reference for downstream MyVariant.info lookups.
209
+ // Primary source is canonical_spdi (NC_xxx:0-based-pos:ref:alt). Fallback to
210
+ // variation_loc / variation_xrefs.
211
+ const vsFirst = (summary?.variation_set || [])[0];
212
+ const loc = (vsFirst?.variation_loc || []).find((l) => l?.assembly_name === 'GRCh38') || (vsFirst?.variation_loc || [])[0];
213
+ const xrefs = (vsFirst?.variation_xrefs || []);
214
+ const dbsnp = xrefs.find((x) => x?.db_source === 'dbSNP');
215
+ const cdnaChange = vsFirst?.cdna_change || '';
216
+ const spdi = vsFirst?.canonical_spdi || '';
217
+ let chr = String(loc?.chr || '');
218
+ let gpos = parseInt(String(loc?.start || '0'), 10);
219
+ let gRef = String(loc?.ref || '');
220
+ let gAlt = String(loc?.alt || '');
221
+ // Parse SPDI: NC_000017.11:44376319:A:G => chr 17, 1-based pos 44376320, ref A, alt G
222
+ if (spdi) {
223
+ const m = spdi.match(/^NC_0*(\d+|X|Y|M)\.\d+:(\d+):([ACGT]*):([ACGT]*)$/i);
224
+ if (m) {
225
+ const chrNum = m[1];
226
+ chr = chr || chrNum;
227
+ const spdiPos = parseInt(m[2], 10);
228
+ if (!gpos)
229
+ gpos = spdiPos + 1; // SPDI is 0-based
230
+ gRef = gRef || m[3];
231
+ gAlt = gAlt || m[4];
232
+ }
233
+ }
234
+ let hgvsGenomic = '';
235
+ if (chr && gpos && gRef && gAlt) {
236
+ hgvsGenomic = `chr${chr}:g.${gpos}${gRef}>${gAlt}`;
237
+ }
238
+ return {
239
+ variation_id: String(summary?.uid || ''),
240
+ hgvs_protein: variationName || singleLetter,
241
+ position: parsed.pos,
242
+ ref: parsed.ref,
243
+ alt: parsed.alt,
244
+ classification: cls,
245
+ classification_simple: simplifyClassification(cls),
246
+ review_status: summary?.germline_classification?.review_status || '',
247
+ last_evaluated: summary?.germline_classification?.last_evaluated || '',
248
+ chr,
249
+ genomic_pos: gpos || undefined,
250
+ cdna_change: cdnaChange,
251
+ dbsnp_rsid: dbsnp ? `rs${dbsnp.db_id}` : undefined,
252
+ hgvs_genomic: hgvsGenomic || undefined,
253
+ };
254
+ }
255
+ const EIIP = {
256
+ A: 0.0373, R: 0.0959, N: 0.0036, D: 0.1263, C: 0.0829,
257
+ E: 0.0058, Q: 0.0761, G: 0.0050, H: 0.0242, I: 0.0000,
258
+ L: 0.0000, K: 0.0371, M: 0.0823, F: 0.0946, P: 0.0198,
259
+ S: 0.0829, T: 0.0941, W: 0.0548, Y: 0.0516, V: 0.0057,
260
+ };
261
+ const PY_BATCH_SCORE = `
262
+ import json, sys, numpy as np
263
+
264
+ EIIP = ${JSON.stringify(EIIP)}
265
+
266
+ d = json.loads(sys.stdin.read())
267
+ seq = d['sequence']
268
+ common_length = d['common_length']
269
+ fc_freq = d['fc_freq']
270
+ peaks = d['peaks']
271
+
272
+ def encode_full(s):
273
+ s = s[:common_length] + 'X' * max(0, common_length - len(s))
274
+ v = np.array([EIIP.get(a, 0.0) for a in s], dtype=float)
275
+ return v - v.mean()
276
+
277
+ def spec_full(s):
278
+ v = encode_full(s)
279
+ X = np.abs(np.fft.rfft(v))
280
+ if X.sum() > 0: X = X / X.sum()
281
+ return X
282
+
283
+ Xw = spec_full(seq)
284
+ N = len(Xw)
285
+ fc_bin = int(round(fc_freq * 2 * (N - 1)))
286
+ fc_bin = max(0, min(N - 1, fc_bin))
287
+
288
+ # Windowed (N=31) features
289
+ def encode_window(s, center, N=31):
290
+ flank = N // 2
291
+ start = center - 1 - flank
292
+ end = center + flank
293
+ w = ''
294
+ for i in range(start, end):
295
+ w += s[i] if 0 <= i < len(s) else 'X'
296
+ return np.array([EIIP.get(a, 0.0) for a in w], dtype=float)
297
+
298
+ results = []
299
+ for v in d['variants']:
300
+ pos, ref, alt = v['position'], v['ref'], v['alt']
301
+ # Sanity check ref matches
302
+ if pos < 1 or pos > len(seq) or seq[pos-1] != ref:
303
+ results.append({**v, 'error': f'Reference mismatch at {pos}: seq has {seq[pos-1] if 0 < pos <= len(seq) else "?"}, HGVS expects {ref}'})
304
+ continue
305
+ mt_seq = seq[:pos-1] + alt + seq[pos:]
306
+ Xm = spec_full(mt_seq)
307
+
308
+ # Full-protein L1 distance + total energy change
309
+ l1 = float(np.sum(np.abs(Xm - Xw)))
310
+ eW = float(np.sum(Xw**2))
311
+ eM = float(np.sum(Xm**2))
312
+ total_de = 100.0 * (eM - eW) / eW if eW > 0 else 0
313
+ fc_ratio = float(Xm[fc_bin] / Xw[fc_bin]) if Xw[fc_bin] > 0 else 0
314
+
315
+ # Weighted aggregate across top peaks
316
+ num = 0.0; den = 0.0
317
+ for p in peaks:
318
+ k = int(p['bin'])
319
+ if k >= N: continue
320
+ m = float(p.get('magnitude', 1))
321
+ xw, xm = Xw[k], Xm[k]
322
+ if xw > 0:
323
+ num += m * 100 * (xm**2 - xw**2) / (xw**2)
324
+ den += m
325
+ wagg = num / den if den > 0 else 0
326
+
327
+ # Windowed Σ|ΔF| (DC excluded)
328
+ wt_win = encode_window(seq, pos, 31)
329
+ mt_win = encode_window(mt_seq, pos, 31)
330
+ Yw = np.abs(np.fft.rfft(wt_win))
331
+ Ym = np.abs(np.fft.rfft(mt_win))
332
+ delta = np.abs(Yw - Ym)
333
+ win_sum = float(delta[1:].sum()) if len(delta) > 1 else 0
334
+
335
+ results.append({
336
+ **v,
337
+ 'windowedSumAbsDFDc': win_sum,
338
+ 'fullSpectrumL1': l1,
339
+ 'fcRatio': fc_ratio,
340
+ 'weightedAggregateDeltaEPct': wagg,
341
+ 'totalEnergyChangePct': total_de,
342
+ })
343
+
344
+ print(json.dumps(results))
345
+ `;
346
+ /**
347
+ * Synthesize pseudo-benign control variants from gnomAD common population
348
+ * data. For rare-disease genes whose ClinVar entries are dominated by
349
+ * pathogenic submissions (typical for genes like COL3A1, COL7A1, FBN1),
350
+ * AUC benchmarking requires negative-class controls. We query MyVariant.info
351
+ * for missense variants in the target gene with gnomAD exome OR genome AF
352
+ * above `minAf` (default 1%), filter to those NOT already present as a
353
+ * ClinVar entry in our parsed set, and return them with classification_simple
354
+ * pre-labeled as 'likely_benign' and a 'source' marker so downstream consumers
355
+ * know these are population-frequency-implied benigns rather than ACMG curated.
356
+ */
357
+ async function synthesizeGnomadPseudoBenigns(gene, uniprot, nWanted, minAf, existingClinVarVariants, quiet) {
358
+ // Build set of (chrom, pos, ref, alt) tuples we already have from ClinVar
359
+ // so we don't double-count if a variant happens to be both ClinVar B+LB and
360
+ // gnomAD common.
361
+ const haveKeys = new Set();
362
+ for (const v of existingClinVarVariants) {
363
+ if (v.hgvs_genomic)
364
+ haveKeys.add(v.hgvs_genomic);
365
+ if (v.hgvs_protein)
366
+ haveKeys.add(`P:${v.hgvs_protein}`);
367
+ }
368
+ // MyVariant.info /query for gene-restricted common missense
369
+ const fields = 'dbsnp.rsid,snpeff.ann.gene_name,snpeff.ann.hgvs_p,snpeff.ann.hgvs_c,snpeff.ann.putative_impact,gnomad_exome.af.af,gnomad_genome.af.af,chrom,vcf.position,vcf.ref,vcf.alt';
370
+ const queryExpr = `snpeff.ann.gene_name:${gene} AND snpeff.ann.putative_impact:MODERATE AND _exists_:gnomad_exome.af.af AND gnomad_exome.af.af:>=${minAf}`;
371
+ const pageSize = Math.min(nWanted * 3, 1000); // pull 3x candidates to account for filtering loss
372
+ const url = `https://myvariant.info/v1/query?q=${encodeURIComponent(queryExpr)}&fields=${encodeURIComponent(fields)}&size=${pageSize}&dotfield=true`;
373
+ const r = (0, child_process_1.spawnSync)('curl', ['-sS', '-A', 'biofs/3.2.0', '--max-time', '60', url], {
374
+ encoding: 'utf8',
375
+ maxBuffer: 50 * 1024 * 1024,
376
+ });
377
+ if (r.status !== 0)
378
+ throw new Error(`MyVariant gnomAD query failed: ${r.stderr}`);
379
+ const data = JSON.parse(r.stdout);
380
+ const hits = (data?.hits || []);
381
+ if (!quiet)
382
+ process.stderr.write(` gnomAD candidates retrieved: ${hits.length}\n`);
383
+ const synthesized = [];
384
+ for (const h of hits) {
385
+ if (synthesized.length >= nWanted)
386
+ break;
387
+ const annArr = h?.['snpeff.ann.hgvs_p'];
388
+ const geneArr = h?.['snpeff.ann.gene_name'];
389
+ const impactArr = h?.['snpeff.ann.putative_impact'];
390
+ const protHgvs = Array.isArray(annArr) ? annArr.find((x) => typeof x === 'string' && x.startsWith('p.')) : annArr;
391
+ if (!protHgvs || typeof protHgvs !== 'string')
392
+ continue;
393
+ // Confirm this is actually in our gene (snpeff can return overlapping transcripts)
394
+ const geneMatch = Array.isArray(geneArr)
395
+ ? geneArr.some((g) => (g || '').toUpperCase() === gene.toUpperCase())
396
+ : (geneArr || '').toUpperCase() === gene.toUpperCase();
397
+ if (!geneMatch)
398
+ continue;
399
+ // Skip if not MODERATE impact (i.e., missense)
400
+ const isMod = Array.isArray(impactArr) ? impactArr.includes('MODERATE') : impactArr === 'MODERATE';
401
+ if (!isMod)
402
+ continue;
403
+ const protKey = `P:${protHgvs}`;
404
+ if (haveKeys.has(protKey))
405
+ continue;
406
+ const parsed = parseProteinHgvs(protHgvs);
407
+ if (!parsed)
408
+ continue;
409
+ const af = (h?.['gnomad_exome.af.af'] ?? h?.['gnomad_genome.af.af']);
410
+ synthesized.push({
411
+ variation_id: `gnomad_${h._id || synthesized.length}`,
412
+ hgvs_protein: protHgvs,
413
+ hgvs_genomic: h._id || null,
414
+ position: parsed.pos,
415
+ ref: parsed.ref,
416
+ alt: parsed.alt,
417
+ classification: 'population-common, presumed benign',
418
+ classification_simple: 'likely_benign',
419
+ review_status: 'gnomad_pseudo_benign',
420
+ dbsnp_rsid: h?.['dbsnp.rsid'] || null,
421
+ gnomad_af: af,
422
+ });
423
+ haveKeys.add(protKey);
424
+ }
425
+ return synthesized;
426
+ }
427
+ function plotDistribution(result, outPath, highlight, quiet) {
428
+ const py = `
429
+ import json, sys
430
+ import matplotlib
431
+ matplotlib.use("Agg")
432
+ import matplotlib.pyplot as plt
433
+ import numpy as np
434
+
435
+ d = json.loads(sys.stdin.read())
436
+ variants = [v for v in d['variants'] if v.get('fullSpectrumL1') is not None]
437
+ classes = ['pathogenic', 'likely_pathogenic', 'vus', 'likely_benign', 'benign']
438
+ colors = {
439
+ 'pathogenic': '#d62728',
440
+ 'likely_pathogenic': '#ff7f0e',
441
+ 'vus': '#7f7f7f',
442
+ 'likely_benign': '#bcbd22',
443
+ 'benign': '#2ca02c',
444
+ 'conflicting': '#9467bd',
445
+ 'other': '#cccccc',
446
+ }
447
+
448
+ fig, axes = plt.subplots(2, 2, figsize=(13, 9))
449
+
450
+ # Panel A: full-spectrum L1 distance by class
451
+ ax = axes[0, 0]
452
+ for cls in classes:
453
+ xs = [v['fullSpectrumL1'] for v in variants if v.get('classification_simple') == cls]
454
+ if not xs: continue
455
+ ax.hist(xs, bins=20, alpha=0.6, label=f'{cls} (n={len(xs)})', color=colors[cls])
456
+ for hl in d['highlight']:
457
+ if hl.get('fullSpectrumL1') is not None:
458
+ ax.axvline(hl['fullSpectrumL1'], color='black', linestyle='--', linewidth=1.4)
459
+ ax.annotate(f" {hl['label']}", xy=(hl['fullSpectrumL1'], 0), xytext=(2, 4),
460
+ textcoords='offset points', rotation=90, fontsize=9, va='bottom')
461
+ ax.set_xlabel('full-spectrum L1 distance')
462
+ ax.set_ylabel('count')
463
+ ax.set_title('Cosic-RRM full-protein L1 distance distribution')
464
+ ax.legend(fontsize=8)
465
+
466
+ # Panel B: windowed Σ|ΔF| by class
467
+ ax = axes[0, 1]
468
+ for cls in classes:
469
+ xs = [v['windowedSumAbsDFDc'] for v in variants if v.get('classification_simple') == cls]
470
+ if not xs: continue
471
+ ax.hist(xs, bins=20, alpha=0.6, label=f'{cls} (n={len(xs)})', color=colors[cls])
472
+ for hl in d['highlight']:
473
+ if hl.get('windowedSumAbsDFDc') is not None:
474
+ ax.axvline(hl['windowedSumAbsDFDc'], color='black', linestyle='--', linewidth=1.4)
475
+ ax.annotate(f" {hl['label']}", xy=(hl['windowedSumAbsDFDc'], 0), xytext=(2, 4),
476
+ textcoords='offset points', rotation=90, fontsize=9, va='bottom')
477
+ ax.set_xlabel('windowed Σ|ΔF| (k≥1), N=31')
478
+ ax.set_ylabel('count')
479
+ ax.set_title('Cosic-RRM windowed Σ|ΔF| distribution')
480
+ ax.legend(fontsize=8)
481
+
482
+ # Panel C: 2D scatter L1 vs windowed Σ|ΔF|
483
+ ax = axes[1, 0]
484
+ for cls in classes:
485
+ xs = [v['fullSpectrumL1'] for v in variants if v.get('classification_simple') == cls]
486
+ ys = [v['windowedSumAbsDFDc'] for v in variants if v.get('classification_simple') == cls]
487
+ if not xs: continue
488
+ ax.scatter(xs, ys, alpha=0.65, label=f'{cls} (n={len(xs)})', color=colors[cls], s=22)
489
+ for hl in d['highlight']:
490
+ if hl.get('fullSpectrumL1') is not None and hl.get('windowedSumAbsDFDc') is not None:
491
+ ax.scatter([hl['fullSpectrumL1']], [hl['windowedSumAbsDFDc']], color='black', marker='X', s=140, zorder=10, linewidths=1.4, edgecolor='white')
492
+ ax.annotate(f" {hl['label']}", (hl['fullSpectrumL1'], hl['windowedSumAbsDFDc']), xytext=(6, 0),
493
+ textcoords='offset points', fontsize=9)
494
+ ax.set_xlabel('full-spectrum L1 distance')
495
+ ax.set_ylabel('windowed Σ|ΔF|')
496
+ ax.set_title('Cosic feature space, full-protein vs windowed')
497
+ ax.legend(fontsize=8)
498
+ ax.grid(True, alpha=0.3)
499
+
500
+ # Panel D: f_c ratio MT/WT by class
501
+ ax = axes[1, 1]
502
+ for cls in classes:
503
+ xs = [v['fcRatio'] for v in variants if v.get('classification_simple') == cls]
504
+ if not xs: continue
505
+ ax.hist(xs, bins=20, alpha=0.6, label=f'{cls} (n={len(xs)})', color=colors[cls])
506
+ for hl in d['highlight']:
507
+ if hl.get('fcRatio') is not None:
508
+ ax.axvline(hl['fcRatio'], color='black', linestyle='--', linewidth=1.4)
509
+ ax.annotate(f" {hl['label']}", xy=(hl['fcRatio'], 0), xytext=(2, 4),
510
+ textcoords='offset points', rotation=90, fontsize=9, va='bottom')
511
+ ax.set_xlabel(f'|X_MT(f_c)| / |X_WT(f_c)| (f_c period {d["fc_period_aa"]:.1f} aa)')
512
+ ax.set_ylabel('count')
513
+ ax.set_title('Cosic-RRM ratio at family characteristic frequency')
514
+ ax.legend(fontsize=8)
515
+ ax.axvline(1.0, color='black', linewidth=0.6, alpha=0.5)
516
+
517
+ fig.suptitle(f"Cosic-RRM ClinVar distribution | {d['gene']} ({d['uniprot']}) | n={len(variants)} classified missense", fontsize=12, y=1.0)
518
+ fig.tight_layout()
519
+ fig.savefig(d['out_path'], dpi=150, bbox_inches='tight')
520
+ print(f"OK: {d['out_path']}", file=sys.stderr)
521
+ `;
522
+ // Compute Cosic features for highlighted variants too
523
+ const cachePath = path.join(RRM_CACHE_DIR, `${result.gene}.json`);
524
+ const cons = JSON.parse(fs.readFileSync(cachePath, 'utf8'));
525
+ const seqPath = path.join(UNIPROT_CACHE_DIR, `${result.uniprot}.fasta`);
526
+ const seq = fs.readFileSync(seqPath, 'utf8').split('\n').slice(1).join('').replace(/\s/g, '').toUpperCase();
527
+ const hl = [];
528
+ for (const h of highlight) {
529
+ const parsed = parseProteinHgvs(h);
530
+ if (!parsed)
531
+ continue;
532
+ const scoreInput = {
533
+ sequence: seq,
534
+ common_length: cons.common_length,
535
+ fc_freq: cons.characteristic_frequency_normalized,
536
+ peaks: cons.consensus_peak_bins || [],
537
+ variants: [{ position: parsed.pos, ref: parsed.ref, alt: parsed.alt }],
538
+ };
539
+ const r = (0, child_process_1.spawnSync)('python3', ['-c', PY_BATCH_SCORE], { encoding: 'utf8', input: JSON.stringify(scoreInput), maxBuffer: 100 * 1024 * 1024 });
540
+ if (r.status === 0) {
541
+ const arr = JSON.parse(r.stdout);
542
+ if (arr[0]) {
543
+ hl.push({ label: h, ...arr[0] });
544
+ }
545
+ }
546
+ }
547
+ const r = (0, child_process_1.spawnSync)('python3', ['-c', py], {
548
+ encoding: 'utf8',
549
+ input: JSON.stringify({
550
+ ...result,
551
+ highlight: hl,
552
+ fc_period_aa: cons.characteristic_frequency_period_aa,
553
+ out_path: outPath,
554
+ }),
555
+ maxBuffer: 200 * 1024 * 1024,
556
+ });
557
+ if (r.status !== 0) {
558
+ throw new Error(`Distribution plot failed: ${r.stderr || r.stdout}`);
559
+ }
560
+ if (!quiet)
561
+ console.error(chalk_1.default.green(`✓ Distribution plot saved to ${outPath}`));
562
+ }
563
+ function reportSummary(r, highlightHgvs) {
564
+ console.log(chalk_1.default.cyan(`\n📊 Cosic-RRM ClinVar distribution ${r.gene}`));
565
+ console.log(chalk_1.default.cyan('─'.repeat(72)));
566
+ console.log(` total ClinVar hits: ${r.total_clinvar_hits}`);
567
+ console.log(` parsed as missense: ${r.parsed_missense}`);
568
+ console.log(` by classification:`);
569
+ for (const [k, v] of Object.entries(r.by_classification)) {
570
+ console.log(` ${k.padEnd(22)} ${v}`);
571
+ }
572
+ console.log(chalk_1.default.cyan('─'.repeat(72)));
573
+ const scored = r.variants.filter(v => v.fullSpectrumL1 !== undefined);
574
+ const byClass = (cls) => scored.filter(v => v.classification_simple === cls);
575
+ const stat = (xs) => {
576
+ if (xs.length === 0)
577
+ return { n: 0, mean: 0, median: 0, max: 0, min: 0 };
578
+ const sorted = [...xs].sort((a, b) => a - b);
579
+ return {
580
+ n: xs.length,
581
+ mean: xs.reduce((a, b) => a + b, 0) / xs.length,
582
+ median: sorted[Math.floor(xs.length / 2)],
583
+ min: sorted[0],
584
+ max: sorted[sorted.length - 1],
585
+ };
586
+ };
587
+ console.log(' Per-class L1 distance summary:');
588
+ for (const cls of ['pathogenic', 'likely_pathogenic', 'vus', 'likely_benign', 'benign']) {
589
+ const xs = byClass(cls).map(v => v.fullSpectrumL1);
590
+ const s = stat(xs);
591
+ if (s.n === 0)
592
+ continue;
593
+ console.log(` ${cls.padEnd(22)} n=${s.n}, median=${s.median.toExponential(2)}, mean=${s.mean.toExponential(2)}, [${s.min.toExponential(2)}, ${s.max.toExponential(2)}]`);
594
+ }
595
+ console.log('');
596
+ }
597
+ async function rrmDistributionCommand(gene, opts) {
598
+ const upper = gene.toUpperCase();
599
+ const uniprot = gene_map_1.GENE_TO_UNIPROT[upper];
600
+ if (!uniprot)
601
+ throw new Error(`No UniProt mapping for ${upper}. Built-in: ${Object.keys(gene_map_1.GENE_TO_UNIPROT).join(', ')}`);
602
+ fs.mkdirSync(RRM_CACHE_DIR, { recursive: true });
603
+ const cachePath = path.join(RRM_CACHE_DIR, `${upper}-distribution.json`);
604
+ if (fs.existsSync(cachePath) && !opts.refresh) {
605
+ if (!opts.quiet)
606
+ console.error(chalk_1.default.gray(`✓ Using cached distribution (use --refresh to recompute)`));
607
+ const cached = JSON.parse(fs.readFileSync(cachePath, 'utf8'));
608
+ reportSummary(cached, (opts.highlight || '').split(',').map(s => s.trim()).filter(Boolean));
609
+ if (opts.plot) {
610
+ plotDistribution(cached, opts.plot, (opts.highlight || '').split(',').map(s => s.trim()).filter(Boolean), opts.quiet || false);
611
+ }
612
+ return;
613
+ }
614
+ // Consensus required
615
+ const consensusPath = path.join(RRM_CACHE_DIR, `${upper}.json`);
616
+ if (!fs.existsSync(consensusPath)) {
617
+ throw new Error(`No consensus f_c cached for ${upper}. Run first: biofs rrm-consensus ${upper}`);
618
+ }
619
+ const cons = JSON.parse(fs.readFileSync(consensusPath, 'utf8'));
620
+ // UniProt sequence (cached or fetch)
621
+ fs.mkdirSync(UNIPROT_CACHE_DIR, { recursive: true });
622
+ const fastaPath = path.join(UNIPROT_CACHE_DIR, `${uniprot}.fasta`);
623
+ if (!fs.existsSync(fastaPath)) {
624
+ const fr = (0, child_process_1.spawnSync)('curl', ['-sS', '-A', 'biofs/3.2.0', '--max-time', '60', `https://rest.uniprot.org/uniprotkb/${uniprot}.fasta`], { encoding: 'utf8' });
625
+ if (fr.status !== 0)
626
+ throw new Error(`UniProt fetch failed for ${uniprot}: ${fr.stderr}`);
627
+ fs.writeFileSync(fastaPath, fr.stdout);
628
+ }
629
+ const seq = fs.readFileSync(fastaPath, 'utf8').split('\n').slice(1).join('').replace(/\s/g, '').toUpperCase();
630
+ // Bumped default retmax from 1000 → 10000 since the new server-side VUS/Conflicting
631
+ // exclusion means many genes (BRCA1, BRCA2, TP53, LDLR) need a larger window to
632
+ // capture all P+LP+B+LB entries. Genes with fewer entries return their actual
633
+ // total; genes with more pages are paginated.
634
+ const retmax = parseInt(opts.retmax || '10000', 10);
635
+ const spinner = opts.quiet ? null : (0, ora_1.default)(`Fetching ClinVar variants for ${upper}...`).start();
636
+ const ids = fetchClinVarIds(upper, retmax, opts.quiet || false);
637
+ if (spinner)
638
+ spinner.succeed(`Found ${ids.length} ClinVar IDs`);
639
+ const sp2 = opts.quiet ? null : (0, ora_1.default)(`Fetching ${ids.length} ClinVar summaries...`).start();
640
+ const summaries = fetchClinVarSummaries(ids, opts.quiet || false);
641
+ if (sp2)
642
+ sp2.succeed(`Retrieved ${summaries.length} summaries`);
643
+ const sp3 = opts.quiet ? null : (0, ora_1.default)(`Parsing missense variants...`).start();
644
+ const parsed = [];
645
+ for (const s of summaries) {
646
+ const v = extractMissenseFromSummary(s);
647
+ if (v)
648
+ parsed.push(v);
649
+ }
650
+ if (sp3)
651
+ sp3.succeed(`Parsed ${parsed.length} missense variants`);
652
+ // Batch score via python
653
+ const sp4 = opts.quiet ? null : (0, ora_1.default)(`Computing Cosic-RRM features for ${parsed.length} variants...`).start();
654
+ const scoreInput = {
655
+ sequence: seq,
656
+ common_length: cons.common_length,
657
+ fc_freq: cons.characteristic_frequency_normalized,
658
+ peaks: cons.consensus_peak_bins || [],
659
+ // Pass the entire parsed object through; Python preserves keys via {**v, ...}
660
+ variants: parsed,
661
+ };
662
+ const pyRes = (0, child_process_1.spawnSync)('python3', ['-c', PY_BATCH_SCORE], { encoding: 'utf8', input: JSON.stringify(scoreInput), maxBuffer: 500 * 1024 * 1024 });
663
+ if (pyRes.status !== 0) {
664
+ if (sp4)
665
+ sp4.fail('Batch scoring failed');
666
+ throw new Error(`Batch Cosic scoring failed: ${pyRes.stderr || pyRes.stdout}`);
667
+ }
668
+ const scored = JSON.parse(pyRes.stdout);
669
+ if (sp4)
670
+ sp4.succeed(`Scored ${scored.filter((v) => v.fullSpectrumL1 !== undefined).length} of ${scored.length} variants (some skipped on reference mismatch)`);
671
+ const byClass = {};
672
+ for (const v of scored) {
673
+ byClass[v.classification_simple] = (byClass[v.classification_simple] || 0) + 1;
674
+ }
675
+ // === gnomAD pseudo-benign synthesis (optional) ===
676
+ // For rare-disease genes whose ClinVar P+LP is large but B+LB is 0, AUC
677
+ // benchmarking is infeasible without negative controls. We synthesize a
678
+ // set of presumed-benign common population variants from gnomAD and label
679
+ // them as likely_benign. These variants are NOT ACMG benign by ClinVar
680
+ // curation; they are population-frequency-implied benigns for cohort-
681
+ // benchmarking purposes only. This is clearly noted in the output JSON.
682
+ let scoredWithBenigns = scored;
683
+ let nSynthesized = 0;
684
+ if (opts.gnomadBenigns) {
685
+ const nWanted = parseInt(opts.gnomadBenigns, 10);
686
+ const minAf = parseFloat(opts.gnomadMinAf || '0.01');
687
+ if (nWanted > 0) {
688
+ if (!opts.quiet) {
689
+ process.stderr.write(`\n Synthesizing up to ${nWanted} gnomAD pseudo-benigns (AF >= ${minAf})...\n`);
690
+ }
691
+ try {
692
+ const synth = await synthesizeGnomadPseudoBenigns(upper, uniprot, nWanted, minAf, parsed, opts.quiet || false);
693
+ nSynthesized = synth.length;
694
+ // Score each synthesized variant via the same Cosic pipeline as ClinVar entries.
695
+ if (nSynthesized > 0) {
696
+ const synthScoreInput = {
697
+ sequence: seq,
698
+ common_length: cons.common_length,
699
+ fc_freq: cons.characteristic_frequency_normalized,
700
+ peaks: cons.consensus_peak_bins || [],
701
+ variants: synth,
702
+ };
703
+ const synthPy = (0, child_process_1.spawnSync)('python3', ['-c', PY_BATCH_SCORE], { encoding: 'utf8', input: JSON.stringify(synthScoreInput), maxBuffer: 500 * 1024 * 1024 });
704
+ if (synthPy.status === 0) {
705
+ const scoredSynth = JSON.parse(synthPy.stdout).map((v) => ({ ...v, source: 'gnomad_pseudo_benign' }));
706
+ scoredWithBenigns = [...scored, ...scoredSynth];
707
+ for (const v of scoredSynth) {
708
+ byClass[v.classification_simple] = (byClass[v.classification_simple] || 0) + 1;
709
+ }
710
+ if (!opts.quiet) {
711
+ process.stderr.write(` ✓ Added ${scoredSynth.length} pseudo-benigns to distribution\n`);
712
+ }
713
+ }
714
+ else if (!opts.quiet) {
715
+ process.stderr.write(` ⚠ Pseudo-benign scoring failed: ${synthPy.stderr || synthPy.stdout}\n`);
716
+ }
717
+ }
718
+ }
719
+ catch (e) {
720
+ if (!opts.quiet)
721
+ process.stderr.write(` ⚠ gnomAD pseudo-benign synthesis failed: ${e.message}\n`);
722
+ }
723
+ }
724
+ }
725
+ const result = {
726
+ gene: upper,
727
+ uniprot,
728
+ total_clinvar_hits: ids.length,
729
+ parsed_missense: parsed.length,
730
+ by_classification: byClass,
731
+ variants: scoredWithBenigns,
732
+ generated_at: new Date().toISOString(),
733
+ gnomad_pseudo_benigns_synthesized: nSynthesized || undefined,
734
+ };
735
+ fs.writeFileSync(cachePath, JSON.stringify(result, null, 2));
736
+ if (!opts.quiet)
737
+ console.error(chalk_1.default.green(`✓ Saved distribution to ${cachePath}${nSynthesized ? ` (incl. ${nSynthesized} gnomAD pseudo-benigns)` : ''}`));
738
+ reportSummary(result, (opts.highlight || '').split(',').map(s => s.trim()).filter(Boolean));
739
+ if (opts.plot) {
740
+ plotDistribution(result, opts.plot, (opts.highlight || '').split(',').map(s => s.trim()).filter(Boolean), opts.quiet || false);
741
+ }
742
+ }
743
+ //# sourceMappingURL=rrm-distribution.js.map