@kent-tokyo/chematic 1.0.19 → 1.0.21

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.0.15. The binding keeps bounded parsing,
7
+ The current workspace line is 1.0.21. 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
 
@@ -36,6 +36,10 @@ npm install @kent-tokyo/chematic
36
36
  - Bounded topology parsing for CML (`mol_from_cml_strict` provides the opt-in
37
37
  non-empty, balanced, single-root boundary), ChemicalJSON (`mol_from_cjson`), MolJSON,
38
38
  CDXML, MOL2, and PDB/mmCIF
39
+ - Index-aligned wildcard/R-group inspection with
40
+ `MolHandle.atom_pseudo_labels_json()` and immutable edits through
41
+ `mol_with_atom_pseudo_label`; labels are bounded to `*`, `R`, and
42
+ `R1..R9999`
39
43
  - PDBx/mmCIF, PQR, QCSchema JSON, ORCA input/output, Gaussian Cube, OpenDX,
40
44
  and LAMMPS data/dump I/O (JSON-based bindings; see `format_io.rs`)
41
45
  - Topological descriptors: Wiener index, Hall-Kier κ, χ connectivity indices, Bertz CT
@@ -158,6 +158,13 @@ export class MolHandle {
158
158
  * Number of heavy atoms (explicit atoms in the graph; does not count implicit H).
159
159
  */
160
160
  atom_count(): number;
161
+ /**
162
+ * Index-aligned pseudoatom labels as stable JSON.
163
+ *
164
+ * Real atoms are `null`; wildcard entries are objects with `kind`,
165
+ * `label`, and nullable `r_group_number` fields.
166
+ */
167
+ atom_pseudo_labels_json(): string;
161
168
  /**
162
169
  * Returns true when TPSA < 90 Ų, MW < 400, HBD ≤ 3.
163
170
  */
@@ -466,6 +473,22 @@ export class MolHandle {
466
473
  zagreb_index_m1(): number;
467
474
  }
468
475
 
476
+ /**
477
+ * Immutable RDKit-compatible ECFP4 preprocessing cache.
478
+ *
479
+ * Create it with [`prepare_rdkit_ecfp4`], then call [`bitvec`](Self::bitvec)
480
+ * repeatedly without repeating aromaticity and ring perception.
481
+ */
482
+ export class PreparedRdkitEcfp4Handle {
483
+ private constructor();
484
+ free(): void;
485
+ [Symbol.dispose](): void;
486
+ /**
487
+ * Compute the cached radius-2, 2048-bit fingerprint as 256 packed bytes.
488
+ */
489
+ bitvec(): Uint8Array;
490
+ }
491
+
469
492
  /**
470
493
  * Reusable prepared index for the RDKit-compatible Morgan profile.
471
494
  *
@@ -1331,9 +1354,10 @@ export function inchi_from_smiles(smiles: string): string;
1331
1354
  export function inchikey_from_smiles(smiles: string): string;
1332
1355
 
1333
1356
  /**
1334
- * Invert the stereochemistry of a tetrahedral stereocenter (U/D wedge bonds).
1357
+ * Invert a tetrahedral stereocenter and synchronize incident U/D wedge bonds.
1335
1358
  *
1336
- * If the atom has no wedge/dash bonds, returns an unchanged copy.
1359
+ * Recorded chirality is inverted even without a wedge; when a wedge/hash is
1360
+ * present its depiction marker is inverted too.
1337
1361
  * Returns error if atom_idx is invalid.
1338
1362
  */
1339
1363
  export function invert_stereocenter_at(mol: MolHandle, atom_idx: number): MolHandle;
@@ -1901,6 +1925,11 @@ export function mol_with_atom_charge(mol: MolHandle, idx: number, charge: number
1901
1925
  */
1902
1926
  export function mol_with_atom_element(mol: MolHandle, idx: number, element_symbol: string): MolHandle;
1903
1927
 
1928
+ /**
1929
+ * Return a molecule with atom `idx` changed to `*`, `R`, or `R<n>`.
1930
+ */
1931
+ export function mol_with_atom_pseudo_label(mol: MolHandle, idx: number, label: string): MolHandle;
1932
+
1904
1933
  /**
1905
1934
  * Return a new `MolHandle` with atom `idx` and all its bonds removed.
1906
1935
  *
@@ -2173,6 +2202,15 @@ export function predict_pka_json(smiles: string): string;
2173
2202
  */
2174
2203
  export function preflight_smiles_json(smiles: string, width: number, height: number): string;
2175
2204
 
2205
+ /**
2206
+ * Perform RDKit-compatible aromaticity/ring preprocessing once.
2207
+ *
2208
+ * This is the prepared-molecule counterpart to RDKit's sanitized molecule
2209
+ * object. Preparation errors remain typed JS errors and are never replaced by
2210
+ * a non-compatible fallback fingerprint.
2211
+ */
2212
+ export function prepare_rdkit_ecfp4(mol: MolHandle): PreparedRdkitEcfp4Handle;
2213
+
2176
2214
  /**
2177
2215
  * Coordinates (Å) plus molecular charge/multiplicity from a QCSchema
2178
2216
  * `qcschema_molecule` document, in the SAME atom order
@@ -2963,6 +3001,7 @@ export interface InitOutput {
2963
3001
  readonly __wbg_depictoptions_free: (a: number, b: number) => void;
2964
3002
  readonly __wbg_mhfplshhandle_free: (a: number, b: number) => void;
2965
3003
  readonly __wbg_molhandle_free: (a: number, b: number) => void;
3004
+ readonly __wbg_preparedrdkitecfp4handle_free: (a: number, b: number) => void;
2966
3005
  readonly __wbg_rdkitsearchindex_free: (a: number, b: number) => void;
2967
3006
  readonly __wbg_smilesbatchstreamhandle_free: (a: number, b: number) => void;
2968
3007
  readonly add_hydrogens: (a: number) => number;
@@ -3134,12 +3173,14 @@ export interface InitOutput {
3134
3173
  readonly mol_with_atom_added: (a: number, b: number, c: number) => [number, number, number];
3135
3174
  readonly mol_with_atom_charge: (a: number, b: number, c: number) => [number, number, number];
3136
3175
  readonly mol_with_atom_element: (a: number, b: number, c: number, d: number) => [number, number, number];
3176
+ readonly mol_with_atom_pseudo_label: (a: number, b: number, c: number, d: number) => [number, number, number];
3137
3177
  readonly mol_with_atom_removed: (a: number, b: number) => [number, number, number];
3138
3178
  readonly mol_with_bond_added: (a: number, b: number, c: number, d: number) => [number, number, number];
3139
3179
  readonly mol_with_bond_removed: (a: number, b: number) => [number, number, number];
3140
3180
  readonly molecule_report_json: (a: number, b: number) => [number, number, number, number];
3141
3181
  readonly molhandle_aromatic_ring_count: (a: number) => number;
3142
3182
  readonly molhandle_assign_cip_json: (a: number) => [number, number];
3183
+ readonly molhandle_atom_pseudo_labels_json: (a: number) => [number, number];
3143
3184
  readonly molhandle_bbb_passes: (a: number) => number;
3144
3185
  readonly molhandle_bbb_score: (a: number) => number;
3145
3186
  readonly molhandle_bertz_ct: (a: number) => number;
@@ -3240,6 +3281,8 @@ export interface InitOutput {
3240
3281
  readonly pqr_to_json: (a: number, b: number) => [number, number, number, number];
3241
3282
  readonly predict_pka_json: (a: number, b: number) => [number, number];
3242
3283
  readonly preflight_smiles_json: (a: number, b: number, c: number, d: number) => [number, number];
3284
+ readonly prepare_rdkit_ecfp4: (a: number) => [number, number, number];
3285
+ readonly preparedrdkitecfp4handle_bitvec: (a: number) => [number, number];
3243
3286
  readonly qcschema_molecule_coords_json: (a: number, b: number) => [number, number, number, number];
3244
3287
  readonly qcschema_validate_atomic_input: (a: number, b: number) => [number, number, number, number];
3245
3288
  readonly qcschema_validate_atomic_result: (a: number, b: number) => [number, number, number, number];
package/chematic_wasm.js CHANGED
@@ -404,6 +404,25 @@ export class MolHandle {
404
404
  const ret = wasm.molhandle_atom_count(this.__wbg_ptr);
405
405
  return ret >>> 0;
406
406
  }
407
+ /**
408
+ * Index-aligned pseudoatom labels as stable JSON.
409
+ *
410
+ * Real atoms are `null`; wildcard entries are objects with `kind`,
411
+ * `label`, and nullable `r_group_number` fields.
412
+ * @returns {string}
413
+ */
414
+ atom_pseudo_labels_json() {
415
+ let deferred1_0;
416
+ let deferred1_1;
417
+ try {
418
+ const ret = wasm.molhandle_atom_pseudo_labels_json(this.__wbg_ptr);
419
+ deferred1_0 = ret[0];
420
+ deferred1_1 = ret[1];
421
+ return getStringFromWasm0(ret[0], ret[1]);
422
+ } finally {
423
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
424
+ }
425
+ }
407
426
  /**
408
427
  * Returns true when TPSA < 90 Ų, MW < 400, HBD ≤ 3.
409
428
  * @returns {boolean}
@@ -1089,6 +1108,42 @@ export class MolHandle {
1089
1108
  }
1090
1109
  if (Symbol.dispose) MolHandle.prototype[Symbol.dispose] = MolHandle.prototype.free;
1091
1110
 
1111
+ /**
1112
+ * Immutable RDKit-compatible ECFP4 preprocessing cache.
1113
+ *
1114
+ * Create it with [`prepare_rdkit_ecfp4`], then call [`bitvec`](Self::bitvec)
1115
+ * repeatedly without repeating aromaticity and ring perception.
1116
+ */
1117
+ export class PreparedRdkitEcfp4Handle {
1118
+ static __wrap(ptr) {
1119
+ const obj = Object.create(PreparedRdkitEcfp4Handle.prototype);
1120
+ obj.__wbg_ptr = ptr;
1121
+ PreparedRdkitEcfp4HandleFinalization.register(obj, obj.__wbg_ptr, obj);
1122
+ return obj;
1123
+ }
1124
+ __destroy_into_raw() {
1125
+ const ptr = this.__wbg_ptr;
1126
+ this.__wbg_ptr = 0;
1127
+ PreparedRdkitEcfp4HandleFinalization.unregister(this);
1128
+ return ptr;
1129
+ }
1130
+ free() {
1131
+ const ptr = this.__destroy_into_raw();
1132
+ wasm.__wbg_preparedrdkitecfp4handle_free(ptr, 0);
1133
+ }
1134
+ /**
1135
+ * Compute the cached radius-2, 2048-bit fingerprint as 256 packed bytes.
1136
+ * @returns {Uint8Array}
1137
+ */
1138
+ bitvec() {
1139
+ const ret = wasm.preparedrdkitecfp4handle_bitvec(this.__wbg_ptr);
1140
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1141
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1142
+ return v1;
1143
+ }
1144
+ }
1145
+ if (Symbol.dispose) PreparedRdkitEcfp4Handle.prototype[Symbol.dispose] = PreparedRdkitEcfp4Handle.prototype.free;
1146
+
1092
1147
  /**
1093
1148
  * Reusable prepared index for the RDKit-compatible Morgan profile.
1094
1149
  *
@@ -3392,9 +3447,10 @@ export function inchikey_from_smiles(smiles) {
3392
3447
  }
3393
3448
 
3394
3449
  /**
3395
- * Invert the stereochemistry of a tetrahedral stereocenter (U/D wedge bonds).
3450
+ * Invert a tetrahedral stereocenter and synchronize incident U/D wedge bonds.
3396
3451
  *
3397
- * If the atom has no wedge/dash bonds, returns an unchanged copy.
3452
+ * Recorded chirality is inverted even without a wedge; when a wedge/hash is
3453
+ * present its depiction marker is inverted too.
3398
3454
  * Returns error if atom_idx is invalid.
3399
3455
  * @param {MolHandle} mol
3400
3456
  * @param {number} atom_idx
@@ -4777,6 +4833,24 @@ export function mol_with_atom_element(mol, idx, element_symbol) {
4777
4833
  return MolHandle.__wrap(ret[0]);
4778
4834
  }
4779
4835
 
4836
+ /**
4837
+ * Return a molecule with atom `idx` changed to `*`, `R`, or `R<n>`.
4838
+ * @param {MolHandle} mol
4839
+ * @param {number} idx
4840
+ * @param {string} label
4841
+ * @returns {MolHandle}
4842
+ */
4843
+ export function mol_with_atom_pseudo_label(mol, idx, label) {
4844
+ _assertClass(mol, MolHandle);
4845
+ const ptr0 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4846
+ const len0 = WASM_VECTOR_LEN;
4847
+ const ret = wasm.mol_with_atom_pseudo_label(mol.__wbg_ptr, idx, ptr0, len0);
4848
+ if (ret[2]) {
4849
+ throw takeFromExternrefTable0(ret[1]);
4850
+ }
4851
+ return MolHandle.__wrap(ret[0]);
4852
+ }
4853
+
4780
4854
  /**
4781
4855
  * Return a new `MolHandle` with atom `idx` and all its bonds removed.
4782
4856
  *
@@ -5572,6 +5646,24 @@ export function preflight_smiles_json(smiles, width, height) {
5572
5646
  }
5573
5647
  }
5574
5648
 
5649
+ /**
5650
+ * Perform RDKit-compatible aromaticity/ring preprocessing once.
5651
+ *
5652
+ * This is the prepared-molecule counterpart to RDKit's sanitized molecule
5653
+ * object. Preparation errors remain typed JS errors and are never replaced by
5654
+ * a non-compatible fallback fingerprint.
5655
+ * @param {MolHandle} mol
5656
+ * @returns {PreparedRdkitEcfp4Handle}
5657
+ */
5658
+ export function prepare_rdkit_ecfp4(mol) {
5659
+ _assertClass(mol, MolHandle);
5660
+ const ret = wasm.prepare_rdkit_ecfp4(mol.__wbg_ptr);
5661
+ if (ret[2]) {
5662
+ throw takeFromExternrefTable0(ret[1]);
5663
+ }
5664
+ return PreparedRdkitEcfp4Handle.__wrap(ret[0]);
5665
+ }
5666
+
5575
5667
  /**
5576
5668
  * Coordinates (Å) plus molecular charge/multiplicity from a QCSchema
5577
5669
  * `qcschema_molecule` document, in the SAME atom order
@@ -8021,6 +8113,9 @@ const MhfpLshHandleFinalization = (typeof FinalizationRegistry === 'undefined')
8021
8113
  const MolHandleFinalization = (typeof FinalizationRegistry === 'undefined')
8022
8114
  ? { register: () => {}, unregister: () => {} }
8023
8115
  : new FinalizationRegistry(ptr => wasm.__wbg_molhandle_free(ptr, 1));
8116
+ const PreparedRdkitEcfp4HandleFinalization = (typeof FinalizationRegistry === 'undefined')
8117
+ ? { register: () => {}, unregister: () => {} }
8118
+ : new FinalizationRegistry(ptr => wasm.__wbg_preparedrdkitecfp4handle_free(ptr, 1));
8024
8119
  const RdkitSearchIndexFinalization = (typeof FinalizationRegistry === 'undefined')
8025
8120
  ? { register: () => {}, unregister: () => {} }
8026
8121
  : new FinalizationRegistry(ptr => wasm.__wbg_rdkitsearchindex_free(ptr, 1));
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.0.19",
8
+ "version": "1.0.21",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",