@kent-tokyo/chematic 1.0.10 → 1.0.11

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
@@ -29,6 +29,8 @@ npm install @kent-tokyo/chematic
29
29
  deterministic input indices and partial/complete status; bounded malformed
30
30
  XYZ frames are grouped inline as rejected records when a later count-line
31
31
  boundary is recoverable (core file-backed readers remain fail-stop)
32
+ - Bounded topology parsing for CML, ChemicalJSON (`mol_from_cjson`), MolJSON,
33
+ CDXML, MOL2, and PDB/mmCIF
32
34
  - PDBx/mmCIF, PQR, QCSchema JSON, ORCA input/output, Gaussian Cube, OpenDX,
33
35
  and LAMMPS data/dump I/O (JSON-based bindings; see `format_io.rs`)
34
36
  - Topological descriptors: Wiener index, Hall-Kier κ, χ connectivity indices, Bertz CT
@@ -73,7 +75,7 @@ console.log(mol.qed()); // drug-likeness score [0, 1]
73
75
  console.log(mol.exact_mass()); // ~180.042
74
76
  console.log(mol.hbd_count()); // 1
75
77
  console.log(mol.hba_count()); // 4
76
- console.log(mol.rotatable_bond_count()); // 3
78
+ console.log(mol.rotatable_bond_count()); // 2 (RDKit Lipinski definition)
77
79
  console.log(mol.aromatic_ring_count()); // 1
78
80
  console.log(mol.lipinski_passes()); // true
79
81
  console.log(mol.canonical_smiles()); // canonical SMILES string
@@ -167,7 +169,7 @@ and enforced correctly on all of them.
167
169
 
168
170
  ## Bundle Size
169
171
 
170
- The optimized v1.0.9 candidate artifact was measured at **3.58 MB raw / 1.31 MB gzip**. Bundle size depends on features and toolchain; see [`benchmarks/2026-09-07-wasm-size-v1.0.9.md`](../../benchmarks/2026-09-07-wasm-size-v1.0.9.md) for exact tools, digest, and reproduction steps.
172
+ The optimized v1.0.10 candidate artifact was measured at **3.73 MB raw / 1.36 MB gzip**. Bundle size depends on features and toolchain; see [`benchmarks/2026-09-09-wasm-size-v1.0.10.md`](../../benchmarks/2026-09-09-wasm-size-v1.0.10.md) for exact tools, digest, and reproduction steps.
171
173
 
172
174
  PNG rasterization (`tiny_skia`) is excluded from the WASM build — use SVG output instead. All SVG depiction APIs remain fully available.
173
175
 
@@ -1603,6 +1603,15 @@ export function mol_block_stereo_diagnostics_json(mol_block: string): string;
1603
1603
  */
1604
1604
  export function mol_from_cdxml(cdxml: string): MolHandle;
1605
1605
 
1606
+ /**
1607
+ * Parse a ChemicalJSON (CJSON) string into a `MolHandle`.
1608
+ *
1609
+ * Coordinates and CJSON-specific metadata are intentionally not retained by
1610
+ * this topology handle; use `convert_common_format` when a serialized CJSON
1611
+ * round trip is required.
1612
+ */
1613
+ export function mol_from_cjson(json: string): MolHandle;
1614
+
1606
1615
  /**
1607
1616
  * Parse a CML string into a `MolHandle`.
1608
1617
  *
@@ -1671,6 +1680,21 @@ export function mol_from_orca_input(text: string): MolHandle;
1671
1680
  */
1672
1681
  export function mol_from_pdb(pdb: string): MolHandle;
1673
1682
 
1683
+ /**
1684
+ * Strict PDB parser. Unlike [`mol_from_pdb`], malformed ATOM/HETATM fields
1685
+ * return an error instead of producing a partially recovered molecule.
1686
+ */
1687
+ export function mol_from_pdb_strict(pdb: string): MolHandle;
1688
+
1689
+ /**
1690
+ * Parse an AutoDock PDBQT block into a topology handle.
1691
+ *
1692
+ * Coordinates and partial charges are intentionally discarded, matching the
1693
+ * Python `from_pdbqt` binding; use the Rust parser when those arrays are
1694
+ * needed. Invalid records return a JS error instead of a partial molecule.
1695
+ */
1696
+ export function mol_from_pdbqt(pdbqt: string): MolHandle;
1697
+
1674
1698
  /**
1675
1699
  * Parse a PQR file and return a `MolHandle` (topology only -- element
1676
1700
  * list inferred per-atom, no bonds; PQR carries no connectivity). Use
@@ -2143,6 +2167,16 @@ export function rdkit_rdk_bitvec(mol: MolHandle): Uint8Array;
2143
2167
  */
2144
2168
  export function rdkit_torsion_bitvec(mol: MolHandle): Uint8Array;
2145
2169
 
2170
+ /**
2171
+ * Check whether a reaction SMILES matches a reaction SMARTS query.
2172
+ *
2173
+ * The middle section of the query supports agent alternatives separated by
2174
+ * `|`. This source-level API remains bounded and returns a typed JS error for
2175
+ * invalid input; the generated Node artifact is updated separately when the
2176
+ * wasm-bindgen toolchain is available.
2177
+ */
2178
+ export function reaction_smarts_match(smarts: string, reaction_smiles: string): boolean;
2179
+
2146
2180
  /**
2147
2181
  * Return a copy of the molecule with all explicit hydrogen atoms removed.
2148
2182
  */
@@ -2876,6 +2910,7 @@ export interface InitOutput {
2876
2910
  readonly mol_block_from_smiles: (a: number, b: number) => [number, number, number, number];
2877
2911
  readonly mol_block_stereo_diagnostics_json: (a: number, b: number) => [number, number, number, number];
2878
2912
  readonly mol_from_cdxml: (a: number, b: number) => [number, number, number];
2913
+ readonly mol_from_cjson: (a: number, b: number) => [number, number, number];
2879
2914
  readonly mol_from_cml: (a: number, b: number) => [number, number, number];
2880
2915
  readonly mol_from_cube: (a: number, b: number) => [number, number, number];
2881
2916
  readonly mol_from_extxyz: (a: number, b: number) => [number, number, number];
@@ -2883,6 +2918,8 @@ export interface InitOutput {
2883
2918
  readonly mol_from_moljson: (a: number, b: number) => [number, number, number];
2884
2919
  readonly mol_from_orca_input: (a: number, b: number) => [number, number, number];
2885
2920
  readonly mol_from_pdb: (a: number, b: number) => number;
2921
+ readonly mol_from_pdb_strict: (a: number, b: number) => [number, number, number];
2922
+ readonly mol_from_pdbqt: (a: number, b: number) => [number, number, number];
2886
2923
  readonly mol_from_pqr: (a: number, b: number) => [number, number, number];
2887
2924
  readonly mol_from_qcschema_molecule: (a: number, b: number) => [number, number, number];
2888
2925
  readonly mol_from_sdf_block: (a: number, b: number) => [number, number, number];
@@ -3012,6 +3049,7 @@ export interface InitOutput {
3012
3049
  readonly rdkit_path_bitvec: (a: number) => [number, number];
3013
3050
  readonly rdkit_rdk_bitvec: (a: number) => [number, number];
3014
3051
  readonly rdkit_torsion_bitvec: (a: number) => [number, number];
3052
+ readonly reaction_smarts_match: (a: number, b: number, c: number, d: number) => [number, number, number];
3015
3053
  readonly remove_hydrogens: (a: number) => number;
3016
3054
  readonly retro_disconnect_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3017
3055
  readonly rgroup_decompose_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
package/chematic_wasm.js CHANGED
@@ -3970,6 +3970,25 @@ export function mol_from_cdxml(cdxml) {
3970
3970
  return MolHandle.__wrap(ret[0]);
3971
3971
  }
3972
3972
 
3973
+ /**
3974
+ * Parse a ChemicalJSON (CJSON) string into a `MolHandle`.
3975
+ *
3976
+ * Coordinates and CJSON-specific metadata are intentionally not retained by
3977
+ * this topology handle; use `convert_common_format` when a serialized CJSON
3978
+ * round trip is required.
3979
+ * @param {string} json
3980
+ * @returns {MolHandle}
3981
+ */
3982
+ export function mol_from_cjson(json) {
3983
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3984
+ const len0 = WASM_VECTOR_LEN;
3985
+ const ret = wasm.mol_from_cjson(ptr0, len0);
3986
+ if (ret[2]) {
3987
+ throw takeFromExternrefTable0(ret[1]);
3988
+ }
3989
+ return MolHandle.__wrap(ret[0]);
3990
+ }
3991
+
3973
3992
  /**
3974
3993
  * Parse a CML string into a `MolHandle`.
3975
3994
  *
@@ -4105,6 +4124,41 @@ export function mol_from_pdb(pdb) {
4105
4124
  return MolHandle.__wrap(ret);
4106
4125
  }
4107
4126
 
4127
+ /**
4128
+ * Strict PDB parser. Unlike [`mol_from_pdb`], malformed ATOM/HETATM fields
4129
+ * return an error instead of producing a partially recovered molecule.
4130
+ * @param {string} pdb
4131
+ * @returns {MolHandle}
4132
+ */
4133
+ export function mol_from_pdb_strict(pdb) {
4134
+ const ptr0 = passStringToWasm0(pdb, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4135
+ const len0 = WASM_VECTOR_LEN;
4136
+ const ret = wasm.mol_from_pdb_strict(ptr0, len0);
4137
+ if (ret[2]) {
4138
+ throw takeFromExternrefTable0(ret[1]);
4139
+ }
4140
+ return MolHandle.__wrap(ret[0]);
4141
+ }
4142
+
4143
+ /**
4144
+ * Parse an AutoDock PDBQT block into a topology handle.
4145
+ *
4146
+ * Coordinates and partial charges are intentionally discarded, matching the
4147
+ * Python `from_pdbqt` binding; use the Rust parser when those arrays are
4148
+ * needed. Invalid records return a JS error instead of a partial molecule.
4149
+ * @param {string} pdbqt
4150
+ * @returns {MolHandle}
4151
+ */
4152
+ export function mol_from_pdbqt(pdbqt) {
4153
+ const ptr0 = passStringToWasm0(pdbqt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4154
+ const len0 = WASM_VECTOR_LEN;
4155
+ const ret = wasm.mol_from_pdbqt(ptr0, len0);
4156
+ if (ret[2]) {
4157
+ throw takeFromExternrefTable0(ret[1]);
4158
+ }
4159
+ return MolHandle.__wrap(ret[0]);
4160
+ }
4161
+
4108
4162
  /**
4109
4163
  * Parse a PQR file and return a `MolHandle` (topology only -- element
4110
4164
  * list inferred per-atom, no bonds; PQR carries no connectivity). Use
@@ -5424,6 +5478,29 @@ export function rdkit_torsion_bitvec(mol) {
5424
5478
  return v1;
5425
5479
  }
5426
5480
 
5481
+ /**
5482
+ * Check whether a reaction SMILES matches a reaction SMARTS query.
5483
+ *
5484
+ * The middle section of the query supports agent alternatives separated by
5485
+ * `|`. This source-level API remains bounded and returns a typed JS error for
5486
+ * invalid input; the generated Node artifact is updated separately when the
5487
+ * wasm-bindgen toolchain is available.
5488
+ * @param {string} smarts
5489
+ * @param {string} reaction_smiles
5490
+ * @returns {boolean}
5491
+ */
5492
+ export function reaction_smarts_match(smarts, reaction_smiles) {
5493
+ const ptr0 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5494
+ const len0 = WASM_VECTOR_LEN;
5495
+ const ptr1 = passStringToWasm0(reaction_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5496
+ const len1 = WASM_VECTOR_LEN;
5497
+ const ret = wasm.reaction_smarts_match(ptr0, len0, ptr1, len1);
5498
+ if (ret[2]) {
5499
+ throw takeFromExternrefTable0(ret[1]);
5500
+ }
5501
+ return ret[0] !== 0;
5502
+ }
5503
+
5427
5504
  /**
5428
5505
  * Return a copy of the molecule with all explicit hydrogen atoms removed.
5429
5506
  * @param {MolHandle} mol
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.10",
8
+ "version": "1.0.11",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",