react-cheminfo 0.76.0 → 0.77.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 (316) hide show
  1. package/README.md +141 -31
  2. package/lib/card/core/cardAddress.d.ts +19 -2
  3. package/lib/card/core/cardAddress.d.ts.map +1 -1
  4. package/lib/card/core/cardAddress.js +35 -2
  5. package/lib/card/core/cardAddress.js.map +1 -1
  6. package/lib/card/core/cardPageUrl.d.ts +7 -1
  7. package/lib/card/core/cardPageUrl.d.ts.map +1 -1
  8. package/lib/card/core/cardPageUrl.js +4 -2
  9. package/lib/card/core/cardPageUrl.js.map +1 -1
  10. package/lib/card/core/index.d.ts +1 -1
  11. package/lib/card/core/index.d.ts.map +1 -1
  12. package/lib/card/core/index.js +1 -1
  13. package/lib/card/core/index.js.map +1 -1
  14. package/lib/credits/core/credits.d.ts +30 -0
  15. package/lib/credits/core/credits.d.ts.map +1 -1
  16. package/lib/credits/core/credits.js +35 -0
  17. package/lib/credits/core/credits.js.map +1 -1
  18. package/lib/download/core/downloadFigure.d.ts +12 -1
  19. package/lib/download/core/downloadFigure.d.ts.map +1 -1
  20. package/lib/download/core/downloadFigure.js +21 -0
  21. package/lib/download/core/downloadFigure.js.map +1 -1
  22. package/lib/download/core/figureDpi.d.ts +59 -0
  23. package/lib/download/core/figureDpi.d.ts.map +1 -0
  24. package/lib/download/core/figureDpi.js +75 -0
  25. package/lib/download/core/figureDpi.js.map +1 -0
  26. package/lib/download/core/figurePng.d.ts +4 -1
  27. package/lib/download/core/figurePng.d.ts.map +1 -1
  28. package/lib/download/core/figurePng.js +11 -2
  29. package/lib/download/core/figurePng.js.map +1 -1
  30. package/lib/download/core/index.d.ts +4 -1
  31. package/lib/download/core/index.d.ts.map +1 -1
  32. package/lib/download/core/index.js +3 -1
  33. package/lib/download/core/index.js.map +1 -1
  34. package/lib/download/core/pngDpi.d.ts +22 -0
  35. package/lib/download/core/pngDpi.d.ts.map +1 -0
  36. package/lib/download/core/pngDpi.js +79 -0
  37. package/lib/download/core/pngDpi.js.map +1 -0
  38. package/lib/download/ui/FigureDownloadPanel.d.ts +13 -0
  39. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  40. package/lib/download/ui/FigureDownloadPanel.js +18 -34
  41. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  42. package/lib/download/ui/figureDownloadHint.d.ts +5 -0
  43. package/lib/download/ui/figureDownloadHint.d.ts.map +1 -1
  44. package/lib/download/ui/figureDownloadHint.js +8 -0
  45. package/lib/download/ui/figureDownloadHint.js.map +1 -1
  46. package/lib/download/ui/figureDownloadOptions.d.ts +84 -0
  47. package/lib/download/ui/figureDownloadOptions.d.ts.map +1 -0
  48. package/lib/download/ui/figureDownloadOptions.js +2 -0
  49. package/lib/download/ui/figureDownloadOptions.js.map +1 -0
  50. package/lib/download/ui/resolutionChoices.d.ts +27 -0
  51. package/lib/download/ui/resolutionChoices.d.ts.map +1 -0
  52. package/lib/download/ui/resolutionChoices.js +48 -0
  53. package/lib/download/ui/resolutionChoices.js.map +1 -0
  54. package/lib/download/ui/useFigureActions.d.ts +4 -1
  55. package/lib/download/ui/useFigureActions.d.ts.map +1 -1
  56. package/lib/download/ui/useFigureActions.js +17 -8
  57. package/lib/download/ui/useFigureActions.js.map +1 -1
  58. package/lib/download/ui/useFigureDownload.d.ts +2 -55
  59. package/lib/download/ui/useFigureDownload.d.ts.map +1 -1
  60. package/lib/download/ui/useFigureDownload.js +45 -13
  61. package/lib/download/ui/useFigureDownload.js.map +1 -1
  62. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  63. package/lib/ecosystem/core/sites.js +14 -0
  64. package/lib/ecosystem/core/sites.js.map +1 -1
  65. package/lib/ecosystem/core/types.d.ts +1 -1
  66. package/lib/ecosystem/core/types.d.ts.map +1 -1
  67. package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
  68. package/lib/ecosystem/ui/glyphs.js +3 -0
  69. package/lib/ecosystem/ui/glyphs.js.map +1 -1
  70. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  71. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  72. package/lib/locales/de.json +30 -1
  73. package/lib/locales/en.json +30 -1
  74. package/lib/locales/es.json +30 -1
  75. package/lib/locales/fr.json +30 -1
  76. package/lib/locales/it.json +30 -1
  77. package/lib/molecule3d/ui/Molecule3DStage.d.ts +4 -33
  78. package/lib/molecule3d/ui/Molecule3DStage.d.ts.map +1 -1
  79. package/lib/molecule3d/ui/Molecule3DStage.js +3 -37
  80. package/lib/molecule3d/ui/Molecule3DStage.js.map +1 -1
  81. package/lib/osiris/core/barGeometry.d.ts +42 -0
  82. package/lib/osiris/core/barGeometry.d.ts.map +1 -0
  83. package/lib/osiris/core/barGeometry.js +46 -0
  84. package/lib/osiris/core/barGeometry.js.map +1 -0
  85. package/lib/osiris/core/computeProperties.d.ts +42 -0
  86. package/lib/osiris/core/computeProperties.d.ts.map +1 -0
  87. package/lib/osiris/core/computeProperties.js +115 -0
  88. package/lib/osiris/core/computeProperties.js.map +1 -0
  89. package/lib/osiris/core/constants.d.ts +70 -0
  90. package/lib/osiris/core/constants.d.ts.map +1 -0
  91. package/lib/osiris/core/constants.js +99 -0
  92. package/lib/osiris/core/constants.js.map +1 -0
  93. package/lib/osiris/core/fitness.d.ts +32 -0
  94. package/lib/osiris/core/fitness.d.ts.map +1 -0
  95. package/lib/osiris/core/fitness.js +48 -0
  96. package/lib/osiris/core/fitness.js.map +1 -0
  97. package/lib/osiris/core/index.d.ts +29 -0
  98. package/lib/osiris/core/index.d.ts.map +1 -0
  99. package/lib/osiris/core/index.js +19 -0
  100. package/lib/osiris/core/index.js.map +1 -0
  101. package/lib/osiris/core/poolSize.d.ts +17 -0
  102. package/lib/osiris/core/poolSize.d.ts.map +1 -0
  103. package/lib/osiris/core/poolSize.js +22 -0
  104. package/lib/osiris/core/poolSize.js.map +1 -0
  105. package/lib/osiris/core/poolTypes.d.ts +140 -0
  106. package/lib/osiris/core/poolTypes.d.ts.map +1 -0
  107. package/lib/osiris/core/poolTypes.js +12 -0
  108. package/lib/osiris/core/poolTypes.js.map +1 -0
  109. package/lib/osiris/core/predictIdCode.d.ts +39 -0
  110. package/lib/osiris/core/predictIdCode.d.ts.map +1 -0
  111. package/lib/osiris/core/predictIdCode.js +54 -0
  112. package/lib/osiris/core/predictIdCode.js.map +1 -0
  113. package/lib/osiris/core/predictProtocol.d.ts +67 -0
  114. package/lib/osiris/core/predictProtocol.d.ts.map +1 -0
  115. package/lib/osiris/core/predictProtocol.js +29 -0
  116. package/lib/osiris/core/predictProtocol.js.map +1 -0
  117. package/lib/osiris/core/predictionPool.d.ts +23 -0
  118. package/lib/osiris/core/predictionPool.d.ts.map +1 -0
  119. package/lib/osiris/core/predictionPool.js +186 -0
  120. package/lib/osiris/core/predictionPool.js.map +1 -0
  121. package/lib/osiris/core/predictionQueue.d.ts +46 -0
  122. package/lib/osiris/core/predictionQueue.d.ts.map +1 -0
  123. package/lib/osiris/core/predictionQueue.js +57 -0
  124. package/lib/osiris/core/predictionQueue.js.map +1 -0
  125. package/lib/osiris/core/predictors.d.ts +62 -0
  126. package/lib/osiris/core/predictors.d.ts.map +1 -0
  127. package/lib/osiris/core/predictors.js +100 -0
  128. package/lib/osiris/core/predictors.js.map +1 -0
  129. package/lib/osiris/core/propertyKeys.d.ts +32 -0
  130. package/lib/osiris/core/propertyKeys.d.ts.map +1 -0
  131. package/lib/osiris/core/propertyKeys.js +44 -0
  132. package/lib/osiris/core/propertyKeys.js.map +1 -0
  133. package/lib/osiris/core/riskAppearance.d.ts +60 -0
  134. package/lib/osiris/core/riskAppearance.d.ts.map +1 -0
  135. package/lib/osiris/core/riskAppearance.js +59 -0
  136. package/lib/osiris/core/riskAppearance.js.map +1 -0
  137. package/lib/osiris/core/riskDetail.d.ts +22 -0
  138. package/lib/osiris/core/riskDetail.d.ts.map +1 -0
  139. package/lib/osiris/core/riskDetail.js +86 -0
  140. package/lib/osiris/core/riskDetail.js.map +1 -0
  141. package/lib/osiris/core/riskDetailRequest.d.ts +31 -0
  142. package/lib/osiris/core/riskDetailRequest.d.ts.map +1 -0
  143. package/lib/osiris/core/riskDetailRequest.js +49 -0
  144. package/lib/osiris/core/riskDetailRequest.js.map +1 -0
  145. package/lib/osiris/core/riskFindings.d.ts +26 -0
  146. package/lib/osiris/core/riskFindings.d.ts.map +1 -0
  147. package/lib/osiris/core/riskFindings.js +79 -0
  148. package/lib/osiris/core/riskFindings.js.map +1 -0
  149. package/lib/osiris/core/runPredictionJob.d.ts +20 -0
  150. package/lib/osiris/core/runPredictionJob.d.ts.map +1 -0
  151. package/lib/osiris/core/runPredictionJob.js +43 -0
  152. package/lib/osiris/core/runPredictionJob.js.map +1 -0
  153. package/lib/osiris/core/scales.d.ts +70 -0
  154. package/lib/osiris/core/scales.d.ts.map +1 -0
  155. package/lib/osiris/core/scales.js +185 -0
  156. package/lib/osiris/core/scales.js.map +1 -0
  157. package/lib/osiris/core/types.d.ts +91 -0
  158. package/lib/osiris/core/types.d.ts.map +1 -0
  159. package/lib/osiris/core/types.js +19 -0
  160. package/lib/osiris/core/types.js.map +1 -0
  161. package/lib/osiris/core/valuation.d.ts +28 -0
  162. package/lib/osiris/core/valuation.d.ts.map +1 -0
  163. package/lib/osiris/core/valuation.js +39 -0
  164. package/lib/osiris/core/valuation.js.map +1 -0
  165. package/lib/osiris/ui/PropertyBar.d.ts +27 -0
  166. package/lib/osiris/ui/PropertyBar.d.ts.map +1 -0
  167. package/lib/osiris/ui/PropertyBar.js +27 -0
  168. package/lib/osiris/ui/PropertyBar.js.map +1 -0
  169. package/lib/osiris/ui/PropertyPanel.d.ts +91 -0
  170. package/lib/osiris/ui/PropertyPanel.d.ts.map +1 -0
  171. package/lib/osiris/ui/PropertyPanel.js +77 -0
  172. package/lib/osiris/ui/PropertyPanel.js.map +1 -0
  173. package/lib/osiris/ui/PropertyRows.d.ts +40 -0
  174. package/lib/osiris/ui/PropertyRows.d.ts.map +1 -0
  175. package/lib/osiris/ui/PropertyRows.js +23 -0
  176. package/lib/osiris/ui/PropertyRows.js.map +1 -0
  177. package/lib/osiris/ui/RiskFindings.d.ts +43 -0
  178. package/lib/osiris/ui/RiskFindings.d.ts.map +1 -0
  179. package/lib/osiris/ui/RiskFindings.js +51 -0
  180. package/lib/osiris/ui/RiskFindings.js.map +1 -0
  181. package/lib/osiris/ui/RiskPanel.d.ts +46 -0
  182. package/lib/osiris/ui/RiskPanel.d.ts.map +1 -0
  183. package/lib/osiris/ui/RiskPanel.js +32 -0
  184. package/lib/osiris/ui/RiskPanel.js.map +1 -0
  185. package/lib/osiris/ui/RiskSquare.d.ts +51 -0
  186. package/lib/osiris/ui/RiskSquare.d.ts.map +1 -0
  187. package/lib/osiris/ui/RiskSquare.js +23 -0
  188. package/lib/osiris/ui/RiskSquare.js.map +1 -0
  189. package/lib/osiris/ui/index.d.ts +15 -0
  190. package/lib/osiris/ui/index.d.ts.map +1 -0
  191. package/lib/osiris/ui/index.js +8 -0
  192. package/lib/osiris/ui/index.js.map +1 -0
  193. package/lib/osiris/ui/usePredictions.d.ts +81 -0
  194. package/lib/osiris/ui/usePredictions.d.ts.map +1 -0
  195. package/lib/osiris/ui/usePredictions.js +102 -0
  196. package/lib/osiris/ui/usePredictions.js.map +1 -0
  197. package/lib/osiris-ui.d.ts +11 -0
  198. package/lib/osiris-ui.d.ts.map +1 -0
  199. package/lib/osiris-ui.js +11 -0
  200. package/lib/osiris-ui.js.map +1 -0
  201. package/lib/osiris.d.ts +17 -0
  202. package/lib/osiris.d.ts.map +1 -0
  203. package/lib/osiris.js +17 -0
  204. package/lib/osiris.js.map +1 -0
  205. package/lib/panel/ui/FilterInput.d.ts.map +1 -1
  206. package/lib/panel/ui/FilterInput.js +3 -1
  207. package/lib/panel/ui/FilterInput.js.map +1 -1
  208. package/lib/panel/ui/SidePanelItem.d.ts +39 -0
  209. package/lib/panel/ui/SidePanelItem.d.ts.map +1 -0
  210. package/lib/panel/ui/SidePanelItem.js +63 -0
  211. package/lib/panel/ui/SidePanelItem.js.map +1 -0
  212. package/lib/panel/ui/SidePanelStack.d.ts +11 -10
  213. package/lib/panel/ui/SidePanelStack.d.ts.map +1 -1
  214. package/lib/panel/ui/SidePanelStack.js +22 -15
  215. package/lib/panel/ui/SidePanelStack.js.map +1 -1
  216. package/lib/panel/ui/SpectrumColorSwatch.d.ts.map +1 -1
  217. package/lib/panel/ui/SpectrumColorSwatch.js +4 -2
  218. package/lib/panel/ui/SpectrumColorSwatch.js.map +1 -1
  219. package/lib/panel/ui/usePanelFolds.d.ts +35 -0
  220. package/lib/panel/ui/usePanelFolds.d.ts.map +1 -0
  221. package/lib/panel/ui/usePanelFolds.js +73 -0
  222. package/lib/panel/ui/usePanelFolds.js.map +1 -0
  223. package/lib/shared/ui/FullscreenStage.d.ts +43 -0
  224. package/lib/shared/ui/FullscreenStage.d.ts.map +1 -0
  225. package/lib/shared/ui/FullscreenStage.js +38 -0
  226. package/lib/shared/ui/FullscreenStage.js.map +1 -0
  227. package/lib/shared/ui/canFillScreen.d.ts +7 -0
  228. package/lib/shared/ui/canFillScreen.d.ts.map +1 -0
  229. package/lib/shared/ui/canFillScreen.js +9 -0
  230. package/lib/shared/ui/canFillScreen.js.map +1 -0
  231. package/lib/shared/ui/index.d.ts +3 -0
  232. package/lib/shared/ui/index.d.ts.map +1 -1
  233. package/lib/shared/ui/index.js +2 -0
  234. package/lib/shared/ui/index.js.map +1 -1
  235. package/lib/split/ui/splitPanes.d.ts +3 -3
  236. package/lib/split/ui/splitPanes.js +1 -1
  237. package/lib/structure/core/structureNotations.d.ts +8 -1
  238. package/lib/structure/core/structureNotations.d.ts.map +1 -1
  239. package/lib/structure/core/structureNotations.js +14 -8
  240. package/lib/structure/core/structureNotations.js.map +1 -1
  241. package/lib/structure/ui/StructureExportPanel.d.ts +8 -0
  242. package/lib/structure/ui/StructureExportPanel.d.ts.map +1 -1
  243. package/lib/structure/ui/StructureExportPanel.js +9 -4
  244. package/lib/structure/ui/StructureExportPanel.js.map +1 -1
  245. package/lib/structure/ui/index.d.ts +1 -0
  246. package/lib/structure/ui/index.d.ts.map +1 -1
  247. package/lib/structure/ui/index.js.map +1 -1
  248. package/package.json +4 -1
  249. package/src/card/core/cardAddress.ts +39 -3
  250. package/src/card/core/cardPageUrl.ts +10 -3
  251. package/src/card/core/index.ts +7 -1
  252. package/src/credits/core/credits.ts +40 -0
  253. package/src/download/core/downloadFigure.ts +26 -1
  254. package/src/download/core/figureDpi.ts +94 -0
  255. package/src/download/core/figurePng.ts +11 -2
  256. package/src/download/core/index.ts +13 -1
  257. package/src/download/core/pngDpi.ts +84 -0
  258. package/src/download/ui/FigureDownloadPanel.tsx +41 -51
  259. package/src/download/ui/figureDownloadHint.ts +13 -0
  260. package/src/download/ui/figureDownloadOptions.ts +85 -0
  261. package/src/download/ui/resolutionChoices.ts +67 -0
  262. package/src/download/ui/useFigureActions.ts +24 -9
  263. package/src/download/ui/useFigureDownload.tsx +57 -71
  264. package/src/ecosystem/core/sites.ts +14 -0
  265. package/src/ecosystem/core/types.ts +2 -1
  266. package/src/ecosystem/ui/glyphs.tsx +20 -0
  267. package/src/locales/de.json +30 -1
  268. package/src/locales/en.json +30 -1
  269. package/src/locales/es.json +30 -1
  270. package/src/locales/fr.json +30 -1
  271. package/src/locales/it.json +30 -1
  272. package/src/molecule3d/ui/Molecule3DStage.tsx +4 -88
  273. package/src/osiris/core/barGeometry.ts +74 -0
  274. package/src/osiris/core/computeProperties.ts +175 -0
  275. package/src/osiris/core/constants.ts +110 -0
  276. package/src/osiris/core/fitness.ts +59 -0
  277. package/src/osiris/core/index.ts +78 -0
  278. package/src/osiris/core/poolSize.ts +24 -0
  279. package/src/osiris/core/poolTypes.ts +140 -0
  280. package/src/osiris/core/predictIdCode.ts +69 -0
  281. package/src/osiris/core/predictProtocol.ts +78 -0
  282. package/src/osiris/core/predictionPool.ts +237 -0
  283. package/src/osiris/core/predictionQueue.ts +89 -0
  284. package/src/osiris/core/predictors.ts +142 -0
  285. package/src/osiris/core/propertyKeys.ts +54 -0
  286. package/src/osiris/core/riskAppearance.ts +86 -0
  287. package/src/osiris/core/riskDetail.ts +120 -0
  288. package/src/osiris/core/riskDetailRequest.ts +64 -0
  289. package/src/osiris/core/riskFindings.ts +92 -0
  290. package/src/osiris/core/runPredictionJob.ts +49 -0
  291. package/src/osiris/core/scales.ts +236 -0
  292. package/src/osiris/core/types.ts +103 -0
  293. package/src/osiris/core/valuation.ts +44 -0
  294. package/src/osiris/ui/PropertyBar.tsx +77 -0
  295. package/src/osiris/ui/PropertyPanel.tsx +227 -0
  296. package/src/osiris/ui/PropertyRows.tsx +92 -0
  297. package/src/osiris/ui/RiskFindings.tsx +137 -0
  298. package/src/osiris/ui/RiskPanel.tsx +81 -0
  299. package/src/osiris/ui/RiskSquare.tsx +108 -0
  300. package/src/osiris/ui/index.ts +17 -0
  301. package/src/osiris/ui/usePredictions.ts +194 -0
  302. package/src/osiris-ui.ts +11 -0
  303. package/src/osiris.ts +17 -0
  304. package/src/panel/ui/FilterInput.tsx +4 -1
  305. package/src/panel/ui/SidePanelItem.tsx +162 -0
  306. package/src/panel/ui/SidePanelStack.tsx +29 -36
  307. package/src/panel/ui/SpectrumColorSwatch.tsx +5 -3
  308. package/src/panel/ui/usePanelFolds.ts +103 -0
  309. package/src/shared/ui/FullscreenStage.tsx +96 -0
  310. package/src/shared/ui/canFillScreen.ts +8 -0
  311. package/src/shared/ui/index.ts +6 -0
  312. package/src/split/ui/splitPanes.tsx +4 -4
  313. package/src/structure/core/structureNotations.ts +25 -8
  314. package/src/structure/ui/StructureExportPanel.tsx +23 -4
  315. package/src/structure/ui/index.ts +4 -0
  316. package/styles/osiris.css +339 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Where a property's bar starts, how far it runs, and where its labelled mark
3
+ * goes.
4
+ *
5
+ * Three numbers come out of the domain and are merely arranged here. The
6
+ * **position** is how far along the scale the value sits and gives the bar its
7
+ * length; the **fitness** is DataWarrior's own `getValuation`, a continuous
8
+ * 0-to-1 score that the stylesheet reads as the green-to-red ramp; the
9
+ * **threshold** is the published rule of thumb — cLogP ≤ 5, logS > −4,
10
+ * molweight < 450, drug-likeness > 0 — drawn as a mark on the track.
11
+ *
12
+ * Nothing here invents a cut-off. A bar whose colour disagreed with the panel's
13
+ * own scale record would be a second opinion nobody could trace.
14
+ */
15
+
16
+ import { propertyFitness, propertyPosition } from './fitness.ts';
17
+ import type { PropertyKey } from './propertyKeys.ts';
18
+ import { propertyScale } from './scales.ts';
19
+
20
+ /** Where a bar's fill and its mark go, all as fractions of the track. */
21
+ export interface BarGeometry {
22
+ /** Where the fill starts, 0 at the left end of the track and 1 at the right. */
23
+ start: number;
24
+ /** How much of the track the fill covers, 0 to 1. */
25
+ length: number;
26
+ /** How good the value is: 0 as bad as the ramp goes, 1 inside the preferred band. */
27
+ fitness: number;
28
+ /**
29
+ * Where the fill grows from: the left end of the track, or its middle for a
30
+ * quantity that runs either side of zero. Drawn as a tick, because a fill
31
+ * that starts at a quarter of the way along says nothing without it.
32
+ */
33
+ origin: number;
34
+ /** Where the published threshold is marked, or `null` where the property has none. */
35
+ mark: number | null;
36
+ /** How that threshold reads, e.g. `≤ 5`, or `null`. */
37
+ markLabel: string | null;
38
+ }
39
+
40
+ /**
41
+ * Where a diverging bar grows from: the middle of its own range, which is
42
+ * drug-likeness 0 and drug score 0.
43
+ */
44
+ const DIVERGING_ORIGIN = 0.5;
45
+
46
+ /**
47
+ * Lay out one property's bar.
48
+ * @param key - Which of the ten properties.
49
+ * @param value - The predicted number, or `null` when the predictor could not answer.
50
+ * @returns The geometry, or `null` when there is no bar to draw.
51
+ */
52
+ export function barGeometry(
53
+ key: PropertyKey,
54
+ value: number | null,
55
+ ): BarGeometry | null {
56
+ const position = propertyPosition(key, value);
57
+ if (position === null) return null;
58
+
59
+ const scale = propertyScale(key);
60
+ const origin = scale.diverging ? DIVERGING_ORIGIN : 0;
61
+ const mark =
62
+ scale.threshold === null
63
+ ? null
64
+ : propertyPosition(key, scale.threshold.value);
65
+
66
+ return {
67
+ start: Math.min(origin, position),
68
+ length: Math.abs(position - origin),
69
+ fitness: propertyFitness(key, value) ?? 0,
70
+ origin,
71
+ mark,
72
+ markLabel: scale.threshold?.label ?? null,
73
+ };
74
+ }
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Everything the tool predicts about one molecule, in one pass.
3
+ *
4
+ * The order of the reads is not arbitrary. `MoleculeProperties`' constructor
5
+ * normalises ambiguous bonds on the molecule it is handed, so the work is done
6
+ * on a copy and the caller's molecule — the one the editor is still drawing —
7
+ * is never touched. Its fields are prototype getters that rerun the whole
8
+ * predictor on every read, at 13 µs each, and the object cannot be spread or
9
+ * serialised at all, so each field is read exactly once into a plain object,
10
+ * and that plain object is what crosses the worker boundary.
11
+ *
12
+ * Nothing here trusts OpenChemLib to fail loudly. An empty molecule answers a
13
+ * full set of innocent numbers and a drug score of 0.63; a failed predictor
14
+ * answers -999, -1 or 0, never `NaN`; and `DrugScoreCalculator` consumes every
15
+ * one of those and returns something plausible. So the empty molecule is
16
+ * refused first, every sentinel becomes `null`, and a drug score is computed
17
+ * only when all of its inputs are real.
18
+ */
19
+
20
+ import type * as OCL from 'openchemlib';
21
+
22
+ import {
23
+ NO_FRAGMENT_MATCHED,
24
+ RISK_TYPE_CODES,
25
+ UNKNOWN_NUMBER,
26
+ UNKNOWN_SURFACE_AREA,
27
+ riskCodeOf,
28
+ riskLevelOf,
29
+ } from './constants.ts';
30
+ import type { OsirisPredictors } from './predictors.ts';
31
+ import type { OsirisProperties, RiskLevel, RiskType } from './types.ts';
32
+ import { RISK_TYPES } from './types.ts';
33
+
34
+ /** What a caller knows about the molecule that the molecule does not. */
35
+ export interface ComputePropertiesOptions {
36
+ /**
37
+ * The name the source carried. The canonical SMILES is used when there is
38
+ * none, so a row always has something to be called.
39
+ * @default the canonical SMILES
40
+ */
41
+ label?: string;
42
+ }
43
+
44
+ /** A structure with no atoms, which has nothing to predict. */
45
+ export const EMPTY_MOLECULE_MESSAGE =
46
+ 'This structure has no atoms, so there is nothing to predict.';
47
+
48
+ /**
49
+ * Predict everything the tool shows for one molecule.
50
+ * @param molecule - The molecule. It is copied before anything touches it, so the caller keeps it exactly as it was.
51
+ * @param predictors - OpenChemLib with its resources registered and checked.
52
+ * @param options - See {@link ComputePropertiesOptions}.
53
+ * @returns The ten numbers, the four risks, and what to call the molecule.
54
+ * @throws {Error} When the molecule has no atoms.
55
+ */
56
+ export function computeProperties(
57
+ molecule: OCL.Molecule,
58
+ predictors: OsirisPredictors,
59
+ options: ComputePropertiesOptions = {},
60
+ ): OsirisProperties {
61
+ if (molecule.getAllAtoms() === 0) throw new Error(EMPTY_MOLECULE_MESSAGE);
62
+
63
+ const working = molecule.getCompactCopy();
64
+ const idCode = working.getIDCode();
65
+ const smiles = working.toIsomericSmiles();
66
+ const { formula, relativeWeight } = working.getMolecularFormula();
67
+
68
+ const properties = new predictors.MoleculeProperties(working);
69
+ const logP = real(properties.logP, UNKNOWN_NUMBER);
70
+ const logS = real(properties.logS, UNKNOWN_NUMBER);
71
+ const polarSurfaceArea = real(
72
+ properties.polarSurfaceArea,
73
+ UNKNOWN_SURFACE_AREA,
74
+ );
75
+ const acceptorCount = properties.acceptorCount;
76
+ const donorCount = properties.donorCount;
77
+ const stereoCenterCount = properties.stereoCenterCount;
78
+ const rotatableBondCount = properties.rotatableBondCount;
79
+
80
+ const assessed = predictors.druglikeness.assessDruglikeness(working);
81
+ const druglikeness =
82
+ assessed === UNKNOWN_NUMBER || assessed === NO_FRAGMENT_MATCHED
83
+ ? null
84
+ : assessed;
85
+
86
+ const risks = assessRisks(working, predictors);
87
+
88
+ return {
89
+ idCode,
90
+ smiles,
91
+ label: options.label ?? smiles,
92
+ molecularFormula: formula,
93
+ molecularWeight: relativeWeight,
94
+ logP,
95
+ logS,
96
+ polarSurfaceArea,
97
+ druglikeness,
98
+ drugScore: drugScore(predictors, {
99
+ logP,
100
+ logS,
101
+ relativeWeight,
102
+ druglikeness,
103
+ risks,
104
+ }),
105
+ acceptorCount,
106
+ donorCount,
107
+ stereoCenterCount,
108
+ rotatableBondCount,
109
+ risks,
110
+ };
111
+ }
112
+
113
+ function assessRisks(
114
+ molecule: OCL.Molecule,
115
+ predictors: OsirisPredictors,
116
+ ): Record<RiskType, RiskLevel> {
117
+ const risks = {} as Record<RiskType, RiskLevel>;
118
+ for (const risk of RISK_TYPES) {
119
+ risks[risk] = riskLevelOf(
120
+ predictors.toxicity.assessRisk(molecule, RISK_TYPE_CODES[risk]),
121
+ );
122
+ }
123
+ return risks;
124
+ }
125
+
126
+ interface DrugScoreInputs {
127
+ logP: number | null;
128
+ logS: number | null;
129
+ relativeWeight: number;
130
+ druglikeness: number | null;
131
+ risks: Record<RiskType, RiskLevel>;
132
+ }
133
+
134
+ /**
135
+ * The drug score, or `null` when any of its five inputs was unknown.
136
+ *
137
+ * `calculate` never refuses: a drug-likeness of -999 simply makes that factor
138
+ * exactly 0.5 and the score comes back looking ordinary, and an unassessed risk
139
+ * applies no penalty where a high one would have applied 0.6. Both read as good
140
+ * news, which is why they are refused here instead.
141
+ *
142
+ * The second argument is the **solubility**. The legacy explorer passed the
143
+ * polar surface area, which is a different number in a different unit; see the
144
+ * test that pins both.
145
+ * @param predictors - OpenChemLib with its resources registered and checked.
146
+ * @param inputs - The four predicted numbers and the four risks.
147
+ * @returns The score, or `null` when it cannot be trusted.
148
+ */
149
+ function drugScore(
150
+ predictors: OsirisPredictors,
151
+ inputs: DrugScoreInputs,
152
+ ): number | null {
153
+ const { logP, logS, relativeWeight, druglikeness, risks } = inputs;
154
+ if (logP === null || logS === null || druglikeness === null) return null;
155
+
156
+ const codes: number[] = [];
157
+ for (const risk of RISK_TYPES) {
158
+ const level = risks[risk];
159
+ if (level === 'unknown') return null;
160
+ codes.push(riskCodeOf(level));
161
+ }
162
+
163
+ return predictors.DrugScoreCalculator.calculate(
164
+ logP,
165
+ logS,
166
+ relativeWeight,
167
+ druglikeness,
168
+ codes,
169
+ );
170
+ }
171
+
172
+ function real(value: number, sentinel: number): number | null {
173
+ if (value === sentinel || !Number.isFinite(value)) return null;
174
+ return value;
175
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * The numbers OpenChemLib speaks, and the words this site says instead.
3
+ *
4
+ * Two translations live here and nowhere else. The first is the library's risk
5
+ * numbering, which is easy to get backwards: `ToxicityPredictor.RISK_NAMES` is
6
+ * indexed by risk *type*, not by risk *level*, and the library exports no level
7
+ * names at all — so reading a level out of `RISK_NAMES` gives a confident,
8
+ * wrong answer. The second is the set of sentinels every predictor returns
9
+ * instead of failing: none of them is `NaN`, and `DrugScoreCalculator` consumes
10
+ * every one of them and hands back a plausible number.
11
+ */
12
+
13
+ import type { RiskLevel, RiskType } from './types.ts';
14
+
15
+ /**
16
+ * Where each risk sits in the library's numbering — `TYPE_MUTAGENIC` 0 through
17
+ * `TYPE_REPRODUCTIVE_EFFECTIVE` 3. It is also the order `DrugScoreCalculator`
18
+ * expects its `toxRisks` array in.
19
+ */
20
+ export const RISK_TYPE_CODES: Record<RiskType, number> = {
21
+ mutagenic: 0,
22
+ tumorigenic: 1,
23
+ irritant: 2,
24
+ reproductive: 3,
25
+ };
26
+
27
+ /**
28
+ * What `assessRisk` returns, read as a word: `RISK_UNKNOWN` 0, `RISK_NO` 1,
29
+ * `RISK_LOW` 2, `RISK_HIGH` 3.
30
+ */
31
+ export const RISK_LEVELS: readonly RiskLevel[] = [
32
+ 'unknown',
33
+ 'none',
34
+ 'low',
35
+ 'high',
36
+ ];
37
+
38
+ /**
39
+ * What the library calls each risk, matching `ToxicityPredictor.RISK_NAMES`.
40
+ * Written out here so reading a label costs no import of a megabyte of
41
+ * OpenChemLib on a page that only draws a table.
42
+ */
43
+ export const RISK_LABELS: Record<RiskType, string> = {
44
+ mutagenic: 'Mutagenicity',
45
+ tumorigenic: 'Tumorigenicity',
46
+ irritant: 'Irritating effects',
47
+ reproductive: 'Reproductive effects',
48
+ };
49
+
50
+ /**
51
+ * How each level reads on screen. OSIRIS's own three words, plus one for the
52
+ * state where the tables did not load — which is not "no risk" and must never
53
+ * be shown as one.
54
+ */
55
+ export const RISK_LEVEL_LABELS: Record<RiskLevel, string> = {
56
+ unknown: 'Not assessed',
57
+ none: 'No risk',
58
+ low: 'Medium risk',
59
+ high: 'High risk',
60
+ };
61
+
62
+ /**
63
+ * What each level multiplies the drug score by, decoded from
64
+ * `DrugScoreCalculator.calculate`. `unknown` applies no factor at all, which is
65
+ * why a score is refused rather than shown when a risk came back unassessed.
66
+ */
67
+ export const DRUG_SCORE_RISK_FACTORS: Record<RiskLevel, number> = {
68
+ unknown: 1,
69
+ none: 1,
70
+ low: 0.8,
71
+ high: 0.6,
72
+ };
73
+
74
+ /**
75
+ * What cLogP, solubility and drug-likeness answer when the predictor failed
76
+ * outright. `CLogPPredictor` returns it on an internal exception, and both
77
+ * `SolubilityPredictor.cSolubilityUnknown` and
78
+ * `DruglikenessPredictor.DRUGLIKENESS_UNKNOWN` are this value.
79
+ */
80
+ export const UNKNOWN_NUMBER = -999;
81
+
82
+ /** What the polar surface area answers when it is unknown — not `-999`. */
83
+ export const UNKNOWN_SURFACE_AREA = -1;
84
+
85
+ /**
86
+ * What `assessDruglikeness` answers when the molecule matched none of the 5294
87
+ * fragments. It is a real return value, not a failure, and it is
88
+ * indistinguishable from a drug-likeness that happens to be exactly -1.
89
+ */
90
+ export const NO_FRAGMENT_MATCHED = -1;
91
+
92
+ /**
93
+ * The word for a risk the library answered with a number.
94
+ * @param code - What `assessRisk` returned, 0 to 3.
95
+ * @returns The level, `unknown` for anything outside the four the library defines.
96
+ */
97
+ export function riskLevelOf(code: number): RiskLevel {
98
+ return RISK_LEVELS[code] ?? 'unknown';
99
+ }
100
+
101
+ /**
102
+ * The number the library uses for a level, for the `toxRisks` argument of
103
+ * `DrugScoreCalculator.calculate`.
104
+ * @param level - The level.
105
+ * @returns 0 to 3.
106
+ */
107
+ export function riskCodeOf(level: RiskLevel): number {
108
+ const code = RISK_LEVELS.indexOf(level);
109
+ return code === -1 ? 0 : code;
110
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * How good one predicted number is, from 0 to 1, and where it sits on its bar.
3
+ *
4
+ * The fitness is what the green-to-red ramp reads; the position is what the
5
+ * bar's length reads. They are deliberately two numbers: a molecular weight of
6
+ * 780 is nearly the full width of its bar and nearly the worst fitness, while
7
+ * a drug-likeness of 0 is halfway along its bar and exactly half fit.
8
+ */
9
+
10
+ import { clamp } from '../../format/core/clamp.ts';
11
+
12
+ import type { PropertyKey } from './propertyKeys.ts';
13
+ import { propertyScale } from './scales.ts';
14
+ import { getValuation } from './valuation.ts';
15
+
16
+ /**
17
+ * How well a value sits in its property's preferred band, from 0 (as bad as
18
+ * the ramp goes) to 1 (inside the band).
19
+ *
20
+ * The drug score is already that fitness — it is the product of the four
21
+ * valuations `DrugScoreCalculator` computes — so it is returned as it stands
22
+ * rather than valued a second time.
23
+ * @param key - Which of the ten properties.
24
+ * @param value - The predicted number, or `null` when the predictor could not answer.
25
+ * @returns The fitness, or `null` for an unknown value.
26
+ */
27
+ export function propertyFitness(
28
+ key: PropertyKey,
29
+ value: number | null,
30
+ ): number | null {
31
+ if (value === null || !Number.isFinite(value)) return null;
32
+ const scale = propertyScale(key);
33
+ if (scale.halfWidth === null) return clamp(value, 0, 1);
34
+ return getValuation(
35
+ value,
36
+ scale.preferredMin,
37
+ scale.preferredMax,
38
+ scale.halfWidth,
39
+ );
40
+ }
41
+
42
+ /**
43
+ * Where a value sits along its bar, from 0 at the left end to 1 at the right.
44
+ *
45
+ * Clamped, because a range is a typical spread rather than a bound: cholesterol
46
+ * runs past the solubility axis and still has to draw.
47
+ * @param key - Which of the ten properties.
48
+ * @param value - The predicted number, or `null`.
49
+ * @returns The position, or `null` for an unknown value.
50
+ */
51
+ export function propertyPosition(
52
+ key: PropertyKey,
53
+ value: number | null,
54
+ ): number | null {
55
+ if (value === null || !Number.isFinite(value)) return null;
56
+ const { rangeMin, rangeMax } = propertyScale(key);
57
+ if (rangeMax === rangeMin) return 0;
58
+ return clamp((value - rangeMin) / (rangeMax - rangeMin), 0, 1);
59
+ }
@@ -0,0 +1,78 @@
1
+ export type { BarGeometry } from './barGeometry.ts';
2
+ export { barGeometry } from './barGeometry.ts';
3
+ export type { ComputePropertiesOptions } from './computeProperties.ts';
4
+ export {
5
+ EMPTY_MOLECULE_MESSAGE,
6
+ computeProperties,
7
+ } from './computeProperties.ts';
8
+ export {
9
+ DRUG_SCORE_RISK_FACTORS,
10
+ NO_FRAGMENT_MATCHED,
11
+ RISK_LABELS,
12
+ RISK_LEVELS,
13
+ RISK_LEVEL_LABELS,
14
+ RISK_TYPE_CODES,
15
+ UNKNOWN_NUMBER,
16
+ UNKNOWN_SURFACE_AREA,
17
+ riskCodeOf,
18
+ riskLevelOf,
19
+ } from './constants.ts';
20
+ export { propertyFitness, propertyPosition } from './fitness.ts';
21
+ export { MAX_POOL_SIZE, predictionPoolSize } from './poolSize.ts';
22
+ export type {
23
+ PredictionInput,
24
+ PredictionOutcome,
25
+ PredictionPool,
26
+ PredictionPoolOptions,
27
+ PredictionProgress,
28
+ } from './poolTypes.ts';
29
+ export {
30
+ UNREADABLE_ID_CODE_MESSAGE,
31
+ predictIdCode,
32
+ riskDetailOfIdCode,
33
+ } from './predictIdCode.ts';
34
+ export type {
35
+ PredictRequest,
36
+ PredictResponse,
37
+ PropertiesRequest,
38
+ RiskDetailRequest,
39
+ } from './predictProtocol.ts';
40
+ export { isPredictRequest } from './predictProtocol.ts';
41
+ export { createPredictionPool } from './predictionPool.ts';
42
+ export type { PredictionQueue } from './predictionQueue.ts';
43
+ export { createPredictionQueue } from './predictionQueue.ts';
44
+ export type { OsirisPredictors, ResourceSource } from './predictors.ts';
45
+ export {
46
+ PredictorsUnavailableError,
47
+ loadPredictors,
48
+ resetPredictors,
49
+ } from './predictors.ts';
50
+ export type { PropertyKey } from './propertyKeys.ts';
51
+ export { PROPERTY_KEYS, isPropertyKey, propertyValue } from './propertyKeys.ts';
52
+ export type { RiskAppearance, RiskTone } from './riskAppearance.ts';
53
+ export {
54
+ KNOWN_MOLECULE_NOTE,
55
+ PENDING_RISK_LABEL,
56
+ RISK_CAVEAT,
57
+ riskAppearance,
58
+ } from './riskAppearance.ts';
59
+ export { riskDetail } from './riskDetail.ts';
60
+ export { parseRiskFindings } from './riskFindings.ts';
61
+ export { runPredictionJob } from './runPredictionJob.ts';
62
+ export type {
63
+ PropertyScale,
64
+ PropertyThreshold,
65
+ ScaleSource,
66
+ } from './scales.ts';
67
+ export { PROPERTY_SCALES, propertyScale } from './scales.ts';
68
+ export type {
69
+ DetailEntry,
70
+ OsirisProperties,
71
+ RiskDetail,
72
+ RiskFinding,
73
+ RiskFindingKind,
74
+ RiskLevel,
75
+ RiskType,
76
+ } from './types.ts';
77
+ export { RISK_TYPES } from './types.ts';
78
+ export { getValuation } from './valuation.ts';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * How many workers to run.
3
+ *
4
+ * One fewer than the machine's cores, so the thread that draws the table keeps
5
+ * one to itself, and never more than eight: measured scaling is 2.45x on two
6
+ * workers and 4.57x on four, and each worker costs its own copy of OpenChemLib
7
+ * and of the 398 kB resource tables.
8
+ */
9
+
10
+ import { clamp } from '../../format/core/clamp.ts';
11
+
12
+ /** The most workers the pool will ever run. */
13
+ export const MAX_POOL_SIZE = 8;
14
+
15
+ /**
16
+ * How many workers a pool should run here.
17
+ * @param requested - What the caller asked for, or `undefined` to read the machine.
18
+ * @returns A count between 1 and {@link MAX_POOL_SIZE}.
19
+ */
20
+ export function predictionPoolSize(requested?: number): number {
21
+ const cores = globalThis.navigator?.hardwareConcurrency;
22
+ const wanted = requested ?? (typeof cores === 'number' ? cores - 1 : 1);
23
+ return Math.trunc(clamp(wanted, 1, MAX_POOL_SIZE, 1));
24
+ }
@@ -0,0 +1,140 @@
1
+ /**
2
+ * What a page asks the prediction pool, and what it hears back.
3
+ *
4
+ * A prediction costs 210 to 380 ms of one thread, so a set of any size is
5
+ * answered a molecule at a time rather than all at once: a row appears as soon
6
+ * as it is read and fills in when its worker returns. Everything here is shaped
7
+ * around that — a per-result callback rather than a promise over the set, a
8
+ * progress figure, a cancel that works, and a way to say which rows the reader
9
+ * can actually see so those are computed first.
10
+ */
11
+
12
+ import type { WorkerLike } from '../../worker/core/messages.ts';
13
+
14
+ import type { PredictRequest, PredictResponse } from './predictProtocol.ts';
15
+ import type { ResourceSource } from './predictors.ts';
16
+ import type { OsirisProperties, RiskDetail, RiskType } from './types.ts';
17
+
18
+ /** One molecule to predict. */
19
+ export interface PredictionInput {
20
+ /**
21
+ * The caller's key for the row, echoed on the answer. It is the row's read
22
+ * position, never its idCode: a real list holds the same structure twice
23
+ * under two names, and both rows have to fill in.
24
+ */
25
+ key: string;
26
+ /** The idCode, with the editor's atom coordinates after a space or without. */
27
+ idCode: string;
28
+ /**
29
+ * The name the source carried.
30
+ * @default the canonical SMILES
31
+ */
32
+ label?: string;
33
+ }
34
+
35
+ /** What came back for one molecule. */
36
+ export type PredictionOutcome =
37
+ | { key: string; ok: true; properties: OsirisProperties }
38
+ | { key: string; ok: false; message: string };
39
+
40
+ /** How far the pool has got. */
41
+ export interface PredictionProgress {
42
+ /** Molecules answered, whether predicted or refused. */
43
+ done: number;
44
+ /** Molecules accepted since the run started. */
45
+ total: number;
46
+ /** Molecules still queued or still being worked on. */
47
+ pending: number;
48
+ /** Whether anything is still to come. */
49
+ running: boolean;
50
+ }
51
+
52
+ /** How a pool is built, and who it reports to. */
53
+ export interface PredictionPoolOptions {
54
+ /**
55
+ * Where the workers register OpenChemLib's resources from — the absolute URL
56
+ * of the site's own `openchemlib-resources.json`, resolved on the main
57
+ * thread. See {@link ResourceSource}.
58
+ */
59
+ resources: ResourceSource;
60
+ /**
61
+ * How many workers to run. Clamped to 1 to 8.
62
+ * @default one fewer than the machine's cores, which measured 2.45x on two workers and 4.57x on four
63
+ */
64
+ size?: number;
65
+ /**
66
+ * Makes one worker, which serves `runPredictionJob` for the requests
67
+ * `isPredictRequest` accepts. Only called where the page has a `Worker` at
68
+ * all. The site writes it because a bundler resolves a worker's address
69
+ * against the module naming it: written in this package, the URL would point
70
+ * inside `node_modules` rather than at a chunk the site's build emitted.
71
+ */
72
+ createWorker: () => WorkerLike;
73
+ /**
74
+ * The same job on this thread, used where there is no `Worker` — Node, a
75
+ * unit test.
76
+ * @default `runPredictionJob`, the same function the worker serves
77
+ */
78
+ runInProcess?: (request: PredictRequest) => Promise<PredictResponse>;
79
+ /**
80
+ * Called once per molecule, as each one comes back.
81
+ * @default undefined
82
+ */
83
+ onResult?: (outcome: PredictionOutcome) => void;
84
+ /**
85
+ * Called whenever the count of answered molecules changes.
86
+ * @default undefined
87
+ */
88
+ onProgress?: (progress: PredictionProgress) => void;
89
+ /**
90
+ * Called once when the resource tables did not load. Every answer from every
91
+ * worker would be `unknown`, so the run stops and nothing more is dispatched.
92
+ * @default undefined
93
+ */
94
+ onUnavailable?: (message: string) => void;
95
+ /**
96
+ * Milliseconds one molecule may take before it is given up on.
97
+ * @default 60000
98
+ */
99
+ timeoutMs?: number;
100
+ }
101
+
102
+ /** A pool of workers answering one molecule at a time, each. */
103
+ export interface PredictionPool {
104
+ /** How many workers it runs. */
105
+ readonly size: number;
106
+ /** How far it has got. */
107
+ readonly progress: PredictionProgress;
108
+ /**
109
+ * Add molecules to predict. One already queued or in flight is ignored, so a
110
+ * page may resubmit its whole set whenever the set changes.
111
+ * @param molecules - The molecules.
112
+ */
113
+ submit: (molecules: readonly PredictionInput[]) => void;
114
+ /**
115
+ * Say which rows to answer first — the ones the reader can see. Molecules
116
+ * already being worked on are left alone; only what is still queued moves.
117
+ * @param keys - The keys, most wanted first.
118
+ */
119
+ prioritize: (keys: readonly string[]) => void;
120
+ /**
121
+ * Why one risk came back as it did. Jumps the queue, because it is a click.
122
+ * A {@link PredictionPool.cancel} is about the set, not about the click, so
123
+ * an explanation it drops is asked for again.
124
+ * @param idCode - The molecule, coordinates included or not.
125
+ * @param risk - Which of the four risks to explain.
126
+ * @returns The findings, with the matched atoms and bonds of every fragment.
127
+ * @throws {Error} When even the second ask was dropped, with a sentence to show the reader.
128
+ */
129
+ riskDetail: (idCode: string, risk: RiskType) => Promise<RiskDetail>;
130
+ /**
131
+ * Drop everything queued and stop reporting. The molecule each worker is
132
+ * already on cannot be interrupted — the library call is synchronous — so it
133
+ * finishes and its answer is thrown away, within about 400 ms. A
134
+ * {@link PredictionPool.submit} made in the same turn is still dispatched, on
135
+ * the slots those abandoned answers free.
136
+ */
137
+ cancel: () => void;
138
+ /** Cancel, and end every worker. */
139
+ terminate: () => void;
140
+ }