@kent-tokyo/chematic 1.1.1 → 1.1.2

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.1. The binding keeps bounded parsing,
7
+ The current workspace line is 1.1.2. 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
 
@@ -18,7 +18,7 @@ npm install @kent-tokyo/chematic
18
18
 
19
19
  - Parse SMILES strings into molecule handles
20
20
  - Molecular descriptors: MW, TPSA, LogP, Fsp3, QED, exact mass, rotatable bonds, HBD/HBA, aromatic ring count, Labute ASA
21
- - Drug-likeness filters: Lipinski, Veber, Egan, REOS, Ghose
21
+ - Drug-likeness filters: Lipinski, Veber, Egan, REOS, Ghose, PAINS, and Brenk
22
22
  - EState indices (Hall & Kier 1991): per-atom values, sum/max/min
23
23
  - Gasteiger-Marsili PEOE partial charges: per-heavy-atom charges
24
24
  - VSA descriptors: SlogP_VSA (×12), SMR_VSA (×10), PEOE_VSA (×14)
@@ -91,6 +91,7 @@ import init, {
91
91
  smr_vsa_json,
92
92
  peoe_vsa_json,
93
93
  identify_functional_groups,
94
+ brenk_report_json,
94
95
  } from '@kent-tokyo/chematic';
95
96
 
96
97
  await init();
@@ -113,6 +114,10 @@ console.log(mol.aromatic_ring_count()); // 1
113
114
  console.log(mol.lipinski_passes()); // true
114
115
  console.log(mol.canonical_smiles()); // canonical SMILES string
115
116
 
117
+ // Brenk alerts, fully local in the browser/Node runtime
118
+ console.log(JSON.parse(brenk_report_json('Oc1ccccc1')));
119
+ // { passes: false, alerts: ['phenol'] }
120
+
116
121
  // BRICS fragmentation
117
122
  console.log(brics_fragment_count(mol)); // ≥ 2
118
123
 
@@ -182,6 +182,14 @@ export class MolHandle {
182
182
  * Number of bonds.
183
183
  */
184
184
  bond_count(): number;
185
+ /**
186
+ * Returns `true` if the molecule has no Brenk structural alerts.
187
+ *
188
+ * This uses the same conservative core contract as the Rust, Python, and
189
+ * MCP bindings: an alert-search budget exhaustion is not reported as a
190
+ * clean pass.
191
+ */
192
+ brenk_passes(): boolean;
185
193
  /**
186
194
  * Palm (1997) Caco-2 intestinal permeability (logPCaco2).
187
195
  * > −5.5 = high permeability.
@@ -740,6 +748,24 @@ export function batch_report_html(smiles_lines: string): string;
740
748
  */
741
749
  export function boiled_egg_json(smiles: string): string;
742
750
 
751
+ /**
752
+ * Brenk structural-alert identifiers matched by `mol` as a JSON array.
753
+ *
754
+ * Returns `[]` when no alerts fire. Identifiers and ordering are identical to
755
+ * the Rust, Python, and MCP bindings.
756
+ */
757
+ export function brenk_matches_json(mol: MolHandle): string;
758
+
759
+ /**
760
+ * Parse `smiles` and return a complete Brenk report as JSON.
761
+ *
762
+ * The stable result shape is `{"passes":boolean,"alerts":string[]}`.
763
+ * Invalid or oversized SMILES throw the same ordinary JavaScript input error
764
+ * as `parse_smiles`; this function never converts invalid input into a clean
765
+ * report.
766
+ */
767
+ export function brenk_report_json(smiles: string): string;
768
+
743
769
  /**
744
770
  * Number of BRICS fragments produced by fragmenting the molecule.
745
771
  *
@@ -788,6 +814,11 @@ export function canonical_tautomer(mol: MolHandle): MolHandle;
788
814
  */
789
815
  export function canonical_tautomer_with_blocked_atoms_json(mol: MolHandle, blocked_atom_indices_json: string): string;
790
816
 
817
+ /**
818
+ * Return caller coordinates centered and aligned to their principal axes.
819
+ */
820
+ export function canonicalize_conformer_from_coords_json(mol: MolHandle, coords_json: string, center_json: string | null | undefined, normalize_covar: boolean, ignore_hs: boolean): string;
821
+
791
822
  /**
792
823
  * Canonicalize a bounded delimiter-separated SMILES batch.
793
824
  *
@@ -914,6 +945,14 @@ export function compare_molecules_batch_json(smiles_batch: string, delimiter: st
914
945
  */
915
946
  export function compare_molecules_json(smiles1: string, smiles2: string): string;
916
947
 
948
+ /**
949
+ * Compute an RDKit-style principal-axis transform from caller coordinates.
950
+ *
951
+ * Returns a row-major 4x4 JSON matrix. `center_json`, when supplied, must be
952
+ * `[x,y,z]`; otherwise the selected-atom centroid is used.
953
+ */
954
+ export function compute_canonical_transform_from_coords_json(mol: MolHandle, coords_json: string, center_json: string | null | undefined, normalize_covar: boolean, ignore_hs: boolean): string;
955
+
917
956
  /**
918
957
  * Generate multiple conformers with RMSD-based pruning.
919
958
  * Returns JSON: `{"conformers": [[[x,y,z],...], ...], "count": int}`.
@@ -1346,6 +1385,11 @@ export function generic_murcko_scaffold(mol: MolHandle): MolHandle;
1346
1385
  */
1347
1386
  export function get_atom_info(mol: MolHandle, idx: number): string;
1348
1387
 
1388
+ /**
1389
+ * Measure angle i-j-k in degrees from caller-supplied coordinates.
1390
+ */
1391
+ export function get_bond_angle_from_coords_json(mol: MolHandle, coords_json: string, i: number, j: number, k: number): number;
1392
+
1349
1393
  /**
1350
1394
  * Return bond information as a JSON object, looked up by the two bonded atom indices.
1351
1395
  *
@@ -1367,6 +1411,15 @@ export function get_bond_between(mol: MolHandle, atom1: number, atom2: number):
1367
1411
  */
1368
1412
  export function get_bond_info(mol: MolHandle, idx: number): string;
1369
1413
 
1414
+ /**
1415
+ * Measure a bond length from caller-supplied coordinates.
1416
+ *
1417
+ * `coords_json` is `[[x,y,z], ...]` in molecule atom order. Unlike the
1418
+ * legacy SMILES convenience function, this does not generate a new
1419
+ * conformer, so callers can measure an imported or previously edited one.
1420
+ */
1421
+ export function get_bond_length_from_coords_json(mol: MolHandle, coords_json: string, i: number, j: number): number;
1422
+
1370
1423
  /**
1371
1424
  * Get bond length in Ångströms between two atoms from a SMILES string.
1372
1425
  * Returns -1.0 if parsing fails or atom indices are out of range.
@@ -1391,6 +1444,11 @@ export function get_bond_length_json(smiles: string, a: number, b: number): numb
1391
1444
  */
1392
1445
  export function get_descriptors_json(mol: MolHandle): string;
1393
1446
 
1447
+ /**
1448
+ * Measure dihedral i-j-k-l in degrees from caller-supplied coordinates.
1449
+ */
1450
+ export function get_dihedral_from_coords_json(mol: MolHandle, coords_json: string, i: number, j: number, k: number, l: number): number;
1451
+
1394
1452
  /**
1395
1453
  * Get dihedral angle A—B—C—D in degrees from a SMILES string.
1396
1454
  * Returns null (JSON null) if any atom index is out of range or atoms are collinear.
@@ -2780,6 +2838,29 @@ export function semantic_expand_json_with_limits(base_smiles: string, model_json
2780
2838
  */
2781
2839
  export function semantic_model_json(model_json: string): string;
2782
2840
 
2841
+ /**
2842
+ * Set angle i-j-k in degrees and return updated coordinate JSON.
2843
+ *
2844
+ * Atoms i and j stay fixed; atom k and its side of the graph rotate
2845
+ * together. If both angle bonds belong to a ring the operation is rejected.
2846
+ */
2847
+ export function set_bond_angle_from_coords_json(mol: MolHandle, coords_json: string, i: number, j: number, k: number, angle_deg: number): string;
2848
+
2849
+ /**
2850
+ * Set bond length i-j in caller-supplied coordinates and return updated JSON.
2851
+ *
2852
+ * Atom i stays fixed; atom j and its side of the graph move together. Ring
2853
+ * bonds are rejected, following RDKit's `SetBondLength` contract.
2854
+ */
2855
+ export function set_bond_length_from_coords_json(mol: MolHandle, coords_json: string, i: number, j: number, length: number): string;
2856
+
2857
+ /**
2858
+ * Set dihedral i-j-k-l in degrees and return updated coordinate JSON.
2859
+ *
2860
+ * The central j-k bond must exist and must not belong to a ring.
2861
+ */
2862
+ export function set_dihedral_from_coords_json(mol: MolHandle, coords_json: string, i: number, j: number, k: number, l: number, angle_deg: number): string;
2863
+
2783
2864
  /**
2784
2865
  * Set dihedral angle A—B—C—D and return PDB block with modified coordinates.
2785
2866
  * Rotates the D-side subtree around the B—C bond.
@@ -3251,11 +3332,14 @@ export interface InitOutput {
3251
3332
  readonly balance_check_json: (a: number, b: number) => [number, number];
3252
3333
  readonly batch_report_html: (a: number, b: number) => [number, number];
3253
3334
  readonly boiled_egg_json: (a: number, b: number) => [number, number];
3335
+ readonly brenk_matches_json: (a: number) => [number, number];
3336
+ readonly brenk_report_json: (a: number, b: number) => [number, number, number, number];
3254
3337
  readonly brics_fragment_count: (a: number) => number;
3255
3338
  readonly brics_fragments_json: (a: number) => [number, number];
3256
3339
  readonly butina_cluster_ecfp4_json: (a: number, b: number, c: number) => [number, number, number, number];
3257
3340
  readonly canonical_tautomer: (a: number) => number;
3258
3341
  readonly canonical_tautomer_with_blocked_atoms_json: (a: number, b: number, c: number) => [number, number];
3342
+ readonly canonicalize_conformer_from_coords_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
3259
3343
  readonly canonicalize_smiles_batch_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3260
3344
  readonly cdxml_document_from_json_v1: (a: number, b: number) => [number, number, number, number];
3261
3345
  readonly cdxml_document_json: (a: number, b: number) => [number, number, number, number];
@@ -3269,6 +3353,7 @@ export interface InitOutput {
3269
3353
  readonly cip_unresolved_json: (a: number) => [number, number];
3270
3354
  readonly compare_molecules_batch_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3271
3355
  readonly compare_molecules_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3356
+ readonly compute_canonical_transform_from_coords_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
3272
3357
  readonly conformer_ensemble_json: (a: number, b: number, c: number) => [number, number];
3273
3358
  readonly conformerhandle_add_generated_conformer: (a: number) => number;
3274
3359
  readonly conformerhandle_add_minimized_conformer: (a: number) => number;
@@ -3340,10 +3425,13 @@ export interface InitOutput {
3340
3425
  readonly generate_3d_pdb: (a: number) => [number, number];
3341
3426
  readonly generic_murcko_scaffold: (a: number) => number;
3342
3427
  readonly get_atom_info: (a: number, b: number) => [number, number];
3428
+ readonly get_bond_angle_from_coords_json: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
3343
3429
  readonly get_bond_between: (a: number, b: number, c: number) => [number, number];
3344
3430
  readonly get_bond_info: (a: number, b: number) => [number, number];
3431
+ readonly get_bond_length_from_coords_json: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
3345
3432
  readonly get_bond_length_json: (a: number, b: number, c: number, d: number) => number;
3346
3433
  readonly get_descriptors_json: (a: number) => [number, number];
3434
+ readonly get_dihedral_from_coords_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
3347
3435
  readonly get_dihedral_json: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
3348
3436
  readonly get_rdkit_descriptors_json: (a: number) => [number, number];
3349
3437
  readonly getaway_descriptors_json: (a: number) => [number, number];
@@ -3423,11 +3511,13 @@ export interface InitOutput {
3423
3511
  readonly molecule_report_json: (a: number, b: number) => [number, number, number, number];
3424
3512
  readonly molhandle_aromatic_ring_count: (a: number) => number;
3425
3513
  readonly molhandle_assign_cip_json: (a: number) => [number, number];
3514
+ readonly molhandle_atom_count: (a: number) => number;
3426
3515
  readonly molhandle_atom_pseudo_labels_json: (a: number) => [number, number];
3427
3516
  readonly molhandle_bbb_passes: (a: number) => number;
3428
3517
  readonly molhandle_bbb_score: (a: number) => number;
3429
3518
  readonly molhandle_bertz_ct: (a: number) => number;
3430
3519
  readonly molhandle_bond_count: (a: number) => number;
3520
+ readonly molhandle_brenk_passes: (a: number) => number;
3431
3521
  readonly molhandle_caco2_permeability: (a: number) => number;
3432
3522
  readonly molhandle_canonical_smiles: (a: number) => [number, number];
3433
3523
  readonly molhandle_chi0: (a: number) => number;
@@ -3598,6 +3688,9 @@ export interface InitOutput {
3598
3688
  readonly semantic_expand_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3599
3689
  readonly semantic_expand_json_with_limits: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
3600
3690
  readonly semantic_model_json: (a: number, b: number) => [number, number, number, number];
3691
+ readonly set_bond_angle_from_coords_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
3692
+ readonly set_bond_length_from_coords_json: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
3693
+ readonly set_dihedral_from_coords_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
3601
3694
  readonly set_dihedral_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
3602
3695
  readonly shape_descriptors_json: (a: number) => [number, number];
3603
3696
  readonly slogp_vsa_json: (a: number) => [number, number];
@@ -3616,6 +3709,7 @@ export interface InitOutput {
3616
3709
  readonly sssr_rings_json: (a: number) => [number, number];
3617
3710
  readonly standardize_smiles: (a: number, b: number) => [number, number];
3618
3711
  readonly standardize_smiles_report_json: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
3712
+ readonly start: () => void;
3619
3713
  readonly stereo_parent_json: (a: number) => [number, number];
3620
3714
  readonly stoichiometry_report_json: (a: number, b: number) => [number, number];
3621
3715
  readonly super_parent_json: (a: number, b: number, c: number, d: number, e: bigint) => [number, number];
@@ -3662,8 +3756,6 @@ export interface InitOutput {
3662
3756
  readonly xlogp3_json: (a: number) => [number, number];
3663
3757
  readonly xlogp3_per_atom_json: (a: number) => [number, number];
3664
3758
  readonly xyz_frames_batch_json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
3665
- readonly molhandle_atom_count: (a: number) => number;
3666
- readonly start: () => void;
3667
3759
  readonly __wbindgen_malloc: (a: number, b: number) => number;
3668
3760
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
3669
3761
  readonly __externref_table_alloc: () => number;
package/chematic_wasm.js CHANGED
@@ -104,7 +104,7 @@ export class ConformerHandle {
104
104
  const ret = wasm.conformerhandle_get_conformer_pdb(this.__wbg_ptr, idx);
105
105
  let v1;
106
106
  if (ret[0] !== 0) {
107
- v1 = getStringFromWasm0(ret[0], ret[1]).slice();
107
+ v1 = getStringFromWasm0(ret[0], ret[1]);
108
108
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
109
109
  }
110
110
  return v1;
@@ -456,6 +456,18 @@ export class MolHandle {
456
456
  const ret = wasm.molhandle_bond_count(this.__wbg_ptr);
457
457
  return ret >>> 0;
458
458
  }
459
+ /**
460
+ * Returns `true` if the molecule has no Brenk structural alerts.
461
+ *
462
+ * This uses the same conservative core contract as the Rust, Python, and
463
+ * MCP bindings: an alert-search budget exhaustion is not reported as a
464
+ * clean pass.
465
+ * @returns {boolean}
466
+ */
467
+ brenk_passes() {
468
+ const ret = wasm.molhandle_brenk_passes(this.__wbg_ptr);
469
+ return ret !== 0;
470
+ }
459
471
  /**
460
472
  * Palm (1997) Caco-2 intestinal permeability (logPCaco2).
461
473
  * > −5.5 = high permeability.
@@ -2039,6 +2051,59 @@ export function boiled_egg_json(smiles) {
2039
2051
  }
2040
2052
  }
2041
2053
 
2054
+ /**
2055
+ * Brenk structural-alert identifiers matched by `mol` as a JSON array.
2056
+ *
2057
+ * Returns `[]` when no alerts fire. Identifiers and ordering are identical to
2058
+ * the Rust, Python, and MCP bindings.
2059
+ * @param {MolHandle} mol
2060
+ * @returns {string}
2061
+ */
2062
+ export function brenk_matches_json(mol) {
2063
+ let deferred1_0;
2064
+ let deferred1_1;
2065
+ try {
2066
+ _assertClass(mol, MolHandle);
2067
+ const ret = wasm.brenk_matches_json(mol.__wbg_ptr);
2068
+ deferred1_0 = ret[0];
2069
+ deferred1_1 = ret[1];
2070
+ return getStringFromWasm0(ret[0], ret[1]);
2071
+ } finally {
2072
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2073
+ }
2074
+ }
2075
+
2076
+ /**
2077
+ * Parse `smiles` and return a complete Brenk report as JSON.
2078
+ *
2079
+ * The stable result shape is `{"passes":boolean,"alerts":string[]}`.
2080
+ * Invalid or oversized SMILES throw the same ordinary JavaScript input error
2081
+ * as `parse_smiles`; this function never converts invalid input into a clean
2082
+ * report.
2083
+ * @param {string} smiles
2084
+ * @returns {string}
2085
+ */
2086
+ export function brenk_report_json(smiles) {
2087
+ let deferred3_0;
2088
+ let deferred3_1;
2089
+ try {
2090
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2091
+ const len0 = WASM_VECTOR_LEN;
2092
+ const ret = wasm.brenk_report_json(ptr0, len0);
2093
+ var ptr2 = ret[0];
2094
+ var len2 = ret[1];
2095
+ if (ret[3]) {
2096
+ ptr2 = 0; len2 = 0;
2097
+ throw takeFromExternrefTable0(ret[2]);
2098
+ }
2099
+ deferred3_0 = ptr2;
2100
+ deferred3_1 = len2;
2101
+ return getStringFromWasm0(ptr2, len2);
2102
+ } finally {
2103
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2104
+ }
2105
+ }
2106
+
2042
2107
  /**
2043
2108
  * Number of BRICS fragments produced by fragmenting the molecule.
2044
2109
  *
@@ -2152,6 +2217,39 @@ export function canonical_tautomer_with_blocked_atoms_json(mol, blocked_atom_ind
2152
2217
  }
2153
2218
  }
2154
2219
 
2220
+ /**
2221
+ * Return caller coordinates centered and aligned to their principal axes.
2222
+ * @param {MolHandle} mol
2223
+ * @param {string} coords_json
2224
+ * @param {string | null | undefined} center_json
2225
+ * @param {boolean} normalize_covar
2226
+ * @param {boolean} ignore_hs
2227
+ * @returns {string}
2228
+ */
2229
+ export function canonicalize_conformer_from_coords_json(mol, coords_json, center_json, normalize_covar, ignore_hs) {
2230
+ let deferred4_0;
2231
+ let deferred4_1;
2232
+ try {
2233
+ _assertClass(mol, MolHandle);
2234
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2235
+ const len0 = WASM_VECTOR_LEN;
2236
+ var ptr1 = isLikeNone(center_json) ? 0 : passStringToWasm0(center_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2237
+ var len1 = WASM_VECTOR_LEN;
2238
+ const ret = wasm.canonicalize_conformer_from_coords_json(mol.__wbg_ptr, ptr0, len0, ptr1, len1, normalize_covar, ignore_hs);
2239
+ var ptr3 = ret[0];
2240
+ var len3 = ret[1];
2241
+ if (ret[3]) {
2242
+ ptr3 = 0; len3 = 0;
2243
+ throw takeFromExternrefTable0(ret[2]);
2244
+ }
2245
+ deferred4_0 = ptr3;
2246
+ deferred4_1 = len3;
2247
+ return getStringFromWasm0(ptr3, len3);
2248
+ } finally {
2249
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2250
+ }
2251
+ }
2252
+
2155
2253
  /**
2156
2254
  * Canonicalize a bounded delimiter-separated SMILES batch.
2157
2255
  *
@@ -2523,6 +2621,42 @@ export function compare_molecules_json(smiles1, smiles2) {
2523
2621
  }
2524
2622
  }
2525
2623
 
2624
+ /**
2625
+ * Compute an RDKit-style principal-axis transform from caller coordinates.
2626
+ *
2627
+ * Returns a row-major 4x4 JSON matrix. `center_json`, when supplied, must be
2628
+ * `[x,y,z]`; otherwise the selected-atom centroid is used.
2629
+ * @param {MolHandle} mol
2630
+ * @param {string} coords_json
2631
+ * @param {string | null | undefined} center_json
2632
+ * @param {boolean} normalize_covar
2633
+ * @param {boolean} ignore_hs
2634
+ * @returns {string}
2635
+ */
2636
+ export function compute_canonical_transform_from_coords_json(mol, coords_json, center_json, normalize_covar, ignore_hs) {
2637
+ let deferred4_0;
2638
+ let deferred4_1;
2639
+ try {
2640
+ _assertClass(mol, MolHandle);
2641
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2642
+ const len0 = WASM_VECTOR_LEN;
2643
+ var ptr1 = isLikeNone(center_json) ? 0 : passStringToWasm0(center_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2644
+ var len1 = WASM_VECTOR_LEN;
2645
+ const ret = wasm.compute_canonical_transform_from_coords_json(mol.__wbg_ptr, ptr0, len0, ptr1, len1, normalize_covar, ignore_hs);
2646
+ var ptr3 = ret[0];
2647
+ var len3 = ret[1];
2648
+ if (ret[3]) {
2649
+ ptr3 = 0; len3 = 0;
2650
+ throw takeFromExternrefTable0(ret[2]);
2651
+ }
2652
+ deferred4_0 = ptr3;
2653
+ deferred4_1 = len3;
2654
+ return getStringFromWasm0(ptr3, len3);
2655
+ } finally {
2656
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2657
+ }
2658
+ }
2659
+
2526
2660
  /**
2527
2661
  * Generate multiple conformers with RMSD-based pruning.
2528
2662
  * Returns JSON: `{"conformers": [[[x,y,z],...], ...], "count": int}`.
@@ -3699,6 +3833,26 @@ export function get_atom_info(mol, idx) {
3699
3833
  }
3700
3834
  }
3701
3835
 
3836
+ /**
3837
+ * Measure angle i-j-k in degrees from caller-supplied coordinates.
3838
+ * @param {MolHandle} mol
3839
+ * @param {string} coords_json
3840
+ * @param {number} i
3841
+ * @param {number} j
3842
+ * @param {number} k
3843
+ * @returns {number}
3844
+ */
3845
+ export function get_bond_angle_from_coords_json(mol, coords_json, i, j, k) {
3846
+ _assertClass(mol, MolHandle);
3847
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3848
+ const len0 = WASM_VECTOR_LEN;
3849
+ const ret = wasm.get_bond_angle_from_coords_json(mol.__wbg_ptr, ptr0, len0, i, j, k);
3850
+ if (ret[2]) {
3851
+ throw takeFromExternrefTable0(ret[1]);
3852
+ }
3853
+ return ret[0];
3854
+ }
3855
+
3702
3856
  /**
3703
3857
  * Return bond information as a JSON object, looked up by the two bonded atom indices.
3704
3858
  *
@@ -3751,6 +3905,29 @@ export function get_bond_info(mol, idx) {
3751
3905
  }
3752
3906
  }
3753
3907
 
3908
+ /**
3909
+ * Measure a bond length from caller-supplied coordinates.
3910
+ *
3911
+ * `coords_json` is `[[x,y,z], ...]` in molecule atom order. Unlike the
3912
+ * legacy SMILES convenience function, this does not generate a new
3913
+ * conformer, so callers can measure an imported or previously edited one.
3914
+ * @param {MolHandle} mol
3915
+ * @param {string} coords_json
3916
+ * @param {number} i
3917
+ * @param {number} j
3918
+ * @returns {number}
3919
+ */
3920
+ export function get_bond_length_from_coords_json(mol, coords_json, i, j) {
3921
+ _assertClass(mol, MolHandle);
3922
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3923
+ const len0 = WASM_VECTOR_LEN;
3924
+ const ret = wasm.get_bond_length_from_coords_json(mol.__wbg_ptr, ptr0, len0, i, j);
3925
+ if (ret[2]) {
3926
+ throw takeFromExternrefTable0(ret[1]);
3927
+ }
3928
+ return ret[0];
3929
+ }
3930
+
3754
3931
  /**
3755
3932
  * Get bond length in Ångströms between two atoms from a SMILES string.
3756
3933
  * Returns -1.0 if parsing fails or atom indices are out of range.
@@ -3798,6 +3975,27 @@ export function get_descriptors_json(mol) {
3798
3975
  }
3799
3976
  }
3800
3977
 
3978
+ /**
3979
+ * Measure dihedral i-j-k-l in degrees from caller-supplied coordinates.
3980
+ * @param {MolHandle} mol
3981
+ * @param {string} coords_json
3982
+ * @param {number} i
3983
+ * @param {number} j
3984
+ * @param {number} k
3985
+ * @param {number} l
3986
+ * @returns {number}
3987
+ */
3988
+ export function get_dihedral_from_coords_json(mol, coords_json, i, j, k, l) {
3989
+ _assertClass(mol, MolHandle);
3990
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3991
+ const len0 = WASM_VECTOR_LEN;
3992
+ const ret = wasm.get_dihedral_from_coords_json(mol.__wbg_ptr, ptr0, len0, i, j, k, l);
3993
+ if (ret[2]) {
3994
+ throw takeFromExternrefTable0(ret[1]);
3995
+ }
3996
+ return ret[0];
3997
+ }
3998
+
3801
3999
  /**
3802
4000
  * Get dihedral angle A—B—C—D in degrees from a SMILES string.
3803
4001
  * Returns null (JSON null) if any atom index is out of range or atoms are collinear.
@@ -6255,7 +6453,7 @@ export function pqr_infer_element(group_pdb, res_name, atom_name) {
6255
6453
  const ret = wasm.pqr_infer_element(ptr0, len0, ptr1, len1, ptr2, len2);
6256
6454
  let v4;
6257
6455
  if (ret[0] !== 0) {
6258
- v4 = getStringFromWasm0(ret[0], ret[1]).slice();
6456
+ v4 = getStringFromWasm0(ret[0], ret[1]);
6259
6457
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
6260
6458
  }
6261
6459
  return v4;
@@ -7535,6 +7733,110 @@ export function semantic_model_json(model_json) {
7535
7733
  }
7536
7734
  }
7537
7735
 
7736
+ /**
7737
+ * Set angle i-j-k in degrees and return updated coordinate JSON.
7738
+ *
7739
+ * Atoms i and j stay fixed; atom k and its side of the graph rotate
7740
+ * together. If both angle bonds belong to a ring the operation is rejected.
7741
+ * @param {MolHandle} mol
7742
+ * @param {string} coords_json
7743
+ * @param {number} i
7744
+ * @param {number} j
7745
+ * @param {number} k
7746
+ * @param {number} angle_deg
7747
+ * @returns {string}
7748
+ */
7749
+ export function set_bond_angle_from_coords_json(mol, coords_json, i, j, k, angle_deg) {
7750
+ let deferred3_0;
7751
+ let deferred3_1;
7752
+ try {
7753
+ _assertClass(mol, MolHandle);
7754
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
7755
+ const len0 = WASM_VECTOR_LEN;
7756
+ const ret = wasm.set_bond_angle_from_coords_json(mol.__wbg_ptr, ptr0, len0, i, j, k, angle_deg);
7757
+ var ptr2 = ret[0];
7758
+ var len2 = ret[1];
7759
+ if (ret[3]) {
7760
+ ptr2 = 0; len2 = 0;
7761
+ throw takeFromExternrefTable0(ret[2]);
7762
+ }
7763
+ deferred3_0 = ptr2;
7764
+ deferred3_1 = len2;
7765
+ return getStringFromWasm0(ptr2, len2);
7766
+ } finally {
7767
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
7768
+ }
7769
+ }
7770
+
7771
+ /**
7772
+ * Set bond length i-j in caller-supplied coordinates and return updated JSON.
7773
+ *
7774
+ * Atom i stays fixed; atom j and its side of the graph move together. Ring
7775
+ * bonds are rejected, following RDKit's `SetBondLength` contract.
7776
+ * @param {MolHandle} mol
7777
+ * @param {string} coords_json
7778
+ * @param {number} i
7779
+ * @param {number} j
7780
+ * @param {number} length
7781
+ * @returns {string}
7782
+ */
7783
+ export function set_bond_length_from_coords_json(mol, coords_json, i, j, length) {
7784
+ let deferred3_0;
7785
+ let deferred3_1;
7786
+ try {
7787
+ _assertClass(mol, MolHandle);
7788
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
7789
+ const len0 = WASM_VECTOR_LEN;
7790
+ const ret = wasm.set_bond_length_from_coords_json(mol.__wbg_ptr, ptr0, len0, i, j, length);
7791
+ var ptr2 = ret[0];
7792
+ var len2 = ret[1];
7793
+ if (ret[3]) {
7794
+ ptr2 = 0; len2 = 0;
7795
+ throw takeFromExternrefTable0(ret[2]);
7796
+ }
7797
+ deferred3_0 = ptr2;
7798
+ deferred3_1 = len2;
7799
+ return getStringFromWasm0(ptr2, len2);
7800
+ } finally {
7801
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
7802
+ }
7803
+ }
7804
+
7805
+ /**
7806
+ * Set dihedral i-j-k-l in degrees and return updated coordinate JSON.
7807
+ *
7808
+ * The central j-k bond must exist and must not belong to a ring.
7809
+ * @param {MolHandle} mol
7810
+ * @param {string} coords_json
7811
+ * @param {number} i
7812
+ * @param {number} j
7813
+ * @param {number} k
7814
+ * @param {number} l
7815
+ * @param {number} angle_deg
7816
+ * @returns {string}
7817
+ */
7818
+ export function set_dihedral_from_coords_json(mol, coords_json, i, j, k, l, angle_deg) {
7819
+ let deferred3_0;
7820
+ let deferred3_1;
7821
+ try {
7822
+ _assertClass(mol, MolHandle);
7823
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
7824
+ const len0 = WASM_VECTOR_LEN;
7825
+ const ret = wasm.set_dihedral_from_coords_json(mol.__wbg_ptr, ptr0, len0, i, j, k, l, angle_deg);
7826
+ var ptr2 = ret[0];
7827
+ var len2 = ret[1];
7828
+ if (ret[3]) {
7829
+ ptr2 = 0; len2 = 0;
7830
+ throw takeFromExternrefTable0(ret[2]);
7831
+ }
7832
+ deferred3_0 = ptr2;
7833
+ deferred3_1 = len2;
7834
+ return getStringFromWasm0(ptr2, len2);
7835
+ } finally {
7836
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
7837
+ }
7838
+ }
7839
+
7538
7840
  /**
7539
7841
  * Set dihedral angle A—B—C—D and return PDB block with modified coordinates.
7540
7842
  * Rotates the D-side subtree around the B—C bond.
@@ -8959,11 +9261,11 @@ export function xyz_frames_batch_json(text, offset, batch_size) {
8959
9261
  function __wbg_get_imports() {
8960
9262
  const import0 = {
8961
9263
  __proto__: null,
8962
- __wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {
9264
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
8963
9265
  const ret = arg0 === undefined;
8964
9266
  return ret;
8965
9267
  },
8966
- __wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
9268
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
8967
9269
  const obj = arg1;
8968
9270
  const ret = typeof(obj) === 'string' ? obj : undefined;
8969
9271
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -8971,18 +9273,18 @@ function __wbg_get_imports() {
8971
9273
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
8972
9274
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
8973
9275
  },
8974
- __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
9276
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
8975
9277
  throw new Error(getStringFromWasm0(arg0, arg1));
8976
9278
  },
8977
- __wbg_error_f085d7e62279b703: function(arg0) {
9279
+ __wbg_error_c9cf3fc2064683a9: function(arg0) {
8978
9280
  console.error(arg0);
8979
9281
  },
8980
- __wbg_new_from_slice_02962bf7778cf945: function(arg0, arg1) {
8981
- const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
9282
+ __wbg_new_from_slice_37a3c3a194266cb8: function(arg0, arg1) {
9283
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
8982
9284
  return ret;
8983
9285
  },
8984
- __wbg_new_from_slice_f92bf65e9a895613: function(arg0, arg1) {
8985
- const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
9286
+ __wbg_new_from_slice_f545fd22ddc142b8: function(arg0, arg1) {
9287
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
8986
9288
  return ret;
8987
9289
  },
8988
9290
  __wbg_now_e7c6795a7f81e10f: function(arg0) {
@@ -8993,28 +9295,28 @@ function __wbg_get_imports() {
8993
9295
  const ret = arg0.performance;
8994
9296
  return ret;
8995
9297
  },
8996
- __wbg_static_accessor_GLOBAL_THIS_02344c9b09eb08a9: function() {
8997
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
9298
+ __wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
9299
+ const ret = typeof global === 'undefined' ? null : global;
8998
9300
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
8999
9301
  },
9000
- __wbg_static_accessor_GLOBAL_ac6d4ac874d5cd54: function() {
9001
- const ret = typeof global === 'undefined' ? null : global;
9302
+ __wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
9303
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
9002
9304
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
9003
9305
  },
9004
- __wbg_static_accessor_SELF_9b2406c23aeb2023: function() {
9306
+ __wbg_static_accessor_SELF_0b583911f537483a: function() {
9005
9307
  const ret = typeof self === 'undefined' ? null : self;
9006
9308
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
9007
9309
  },
9008
- __wbg_static_accessor_WINDOW_b34d2126934e16ba: function() {
9310
+ __wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
9009
9311
  const ret = typeof window === 'undefined' ? null : window;
9010
9312
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
9011
9313
  },
9012
- __wbindgen_cast_0000000000000001: function(arg0) {
9314
+ __wbindgen_generic_0000000000000001: function(arg0) {
9013
9315
  // Cast intrinsic for `F64 -> Externref`.
9014
9316
  const ret = arg0;
9015
9317
  return ret;
9016
9318
  },
9017
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
9319
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
9018
9320
  // Cast intrinsic for `Ref(String) -> Externref`.
9019
9321
  const ret = getStringFromWasm0(arg0, arg1);
9020
9322
  return ret;
@@ -9221,11 +9523,15 @@ function __wbg_finalize_init(instance, module) {
9221
9523
 
9222
9524
  async function __wbg_load(module, imports) {
9223
9525
  if (typeof Response === 'function' && module instanceof Response) {
9526
+ if (!module.ok) {
9527
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
9528
+ }
9529
+
9224
9530
  if (typeof WebAssembly.instantiateStreaming === 'function') {
9225
9531
  try {
9226
9532
  return await WebAssembly.instantiateStreaming(module, imports);
9227
9533
  } catch (e) {
9228
- const validResponse = module.ok && expectedResponseType(module.type);
9534
+ const validResponse = expectedResponseType(module.type);
9229
9535
 
9230
9536
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
9231
9537
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
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.1",
8
+ "version": "1.1.2",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",