@kent-tokyo/chematic 1.1.0 → 1.1.1

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
@@ -4,7 +4,7 @@ WebAssembly bindings for [chematic](https://github.com/kent-tokyo/chematic), a p
4
4
 
5
5
  Published to npm as [`@kent-tokyo/chematic`](https://www.npmjs.com/package/@kent-tokyo/chematic).
6
6
 
7
- The current workspace line is 1.1.0. The binding keeps bounded parsing,
7
+ The current workspace line is 1.1.1. The binding keeps bounded parsing,
8
8
  typed failures, and opt-in `embed_pipeline_v2_json`; 3D/MMFF94 behavior remains
9
9
  Experimental and is not a claim of full RDKit parity.
10
10
 
@@ -43,6 +43,11 @@ npm install @kent-tokyo/chematic
43
43
  `MolHandle.atom_pseudo_labels_json()` and immutable edits through
44
44
  `mol_with_atom_pseudo_label`; labels are bounded to `*`, `R`, and
45
45
  `R1..R9999`
46
+ - Label-stable R-group decomposition through
47
+ `rgroup_decompose_columns_json(smilesJson, coreSmarts)`. The returned JSON
48
+ contains input-aligned `Core`, `R1`, `R2`, ... columns and uses `null` for
49
+ unmatched molecules or substituents absent from a matched row. The legacy
50
+ `rgroup_decompose_json` row API is unchanged.
46
51
  - PDBx/mmCIF, PQR, QCSchema JSON, ORCA input/output, Gaussian Cube, OpenDX,
47
52
  and LAMMPS data/dump I/O (JSON-based bindings; see `format_io.rs`)
48
53
  - Topological descriptors: Wiener index, Hall-Kier κ, χ connectivity indices, Bertz CT
@@ -50,6 +55,8 @@ npm install @kent-tokyo/chematic
50
55
  - 2D SVG depiction with CPK colors and atom/bond highlighting
51
56
  - SVG grid layout for multiple molecules
52
57
  - Reaction SMILES/SMIRKS parsing and transform
58
+ (`run_reactants_checked` includes typed native and RDKit-profile rejection
59
+ diagnostics without returning rejected products as successes)
53
60
  - Add/remove explicit hydrogens
54
61
  - `embed_pipeline_v2_json`: torsion-knowledge-aware 3D embedding + stereo
55
62
  verification/repair + policy-gated force field, mirroring the Python
@@ -925,12 +925,16 @@ export function conformer_ensemble_json(mol: MolHandle, n: number, rmsd_threshol
925
925
  *
926
926
  * This is the WASM counterpart of Python's `convert_format`. It supports
927
927
  * SMILES, MOL/SDF, MOL V3000, MOL2, CML, ChemicalJSON, MolJSON, and CDXML.
928
- * Coordinates and format-specific metadata are intentionally not carried
929
- * across this topology-only bridge; use the format-specific coordinate APIs
930
- * when those fields must be preserved.
928
+ * MOL2-to-MOL2 validates and retains the exact source. Other conversions use
929
+ * the topology-only bridge and do not carry format-specific metadata.
931
930
  */
932
931
  export function convert_common_format(text: string, input_format: string, output_format: string): string;
933
932
 
933
+ /**
934
+ * Checked MOL2/CJSON conversion using the shared report schema.
935
+ */
936
+ export function convert_with_report_json(text: string, input_format: string, output_format: string, policy: string): string;
937
+
934
938
  /**
935
939
  * Return the CPK color (CSS hex string) for the given element symbol.
936
940
  *
@@ -2219,6 +2223,11 @@ export function orca_output_to_json(text: string): string;
2219
2223
  */
2220
2224
  export function pains_matches_json(mol: MolHandle): string;
2221
2225
 
2226
+ /**
2227
+ * Inspect strictly validated CJSON with exact source and opaque field paths.
2228
+ */
2229
+ export function parse_cjson_record_json(text: string): string;
2230
+
2222
2231
  /**
2223
2232
  * Parse CXSMARTS and return preserved metadata as JSON.
2224
2233
  * Returns error if atom count exceeds 10,000.
@@ -2235,6 +2244,11 @@ export function parse_cxsmarts_json(s: string): string;
2235
2244
  */
2236
2245
  export function parse_cxsmiles_json(s: string): string;
2237
2246
 
2247
+ /**
2248
+ * Inspect partial charges, atom types and source retention for MOL2.
2249
+ */
2250
+ export function parse_mol2_record_json(text: string): string;
2251
+
2238
2252
  /**
2239
2253
  * Parse a SMILES string into a `MolHandle`.
2240
2254
  *
@@ -2565,6 +2579,18 @@ export function remove_hydrogens(mol: MolHandle): MolHandle;
2565
2579
  */
2566
2580
  export function retro_disconnect_json(mol: MolHandle, max_results: number, reaction_class: string): string;
2567
2581
 
2582
+ /**
2583
+ * Label-stable R-group decomposition returned as RDKit-style table columns.
2584
+ *
2585
+ * `core_smarts` accepts the bounded mapped-core contract used by Rust and
2586
+ * Python: terminal mapped wildcards such as `[*:2]`, or mapped core atoms.
2587
+ * The returned JSON object contains `Core`, `R1`, `R2`, ... arrays parallel
2588
+ * to the input rows. Unmatched rows and absent substituents are `null`.
2589
+ * Output fragments retain their mapped attachment wildcard. The legacy
2590
+ * [`super::rgroup_decompose_json`] function is unchanged.
2591
+ */
2592
+ export function rgroup_decompose_columns_json(smiles_json: string, core_smarts: string): string;
2593
+
2568
2594
  /**
2569
2595
  * Decompose a set of molecules against a core SMARTS, returning R-group SMILES.
2570
2596
  *
@@ -2594,6 +2620,16 @@ export function rgroup_decompose_json(smiles_json: string, core_smarts: string):
2594
2620
  */
2595
2621
  export function ring_families_json(mol: MolHandle): string;
2596
2622
 
2623
+ /**
2624
+ * Validate the local CJSON profile and retain the exact UTF-8 source.
2625
+ */
2626
+ export function roundtrip_cjson_record(text: string): string;
2627
+
2628
+ /**
2629
+ * Validate one MOL2 record and preserve its exact source, including metadata.
2630
+ */
2631
+ export function roundtrip_mol2_record(text: string): string;
2632
+
2597
2633
  /**
2598
2634
  * Parse and serialize a V3000 block while preserving V3000 metadata.
2599
2635
  *
@@ -3245,6 +3281,7 @@ export interface InitOutput {
3245
3281
  readonly conformerhandle_new: (a: number, b: number) => [number, number, number];
3246
3282
  readonly conformerhandle_remove_conformer: (a: number, b: number) => number;
3247
3283
  readonly convert_common_format: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
3284
+ readonly convert_with_report_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
3248
3285
  readonly cpk_color: (a: number, b: number) => [number, number];
3249
3286
  readonly cube_grid_json: (a: number, b: number) => [number, number, number, number];
3250
3287
  readonly cube_shape_u32: (a: number, b: number) => [number, number, number];
@@ -3491,8 +3528,10 @@ export interface InitOutput {
3491
3528
  readonly orca_input_to_json: (a: number, b: number) => [number, number, number, number];
3492
3529
  readonly orca_output_to_json: (a: number, b: number) => [number, number, number, number];
3493
3530
  readonly pains_matches_json: (a: number) => [number, number];
3531
+ readonly parse_cjson_record_json: (a: number, b: number) => [number, number, number, number];
3494
3532
  readonly parse_cxsmarts_json: (a: number, b: number) => [number, number, number, number];
3495
3533
  readonly parse_cxsmiles_json: (a: number, b: number) => [number, number, number, number];
3534
+ readonly parse_mol2_record_json: (a: number, b: number) => [number, number, number, number];
3496
3535
  readonly parse_smiles: (a: number, b: number) => [number, number, number];
3497
3536
  readonly pdb_coords_json: (a: number, b: number) => [number, number];
3498
3537
  readonly peoe_vsa_json: (a: number) => [number, number];
@@ -3539,8 +3578,11 @@ export interface InitOutput {
3539
3578
  readonly reaction_smarts_match: (a: number, b: number, c: number, d: number) => [number, number, number];
3540
3579
  readonly remove_hydrogens: (a: number) => number;
3541
3580
  readonly retro_disconnect_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3581
+ readonly rgroup_decompose_columns_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3542
3582
  readonly rgroup_decompose_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3543
3583
  readonly ring_families_json: (a: number) => [number, number, number, number];
3584
+ readonly roundtrip_cjson_record: (a: number, b: number) => [number, number, number, number];
3585
+ readonly roundtrip_mol2_record: (a: number, b: number) => [number, number, number, number];
3544
3586
  readonly roundtrip_mol_v3000_block: (a: number, b: number) => [number, number, number, number];
3545
3587
  readonly run_reactants: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3546
3588
  readonly run_reactants_checked: (a: number, b: number, c: number, d: number, e: number) => [number, number];
package/chematic_wasm.js CHANGED
@@ -2550,9 +2550,8 @@ export function conformer_ensemble_json(mol, n, rmsd_threshold) {
2550
2550
  *
2551
2551
  * This is the WASM counterpart of Python's `convert_format`. It supports
2552
2552
  * SMILES, MOL/SDF, MOL V3000, MOL2, CML, ChemicalJSON, MolJSON, and CDXML.
2553
- * Coordinates and format-specific metadata are intentionally not carried
2554
- * across this topology-only bridge; use the format-specific coordinate APIs
2555
- * when those fields must be preserved.
2553
+ * MOL2-to-MOL2 validates and retains the exact source. Other conversions use
2554
+ * the topology-only bridge and do not carry format-specific metadata.
2556
2555
  * @param {string} text
2557
2556
  * @param {string} input_format
2558
2557
  * @param {string} output_format
@@ -2583,6 +2582,41 @@ export function convert_common_format(text, input_format, output_format) {
2583
2582
  }
2584
2583
  }
2585
2584
 
2585
+ /**
2586
+ * Checked MOL2/CJSON conversion using the shared report schema.
2587
+ * @param {string} text
2588
+ * @param {string} input_format
2589
+ * @param {string} output_format
2590
+ * @param {string} policy
2591
+ * @returns {string}
2592
+ */
2593
+ export function convert_with_report_json(text, input_format, output_format, policy) {
2594
+ let deferred6_0;
2595
+ let deferred6_1;
2596
+ try {
2597
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2598
+ const len0 = WASM_VECTOR_LEN;
2599
+ const ptr1 = passStringToWasm0(input_format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2600
+ const len1 = WASM_VECTOR_LEN;
2601
+ const ptr2 = passStringToWasm0(output_format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2602
+ const len2 = WASM_VECTOR_LEN;
2603
+ const ptr3 = passStringToWasm0(policy, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2604
+ const len3 = WASM_VECTOR_LEN;
2605
+ const ret = wasm.convert_with_report_json(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
2606
+ var ptr5 = ret[0];
2607
+ var len5 = ret[1];
2608
+ if (ret[3]) {
2609
+ ptr5 = 0; len5 = 0;
2610
+ throw takeFromExternrefTable0(ret[2]);
2611
+ }
2612
+ deferred6_0 = ptr5;
2613
+ deferred6_1 = len5;
2614
+ return getStringFromWasm0(ptr5, len5);
2615
+ } finally {
2616
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
2617
+ }
2618
+ }
2619
+
2586
2620
  /**
2587
2621
  * Return the CPK color (CSS hex string) for the given element symbol.
2588
2622
  *
@@ -5875,6 +5909,32 @@ export function pains_matches_json(mol) {
5875
5909
  }
5876
5910
  }
5877
5911
 
5912
+ /**
5913
+ * Inspect strictly validated CJSON with exact source and opaque field paths.
5914
+ * @param {string} text
5915
+ * @returns {string}
5916
+ */
5917
+ export function parse_cjson_record_json(text) {
5918
+ let deferred3_0;
5919
+ let deferred3_1;
5920
+ try {
5921
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5922
+ const len0 = WASM_VECTOR_LEN;
5923
+ const ret = wasm.parse_cjson_record_json(ptr0, len0);
5924
+ var ptr2 = ret[0];
5925
+ var len2 = ret[1];
5926
+ if (ret[3]) {
5927
+ ptr2 = 0; len2 = 0;
5928
+ throw takeFromExternrefTable0(ret[2]);
5929
+ }
5930
+ deferred3_0 = ptr2;
5931
+ deferred3_1 = len2;
5932
+ return getStringFromWasm0(ptr2, len2);
5933
+ } finally {
5934
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
5935
+ }
5936
+ }
5937
+
5878
5938
  /**
5879
5939
  * Parse CXSMARTS and return preserved metadata as JSON.
5880
5940
  * Returns error if atom count exceeds 10,000.
@@ -5933,6 +5993,32 @@ export function parse_cxsmiles_json(s) {
5933
5993
  }
5934
5994
  }
5935
5995
 
5996
+ /**
5997
+ * Inspect partial charges, atom types and source retention for MOL2.
5998
+ * @param {string} text
5999
+ * @returns {string}
6000
+ */
6001
+ export function parse_mol2_record_json(text) {
6002
+ let deferred3_0;
6003
+ let deferred3_1;
6004
+ try {
6005
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6006
+ const len0 = WASM_VECTOR_LEN;
6007
+ const ret = wasm.parse_mol2_record_json(ptr0, len0);
6008
+ var ptr2 = ret[0];
6009
+ var len2 = ret[1];
6010
+ if (ret[3]) {
6011
+ ptr2 = 0; len2 = 0;
6012
+ throw takeFromExternrefTable0(ret[2]);
6013
+ }
6014
+ deferred3_0 = ptr2;
6015
+ deferred3_1 = len2;
6016
+ return getStringFromWasm0(ptr2, len2);
6017
+ } finally {
6018
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6019
+ }
6020
+ }
6021
+
5936
6022
  /**
5937
6023
  * Parse a SMILES string into a `MolHandle`.
5938
6024
  *
@@ -6833,6 +6919,42 @@ export function retro_disconnect_json(mol, max_results, reaction_class) {
6833
6919
  }
6834
6920
  }
6835
6921
 
6922
+ /**
6923
+ * Label-stable R-group decomposition returned as RDKit-style table columns.
6924
+ *
6925
+ * `core_smarts` accepts the bounded mapped-core contract used by Rust and
6926
+ * Python: terminal mapped wildcards such as `[*:2]`, or mapped core atoms.
6927
+ * The returned JSON object contains `Core`, `R1`, `R2`, ... arrays parallel
6928
+ * to the input rows. Unmatched rows and absent substituents are `null`.
6929
+ * Output fragments retain their mapped attachment wildcard. The legacy
6930
+ * [`super::rgroup_decompose_json`] function is unchanged.
6931
+ * @param {string} smiles_json
6932
+ * @param {string} core_smarts
6933
+ * @returns {string}
6934
+ */
6935
+ export function rgroup_decompose_columns_json(smiles_json, core_smarts) {
6936
+ let deferred4_0;
6937
+ let deferred4_1;
6938
+ try {
6939
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6940
+ const len0 = WASM_VECTOR_LEN;
6941
+ const ptr1 = passStringToWasm0(core_smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6942
+ const len1 = WASM_VECTOR_LEN;
6943
+ const ret = wasm.rgroup_decompose_columns_json(ptr0, len0, ptr1, len1);
6944
+ var ptr3 = ret[0];
6945
+ var len3 = ret[1];
6946
+ if (ret[3]) {
6947
+ ptr3 = 0; len3 = 0;
6948
+ throw takeFromExternrefTable0(ret[2]);
6949
+ }
6950
+ deferred4_0 = ptr3;
6951
+ deferred4_1 = len3;
6952
+ return getStringFromWasm0(ptr3, len3);
6953
+ } finally {
6954
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
6955
+ }
6956
+ }
6957
+
6836
6958
  /**
6837
6959
  * Decompose a set of molecules against a core SMARTS, returning R-group SMILES.
6838
6960
  *
@@ -6906,6 +7028,58 @@ export function ring_families_json(mol) {
6906
7028
  }
6907
7029
  }
6908
7030
 
7031
+ /**
7032
+ * Validate the local CJSON profile and retain the exact UTF-8 source.
7033
+ * @param {string} text
7034
+ * @returns {string}
7035
+ */
7036
+ export function roundtrip_cjson_record(text) {
7037
+ let deferred3_0;
7038
+ let deferred3_1;
7039
+ try {
7040
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
7041
+ const len0 = WASM_VECTOR_LEN;
7042
+ const ret = wasm.roundtrip_cjson_record(ptr0, len0);
7043
+ var ptr2 = ret[0];
7044
+ var len2 = ret[1];
7045
+ if (ret[3]) {
7046
+ ptr2 = 0; len2 = 0;
7047
+ throw takeFromExternrefTable0(ret[2]);
7048
+ }
7049
+ deferred3_0 = ptr2;
7050
+ deferred3_1 = len2;
7051
+ return getStringFromWasm0(ptr2, len2);
7052
+ } finally {
7053
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
7054
+ }
7055
+ }
7056
+
7057
+ /**
7058
+ * Validate one MOL2 record and preserve its exact source, including metadata.
7059
+ * @param {string} text
7060
+ * @returns {string}
7061
+ */
7062
+ export function roundtrip_mol2_record(text) {
7063
+ let deferred3_0;
7064
+ let deferred3_1;
7065
+ try {
7066
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
7067
+ const len0 = WASM_VECTOR_LEN;
7068
+ const ret = wasm.roundtrip_mol2_record(ptr0, len0);
7069
+ var ptr2 = ret[0];
7070
+ var len2 = ret[1];
7071
+ if (ret[3]) {
7072
+ ptr2 = 0; len2 = 0;
7073
+ throw takeFromExternrefTable0(ret[2]);
7074
+ }
7075
+ deferred3_0 = ptr2;
7076
+ deferred3_1 = len2;
7077
+ return getStringFromWasm0(ptr2, len2);
7078
+ } finally {
7079
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
7080
+ }
7081
+ }
7082
+
6909
7083
  /**
6910
7084
  * Parse and serialize a V3000 block while preserving V3000 metadata.
6911
7085
  *
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Kentaro Tanabe (kent-tokyo) <kent-tokyo@users.noreply.github.com>"
6
6
  ],
7
7
  "description": "WebAssembly bindings for chematic — use chematic from JavaScript/TypeScript",
8
- "version": "1.1.0",
8
+ "version": "1.1.1",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",