@kent-tokyo/chematic 0.18.0 → 0.20.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.
package/README.md CHANGED
@@ -122,13 +122,34 @@ const response = JSON.parse(embed_pipeline_v2_json(mol, JSON.stringify({
122
122
  forceFieldPolicy: "none",
123
123
  forceFieldMaxIterations: 200,
124
124
  gateMmff94TorsionOop: false,
125
+ gateMmff94StretchBend: false,
125
126
  ringTorsionPolicy: "fail_closed",
126
127
  totalTimeoutMs: null,
128
+ enforceChirality: false,
129
+ expandImplicitHThroughPipeline: false,
127
130
  })));
128
131
  // response.ok, response.result / response.error — same shape as
129
132
  // Mol.embed_pipeline_v2() in the Python binding.
130
133
  ```
131
134
 
135
+ For ring-fused declared stereocenters (e.g. testosterone, cholesterol) that
136
+ `enforceChirality` alone can't repair, `stereoPolicy: "repair_and_verify"` +
137
+ `enforceChirality: true` + `expandImplicitHThroughPipeline: true` are needed
138
+ *together* (issue #291/#383) — `pipeline_v2_stereo_safe_config_json` builds
139
+ that exact combination so a caller can't set one and forget another:
140
+
141
+ ```js
142
+ const configResponse = JSON.parse(pipeline_v2_stereo_safe_config_json(
143
+ "mmff94_with_uff_fallback", "fail_closed"
144
+ ));
145
+ // configResponse.ok, configResponse.config (or configResponse.error, same
146
+ // shape as embed_pipeline_v2_json's own error) — modify configResponse.config
147
+ // (e.g. a different embedSeed) before passing it to embed_pipeline_v2_json.
148
+ const response = JSON.parse(
149
+ embed_pipeline_v2_json(mol, JSON.stringify(configResponse.config))
150
+ );
151
+ ```
152
+
132
153
  Verified working end-to-end under real WASM (both `wasm-pack --target nodejs`
133
154
  and `--target web`, the latter being what this package's npm build actually
134
155
  uses) — success, typed-failure, and typed-timeout paths all return real
@@ -593,6 +593,15 @@ export function canonical_tautomer_with_blocked_atoms_json(mol: MolHandle, block
593
593
  */
594
594
  export function cdxml_to_smiles_json(cdxml: string): string;
595
595
 
596
+ /**
597
+ * The `chematic-wasm` crate version (matches the workspace release version).
598
+ *
599
+ * Lets callers (e.g. the browser playground demo) display the running
600
+ * version without hardcoding it — `demo/index.html` previously had a
601
+ * static version string that silently went stale across releases.
602
+ */
603
+ export function chematic_version(): string;
604
+
596
605
  /**
597
606
  * CIP stereo assignments via the accurate hierarchical-digraph engine, as a JSON
598
607
  * array of `{atomIdx, cipCode}` objects -- same shape as [`cip_assignments_json`],
@@ -1349,8 +1358,13 @@ export function minimize_mmff94_lbfgs_json(mol: MolHandle, max_iter: number): st
1349
1358
  * `coords_json` — JSON array of `[x,y,z]` arrays (Å), one per atom.
1350
1359
  * `max_iter` — maximum iterations (0 = default 500).
1351
1360
  *
1352
- * Returns JSON: `{"coords":[[x,y,z],...], "energy":float, "iterations":int, "converged":bool}`
1353
- * or `{"error":"<msg>"}` on failure.
1361
+ * Returns JSON: `{"coords":[[x,y,z],...], "energy":float, "iterations":int, "converged":bool, "sound":bool}`
1362
+ * or `{"error":"<msg>"}` on failure. `sound` is all-finite coordinates and
1363
+ * no bond stretched past a sane covalent-bond length — independent of
1364
+ * `converged`, since steepest descent often reports `converged:false` on
1365
+ * geometries that are perfectly fine but simply haven't hit the tight
1366
+ * RMS-gradient threshold yet. Check `sound`, not just `converged`, before
1367
+ * trusting a result.
1354
1368
  */
1355
1369
  export function minimize_uff_json(smiles: string, coords_json: string, max_iter: number): string;
1356
1370
 
@@ -1835,6 +1849,30 @@ export function pharmacophore_fp_2d_summary(mol: MolHandle): string;
1835
1849
  */
1836
1850
  export function pharmacophore_fp_3d_summary(mol: MolHandle): string;
1837
1851
 
1852
+ /**
1853
+ * Returns a ready-to-use `embed_pipeline_v2_json` config JSON string for the
1854
+ * "stereo-safe" configuration (issue #291/#383): `stereoPolicy:
1855
+ * "repair_and_verify"`, `enforceChirality: true`, and
1856
+ * `expandImplicitHThroughPipeline: true` together -- the exact combination
1857
+ * measured to correctly handle ring-fused declared stereocenters (e.g.
1858
+ * testosterone, cholesterol) that `enforceChirality` alone cannot repair.
1859
+ * Mirrors `PipelineV2Config::stereo_safe`/the Python binding's
1860
+ * `PipelineV2Config.stereo_safe(...)` -- prefer this over setting those three
1861
+ * fields individually: they only work correctly as a set, and forgetting one
1862
+ * silently falls back to a configuration issue #291 measured as unsound for
1863
+ * that molecule class. `forceFieldPolicy`/`ringTorsionPolicy` are still
1864
+ * required, explicit arguments; everything else takes the same conservative
1865
+ * defaults `embed_pipeline_v2_json`'s own documented examples do. The caller
1866
+ * may parse and further override individual fields before passing the result
1867
+ * to `embed_pipeline_v2_json` (e.g. a different `embedSeed`).
1868
+ *
1869
+ * Never throws, matching `embed_pipeline_v2_json`'s own convention: an
1870
+ * unknown `force_field`/`ring_torsion_policy` string returns the same
1871
+ * `{"ok": false, "error": {...}}` shape `embed_pipeline_v2_json` would for an
1872
+ * invalid config, tagged `schemaVersion: 1`.
1873
+ */
1874
+ export function pipeline_v2_stereo_safe_config_json(force_field: string, ring_torsion_policy: string): string;
1875
+
1838
1876
  /**
1839
1877
  * Cartesian coordinates from a PQR file, in the SAME atom order
1840
1878
  * [`mol_from_pqr`] returns topology for. Returns JSON `[[x,y,z],...]` (Å).
@@ -2480,6 +2518,7 @@ export interface InitOutput {
2480
2518
  readonly canonical_tautomer: (a: number) => number;
2481
2519
  readonly canonical_tautomer_with_blocked_atoms_json: (a: number, b: number, c: number) => [number, number];
2482
2520
  readonly cdxml_to_smiles_json: (a: number, b: number) => [number, number, number, number];
2521
+ readonly chematic_version: () => [number, number];
2483
2522
  readonly cip_assignments_accurate_json: (a: number) => [number, number];
2484
2523
  readonly cip_assignments_json: (a: number) => [number, number];
2485
2524
  readonly cip_unresolved_json: (a: number) => [number, number];
@@ -2712,6 +2751,7 @@ export interface InitOutput {
2712
2751
  readonly pharmacophore_features_json: (a: number) => [number, number];
2713
2752
  readonly pharmacophore_fp_2d_summary: (a: number) => [number, number];
2714
2753
  readonly pharmacophore_fp_3d_summary: (a: number) => [number, number];
2754
+ readonly pipeline_v2_stereo_safe_config_json: (a: number, b: number, c: number, d: number) => [number, number];
2715
2755
  readonly pqr_coords_json: (a: number, b: number) => [number, number, number, number];
2716
2756
  readonly pqr_infer_element: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
2717
2757
  readonly pqr_to_json: (a: number, b: number) => [number, number, number, number];
package/chematic_wasm.js CHANGED
@@ -1398,6 +1398,27 @@ export function cdxml_to_smiles_json(cdxml) {
1398
1398
  }
1399
1399
  }
1400
1400
 
1401
+ /**
1402
+ * The `chematic-wasm` crate version (matches the workspace release version).
1403
+ *
1404
+ * Lets callers (e.g. the browser playground demo) display the running
1405
+ * version without hardcoding it — `demo/index.html` previously had a
1406
+ * static version string that silently went stale across releases.
1407
+ * @returns {string}
1408
+ */
1409
+ export function chematic_version() {
1410
+ let deferred1_0;
1411
+ let deferred1_1;
1412
+ try {
1413
+ const ret = wasm.chematic_version();
1414
+ deferred1_0 = ret[0];
1415
+ deferred1_1 = ret[1];
1416
+ return getStringFromWasm0(ret[0], ret[1]);
1417
+ } finally {
1418
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1419
+ }
1420
+ }
1421
+
1401
1422
  /**
1402
1423
  * CIP stereo assignments via the accurate hierarchical-digraph engine, as a JSON
1403
1424
  * array of `{atomIdx, cipCode}` objects -- same shape as [`cip_assignments_json`],
@@ -3259,8 +3280,13 @@ export function minimize_mmff94_lbfgs_json(mol, max_iter) {
3259
3280
  * `coords_json` — JSON array of `[x,y,z]` arrays (Å), one per atom.
3260
3281
  * `max_iter` — maximum iterations (0 = default 500).
3261
3282
  *
3262
- * Returns JSON: `{"coords":[[x,y,z],...], "energy":float, "iterations":int, "converged":bool}`
3263
- * or `{"error":"<msg>"}` on failure.
3283
+ * Returns JSON: `{"coords":[[x,y,z],...], "energy":float, "iterations":int, "converged":bool, "sound":bool}`
3284
+ * or `{"error":"<msg>"}` on failure. `sound` is all-finite coordinates and
3285
+ * no bond stretched past a sane covalent-bond length — independent of
3286
+ * `converged`, since steepest descent often reports `converged:false` on
3287
+ * geometries that are perfectly fine but simply haven't hit the tight
3288
+ * RMS-gradient threshold yet. Check `sound`, not just `converged`, before
3289
+ * trusting a result.
3264
3290
  * @param {string} smiles
3265
3291
  * @param {string} coords_json
3266
3292
  * @param {number} max_iter
@@ -4563,6 +4589,48 @@ export function pharmacophore_fp_3d_summary(mol) {
4563
4589
  }
4564
4590
  }
4565
4591
 
4592
+ /**
4593
+ * Returns a ready-to-use `embed_pipeline_v2_json` config JSON string for the
4594
+ * "stereo-safe" configuration (issue #291/#383): `stereoPolicy:
4595
+ * "repair_and_verify"`, `enforceChirality: true`, and
4596
+ * `expandImplicitHThroughPipeline: true` together -- the exact combination
4597
+ * measured to correctly handle ring-fused declared stereocenters (e.g.
4598
+ * testosterone, cholesterol) that `enforceChirality` alone cannot repair.
4599
+ * Mirrors `PipelineV2Config::stereo_safe`/the Python binding's
4600
+ * `PipelineV2Config.stereo_safe(...)` -- prefer this over setting those three
4601
+ * fields individually: they only work correctly as a set, and forgetting one
4602
+ * silently falls back to a configuration issue #291 measured as unsound for
4603
+ * that molecule class. `forceFieldPolicy`/`ringTorsionPolicy` are still
4604
+ * required, explicit arguments; everything else takes the same conservative
4605
+ * defaults `embed_pipeline_v2_json`'s own documented examples do. The caller
4606
+ * may parse and further override individual fields before passing the result
4607
+ * to `embed_pipeline_v2_json` (e.g. a different `embedSeed`).
4608
+ *
4609
+ * Never throws, matching `embed_pipeline_v2_json`'s own convention: an
4610
+ * unknown `force_field`/`ring_torsion_policy` string returns the same
4611
+ * `{"ok": false, "error": {...}}` shape `embed_pipeline_v2_json` would for an
4612
+ * invalid config, tagged `schemaVersion: 1`.
4613
+ * @param {string} force_field
4614
+ * @param {string} ring_torsion_policy
4615
+ * @returns {string}
4616
+ */
4617
+ export function pipeline_v2_stereo_safe_config_json(force_field, ring_torsion_policy) {
4618
+ let deferred3_0;
4619
+ let deferred3_1;
4620
+ try {
4621
+ const ptr0 = passStringToWasm0(force_field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4622
+ const len0 = WASM_VECTOR_LEN;
4623
+ const ptr1 = passStringToWasm0(ring_torsion_policy, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4624
+ const len1 = WASM_VECTOR_LEN;
4625
+ const ret = wasm.pipeline_v2_stereo_safe_config_json(ptr0, len0, ptr1, len1);
4626
+ deferred3_0 = ret[0];
4627
+ deferred3_1 = ret[1];
4628
+ return getStringFromWasm0(ret[0], ret[1]);
4629
+ } finally {
4630
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4631
+ }
4632
+ }
4633
+
4566
4634
  /**
4567
4635
  * Cartesian coordinates from a PQR file, in the SAME atom order
4568
4636
  * [`mol_from_pqr`] returns topology for. Returns JSON `[[x,y,z],...]` (Å).
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "kent-tokyo <kent-tokyo@users.noreply.github.com>"
6
6
  ],
7
7
  "description": "WebAssembly bindings for chematic — use chematic from JavaScript/TypeScript",
8
- "version": "0.18.0",
8
+ "version": "0.20.0",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",