@kent-tokyo/chematic 0.2.0 → 0.2.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/chematic_wasm.js CHANGED
@@ -1,9 +1,4792 @@
1
1
  /* @ts-self-types="./chematic_wasm.d.ts" */
2
- import * as wasm from "./chematic_wasm_bg.wasm";
3
- import { __wbg_set_wasm } from "./chematic_wasm_bg.js";
4
-
5
- __wbg_set_wasm(wasm);
6
- wasm.__wbindgen_start();
7
- export {
8
- ConformerHandle, DepictOptions, MhfpLshHandle, MolHandle, add_hydrogens, atom_pair_bitvec, autocorr_2d_json, autocorr_3d_json, balance_check_json, brics_fragment_count, brics_fragments_json, butina_cluster_ecfp4_json, canonical_tautomer, cdxml_to_smiles_json, cip_assignments_json, compare_molecules_batch_json, compare_molecules_json, coulomb_energy_json, cpk_color, depict_data_json, depict_data_with_coords_json, depict_reaction_svg, depict_svg_grid, depict_svg_grid_highlighted, detect_functional_groups, dice_ecfp4, dice_ecfp6, dice_maccs, ecfp4_bitvec, ecfp4_bitvec_with_chirality, ecfp6_bitvec, ecfp6_bitvec_with_chirality, ecfp_bitvec_custom, enumerate_library_2way, enumerate_stereo_isomers_json, enumerate_tautomers_json, estate_indices_json, fcfp4_bitvec, fcfp6_bitvec, find_reaction_center_json, gasteiger_charges_json, generate_3d_etkdg_minimized_pdb, generate_3d_etkdg_pdb, generate_3d_from_smiles, generate_3d_minimized_pdb, generate_3d_optimized_pdb, generate_3d_pdb, generic_murcko_scaffold, get_atom_info, get_bond_between, get_bond_info, get_bond_length_json, get_descriptors_json, get_dihedral_json, getaway_descriptors_json, identify_functional_groups, inchi_from_smiles, inchikey_from_smiles, invert_stereocenter_at, is_valid_smiles, labute_asa_per_atom_json, largest_fragment, logp_per_atom_json, maccs_bitvec, match_smarts_smiles, maxmin_picks_ecfp4_json, mcs_smiles_json, mhfp_hashes_json, minimize_dreiding_json, mmff94_charges_json, mmp_pairs_json, mol2_to_smiles, mol_block_coords_json, mol_block_from_smiles, mol_from_cdxml, mol_from_cml, mol_from_pdb, mol_from_sdf_block, mol_from_v3000_block, mol_from_xyz, mol_next_atom_idx, mol_with_atom_added, mol_with_atom_charge, mol_with_atom_element, mol_with_atom_removed, mol_with_bond_added, mol_with_bond_removed, molecule_report_json, mqn_json, mr_per_atom_json, murcko_scaffold, nearest_neighbors_json, neutralize_charges, normalize_cxsmiles, normalize_reaction_smiles, pains_matches_json, parse_cxsmarts_json, parse_cxsmiles_json, parse_smiles, peoe_vsa_json, pharmacophore_features_json, pharmacophore_fp_2d_summary, pharmacophore_fp_3d_summary, random_smiles_json, remove_hydrogens, rgroup_decompose_json, ring_families_json, run_md_json, run_reactants, sa_score, screen_smiles_json, sdf_from_records_json, sdf_to_records_json, sdf_to_smiles_json, set_dihedral_json, shape_descriptors_json, slogp_vsa_json, smarts_match_atoms, smarts_match_atoms_with_chirality, smiles_array_to_sdf, smiles_to_mol2, smiles_to_svg_highlighted, smr_vsa_json, sssr_rings_json, standardize_smiles, standardize_smiles_report_json, start, tanimoto_atom_pair, tanimoto_ecfp4, tanimoto_ecfp6, tanimoto_fcfp4, tanimoto_fcfp6, tanimoto_maccs, tanimoto_mhfp_smiles, tanimoto_smiles, tanimoto_topo_path, tanimoto_torsion, to_cml, to_mol_block, to_mol_v3000_block, to_xyz, torsion_bitvec, whim_descriptors_json, whim_getaway_combined_json, write_smiles
9
- } from "./chematic_wasm_bg.js";
2
+
3
+ /**
4
+ * A conformer ensemble: one molecule geometry with multiple 3D coordinate sets.
5
+ *
6
+ * Create with `new(smiles)`, then add conformers with `add_generated_conformer`
7
+ * or `add_minimized_conformer`. Retrieve coordinates as PDB strings via
8
+ * `get_conformer_pdb(idx)`. Compare conformers with `conformer_rmsd`.
9
+ */
10
+ export class ConformerHandle {
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ ConformerHandleFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_conformerhandle_free(ptr, 0);
20
+ }
21
+ /**
22
+ * Generate a new 3D conformer using distance-geometry and add it to the ensemble.
23
+ *
24
+ * Returns the index of the newly added conformer.
25
+ * @returns {number}
26
+ */
27
+ add_generated_conformer() {
28
+ const ret = wasm.conformerhandle_add_generated_conformer(this.__wbg_ptr);
29
+ return ret >>> 0;
30
+ }
31
+ /**
32
+ * Generate a new 3D conformer, run force-field minimization, and add it.
33
+ *
34
+ * Returns the index of the newly added conformer.
35
+ * @returns {number}
36
+ */
37
+ add_minimized_conformer() {
38
+ const ret = wasm.conformerhandle_add_minimized_conformer(this.__wbg_ptr);
39
+ return ret >>> 0;
40
+ }
41
+ /**
42
+ * Cluster conformers by Kabsch-aligned RMSD and return a JSON object
43
+ * describing which conformers to keep.
44
+ *
45
+ * Uses greedy leader-linkage: conformers are visited in index order; each
46
+ * is compared against existing cluster representatives. If the RMSD to any
47
+ * representative is < `rms_threshold`, the conformer is discarded; otherwise
48
+ * it starts a new cluster and is kept.
49
+ *
50
+ * Returns `{"kept_indices":[0,3,7,...],"removed_count":5}` on success.
51
+ * @param {number} rms_threshold
52
+ * @returns {string}
53
+ */
54
+ cluster_conformers_json(rms_threshold) {
55
+ let deferred1_0;
56
+ let deferred1_1;
57
+ try {
58
+ const ret = wasm.conformerhandle_cluster_conformers_json(this.__wbg_ptr, rms_threshold);
59
+ deferred1_0 = ret[0];
60
+ deferred1_1 = ret[1];
61
+ return getStringFromWasm0(ret[0], ret[1]);
62
+ } finally {
63
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
64
+ }
65
+ }
66
+ /**
67
+ * Number of conformers currently stored.
68
+ * @returns {number}
69
+ */
70
+ conformer_count() {
71
+ const ret = wasm.conformerhandle_conformer_count(this.__wbg_ptr);
72
+ return ret >>> 0;
73
+ }
74
+ /**
75
+ * Kabsch-aligned RMSD (Å) between conformers `a` and `b`.
76
+ *
77
+ * Returns `NaN` if either index is out of range.
78
+ * @param {number} a
79
+ * @param {number} b
80
+ * @returns {number}
81
+ */
82
+ conformer_rmsd(a, b) {
83
+ const ret = wasm.conformerhandle_conformer_rmsd(this.__wbg_ptr, a, b);
84
+ return ret;
85
+ }
86
+ /**
87
+ * Un-aligned (translation + rotation NOT removed) RMSD (Å) between conformers `a` and `b`.
88
+ *
89
+ * Returns `NaN` if either index is out of range.
90
+ * @param {number} a
91
+ * @param {number} b
92
+ * @returns {number}
93
+ */
94
+ conformer_rmsd_no_align(a, b) {
95
+ const ret = wasm.conformerhandle_conformer_rmsd_no_align(this.__wbg_ptr, a, b);
96
+ return ret;
97
+ }
98
+ /**
99
+ * Return conformer `idx` as a PDB string, or `null` if `idx` is out of range.
100
+ * @param {number} idx
101
+ * @returns {string | undefined}
102
+ */
103
+ get_conformer_pdb(idx) {
104
+ const ret = wasm.conformerhandle_get_conformer_pdb(this.__wbg_ptr, idx);
105
+ let v1;
106
+ if (ret[0] !== 0) {
107
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
108
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
109
+ }
110
+ return v1;
111
+ }
112
+ /**
113
+ * The ensemble's molecule as a `MolHandle`.
114
+ * @returns {MolHandle}
115
+ */
116
+ mol() {
117
+ const ret = wasm.conformerhandle_mol(this.__wbg_ptr);
118
+ return MolHandle.__wrap(ret);
119
+ }
120
+ /**
121
+ * Create a new empty ensemble for the molecule given by `smiles`.
122
+ *
123
+ * Returns a JS error on SMILES parse failure.
124
+ * @param {string} smiles
125
+ */
126
+ constructor(smiles) {
127
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
128
+ const len0 = WASM_VECTOR_LEN;
129
+ const ret = wasm.conformerhandle_new(ptr0, len0);
130
+ if (ret[2]) {
131
+ throw takeFromExternrefTable0(ret[1]);
132
+ }
133
+ this.__wbg_ptr = ret[0];
134
+ ConformerHandleFinalization.register(this, this.__wbg_ptr, this);
135
+ return this;
136
+ }
137
+ /**
138
+ * Remove conformer `idx` and return `true`, or `false` if `idx` is out of range.
139
+ * @param {number} idx
140
+ * @returns {boolean}
141
+ */
142
+ remove_conformer(idx) {
143
+ const ret = wasm.conformerhandle_remove_conformer(this.__wbg_ptr, idx);
144
+ return ret !== 0;
145
+ }
146
+ }
147
+ if (Symbol.dispose) ConformerHandle.prototype[Symbol.dispose] = ConformerHandle.prototype.free;
148
+
149
+ /**
150
+ * Style options for [`MolHandle::depict_svg_opts`].
151
+ *
152
+ * Construct with `new DepictOptions()`, then call setters:
153
+ * ```js
154
+ * const opts = new DepictOptions();
155
+ * opts.set_background("transparent");
156
+ * opts.set_dark(true);
157
+ * opts.set_width(240);
158
+ * opts.set_height(240);
159
+ * ```
160
+ */
161
+ export class DepictOptions {
162
+ __destroy_into_raw() {
163
+ const ptr = this.__wbg_ptr;
164
+ this.__wbg_ptr = 0;
165
+ DepictOptionsFinalization.unregister(this);
166
+ return ptr;
167
+ }
168
+ free() {
169
+ const ptr = this.__destroy_into_raw();
170
+ wasm.__wbg_depictoptions_free(ptr, 0);
171
+ }
172
+ constructor() {
173
+ const ret = wasm.depictoptions_new();
174
+ this.__wbg_ptr = ret;
175
+ DepictOptionsFinalization.register(this, this.__wbg_ptr, this);
176
+ return this;
177
+ }
178
+ /**
179
+ * Set a per-atom color override (CSS color string). Calling multiple times
180
+ * for the same `idx` uses the last value. The atom is highlighted even if
181
+ * not in `set_highlight_atoms`.
182
+ * @param {number} idx
183
+ * @param {string} color
184
+ */
185
+ set_atom_color(idx, color) {
186
+ const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
187
+ const len0 = WASM_VECTOR_LEN;
188
+ wasm.depictoptions_set_atom_color(this.__wbg_ptr, idx, ptr0, len0);
189
+ }
190
+ /**
191
+ * @param {boolean} v
192
+ */
193
+ set_atom_ids(v) {
194
+ wasm.depictoptions_set_atom_ids(this.__wbg_ptr, v);
195
+ }
196
+ /**
197
+ * @param {string} bg
198
+ */
199
+ set_background(bg) {
200
+ const ptr0 = passStringToWasm0(bg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
201
+ const len0 = WASM_VECTOR_LEN;
202
+ wasm.depictoptions_set_background(this.__wbg_ptr, ptr0, len0);
203
+ }
204
+ /**
205
+ * @param {boolean} dark
206
+ */
207
+ set_dark(dark) {
208
+ wasm.depictoptions_set_dark(this.__wbg_ptr, dark);
209
+ }
210
+ /**
211
+ * @param {number} h
212
+ */
213
+ set_height(h) {
214
+ wasm.depictoptions_set_height(this.__wbg_ptr, h);
215
+ }
216
+ /**
217
+ * @param {Uint32Array} atoms
218
+ */
219
+ set_highlight_atoms(atoms) {
220
+ const ptr0 = passArray32ToWasm0(atoms, wasm.__wbindgen_malloc);
221
+ const len0 = WASM_VECTOR_LEN;
222
+ wasm.depictoptions_set_highlight_atoms(this.__wbg_ptr, ptr0, len0);
223
+ }
224
+ /**
225
+ * @param {Uint32Array} bonds
226
+ */
227
+ set_highlight_bonds(bonds) {
228
+ const ptr0 = passArray32ToWasm0(bonds, wasm.__wbindgen_malloc);
229
+ const len0 = WASM_VECTOR_LEN;
230
+ wasm.depictoptions_set_highlight_bonds(this.__wbg_ptr, ptr0, len0);
231
+ }
232
+ /**
233
+ * @param {string} color
234
+ */
235
+ set_highlight_color(color) {
236
+ const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
237
+ const len0 = WASM_VECTOR_LEN;
238
+ wasm.depictoptions_set_highlight_color(this.__wbg_ptr, ptr0, len0);
239
+ }
240
+ /**
241
+ * @param {boolean} v
242
+ */
243
+ set_kekulize(v) {
244
+ wasm.depictoptions_set_kekulize(this.__wbg_ptr, v);
245
+ }
246
+ /**
247
+ * @param {number} p
248
+ */
249
+ set_padding(p) {
250
+ wasm.depictoptions_set_padding(this.__wbg_ptr, p);
251
+ }
252
+ /**
253
+ * @param {boolean} v
254
+ */
255
+ set_show_atom_indices(v) {
256
+ wasm.depictoptions_set_show_atom_indices(this.__wbg_ptr, v);
257
+ }
258
+ /**
259
+ * @param {number} w
260
+ */
261
+ set_width(w) {
262
+ wasm.depictoptions_set_width(this.__wbg_ptr, w);
263
+ }
264
+ }
265
+ if (Symbol.dispose) DepictOptions.prototype[Symbol.dispose] = DepictOptions.prototype.free;
266
+
267
+ /**
268
+ * MinHash LSH index: insert MHFP fingerprints and query by approximate similarity.
269
+ *
270
+ * ```js
271
+ * const idx = new MhfpLshHandle(128);
272
+ * const i0 = idx.add_smiles("c1ccccc1"); // benzene → index 0
273
+ * const i1 = idx.add_smiles("Cc1ccccc1"); // toluene → index 1
274
+ * const hits = JSON.parse(idx.query_json("c1ccccc1", 0.5));
275
+ * // hits: [{index:0,similarity:1.0}, {index:1,similarity:0.xxx}]
276
+ * ```
277
+ */
278
+ export class MhfpLshHandle {
279
+ __destroy_into_raw() {
280
+ const ptr = this.__wbg_ptr;
281
+ this.__wbg_ptr = 0;
282
+ MhfpLshHandleFinalization.unregister(this);
283
+ return ptr;
284
+ }
285
+ free() {
286
+ const ptr = this.__destroy_into_raw();
287
+ wasm.__wbg_mhfplshhandle_free(ptr, 0);
288
+ }
289
+ /**
290
+ * Add a molecule by SMILES; returns its 0-based index in the index.
291
+ * @param {string} smiles
292
+ * @returns {number}
293
+ */
294
+ add_smiles(smiles) {
295
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
296
+ const len0 = WASM_VECTOR_LEN;
297
+ const ret = wasm.mhfplshhandle_add_smiles(this.__wbg_ptr, ptr0, len0);
298
+ if (ret[2]) {
299
+ throw takeFromExternrefTable0(ret[1]);
300
+ }
301
+ return ret[0] >>> 0;
302
+ }
303
+ /**
304
+ * True if the index contains no molecules.
305
+ * @returns {boolean}
306
+ */
307
+ is_empty() {
308
+ const ret = wasm.mhfplshhandle_is_empty(this.__wbg_ptr);
309
+ return ret !== 0;
310
+ }
311
+ /**
312
+ * Number of molecules in the index.
313
+ * @returns {number}
314
+ */
315
+ len() {
316
+ const ret = wasm.mhfplshhandle_len(this.__wbg_ptr);
317
+ return ret >>> 0;
318
+ }
319
+ /**
320
+ * Create a new LSH index for MHFP fingerprints with `num_hashes` hash lanes.
321
+ * Default band decomposition: 16 bands × (num_hashes / 16) rows.
322
+ * `num_hashes` must be a multiple of 16 (e.g. 128).
323
+ * @param {number} num_hashes
324
+ */
325
+ constructor(num_hashes) {
326
+ const ret = wasm.mhfplshhandle_new(num_hashes);
327
+ this.__wbg_ptr = ret;
328
+ MhfpLshHandleFinalization.register(this, this.__wbg_ptr, this);
329
+ return this;
330
+ }
331
+ /**
332
+ * Query by SMILES for all entries with similarity ≥ threshold.
333
+ *
334
+ * Returns a JSON array `[{"index":N,"similarity":0.xxx},...]` sorted by
335
+ * descending similarity. Empty array `[]` when nothing qualifies.
336
+ * @param {string} query_smiles
337
+ * @param {number} threshold
338
+ * @returns {string}
339
+ */
340
+ query_json(query_smiles, threshold) {
341
+ let deferred3_0;
342
+ let deferred3_1;
343
+ try {
344
+ const ptr0 = passStringToWasm0(query_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
345
+ const len0 = WASM_VECTOR_LEN;
346
+ const ret = wasm.mhfplshhandle_query_json(this.__wbg_ptr, ptr0, len0, threshold);
347
+ var ptr2 = ret[0];
348
+ var len2 = ret[1];
349
+ if (ret[3]) {
350
+ ptr2 = 0; len2 = 0;
351
+ throw takeFromExternrefTable0(ret[2]);
352
+ }
353
+ deferred3_0 = ptr2;
354
+ deferred3_1 = len2;
355
+ return getStringFromWasm0(ptr2, len2);
356
+ } finally {
357
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
358
+ }
359
+ }
360
+ }
361
+ if (Symbol.dispose) MhfpLshHandle.prototype[Symbol.dispose] = MhfpLshHandle.prototype.free;
362
+
363
+ /**
364
+ * A handle to a parsed molecule. Owns the molecule behind an `Rc` so that
365
+ * it can be cheaply cloned on the JS side without copying atom/bond data.
366
+ */
367
+ export class MolHandle {
368
+ static __wrap(ptr) {
369
+ const obj = Object.create(MolHandle.prototype);
370
+ obj.__wbg_ptr = ptr;
371
+ MolHandleFinalization.register(obj, obj.__wbg_ptr, obj);
372
+ return obj;
373
+ }
374
+ __destroy_into_raw() {
375
+ const ptr = this.__wbg_ptr;
376
+ this.__wbg_ptr = 0;
377
+ MolHandleFinalization.unregister(this);
378
+ return ptr;
379
+ }
380
+ free() {
381
+ const ptr = this.__destroy_into_raw();
382
+ wasm.__wbg_molhandle_free(ptr, 0);
383
+ }
384
+ /**
385
+ * Number of aromatic rings (all ring atoms aromatic).
386
+ * @returns {number}
387
+ */
388
+ aromatic_ring_count() {
389
+ const ret = wasm.molhandle_aromatic_ring_count(this.__wbg_ptr);
390
+ return ret >>> 0;
391
+ }
392
+ /**
393
+ * Assign CIP (R/S/E/Z) stereocenters and return JSON.
394
+ *
395
+ * Format: `{"centers":[{"atom":0,"code":"R"},{"atom":3,"code":"E"}]}`
396
+ * @returns {string}
397
+ */
398
+ assign_cip_json() {
399
+ let deferred1_0;
400
+ let deferred1_1;
401
+ try {
402
+ const ret = wasm.molhandle_assign_cip_json(this.__wbg_ptr);
403
+ deferred1_0 = ret[0];
404
+ deferred1_1 = ret[1];
405
+ return getStringFromWasm0(ret[0], ret[1]);
406
+ } finally {
407
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
408
+ }
409
+ }
410
+ /**
411
+ * Number of heavy atoms (explicit atoms in the graph; does not count implicit H).
412
+ * @returns {number}
413
+ */
414
+ atom_count() {
415
+ const ret = wasm.molhandle_atom_count(this.__wbg_ptr);
416
+ return ret >>> 0;
417
+ }
418
+ /**
419
+ * Bertz complexity index (BertzCT).
420
+ * @returns {number}
421
+ */
422
+ bertz_ct() {
423
+ const ret = wasm.molhandle_bertz_ct(this.__wbg_ptr);
424
+ return ret;
425
+ }
426
+ /**
427
+ * Number of bonds.
428
+ * @returns {number}
429
+ */
430
+ bond_count() {
431
+ const ret = wasm.molhandle_bond_count(this.__wbg_ptr);
432
+ return ret >>> 0;
433
+ }
434
+ /**
435
+ * Canonical SMILES string.
436
+ * @returns {string}
437
+ */
438
+ canonical_smiles() {
439
+ let deferred1_0;
440
+ let deferred1_1;
441
+ try {
442
+ const ret = wasm.molhandle_canonical_smiles(this.__wbg_ptr);
443
+ deferred1_0 = ret[0];
444
+ deferred1_1 = ret[1];
445
+ return getStringFromWasm0(ret[0], ret[1]);
446
+ } finally {
447
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
448
+ }
449
+ }
450
+ /**
451
+ * Kier–Hall χ0 molecular connectivity index.
452
+ * @returns {number}
453
+ */
454
+ chi0() {
455
+ const ret = wasm.molhandle_chi0(this.__wbg_ptr);
456
+ return ret;
457
+ }
458
+ /**
459
+ * Kier–Hall χ0v valence-weighted connectivity index.
460
+ * @returns {number}
461
+ */
462
+ chi0v() {
463
+ const ret = wasm.molhandle_chi0v(this.__wbg_ptr);
464
+ return ret;
465
+ }
466
+ /**
467
+ * Kier–Hall χ1 molecular connectivity index.
468
+ * @returns {number}
469
+ */
470
+ chi1() {
471
+ const ret = wasm.molhandle_chi1(this.__wbg_ptr);
472
+ return ret;
473
+ }
474
+ /**
475
+ * Kier–Hall χ1v valence-weighted connectivity index.
476
+ * @returns {number}
477
+ */
478
+ chi1v() {
479
+ const ret = wasm.molhandle_chi1v(this.__wbg_ptr);
480
+ return ret;
481
+ }
482
+ /**
483
+ * Kier–Hall χ2 molecular connectivity index.
484
+ * @returns {number}
485
+ */
486
+ chi2() {
487
+ const ret = wasm.molhandle_chi2(this.__wbg_ptr);
488
+ return ret;
489
+ }
490
+ /**
491
+ * Kier–Hall χ2v valence-weighted connectivity index.
492
+ * @returns {number}
493
+ */
494
+ chi2v() {
495
+ const ret = wasm.molhandle_chi2v(this.__wbg_ptr);
496
+ return ret;
497
+ }
498
+ /**
499
+ * Kier–Hall χ3 molecular connectivity index.
500
+ * @returns {number}
501
+ */
502
+ chi3() {
503
+ const ret = wasm.molhandle_chi3(this.__wbg_ptr);
504
+ return ret;
505
+ }
506
+ /**
507
+ * Kier–Hall χ3v valence-weighted connectivity index.
508
+ * @returns {number}
509
+ */
510
+ chi3v() {
511
+ const ret = wasm.molhandle_chi3v(this.__wbg_ptr);
512
+ return ret;
513
+ }
514
+ /**
515
+ * Kier–Hall χ4 molecular connectivity index.
516
+ * @returns {number}
517
+ */
518
+ chi4() {
519
+ const ret = wasm.molhandle_chi4(this.__wbg_ptr);
520
+ return ret;
521
+ }
522
+ /**
523
+ * Kier–Hall χ4v valence-weighted connectivity index.
524
+ * @returns {number}
525
+ */
526
+ chi4v() {
527
+ const ret = wasm.molhandle_chi4v(this.__wbg_ptr);
528
+ return ret;
529
+ }
530
+ /**
531
+ * 2D PNG depiction (rasterized from SVG).
532
+ * Returns PNG data as base64-encoded string for embedding in HTML/JS.
533
+ * @returns {Uint8Array}
534
+ */
535
+ depict_png() {
536
+ const ret = wasm.molhandle_depict_png(this.__wbg_ptr);
537
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
538
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
539
+ return v1;
540
+ }
541
+ /**
542
+ * 2D SVG depiction of the molecule (CPK coloring).
543
+ * @returns {string}
544
+ */
545
+ depict_svg() {
546
+ let deferred1_0;
547
+ let deferred1_1;
548
+ try {
549
+ const ret = wasm.molhandle_depict_svg(this.__wbg_ptr);
550
+ deferred1_0 = ret[0];
551
+ deferred1_1 = ret[1];
552
+ return getStringFromWasm0(ret[0], ret[1]);
553
+ } finally {
554
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
555
+ }
556
+ }
557
+ /**
558
+ * 2D SVG depiction with style options.
559
+ * @param {DepictOptions} opts
560
+ * @returns {string}
561
+ */
562
+ depict_svg_opts(opts) {
563
+ let deferred1_0;
564
+ let deferred1_1;
565
+ try {
566
+ _assertClass(opts, DepictOptions);
567
+ const ret = wasm.molhandle_depict_svg_opts(this.__wbg_ptr, opts.__wbg_ptr);
568
+ deferred1_0 = ret[0];
569
+ deferred1_1 = ret[1];
570
+ return getStringFromWasm0(ret[0], ret[1]);
571
+ } finally {
572
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
573
+ }
574
+ }
575
+ /**
576
+ * Returns `true` if the molecule passes Egan's absorption criteria
577
+ * (TPSA ≤ 131.6 Ų and LogP ≤ 5.88).
578
+ * @returns {boolean}
579
+ */
580
+ egan_passes() {
581
+ const ret = wasm.molhandle_egan_passes(this.__wbg_ptr);
582
+ return ret !== 0;
583
+ }
584
+ /**
585
+ * Monoisotopic (exact) mass.
586
+ * @returns {number}
587
+ */
588
+ exact_mass() {
589
+ const ret = wasm.molhandle_exact_mass(this.__wbg_ptr);
590
+ return ret;
591
+ }
592
+ /**
593
+ * Sum of formal charges.
594
+ * @returns {number}
595
+ */
596
+ formal_charge_sum() {
597
+ const ret = wasm.molhandle_formal_charge_sum(this.__wbg_ptr);
598
+ return ret;
599
+ }
600
+ /**
601
+ * Molecular formula string (Hill notation: C first, H second, then alphabetical).
602
+ * @returns {string}
603
+ */
604
+ formula() {
605
+ let deferred1_0;
606
+ let deferred1_1;
607
+ try {
608
+ const ret = wasm.molhandle_formula(this.__wbg_ptr);
609
+ deferred1_0 = ret[0];
610
+ deferred1_1 = ret[1];
611
+ return getStringFromWasm0(ret[0], ret[1]);
612
+ } finally {
613
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
614
+ }
615
+ }
616
+ /**
617
+ * Fraction of sp3 carbons (Fsp3).
618
+ * @returns {number}
619
+ */
620
+ fsp3() {
621
+ const ret = wasm.molhandle_fsp3(this.__wbg_ptr);
622
+ return ret;
623
+ }
624
+ /**
625
+ * Returns `true` if the molecule passes Ghose's drug-likeness filter
626
+ * (MW 160–480, LogP −0.4–5.6, HeavyAtoms 20–70, MR 40–130).
627
+ * @returns {boolean}
628
+ */
629
+ ghose_passes() {
630
+ const ret = wasm.molhandle_ghose_passes(this.__wbg_ptr);
631
+ return ret !== 0;
632
+ }
633
+ /**
634
+ * Number of hydrogen bond acceptors (Lipinski: all N and O atoms).
635
+ * @returns {number}
636
+ */
637
+ hba_count() {
638
+ const ret = wasm.molhandle_hba_count(this.__wbg_ptr);
639
+ return ret >>> 0;
640
+ }
641
+ /**
642
+ * Number of hydrogen bond donors (N-H or O-H groups).
643
+ * @returns {number}
644
+ */
645
+ hbd_count() {
646
+ const ret = wasm.molhandle_hbd_count(this.__wbg_ptr);
647
+ return ret >>> 0;
648
+ }
649
+ /**
650
+ * Number of non-hydrogen heavy atoms.
651
+ * @returns {number}
652
+ */
653
+ heavy_atom_count() {
654
+ const ret = wasm.molhandle_heavy_atom_count(this.__wbg_ptr);
655
+ return ret >>> 0;
656
+ }
657
+ /**
658
+ * Isotope distribution as JSON.
659
+ *
660
+ * Returns `[{"mass":100.0,"abundance":0.9},...]` sorted by mass.
661
+ * `resolution`: m/z bin width in Da (e.g. `0.1` for nominal, `0.01` for high-res).
662
+ * @param {number} resolution
663
+ * @returns {string}
664
+ */
665
+ isotope_distribution_json(resolution) {
666
+ let deferred1_0;
667
+ let deferred1_1;
668
+ try {
669
+ const ret = wasm.molhandle_isotope_distribution_json(this.__wbg_ptr, resolution);
670
+ deferred1_0 = ret[0];
671
+ deferred1_1 = ret[1];
672
+ return getStringFromWasm0(ret[0], ret[1]);
673
+ } finally {
674
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
675
+ }
676
+ }
677
+ /**
678
+ * Generate IUPAC systematic name for the molecule.
679
+ *
680
+ * Returns the name string on success, or an empty string when the
681
+ * structure is outside the supported naming scope (complex polycyclics,
682
+ * multi-functional groups, etc.).
683
+ * @returns {string}
684
+ */
685
+ iupac_name() {
686
+ let deferred1_0;
687
+ let deferred1_1;
688
+ try {
689
+ const ret = wasm.molhandle_iupac_name(this.__wbg_ptr);
690
+ deferred1_0 = ret[0];
691
+ deferred1_1 = ret[1];
692
+ return getStringFromWasm0(ret[0], ret[1]);
693
+ } finally {
694
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
695
+ }
696
+ }
697
+ /**
698
+ * Hall–Kier κ1 shape index.
699
+ * @returns {number}
700
+ */
701
+ kappa1() {
702
+ const ret = wasm.molhandle_kappa1(this.__wbg_ptr);
703
+ return ret;
704
+ }
705
+ /**
706
+ * Hall–Kier κ2 shape index.
707
+ * @returns {number}
708
+ */
709
+ kappa2() {
710
+ const ret = wasm.molhandle_kappa2(this.__wbg_ptr);
711
+ return ret;
712
+ }
713
+ /**
714
+ * Hall–Kier κ3 shape index.
715
+ * @returns {number}
716
+ */
717
+ kappa3() {
718
+ const ret = wasm.molhandle_kappa3(this.__wbg_ptr);
719
+ return ret;
720
+ }
721
+ /**
722
+ * Labute approximate surface area (Ų).
723
+ * @returns {number}
724
+ */
725
+ labute_asa() {
726
+ const ret = wasm.molhandle_labute_asa(this.__wbg_ptr);
727
+ return ret;
728
+ }
729
+ /**
730
+ * Returns `true` if the molecule satisfies Lipinski's Rule of Five.
731
+ * @returns {boolean}
732
+ */
733
+ lipinski_passes() {
734
+ const ret = wasm.molhandle_lipinski_passes(this.__wbg_ptr);
735
+ return ret !== 0;
736
+ }
737
+ /**
738
+ * LogD (distribution coefficient) at a specific pH.
739
+ *
740
+ * Accounts for ionization state: neutral molecules return LogP unchanged,
741
+ * ionizable molecules are adjusted by log(neutral_fraction).
742
+ * @param {number} ph
743
+ * @returns {number}
744
+ */
745
+ logd_at_ph(ph) {
746
+ const ret = wasm.molhandle_logd_at_ph(this.__wbg_ptr, ph);
747
+ return ret;
748
+ }
749
+ /**
750
+ * LogD profile across a pH range as JSON.
751
+ *
752
+ * Returns `[{"ph":0.0,"logd":2.5}, ...]` with `steps` evenly-spaced pH points.
753
+ * @param {number} ph_start
754
+ * @param {number} ph_end
755
+ * @param {number} steps
756
+ * @returns {string}
757
+ */
758
+ logd_profile_json(ph_start, ph_end, steps) {
759
+ let deferred1_0;
760
+ let deferred1_1;
761
+ try {
762
+ const ret = wasm.molhandle_logd_profile_json(this.__wbg_ptr, ph_start, ph_end, steps);
763
+ deferred1_0 = ret[0];
764
+ deferred1_1 = ret[1];
765
+ return getStringFromWasm0(ret[0], ret[1]);
766
+ } finally {
767
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
768
+ }
769
+ }
770
+ /**
771
+ * Crippen–Wildman octanol/water partition coefficient (LogP).
772
+ * @returns {number}
773
+ */
774
+ logp_crippen() {
775
+ const ret = wasm.molhandle_logp_crippen(this.__wbg_ptr);
776
+ return ret;
777
+ }
778
+ /**
779
+ * Maximum EState index across all heavy atoms.
780
+ * @returns {number}
781
+ */
782
+ max_estate() {
783
+ const ret = wasm.molhandle_max_estate(this.__wbg_ptr);
784
+ return ret;
785
+ }
786
+ /**
787
+ * Minimum EState index across all heavy atoms.
788
+ * @returns {number}
789
+ */
790
+ min_estate() {
791
+ const ret = wasm.molhandle_min_estate(this.__wbg_ptr);
792
+ return ret;
793
+ }
794
+ /**
795
+ * Wildman–Crippen molar refractivity (MR).
796
+ * @returns {number}
797
+ */
798
+ molar_refractivity() {
799
+ const ret = wasm.molhandle_molar_refractivity(this.__wbg_ptr);
800
+ return ret;
801
+ }
802
+ /**
803
+ * Average molecular weight (Da).
804
+ * @returns {number}
805
+ */
806
+ molecular_weight() {
807
+ const ret = wasm.molhandle_molecular_weight(this.__wbg_ptr);
808
+ return ret;
809
+ }
810
+ /**
811
+ * Morgan count fingerprint as a JSON object string (`{"<hash>": count, …}`).
812
+ *
813
+ * `radius` controls the ECFP radius (2 = ECFP4-equivalent).
814
+ * @param {number} radius
815
+ * @returns {string}
816
+ */
817
+ morgan_fp_counts_json(radius) {
818
+ let deferred1_0;
819
+ let deferred1_1;
820
+ try {
821
+ const ret = wasm.molhandle_morgan_fp_counts_json(this.__wbg_ptr, radius);
822
+ deferred1_0 = ret[0];
823
+ deferred1_1 = ret[1];
824
+ return getStringFromWasm0(ret[0], ret[1]);
825
+ } finally {
826
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
827
+ }
828
+ }
829
+ /**
830
+ * Number of non-aromatic rings containing at least one heteroatom.
831
+ * @returns {number}
832
+ */
833
+ num_aliphatic_heterocycles() {
834
+ const ret = wasm.molhandle_num_aliphatic_heterocycles(this.__wbg_ptr);
835
+ return ret >>> 0;
836
+ }
837
+ /**
838
+ * Count of aliphatic (non-aromatic) rings in the SSSR.
839
+ * @returns {number}
840
+ */
841
+ num_aliphatic_rings() {
842
+ const ret = wasm.molhandle_num_aliphatic_rings(this.__wbg_ptr);
843
+ return ret >>> 0;
844
+ }
845
+ /**
846
+ * Number of aromatic rings containing at least one heteroatom (N, O, S, …).
847
+ * @returns {number}
848
+ */
849
+ num_aromatic_heterocycles() {
850
+ const ret = wasm.molhandle_num_aromatic_heterocycles(this.__wbg_ptr);
851
+ return ret >>> 0;
852
+ }
853
+ /**
854
+ * Number of bridgehead atoms (shared by ≥2 rings with ≥3 ring bonds).
855
+ * @returns {number}
856
+ */
857
+ num_bridgehead_atoms() {
858
+ const ret = wasm.molhandle_num_bridgehead_atoms(this.__wbg_ptr);
859
+ return ret >>> 0;
860
+ }
861
+ /**
862
+ * Number of heteroatoms (non-C, non-H heavy atoms).
863
+ * @returns {number}
864
+ */
865
+ num_heteroatoms() {
866
+ const ret = wasm.molhandle_num_heteroatoms(this.__wbg_ptr);
867
+ return ret >>> 0;
868
+ }
869
+ /**
870
+ * Number of fully saturated rings containing at least one heteroatom.
871
+ * @returns {number}
872
+ */
873
+ num_saturated_heterocycles() {
874
+ const ret = wasm.molhandle_num_saturated_heterocycles(this.__wbg_ptr);
875
+ return ret >>> 0;
876
+ }
877
+ /**
878
+ * Count of fully saturated rings in the SSSR.
879
+ * @returns {number}
880
+ */
881
+ num_saturated_rings() {
882
+ const ret = wasm.molhandle_num_saturated_rings(this.__wbg_ptr);
883
+ return ret >>> 0;
884
+ }
885
+ /**
886
+ * Number of spiro atoms (sole shared atom between exactly 2 rings).
887
+ * @returns {number}
888
+ */
889
+ num_spiro_atoms() {
890
+ const ret = wasm.molhandle_num_spiro_atoms(this.__wbg_ptr);
891
+ return ret >>> 0;
892
+ }
893
+ /**
894
+ * Number of assigned stereocenters (R/S).
895
+ * @returns {number}
896
+ */
897
+ num_stereocenters() {
898
+ const ret = wasm.molhandle_num_stereocenters(this.__wbg_ptr);
899
+ return ret >>> 0;
900
+ }
901
+ /**
902
+ * Count of tetrahedral stereocenters with unspecified configuration.
903
+ * @returns {number}
904
+ */
905
+ num_unspecified_stereocenters() {
906
+ const ret = wasm.molhandle_num_unspecified_stereocenters(this.__wbg_ptr);
907
+ return ret >>> 0;
908
+ }
909
+ /**
910
+ * Returns `true` if the molecule has no PAINS structural alerts.
911
+ * @returns {boolean}
912
+ */
913
+ pains_passes() {
914
+ const ret = wasm.molhandle_pains_passes(this.__wbg_ptr);
915
+ return ret !== 0;
916
+ }
917
+ /**
918
+ * Quantitative Estimate of Drug-likeness (QED); range [0, 1].
919
+ * @returns {number}
920
+ */
921
+ qed() {
922
+ const ret = wasm.molhandle_qed(this.__wbg_ptr);
923
+ return ret;
924
+ }
925
+ /**
926
+ * Randić connectivity index (χ₀).
927
+ *
928
+ * χ₀ = Σ 1/√(d_i × d_j) over all bonds, where d is heavy-atom degree.
929
+ * @returns {number}
930
+ */
931
+ randic_index() {
932
+ const ret = wasm.molhandle_randic_index(this.__wbg_ptr);
933
+ return ret;
934
+ }
935
+ /**
936
+ * Returns `true` if the molecule passes the REOS (Rapid Elimination Of Swill) filter.
937
+ * @returns {boolean}
938
+ */
939
+ reos_passes() {
940
+ const ret = wasm.molhandle_reos_passes(this.__wbg_ptr);
941
+ return ret !== 0;
942
+ }
943
+ /**
944
+ * Total number of rings (SSSR count).
945
+ * @returns {number}
946
+ */
947
+ ring_count() {
948
+ const ret = wasm.molhandle_ring_count(this.__wbg_ptr);
949
+ return ret >>> 0;
950
+ }
951
+ /**
952
+ * Number of rotatable bonds.
953
+ * @returns {number}
954
+ */
955
+ rotatable_bond_count() {
956
+ const ret = wasm.molhandle_rotatable_bond_count(this.__wbg_ptr);
957
+ return ret >>> 0;
958
+ }
959
+ /**
960
+ * Sum of EState indices over all heavy atoms.
961
+ * @returns {number}
962
+ */
963
+ sum_estate() {
964
+ const ret = wasm.molhandle_sum_estate(this.__wbg_ptr);
965
+ return ret;
966
+ }
967
+ /**
968
+ * InChI string representation of the molecule.
969
+ * @returns {string}
970
+ */
971
+ to_inchi() {
972
+ let deferred1_0;
973
+ let deferred1_1;
974
+ try {
975
+ const ret = wasm.molhandle_to_inchi(this.__wbg_ptr);
976
+ deferred1_0 = ret[0];
977
+ deferred1_1 = ret[1];
978
+ return getStringFromWasm0(ret[0], ret[1]);
979
+ } finally {
980
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
981
+ }
982
+ }
983
+ /**
984
+ * InChIKey (27-character identifier) for the molecule.
985
+ * @returns {string}
986
+ */
987
+ to_inchikey() {
988
+ let deferred1_0;
989
+ let deferred1_1;
990
+ try {
991
+ const ret = wasm.molhandle_to_inchikey(this.__wbg_ptr);
992
+ deferred1_0 = ret[0];
993
+ deferred1_1 = ret[1];
994
+ return getStringFromWasm0(ret[0], ret[1]);
995
+ } finally {
996
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
997
+ }
998
+ }
999
+ /**
1000
+ * Topological polar surface area (Ų).
1001
+ * @returns {number}
1002
+ */
1003
+ tpsa() {
1004
+ const ret = wasm.molhandle_tpsa(this.__wbg_ptr);
1005
+ return ret;
1006
+ }
1007
+ /**
1008
+ * Returns `true` if the molecule passes Veber's oral bioavailability criteria
1009
+ * (TPSA ≤ 140 Ų and rotatable bonds ≤ 10).
1010
+ * @returns {boolean}
1011
+ */
1012
+ veber_passes() {
1013
+ const ret = wasm.molhandle_veber_passes(this.__wbg_ptr);
1014
+ return ret !== 0;
1015
+ }
1016
+ /**
1017
+ * Wiener topological index (sum of all pairwise shortest-path distances).
1018
+ * @returns {number}
1019
+ */
1020
+ wiener_index() {
1021
+ const ret = wasm.molhandle_wiener_index(this.__wbg_ptr);
1022
+ return ret;
1023
+ }
1024
+ /**
1025
+ * Zagreb index M1: Σ d_i² over all heavy atoms.
1026
+ * @returns {number}
1027
+ */
1028
+ zagreb_index_m1() {
1029
+ const ret = wasm.molhandle_zagreb_index_m1(this.__wbg_ptr);
1030
+ return ret >>> 0;
1031
+ }
1032
+ }
1033
+ if (Symbol.dispose) MolHandle.prototype[Symbol.dispose] = MolHandle.prototype.free;
1034
+
1035
+ /**
1036
+ * Return a copy of the molecule with all implicit hydrogens converted to explicit H atoms.
1037
+ * @param {MolHandle} mol
1038
+ * @returns {MolHandle}
1039
+ */
1040
+ export function add_hydrogens(mol) {
1041
+ _assertClass(mol, MolHandle);
1042
+ const ret = wasm.add_hydrogens(mol.__wbg_ptr);
1043
+ return MolHandle.__wrap(ret);
1044
+ }
1045
+
1046
+ /**
1047
+ * AtomPair fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
1048
+ * @param {MolHandle} mol
1049
+ * @returns {Uint8Array}
1050
+ */
1051
+ export function atom_pair_bitvec(mol) {
1052
+ _assertClass(mol, MolHandle);
1053
+ const ret = wasm.atom_pair_bitvec(mol.__wbg_ptr);
1054
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1055
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1056
+ return v1;
1057
+ }
1058
+
1059
+ /**
1060
+ * AutoCorr2D descriptor (7 values: topological distance lags 1-7).
1061
+ * @param {MolHandle} mol
1062
+ * @returns {string}
1063
+ */
1064
+ export function autocorr_2d_json(mol) {
1065
+ let deferred1_0;
1066
+ let deferred1_1;
1067
+ try {
1068
+ _assertClass(mol, MolHandle);
1069
+ const ret = wasm.autocorr_2d_json(mol.__wbg_ptr);
1070
+ deferred1_0 = ret[0];
1071
+ deferred1_1 = ret[1];
1072
+ return getStringFromWasm0(ret[0], ret[1]);
1073
+ } finally {
1074
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1075
+ }
1076
+ }
1077
+
1078
+ /**
1079
+ * AutoCorr3D descriptor (8 values: Euclidean distance bins 1-8 Å).
1080
+ * Requires 3D coordinates (generated automatically).
1081
+ * @param {MolHandle} mol
1082
+ * @returns {string}
1083
+ */
1084
+ export function autocorr_3d_json(mol) {
1085
+ let deferred1_0;
1086
+ let deferred1_1;
1087
+ try {
1088
+ _assertClass(mol, MolHandle);
1089
+ const ret = wasm.autocorr_3d_json(mol.__wbg_ptr);
1090
+ deferred1_0 = ret[0];
1091
+ deferred1_1 = ret[1];
1092
+ return getStringFromWasm0(ret[0], ret[1]);
1093
+ } finally {
1094
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1095
+ }
1096
+ }
1097
+
1098
+ /**
1099
+ * Check whether a reaction SMILES is atom-balanced.
1100
+ *
1101
+ * Returns JSON: `{ "balanced": true|false, "diff": ["C: 1 reactant vs 2 product", ...] }`
1102
+ * Returns `"error:<msg>"` on parse failure.
1103
+ * @param {string} reaction_smiles
1104
+ * @returns {string}
1105
+ */
1106
+ export function balance_check_json(reaction_smiles) {
1107
+ let deferred2_0;
1108
+ let deferred2_1;
1109
+ try {
1110
+ const ptr0 = passStringToWasm0(reaction_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1111
+ const len0 = WASM_VECTOR_LEN;
1112
+ const ret = wasm.balance_check_json(ptr0, len0);
1113
+ deferred2_0 = ret[0];
1114
+ deferred2_1 = ret[1];
1115
+ return getStringFromWasm0(ret[0], ret[1]);
1116
+ } finally {
1117
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1118
+ }
1119
+ }
1120
+
1121
+ /**
1122
+ * Number of BRICS fragments produced by fragmenting the molecule.
1123
+ *
1124
+ * Returns 1 if no BRICS-breakable bonds exist (whole molecule is one fragment).
1125
+ * @param {MolHandle} mol
1126
+ * @returns {number}
1127
+ */
1128
+ export function brics_fragment_count(mol) {
1129
+ _assertClass(mol, MolHandle);
1130
+ const ret = wasm.brics_fragment_count(mol.__wbg_ptr);
1131
+ return ret >>> 0;
1132
+ }
1133
+
1134
+ /**
1135
+ * BRICS fragment SMILES as a JSON array.
1136
+ *
1137
+ * Applies the BRICS fragmentation rules and returns the canonical SMILES of
1138
+ * every resulting fragment. Returns `[]` for molecules with no BRICS-breakable
1139
+ * bonds (e.g. benzene).
1140
+ *
1141
+ * The count of fragments equals `brics_fragment_count`.
1142
+ * @param {MolHandle} mol
1143
+ * @returns {string}
1144
+ */
1145
+ export function brics_fragments_json(mol) {
1146
+ let deferred1_0;
1147
+ let deferred1_1;
1148
+ try {
1149
+ _assertClass(mol, MolHandle);
1150
+ const ret = wasm.brics_fragments_json(mol.__wbg_ptr);
1151
+ deferred1_0 = ret[0];
1152
+ deferred1_1 = ret[1];
1153
+ return getStringFromWasm0(ret[0], ret[1]);
1154
+ } finally {
1155
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1156
+ }
1157
+ }
1158
+
1159
+ /**
1160
+ * Cluster molecules by structural similarity (Butina algorithm, ECFP4 Tanimoto).
1161
+ *
1162
+ * `smiles_json` — a JSON array of SMILES strings.
1163
+ * `cutoff` — Tanimoto similarity threshold (0.0–1.0); molecules within this
1164
+ * distance of a cluster centre are assigned to that cluster.
1165
+ * Returns a JSON array of clusters, each cluster being an array of 0-based input indices.
1166
+ * Returns a JS error if any SMILES fails to parse.
1167
+ * @param {string} smiles_json
1168
+ * @param {number} cutoff
1169
+ * @returns {string}
1170
+ */
1171
+ export function butina_cluster_ecfp4_json(smiles_json, cutoff) {
1172
+ let deferred3_0;
1173
+ let deferred3_1;
1174
+ try {
1175
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1176
+ const len0 = WASM_VECTOR_LEN;
1177
+ const ret = wasm.butina_cluster_ecfp4_json(ptr0, len0, cutoff);
1178
+ var ptr2 = ret[0];
1179
+ var len2 = ret[1];
1180
+ if (ret[3]) {
1181
+ ptr2 = 0; len2 = 0;
1182
+ throw takeFromExternrefTable0(ret[2]);
1183
+ }
1184
+ deferred3_0 = ptr2;
1185
+ deferred3_1 = len2;
1186
+ return getStringFromWasm0(ptr2, len2);
1187
+ } finally {
1188
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1189
+ }
1190
+ }
1191
+
1192
+ /**
1193
+ * Canonical tautomer of `mol`.
1194
+ *
1195
+ * Applies a rule-based tautomer normalisation and returns the canonical form
1196
+ * as a new `MolHandle`.
1197
+ * @param {MolHandle} mol
1198
+ * @returns {MolHandle}
1199
+ */
1200
+ export function canonical_tautomer(mol) {
1201
+ _assertClass(mol, MolHandle);
1202
+ const ret = wasm.canonical_tautomer(mol.__wbg_ptr);
1203
+ return MolHandle.__wrap(ret);
1204
+ }
1205
+
1206
+ /**
1207
+ * Compute the canonical tautomer with specific atoms blocked from H-transfer.
1208
+ *
1209
+ * `blocked_atom_indices_json`: JSON array of 0-based atom indices, e.g. `[0, 3]`.
1210
+ * Any tautomer move whose donor, bridge, or acceptor is in the blocked set is suppressed.
1211
+ *
1212
+ * Returns canonical SMILES of the result, or `{"error":"..."}` on failure.
1213
+ * Out-of-range indices are silently ignored (no effect).
1214
+ * @param {MolHandle} mol
1215
+ * @param {string} blocked_atom_indices_json
1216
+ * @returns {string}
1217
+ */
1218
+ export function canonical_tautomer_with_blocked_atoms_json(mol, blocked_atom_indices_json) {
1219
+ let deferred2_0;
1220
+ let deferred2_1;
1221
+ try {
1222
+ _assertClass(mol, MolHandle);
1223
+ const ptr0 = passStringToWasm0(blocked_atom_indices_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1224
+ const len0 = WASM_VECTOR_LEN;
1225
+ const ret = wasm.canonical_tautomer_with_blocked_atoms_json(mol.__wbg_ptr, ptr0, len0);
1226
+ deferred2_0 = ret[0];
1227
+ deferred2_1 = ret[1];
1228
+ return getStringFromWasm0(ret[0], ret[1]);
1229
+ } finally {
1230
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1231
+ }
1232
+ }
1233
+
1234
+ /**
1235
+ * Parse all molecular fragments from a CDXML string.
1236
+ *
1237
+ * Returns a JSON array of SMILES strings, one per fragment:
1238
+ * `["CC","c1ccccc1"]`
1239
+ *
1240
+ * Stereochemistry (wedge/dash bonds) is read from the `Display` attribute
1241
+ * of bond elements.
1242
+ * @param {string} cdxml
1243
+ * @returns {string}
1244
+ */
1245
+ export function cdxml_to_smiles_json(cdxml) {
1246
+ let deferred3_0;
1247
+ let deferred3_1;
1248
+ try {
1249
+ const ptr0 = passStringToWasm0(cdxml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1250
+ const len0 = WASM_VECTOR_LEN;
1251
+ const ret = wasm.cdxml_to_smiles_json(ptr0, len0);
1252
+ var ptr2 = ret[0];
1253
+ var len2 = ret[1];
1254
+ if (ret[3]) {
1255
+ ptr2 = 0; len2 = 0;
1256
+ throw takeFromExternrefTable0(ret[2]);
1257
+ }
1258
+ deferred3_0 = ptr2;
1259
+ deferred3_1 = len2;
1260
+ return getStringFromWasm0(ptr2, len2);
1261
+ } finally {
1262
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1263
+ }
1264
+ }
1265
+
1266
+ /**
1267
+ * CIP stereo assignments as a JSON array of `{atomIdx, cipCode}` objects.
1268
+ *
1269
+ * `cipCode` is one of `"R"`, `"S"`, `"E"`, or `"Z"`.
1270
+ * Returns `[]` for molecules with no specified stereocenters.
1271
+ * @param {MolHandle} mol
1272
+ * @returns {string}
1273
+ */
1274
+ export function cip_assignments_json(mol) {
1275
+ let deferred1_0;
1276
+ let deferred1_1;
1277
+ try {
1278
+ _assertClass(mol, MolHandle);
1279
+ const ret = wasm.cip_assignments_json(mol.__wbg_ptr);
1280
+ deferred1_0 = ret[0];
1281
+ deferred1_1 = ret[1];
1282
+ return getStringFromWasm0(ret[0], ret[1]);
1283
+ } finally {
1284
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1285
+ }
1286
+ }
1287
+
1288
+ /**
1289
+ * Compare multiple SMILES strings (up to 256 by default).
1290
+ * Accepts a delimiter-separated list (e.g., newline or comma).
1291
+ *
1292
+ * # Example (JS)
1293
+ * ```javascript
1294
+ * const smilesList = "c1ccccc1\nCc1ccccc1\nCCc1ccccc1";
1295
+ * const json = module.compare_molecules_batch_json(smilesList, "\n");
1296
+ * const comparison = JSON.parse(json);
1297
+ * ```
1298
+ * @param {string} smiles_batch
1299
+ * @param {string} delimiter
1300
+ * @returns {string}
1301
+ */
1302
+ export function compare_molecules_batch_json(smiles_batch, delimiter) {
1303
+ let deferred4_0;
1304
+ let deferred4_1;
1305
+ try {
1306
+ const ptr0 = passStringToWasm0(smiles_batch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1307
+ const len0 = WASM_VECTOR_LEN;
1308
+ const ptr1 = passStringToWasm0(delimiter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1309
+ const len1 = WASM_VECTOR_LEN;
1310
+ const ret = wasm.compare_molecules_batch_json(ptr0, len0, ptr1, len1);
1311
+ var ptr3 = ret[0];
1312
+ var len3 = ret[1];
1313
+ if (ret[3]) {
1314
+ ptr3 = 0; len3 = 0;
1315
+ throw takeFromExternrefTable0(ret[2]);
1316
+ }
1317
+ deferred4_0 = ptr3;
1318
+ deferred4_1 = len3;
1319
+ return getStringFromWasm0(ptr3, len3);
1320
+ } finally {
1321
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1322
+ }
1323
+ }
1324
+
1325
+ /**
1326
+ * Compare two or more SMILES strings (JSON string output).
1327
+ * Returns the JSON representation of a `MoleculeComparison` struct.
1328
+ *
1329
+ * # Example (JS)
1330
+ * ```javascript
1331
+ * const json = module.compare_molecules_json("c1ccccc1", "Cc1ccccc1");
1332
+ * const comparison = JSON.parse(json);
1333
+ * console.log(comparison.pairwise[0].similarities.ecfp4_tanimoto);
1334
+ * ```
1335
+ * @param {string} smiles1
1336
+ * @param {string} smiles2
1337
+ * @returns {string}
1338
+ */
1339
+ export function compare_molecules_json(smiles1, smiles2) {
1340
+ let deferred4_0;
1341
+ let deferred4_1;
1342
+ try {
1343
+ const ptr0 = passStringToWasm0(smiles1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1344
+ const len0 = WASM_VECTOR_LEN;
1345
+ const ptr1 = passStringToWasm0(smiles2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1346
+ const len1 = WASM_VECTOR_LEN;
1347
+ const ret = wasm.compare_molecules_json(ptr0, len0, ptr1, len1);
1348
+ var ptr3 = ret[0];
1349
+ var len3 = ret[1];
1350
+ if (ret[3]) {
1351
+ ptr3 = 0; len3 = 0;
1352
+ throw takeFromExternrefTable0(ret[2]);
1353
+ }
1354
+ deferred4_0 = ptr3;
1355
+ deferred4_1 = len3;
1356
+ return getStringFromWasm0(ptr3, len3);
1357
+ } finally {
1358
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1359
+ }
1360
+ }
1361
+
1362
+ /**
1363
+ * Compute direct Coulomb energy for a molecule with Gasteiger partial charges.
1364
+ *
1365
+ * Returns JSON object: `{ "coulomb_energy": E, "unit": "kcal/mol" }`
1366
+ *
1367
+ * # Arguments
1368
+ * * `mol` - Molecule to evaluate
1369
+ *
1370
+ * # Example (JavaScript)
1371
+ * ```js
1372
+ * const mol = parse_smiles("CCO");
1373
+ * const result = coulomb_energy_json(mol);
1374
+ * // { "coulomb_energy": -12.34, "unit": "kcal/mol" }
1375
+ * ```
1376
+ * @param {MolHandle} mol
1377
+ * @returns {string}
1378
+ */
1379
+ export function coulomb_energy_json(mol) {
1380
+ let deferred1_0;
1381
+ let deferred1_1;
1382
+ try {
1383
+ _assertClass(mol, MolHandle);
1384
+ const ret = wasm.coulomb_energy_json(mol.__wbg_ptr);
1385
+ deferred1_0 = ret[0];
1386
+ deferred1_1 = ret[1];
1387
+ return getStringFromWasm0(ret[0], ret[1]);
1388
+ } finally {
1389
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1390
+ }
1391
+ }
1392
+
1393
+ /**
1394
+ * Return the CPK color (CSS hex string) for the given element symbol.
1395
+ *
1396
+ * Returns `"#000000"` (black) for carbon and unknown elements.
1397
+ * @param {string} element_symbol
1398
+ * @returns {string}
1399
+ */
1400
+ export function cpk_color(element_symbol) {
1401
+ let deferred2_0;
1402
+ let deferred2_1;
1403
+ try {
1404
+ const ptr0 = passStringToWasm0(element_symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1405
+ const len0 = WASM_VECTOR_LEN;
1406
+ const ret = wasm.cpk_color(ptr0, len0);
1407
+ deferred2_0 = ret[0];
1408
+ deferred2_1 = ret[1];
1409
+ return getStringFromWasm0(ret[0], ret[1]);
1410
+ } finally {
1411
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1412
+ }
1413
+ }
1414
+
1415
+ /**
1416
+ * Compute structured depiction data for `mol` as a JSON object.
1417
+ *
1418
+ * Returns:
1419
+ * ```json
1420
+ * {
1421
+ * "atoms": [
1422
+ * {"idx": 0, "element": "C", "x": 1.5, "y": 0.0, "charge": 0,
1423
+ * "label": null, "color": "#000000"},
1424
+ * ...
1425
+ * ],
1426
+ * "bonds": [
1427
+ * {"idx": 0, "atom1": 0, "atom2": 1, "kind": "Single"},
1428
+ * ...
1429
+ * ]
1430
+ * }
1431
+ * ```
1432
+ *
1433
+ * `label` is `null` for carbon atoms in skeletal structures (label suppressed).
1434
+ * `kind` is one of `"Single"`, `"Double"`, `"Triple"`, `"Aromatic"`, `"Up"`, `"Down"`.
1435
+ * @param {MolHandle} mol
1436
+ * @returns {string}
1437
+ */
1438
+ export function depict_data_json(mol) {
1439
+ let deferred1_0;
1440
+ let deferred1_1;
1441
+ try {
1442
+ _assertClass(mol, MolHandle);
1443
+ const ret = wasm.depict_data_json(mol.__wbg_ptr);
1444
+ deferred1_0 = ret[0];
1445
+ deferred1_1 = ret[1];
1446
+ return getStringFromWasm0(ret[0], ret[1]);
1447
+ } finally {
1448
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1449
+ }
1450
+ }
1451
+
1452
+ /**
1453
+ * Compute structured depiction data using caller-supplied 2D coordinates.
1454
+ *
1455
+ * `coords_json` — JSON array of `[x, y]` pairs, one per atom in order.
1456
+ *
1457
+ * Returns the same JSON format as `depict_data_json`.
1458
+ * @param {MolHandle} mol
1459
+ * @param {string} coords_json
1460
+ * @returns {string}
1461
+ */
1462
+ export function depict_data_with_coords_json(mol, coords_json) {
1463
+ let deferred2_0;
1464
+ let deferred2_1;
1465
+ try {
1466
+ _assertClass(mol, MolHandle);
1467
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1468
+ const len0 = WASM_VECTOR_LEN;
1469
+ const ret = wasm.depict_data_with_coords_json(mol.__wbg_ptr, ptr0, len0);
1470
+ deferred2_0 = ret[0];
1471
+ deferred2_1 = ret[1];
1472
+ return getStringFromWasm0(ret[0], ret[1]);
1473
+ } finally {
1474
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1475
+ }
1476
+ }
1477
+
1478
+ /**
1479
+ * Render a reaction SMILES string (e.g. `"CC(=O)O.CCO>>CC(=O)OCC.O"`) as a
1480
+ * single SVG showing reactants → products with `+` separators.
1481
+ *
1482
+ * Returns a self-contained SVG string. Returns a JS error on invalid input.
1483
+ * @param {string} rxn_smiles
1484
+ * @returns {string}
1485
+ */
1486
+ export function depict_reaction_svg(rxn_smiles) {
1487
+ let deferred3_0;
1488
+ let deferred3_1;
1489
+ try {
1490
+ const ptr0 = passStringToWasm0(rxn_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1491
+ const len0 = WASM_VECTOR_LEN;
1492
+ const ret = wasm.depict_reaction_svg(ptr0, len0);
1493
+ var ptr2 = ret[0];
1494
+ var len2 = ret[1];
1495
+ if (ret[3]) {
1496
+ ptr2 = 0; len2 = 0;
1497
+ throw takeFromExternrefTable0(ret[2]);
1498
+ }
1499
+ deferred3_0 = ptr2;
1500
+ deferred3_1 = len2;
1501
+ return getStringFromWasm0(ptr2, len2);
1502
+ } finally {
1503
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1504
+ }
1505
+ }
1506
+
1507
+ /**
1508
+ * Render a grid SVG from newline-separated SMILES (one per line).
1509
+ *
1510
+ * Lines that fail to parse are silently skipped.
1511
+ * `cols` controls the number of columns (each cell is 200×200 px).
1512
+ * @param {string} smiles_block
1513
+ * @param {number} cols
1514
+ * @returns {string}
1515
+ */
1516
+ export function depict_svg_grid(smiles_block, cols) {
1517
+ let deferred2_0;
1518
+ let deferred2_1;
1519
+ try {
1520
+ const ptr0 = passStringToWasm0(smiles_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1521
+ const len0 = WASM_VECTOR_LEN;
1522
+ const ret = wasm.depict_svg_grid(ptr0, len0, cols);
1523
+ deferred2_0 = ret[0];
1524
+ deferred2_1 = ret[1];
1525
+ return getStringFromWasm0(ret[0], ret[1]);
1526
+ } finally {
1527
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1528
+ }
1529
+ }
1530
+
1531
+ /**
1532
+ * Render a molecule grid with SMARTS-based atom highlighting.
1533
+ *
1534
+ * `smiles_block` — newline-separated SMILES strings (same format as `depict_svg_grid`).
1535
+ * `cols` — number of grid columns.
1536
+ * `match_smarts` — SMARTS pattern; matched atoms in each molecule are highlighted.
1537
+ * Pass an empty string `""` to render without any highlighting.
1538
+ *
1539
+ * Invalid SMILES are rendered as empty cells; SMARTS parse failure returns an
1540
+ * unhighlighted grid (the SMARTS is silently ignored).
1541
+ * @param {string} smiles_block
1542
+ * @param {number} cols
1543
+ * @param {string} match_smarts
1544
+ * @returns {string}
1545
+ */
1546
+ export function depict_svg_grid_highlighted(smiles_block, cols, match_smarts) {
1547
+ let deferred3_0;
1548
+ let deferred3_1;
1549
+ try {
1550
+ const ptr0 = passStringToWasm0(smiles_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1551
+ const len0 = WASM_VECTOR_LEN;
1552
+ const ptr1 = passStringToWasm0(match_smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1553
+ const len1 = WASM_VECTOR_LEN;
1554
+ const ret = wasm.depict_svg_grid_highlighted(ptr0, len0, cols, ptr1, len1);
1555
+ deferred3_0 = ret[0];
1556
+ deferred3_1 = ret[1];
1557
+ return getStringFromWasm0(ret[0], ret[1]);
1558
+ } finally {
1559
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1560
+ }
1561
+ }
1562
+
1563
+ /**
1564
+ * Detect named functional groups in `mol`.
1565
+ *
1566
+ * Returns a JSON array of `{"name":"hydroxyl","atoms":[3]}` objects.
1567
+ * Multiple matches of the same group (e.g. two hydroxyl groups) each appear
1568
+ * as a separate entry. Overlapping groups (carboxylic acid → "carboxyl" +
1569
+ * "hydroxyl" + "carbonyl") are all returned.
1570
+ * @param {MolHandle} mol
1571
+ * @returns {string}
1572
+ */
1573
+ export function detect_functional_groups(mol) {
1574
+ let deferred1_0;
1575
+ let deferred1_1;
1576
+ try {
1577
+ _assertClass(mol, MolHandle);
1578
+ const ret = wasm.detect_functional_groups(mol.__wbg_ptr);
1579
+ deferred1_0 = ret[0];
1580
+ deferred1_1 = ret[1];
1581
+ return getStringFromWasm0(ret[0], ret[1]);
1582
+ } finally {
1583
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1584
+ }
1585
+ }
1586
+
1587
+ /**
1588
+ * Infer bond connectivity and bond orders from an XYZ-format string.
1589
+ *
1590
+ * Explicit hydrogen atoms must be present in the XYZ for reliable bond-order
1591
+ * assignment (without H, carbonyl C=O cannot be distinguished from C-O).
1592
+ *
1593
+ * Returns JSON on success: `{"smiles":"CCO","atom_count":3,"bond_count":2}`.
1594
+ * `atom_count` and `bond_count` refer to the heavy-atom skeleton (H removed).
1595
+ *
1596
+ * Returns JSON on error: `{"error":"molecule has 450 atoms; maximum is 300"}`.
1597
+ *
1598
+ * Safe: never freezes. All internal loops are O(n²). Capped at 300 atoms.
1599
+ * @param {string} xyz_str
1600
+ * @returns {string}
1601
+ */
1602
+ export function determine_bonds_from_xyz_json(xyz_str) {
1603
+ let deferred2_0;
1604
+ let deferred2_1;
1605
+ try {
1606
+ const ptr0 = passStringToWasm0(xyz_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1607
+ const len0 = WASM_VECTOR_LEN;
1608
+ const ret = wasm.determine_bonds_from_xyz_json(ptr0, len0);
1609
+ deferred2_0 = ret[0];
1610
+ deferred2_1 = ret[1];
1611
+ return getStringFromWasm0(ret[0], ret[1]);
1612
+ } finally {
1613
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1614
+ }
1615
+ }
1616
+
1617
+ /**
1618
+ * Dice similarity between `a` and `b` using ECFP4 fingerprints.
1619
+ * @param {MolHandle} a
1620
+ * @param {MolHandle} b
1621
+ * @returns {number}
1622
+ */
1623
+ export function dice_ecfp4(a, b) {
1624
+ _assertClass(a, MolHandle);
1625
+ _assertClass(b, MolHandle);
1626
+ const ret = wasm.dice_ecfp4(a.__wbg_ptr, b.__wbg_ptr);
1627
+ return ret;
1628
+ }
1629
+
1630
+ /**
1631
+ * Dice similarity between `a` and `b` using ECFP6 fingerprints.
1632
+ * @param {MolHandle} a
1633
+ * @param {MolHandle} b
1634
+ * @returns {number}
1635
+ */
1636
+ export function dice_ecfp6(a, b) {
1637
+ _assertClass(a, MolHandle);
1638
+ _assertClass(b, MolHandle);
1639
+ const ret = wasm.dice_ecfp6(a.__wbg_ptr, b.__wbg_ptr);
1640
+ return ret;
1641
+ }
1642
+
1643
+ /**
1644
+ * Dice similarity between `a` and `b` using MACCS 166-bit fingerprints.
1645
+ * @param {MolHandle} a
1646
+ * @param {MolHandle} b
1647
+ * @returns {number}
1648
+ */
1649
+ export function dice_maccs(a, b) {
1650
+ _assertClass(a, MolHandle);
1651
+ _assertClass(b, MolHandle);
1652
+ const ret = wasm.dice_maccs(a.__wbg_ptr, b.__wbg_ptr);
1653
+ return ret;
1654
+ }
1655
+
1656
+ /**
1657
+ * Compute the ECFP4 fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
1658
+ * @param {MolHandle} mol
1659
+ * @returns {Uint8Array}
1660
+ */
1661
+ export function ecfp4_bitvec(mol) {
1662
+ _assertClass(mol, MolHandle);
1663
+ const ret = wasm.ecfp4_bitvec(mol.__wbg_ptr);
1664
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1665
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1666
+ return v1;
1667
+ }
1668
+
1669
+ /**
1670
+ * Like `ecfp4_bitvec` but with explicit chirality control.
1671
+ *
1672
+ * When `use_chirality=true`, tetrahedral stereochemistry is included in the
1673
+ * initial atom hash, making enantiomers have different fingerprints.
1674
+ * When `false` (default), chirality is ignored.
1675
+ * @param {MolHandle} mol
1676
+ * @param {boolean} use_chirality
1677
+ * @returns {Uint8Array}
1678
+ */
1679
+ export function ecfp4_bitvec_with_chirality(mol, use_chirality) {
1680
+ _assertClass(mol, MolHandle);
1681
+ const ret = wasm.ecfp4_bitvec_with_chirality(mol.__wbg_ptr, use_chirality);
1682
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1683
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1684
+ return v1;
1685
+ }
1686
+
1687
+ /**
1688
+ * ECFP6 (radius-3) fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
1689
+ * @param {MolHandle} mol
1690
+ * @returns {Uint8Array}
1691
+ */
1692
+ export function ecfp6_bitvec(mol) {
1693
+ _assertClass(mol, MolHandle);
1694
+ const ret = wasm.ecfp6_bitvec(mol.__wbg_ptr);
1695
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1696
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1697
+ return v1;
1698
+ }
1699
+
1700
+ /**
1701
+ * Like `ecfp6_bitvec` but with explicit chirality control.
1702
+ *
1703
+ * When `use_chirality=true`, tetrahedral stereochemistry is included in the
1704
+ * initial atom hash, making enantiomers have different fingerprints.
1705
+ * When `false` (default), chirality is ignored.
1706
+ * @param {MolHandle} mol
1707
+ * @param {boolean} use_chirality
1708
+ * @returns {Uint8Array}
1709
+ */
1710
+ export function ecfp6_bitvec_with_chirality(mol, use_chirality) {
1711
+ _assertClass(mol, MolHandle);
1712
+ const ret = wasm.ecfp6_bitvec_with_chirality(mol.__wbg_ptr, use_chirality);
1713
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1714
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1715
+ return v1;
1716
+ }
1717
+
1718
+ /**
1719
+ * Compute a fingerprint bit-vector with configurable ECFP radius and bit width.
1720
+ *
1721
+ * `radius` — Morgan radius (1 = ECFP2, 2 = ECFP4, 3 = ECFP6).
1722
+ * `nbits` — bit width; must be one of 256, 512, 1024, or 2048.
1723
+ * Returns a `Uint8Array` of `nbits/8` bytes.
1724
+ *
1725
+ * The hash modulo is applied at fingerprint-generation time (`id % nbits`),
1726
+ * so no post-processing fold is needed.
1727
+ * Compute a custom ECFP (Extended Connectivity FingerPrint) with specified radius and bit count.
1728
+ *
1729
+ * When `use_chirality=true`, tetrahedral stereochemistry is included in the initial
1730
+ * atom hash. When `false` (default), chirality is ignored.
1731
+ * @param {MolHandle} mol
1732
+ * @param {number} radius
1733
+ * @param {number} nbits
1734
+ * @param {boolean} use_chirality
1735
+ * @returns {Uint8Array}
1736
+ */
1737
+ export function ecfp_bitvec_custom(mol, radius, nbits, use_chirality) {
1738
+ _assertClass(mol, MolHandle);
1739
+ const ret = wasm.ecfp_bitvec_custom(mol.__wbg_ptr, radius, nbits, use_chirality);
1740
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1741
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1742
+ return v1;
1743
+ }
1744
+
1745
+ /**
1746
+ * Enumerate a combinatorial library from a SMIRKS template and two fragment sets.
1747
+ *
1748
+ * Generates all products by combining every scaffold with every building block.
1749
+ * Input format: `scaffolds_smiles` and `building_blocks_smiles` are pipe-delimited
1750
+ * SMILES strings (e.g., `"c1ccccc1|Cc1ccccc1"`).
1751
+ *
1752
+ * Returns JSON array of product SMILES strings.
1753
+ * Example: `enumerate_library_2way("[C:1][Cl].[C:2][NH2]>>[C:1]N[C:2]", "c1ccccc1|Cc1ccccc1", "NCc1ccccc1|NCC")`
1754
+ * @param {string} template
1755
+ * @param {string} scaffolds_smiles
1756
+ * @param {string} building_blocks_smiles
1757
+ * @returns {string}
1758
+ */
1759
+ export function enumerate_library_2way(template, scaffolds_smiles, building_blocks_smiles) {
1760
+ let deferred5_0;
1761
+ let deferred5_1;
1762
+ try {
1763
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1764
+ const len0 = WASM_VECTOR_LEN;
1765
+ const ptr1 = passStringToWasm0(scaffolds_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1766
+ const len1 = WASM_VECTOR_LEN;
1767
+ const ptr2 = passStringToWasm0(building_blocks_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1768
+ const len2 = WASM_VECTOR_LEN;
1769
+ const ret = wasm.enumerate_library_2way(ptr0, len0, ptr1, len1, ptr2, len2);
1770
+ var ptr4 = ret[0];
1771
+ var len4 = ret[1];
1772
+ if (ret[3]) {
1773
+ ptr4 = 0; len4 = 0;
1774
+ throw takeFromExternrefTable0(ret[2]);
1775
+ }
1776
+ deferred5_0 = ptr4;
1777
+ deferred5_1 = len4;
1778
+ return getStringFromWasm0(ptr4, len4);
1779
+ } finally {
1780
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
1781
+ }
1782
+ }
1783
+
1784
+ /**
1785
+ * Enumerate all stereoisomers arising from unspecified tetrahedral stereocenters.
1786
+ *
1787
+ * Only considers carbon stereocenters without explicit `@`/`@@` annotation.
1788
+ * Already-specified centers and E/Z double-bond geometry are unchanged.
1789
+ * Returns a JSON array of canonical SMILES strings.
1790
+ *
1791
+ * At most 2^6 = 64 combinations are enumerated; if more than 6 unspecified
1792
+ * centers are present this function returns a JS error to avoid combinatorial
1793
+ * explosion.
1794
+ * @param {MolHandle} mol
1795
+ * @returns {string}
1796
+ */
1797
+ export function enumerate_stereo_isomers_json(mol) {
1798
+ let deferred2_0;
1799
+ let deferred2_1;
1800
+ try {
1801
+ _assertClass(mol, MolHandle);
1802
+ const ret = wasm.enumerate_stereo_isomers_json(mol.__wbg_ptr);
1803
+ var ptr1 = ret[0];
1804
+ var len1 = ret[1];
1805
+ if (ret[3]) {
1806
+ ptr1 = 0; len1 = 0;
1807
+ throw takeFromExternrefTable0(ret[2]);
1808
+ }
1809
+ deferred2_0 = ptr1;
1810
+ deferred2_1 = len1;
1811
+ return getStringFromWasm0(ptr1, len1);
1812
+ } finally {
1813
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1814
+ }
1815
+ }
1816
+
1817
+ /**
1818
+ * All enumerated tautomers of `mol` as a JSON array of canonical SMILES strings.
1819
+ *
1820
+ * Example return value: `["Oc1cccc2ccccc12","O=C1C=CC=Cc2ccccc21"]`
1821
+ * @param {MolHandle} mol
1822
+ * @returns {string}
1823
+ */
1824
+ export function enumerate_tautomers_json(mol) {
1825
+ let deferred1_0;
1826
+ let deferred1_1;
1827
+ try {
1828
+ _assertClass(mol, MolHandle);
1829
+ const ret = wasm.enumerate_tautomers_json(mol.__wbg_ptr);
1830
+ deferred1_0 = ret[0];
1831
+ deferred1_1 = ret[1];
1832
+ return getStringFromWasm0(ret[0], ret[1]);
1833
+ } finally {
1834
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1835
+ }
1836
+ }
1837
+
1838
+ /**
1839
+ * Compute ERG-style 315-element float histogram fingerprint.
1840
+ * Returns JSON: {"len":315,"values":[f64,...]} or {"error":"..."}.
1841
+ * Format: 21 pharmacophore-feature-pair × 15 distance bins with Gaussian fuzzing.
1842
+ * See `chematic_fp::erg_vec` for details.
1843
+ * @param {MolHandle} mol
1844
+ * @returns {string}
1845
+ */
1846
+ export function erg_vec_json(mol) {
1847
+ let deferred1_0;
1848
+ let deferred1_1;
1849
+ try {
1850
+ _assertClass(mol, MolHandle);
1851
+ const ret = wasm.erg_vec_json(mol.__wbg_ptr);
1852
+ deferred1_0 = ret[0];
1853
+ deferred1_1 = ret[1];
1854
+ return getStringFromWasm0(ret[0], ret[1]);
1855
+ } finally {
1856
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1857
+ }
1858
+ }
1859
+
1860
+ /**
1861
+ * Per-atom EState values as a JSON array of f64.
1862
+ *
1863
+ * Indices match `mol.atoms()` order. Hydrogen atoms get 0.0.
1864
+ * @param {MolHandle} mol
1865
+ * @returns {string}
1866
+ */
1867
+ export function estate_indices_json(mol) {
1868
+ let deferred1_0;
1869
+ let deferred1_1;
1870
+ try {
1871
+ _assertClass(mol, MolHandle);
1872
+ const ret = wasm.estate_indices_json(mol.__wbg_ptr);
1873
+ deferred1_0 = ret[0];
1874
+ deferred1_1 = ret[1];
1875
+ return getStringFromWasm0(ret[0], ret[1]);
1876
+ } finally {
1877
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1878
+ }
1879
+ }
1880
+
1881
+ /**
1882
+ * FCFP4 (pharmacophore, radius-2) fingerprint as a bit-packed byte vector (256 bytes).
1883
+ * @param {MolHandle} mol
1884
+ * @returns {Uint8Array}
1885
+ */
1886
+ export function fcfp4_bitvec(mol) {
1887
+ _assertClass(mol, MolHandle);
1888
+ const ret = wasm.fcfp4_bitvec(mol.__wbg_ptr);
1889
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1890
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1891
+ return v1;
1892
+ }
1893
+
1894
+ /**
1895
+ * FCFP6 (pharmacophore, radius-3) fingerprint as a bit-packed byte vector (256 bytes).
1896
+ * @param {MolHandle} mol
1897
+ * @returns {Uint8Array}
1898
+ */
1899
+ export function fcfp6_bitvec(mol) {
1900
+ _assertClass(mol, MolHandle);
1901
+ const ret = wasm.fcfp6_bitvec(mol.__wbg_ptr);
1902
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1903
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1904
+ return v1;
1905
+ }
1906
+
1907
+ /**
1908
+ * Analyze a reaction SMILES and return the reaction center as JSON.
1909
+ *
1910
+ * JSON schema: `{ broken: [[a1,a2],...], formed: [[a1,a2],...], changed: [a,...] }`
1911
+ * where atom indices are 0-based within the first reactant molecule.
1912
+ * Returns an error string prefixed with `"error:"` on failure.
1913
+ * @param {string} reaction_smiles
1914
+ * @returns {string}
1915
+ */
1916
+ export function find_reaction_center_json(reaction_smiles) {
1917
+ let deferred2_0;
1918
+ let deferred2_1;
1919
+ try {
1920
+ const ptr0 = passStringToWasm0(reaction_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1921
+ const len0 = WASM_VECTOR_LEN;
1922
+ const ret = wasm.find_reaction_center_json(ptr0, len0);
1923
+ deferred2_0 = ret[0];
1924
+ deferred2_1 = ret[1];
1925
+ return getStringFromWasm0(ret[0], ret[1]);
1926
+ } finally {
1927
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1928
+ }
1929
+ }
1930
+
1931
+ /**
1932
+ * Gasteiger-Marsili PEOE partial charges as a JSON array of f64.
1933
+ * @param {MolHandle} mol
1934
+ * @returns {string}
1935
+ */
1936
+ export function gasteiger_charges_json(mol) {
1937
+ let deferred1_0;
1938
+ let deferred1_1;
1939
+ try {
1940
+ _assertClass(mol, MolHandle);
1941
+ const ret = wasm.gasteiger_charges_json(mol.__wbg_ptr);
1942
+ deferred1_0 = ret[0];
1943
+ deferred1_1 = ret[1];
1944
+ return getStringFromWasm0(ret[0], ret[1]);
1945
+ } finally {
1946
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1947
+ }
1948
+ }
1949
+
1950
+ /**
1951
+ * Generate 3D coordinates using ETKDG and minimize with DREIDING force field.
1952
+ * @param {MolHandle} mol
1953
+ * @returns {string}
1954
+ */
1955
+ export function generate_3d_etkdg_minimized_pdb(mol) {
1956
+ let deferred1_0;
1957
+ let deferred1_1;
1958
+ try {
1959
+ _assertClass(mol, MolHandle);
1960
+ const ret = wasm.generate_3d_etkdg_minimized_pdb(mol.__wbg_ptr);
1961
+ deferred1_0 = ret[0];
1962
+ deferred1_1 = ret[1];
1963
+ return getStringFromWasm0(ret[0], ret[1]);
1964
+ } finally {
1965
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1966
+ }
1967
+ }
1968
+
1969
+ /**
1970
+ * Generate 3D coordinates using ETKDG (torsion angle preferences) and return PDB block.
1971
+ * ETKDG produces higher-quality conformations than rule-based DG by applying
1972
+ * experimental torsion angle preferences to common structural patterns.
1973
+ * @param {MolHandle} mol
1974
+ * @returns {string}
1975
+ */
1976
+ export function generate_3d_etkdg_pdb(mol) {
1977
+ let deferred1_0;
1978
+ let deferred1_1;
1979
+ try {
1980
+ _assertClass(mol, MolHandle);
1981
+ const ret = wasm.generate_3d_etkdg_pdb(mol.__wbg_ptr);
1982
+ deferred1_0 = ret[0];
1983
+ deferred1_1 = ret[1];
1984
+ return getStringFromWasm0(ret[0], ret[1]);
1985
+ } finally {
1986
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1987
+ }
1988
+ }
1989
+
1990
+ /**
1991
+ * Generate 3D coordinates from SMILES (raw distance geometry, no minimization).
1992
+ * Returns PDB format string with atoms positioned in 3D space.
1993
+ *
1994
+ * # Example (JS)
1995
+ * ```javascript
1996
+ * const pdbStr = module.generate_3d_from_smiles("c1ccccc1");
1997
+ * console.log(pdbStr); // PDB file content
1998
+ * ```
1999
+ * @param {string} smiles
2000
+ * @returns {string}
2001
+ */
2002
+ export function generate_3d_from_smiles(smiles) {
2003
+ let deferred3_0;
2004
+ let deferred3_1;
2005
+ try {
2006
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2007
+ const len0 = WASM_VECTOR_LEN;
2008
+ const ret = wasm.generate_3d_from_smiles(ptr0, len0);
2009
+ var ptr2 = ret[0];
2010
+ var len2 = ret[1];
2011
+ if (ret[3]) {
2012
+ ptr2 = 0; len2 = 0;
2013
+ throw takeFromExternrefTable0(ret[2]);
2014
+ }
2015
+ deferred3_0 = ptr2;
2016
+ deferred3_1 = len2;
2017
+ return getStringFromWasm0(ptr2, len2);
2018
+ } finally {
2019
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2020
+ }
2021
+ }
2022
+
2023
+ /**
2024
+ * Generate energy-minimized 3D coordinates and return a PDB string.
2025
+ *
2026
+ * Runs distance-geometry placement followed by gradient-descent force-field
2027
+ * minimization. Geometry quality is better than `generate_3d_pdb` for
2028
+ * flexible molecules; the force field is approximate (not MMFF94/UFF).
2029
+ * @param {MolHandle} mol
2030
+ * @returns {string}
2031
+ */
2032
+ export function generate_3d_minimized_pdb(mol) {
2033
+ let deferred1_0;
2034
+ let deferred1_1;
2035
+ try {
2036
+ _assertClass(mol, MolHandle);
2037
+ const ret = wasm.generate_3d_minimized_pdb(mol.__wbg_ptr);
2038
+ deferred1_0 = ret[0];
2039
+ deferred1_1 = ret[1];
2040
+ return getStringFromWasm0(ret[0], ret[1]);
2041
+ } finally {
2042
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2043
+ }
2044
+ }
2045
+
2046
+ /**
2047
+ * Generate 3D coordinates and minimize from SMILES string.
2048
+ * Pipeline: distance geometry → DREIDING minimization.
2049
+ * Better geometry quality than raw DG; suitable for graphics.
2050
+ *
2051
+ * # Example (JS)
2052
+ * ```javascript
2053
+ * const pdbStr = module.generate_3d_optimized_pdb("c1ccccc1");
2054
+ * console.log(pdbStr); // PDB file with optimized geometry
2055
+ * ```
2056
+ * @param {string} smiles
2057
+ * @returns {string}
2058
+ */
2059
+ export function generate_3d_optimized_pdb(smiles) {
2060
+ let deferred3_0;
2061
+ let deferred3_1;
2062
+ try {
2063
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2064
+ const len0 = WASM_VECTOR_LEN;
2065
+ const ret = wasm.generate_3d_optimized_pdb(ptr0, len0);
2066
+ var ptr2 = ret[0];
2067
+ var len2 = ret[1];
2068
+ if (ret[3]) {
2069
+ ptr2 = 0; len2 = 0;
2070
+ throw takeFromExternrefTable0(ret[2]);
2071
+ }
2072
+ deferred3_0 = ptr2;
2073
+ deferred3_1 = len2;
2074
+ return getStringFromWasm0(ptr2, len2);
2075
+ } finally {
2076
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2077
+ }
2078
+ }
2079
+
2080
+ /**
2081
+ * Generate 3D coordinates for the molecule and return a PDB string.
2082
+ *
2083
+ * Coordinates are generated using distance-geometry placement with ring templates.
2084
+ * Returns heavy-atom PDB (HETATM records, no explicit H).
2085
+ * @param {MolHandle} mol
2086
+ * @returns {string}
2087
+ */
2088
+ export function generate_3d_pdb(mol) {
2089
+ let deferred1_0;
2090
+ let deferred1_1;
2091
+ try {
2092
+ _assertClass(mol, MolHandle);
2093
+ const ret = wasm.generate_3d_pdb(mol.__wbg_ptr);
2094
+ deferred1_0 = ret[0];
2095
+ deferred1_1 = ret[1];
2096
+ return getStringFromWasm0(ret[0], ret[1]);
2097
+ } finally {
2098
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2099
+ }
2100
+ }
2101
+
2102
+ /**
2103
+ * Generic (atom-type-erased) Murcko scaffold of `mol`.
2104
+ *
2105
+ * All atoms become carbon and all bonds become single bonds, giving the pure
2106
+ * graph topology of the scaffold.
2107
+ * @param {MolHandle} mol
2108
+ * @returns {MolHandle}
2109
+ */
2110
+ export function generic_murcko_scaffold(mol) {
2111
+ _assertClass(mol, MolHandle);
2112
+ const ret = wasm.generic_murcko_scaffold(mol.__wbg_ptr);
2113
+ return MolHandle.__wrap(ret);
2114
+ }
2115
+
2116
+ /**
2117
+ * Return information about a single atom as a JSON object.
2118
+ *
2119
+ * `idx` is the 0-based atom index (matching `atoms()` order).
2120
+ * Returns `"null"` if `idx` is out of range.
2121
+ *
2122
+ * Fields: `element` (symbol), `hybridization` ("sp"/"sp2"/"sp3"),
2123
+ * `charge` (formal charge integer), `isAromatic` (bool),
2124
+ * `totalHydrogens` (explicit + implicit H count, integer).
2125
+ * sp3d/sp3d2 (hypervalent P/S) are not distinguished from sp3/sp2.
2126
+ * @param {MolHandle} mol
2127
+ * @param {number} idx
2128
+ * @returns {string}
2129
+ */
2130
+ export function get_atom_info(mol, idx) {
2131
+ let deferred1_0;
2132
+ let deferred1_1;
2133
+ try {
2134
+ _assertClass(mol, MolHandle);
2135
+ const ret = wasm.get_atom_info(mol.__wbg_ptr, idx);
2136
+ deferred1_0 = ret[0];
2137
+ deferred1_1 = ret[1];
2138
+ return getStringFromWasm0(ret[0], ret[1]);
2139
+ } finally {
2140
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2141
+ }
2142
+ }
2143
+
2144
+ /**
2145
+ * Return bond information as a JSON object, looked up by the two bonded atom indices.
2146
+ *
2147
+ * Useful when you know the atom indices from SMARTS matching or `data-atom-idx` SVG
2148
+ * attributes but not the bond index. Returns `"null"` if no bond exists between them.
2149
+ *
2150
+ * Fields: same as `get_bond_info` plus `bondIdx` (u32).
2151
+ * @param {MolHandle} mol
2152
+ * @param {number} atom1
2153
+ * @param {number} atom2
2154
+ * @returns {string}
2155
+ */
2156
+ export function get_bond_between(mol, atom1, atom2) {
2157
+ let deferred1_0;
2158
+ let deferred1_1;
2159
+ try {
2160
+ _assertClass(mol, MolHandle);
2161
+ const ret = wasm.get_bond_between(mol.__wbg_ptr, atom1, atom2);
2162
+ deferred1_0 = ret[0];
2163
+ deferred1_1 = ret[1];
2164
+ return getStringFromWasm0(ret[0], ret[1]);
2165
+ } finally {
2166
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2167
+ }
2168
+ }
2169
+
2170
+ /**
2171
+ * Return bond information as a JSON object, looked up by bond index.
2172
+ *
2173
+ * `idx` is the 0-based bond index (order matches `mol.bonds()` iteration).
2174
+ * Returns `"null"` if `idx` is out of range.
2175
+ *
2176
+ * Fields: `bondOrder` (1.0/1.5/2.0/3.0), `isAromatic` (bool),
2177
+ * `isInRing` (bool), `atomFrom` (u32), `atomTo` (u32).
2178
+ * @param {MolHandle} mol
2179
+ * @param {number} idx
2180
+ * @returns {string}
2181
+ */
2182
+ export function get_bond_info(mol, idx) {
2183
+ let deferred1_0;
2184
+ let deferred1_1;
2185
+ try {
2186
+ _assertClass(mol, MolHandle);
2187
+ const ret = wasm.get_bond_info(mol.__wbg_ptr, idx);
2188
+ deferred1_0 = ret[0];
2189
+ deferred1_1 = ret[1];
2190
+ return getStringFromWasm0(ret[0], ret[1]);
2191
+ } finally {
2192
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2193
+ }
2194
+ }
2195
+
2196
+ /**
2197
+ * Get bond length in Ångströms between two atoms from a SMILES string.
2198
+ * Returns -1.0 if parsing fails or atom indices are out of range.
2199
+ *
2200
+ * # Arguments
2201
+ * - `smiles`: SMILES string
2202
+ * - `a`: first atom index
2203
+ * - `b`: second atom index
2204
+ *
2205
+ * # Example
2206
+ * ```javascript
2207
+ * const len = get_bond_length_json("CC", 0, 1); // C-C single bond ≈ 1.54 Å
2208
+ * ```
2209
+ * @param {string} smiles
2210
+ * @param {number} a
2211
+ * @param {number} b
2212
+ * @returns {number}
2213
+ */
2214
+ export function get_bond_length_json(smiles, a, b) {
2215
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2216
+ const len0 = WASM_VECTOR_LEN;
2217
+ const ret = wasm.get_bond_length_json(ptr0, len0, a, b);
2218
+ return ret;
2219
+ }
2220
+
2221
+ /**
2222
+ * All scalar molecular descriptors as a single JSON object.
2223
+ *
2224
+ * Keys use camelCase and match the individual `MolHandle` method names.
2225
+ * Drug-likeness rule outcomes are included as boolean fields.
2226
+ * @param {MolHandle} mol
2227
+ * @returns {string}
2228
+ */
2229
+ export function get_descriptors_json(mol) {
2230
+ let deferred1_0;
2231
+ let deferred1_1;
2232
+ try {
2233
+ _assertClass(mol, MolHandle);
2234
+ const ret = wasm.get_descriptors_json(mol.__wbg_ptr);
2235
+ deferred1_0 = ret[0];
2236
+ deferred1_1 = ret[1];
2237
+ return getStringFromWasm0(ret[0], ret[1]);
2238
+ } finally {
2239
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2240
+ }
2241
+ }
2242
+
2243
+ /**
2244
+ * Get dihedral angle A—B—C—D in degrees from a SMILES string.
2245
+ * Returns null (JSON null) if any atom index is out of range or atoms are collinear.
2246
+ *
2247
+ * # Arguments
2248
+ * - `smiles`: SMILES string
2249
+ * - `a`, `b`, `c`, `d`: atom indices
2250
+ *
2251
+ * # Example
2252
+ * ```javascript
2253
+ * const dihedral = get_dihedral_json("CCCC", 0, 1, 2, 3); // A-B-C-D
2254
+ * ```
2255
+ * @param {string} smiles
2256
+ * @param {number} a
2257
+ * @param {number} b
2258
+ * @param {number} c
2259
+ * @param {number} d
2260
+ * @returns {any}
2261
+ */
2262
+ export function get_dihedral_json(smiles, a, b, c, d) {
2263
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2264
+ const len0 = WASM_VECTOR_LEN;
2265
+ const ret = wasm.get_dihedral_json(ptr0, len0, a, b, c, d);
2266
+ return ret;
2267
+ }
2268
+
2269
+ /**
2270
+ * Compute GETAWAY descriptors (GEometric, Topologic And wAveleT descriptors) from 3D coordinates.
2271
+ * Returns JSON array of 9 values: [G1, G2, G3, D1, D2, D3, T, V, A]
2272
+ * where G* = geometric autocorrelations (lag-1,2,3), D* = topologic distances,
2273
+ * T = total pairwise distance, V = bounding-box volume, A = anisotropy ratio.
2274
+ * @param {MolHandle} mol
2275
+ * @returns {string}
2276
+ */
2277
+ export function getaway_descriptors_json(mol) {
2278
+ let deferred1_0;
2279
+ let deferred1_1;
2280
+ try {
2281
+ _assertClass(mol, MolHandle);
2282
+ const ret = wasm.getaway_descriptors_json(mol.__wbg_ptr);
2283
+ deferred1_0 = ret[0];
2284
+ deferred1_1 = ret[1];
2285
+ return getStringFromWasm0(ret[0], ret[1]);
2286
+ } finally {
2287
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2288
+ }
2289
+ }
2290
+
2291
+ /**
2292
+ * Identify functional groups. Returns a JSON array of objects:
2293
+ * `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
2294
+ * @param {MolHandle} mol
2295
+ * @returns {string}
2296
+ */
2297
+ export function identify_functional_groups(mol) {
2298
+ let deferred1_0;
2299
+ let deferred1_1;
2300
+ try {
2301
+ _assertClass(mol, MolHandle);
2302
+ const ret = wasm.identify_functional_groups(mol.__wbg_ptr);
2303
+ deferred1_0 = ret[0];
2304
+ deferred1_1 = ret[1];
2305
+ return getStringFromWasm0(ret[0], ret[1]);
2306
+ } finally {
2307
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2308
+ }
2309
+ }
2310
+
2311
+ /**
2312
+ * Generate InChI string from SMILES.
2313
+ *
2314
+ * Returns `"error:<msg>"` on parse failure.
2315
+ * @param {string} smiles
2316
+ * @returns {string}
2317
+ */
2318
+ export function inchi_from_smiles(smiles) {
2319
+ let deferred2_0;
2320
+ let deferred2_1;
2321
+ try {
2322
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2323
+ const len0 = WASM_VECTOR_LEN;
2324
+ const ret = wasm.inchi_from_smiles(ptr0, len0);
2325
+ deferred2_0 = ret[0];
2326
+ deferred2_1 = ret[1];
2327
+ return getStringFromWasm0(ret[0], ret[1]);
2328
+ } finally {
2329
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2330
+ }
2331
+ }
2332
+
2333
+ /**
2334
+ * Generate InChIKey from SMILES (27-character identifier).
2335
+ *
2336
+ * Returns `"error:<msg>"` on parse failure.
2337
+ * @param {string} smiles
2338
+ * @returns {string}
2339
+ */
2340
+ export function inchikey_from_smiles(smiles) {
2341
+ let deferred2_0;
2342
+ let deferred2_1;
2343
+ try {
2344
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2345
+ const len0 = WASM_VECTOR_LEN;
2346
+ const ret = wasm.inchikey_from_smiles(ptr0, len0);
2347
+ deferred2_0 = ret[0];
2348
+ deferred2_1 = ret[1];
2349
+ return getStringFromWasm0(ret[0], ret[1]);
2350
+ } finally {
2351
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2352
+ }
2353
+ }
2354
+
2355
+ /**
2356
+ * Invert the stereochemistry of a tetrahedral stereocenter (U/D wedge bonds).
2357
+ *
2358
+ * If the atom has no wedge/dash bonds, returns an unchanged copy.
2359
+ * Returns error if atom_idx is invalid.
2360
+ * @param {MolHandle} mol
2361
+ * @param {number} atom_idx
2362
+ * @returns {MolHandle}
2363
+ */
2364
+ export function invert_stereocenter_at(mol, atom_idx) {
2365
+ _assertClass(mol, MolHandle);
2366
+ const ret = wasm.invert_stereocenter_at(mol.__wbg_ptr, atom_idx);
2367
+ if (ret[2]) {
2368
+ throw takeFromExternrefTable0(ret[1]);
2369
+ }
2370
+ return MolHandle.__wrap(ret[0]);
2371
+ }
2372
+
2373
+ /**
2374
+ * Returns `true` if the SMILES string can be parsed without error.
2375
+ * @param {string} s
2376
+ * @returns {boolean}
2377
+ */
2378
+ export function is_valid_smiles(s) {
2379
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2380
+ const len0 = WASM_VECTOR_LEN;
2381
+ const ret = wasm.is_valid_smiles(ptr0, len0);
2382
+ return ret !== 0;
2383
+ }
2384
+
2385
+ /**
2386
+ * Per-atom Labute approximate surface area contributions as a JSON array of f64.
2387
+ *
2388
+ * Non-finite values (single-atom molecules etc.) are emitted as JSON `null`.
2389
+ * @param {MolHandle} mol
2390
+ * @returns {string}
2391
+ */
2392
+ export function labute_asa_per_atom_json(mol) {
2393
+ let deferred1_0;
2394
+ let deferred1_1;
2395
+ try {
2396
+ _assertClass(mol, MolHandle);
2397
+ const ret = wasm.labute_asa_per_atom_json(mol.__wbg_ptr);
2398
+ deferred1_0 = ret[0];
2399
+ deferred1_1 = ret[1];
2400
+ return getStringFromWasm0(ret[0], ret[1]);
2401
+ } finally {
2402
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2403
+ }
2404
+ }
2405
+
2406
+ /**
2407
+ * Return the largest fragment of `mol` (salt/solvent stripping).
2408
+ *
2409
+ * For single-component molecules returns a copy of the same molecule.
2410
+ * @param {MolHandle} mol
2411
+ * @returns {MolHandle}
2412
+ */
2413
+ export function largest_fragment(mol) {
2414
+ _assertClass(mol, MolHandle);
2415
+ const ret = wasm.largest_fragment(mol.__wbg_ptr);
2416
+ return MolHandle.__wrap(ret);
2417
+ }
2418
+
2419
+ /**
2420
+ * Per-atom Crippen LogP contributions as a JSON array of f64.
2421
+ *
2422
+ * Index `i` corresponds to atom `i` in `mol.atoms()` order.
2423
+ * @param {MolHandle} mol
2424
+ * @returns {string}
2425
+ */
2426
+ export function logp_per_atom_json(mol) {
2427
+ let deferred1_0;
2428
+ let deferred1_1;
2429
+ try {
2430
+ _assertClass(mol, MolHandle);
2431
+ const ret = wasm.logp_per_atom_json(mol.__wbg_ptr);
2432
+ deferred1_0 = ret[0];
2433
+ deferred1_1 = ret[1];
2434
+ return getStringFromWasm0(ret[0], ret[1]);
2435
+ } finally {
2436
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2437
+ }
2438
+ }
2439
+
2440
+ /**
2441
+ * MACCS 166-bit structural keys fingerprint as a byte array (21 bytes, LSB-first).
2442
+ *
2443
+ * Bit `i` (0-indexed) corresponds to MACCS key `i+1`.
2444
+ * @param {MolHandle} mol
2445
+ * @returns {Uint8Array}
2446
+ */
2447
+ export function maccs_bitvec(mol) {
2448
+ _assertClass(mol, MolHandle);
2449
+ const ret = wasm.maccs_bitvec(mol.__wbg_ptr);
2450
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2451
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2452
+ return v1;
2453
+ }
2454
+
2455
+ /**
2456
+ * Find all SMARTS matches in a molecule given only SMILES strings.
2457
+ *
2458
+ * Convenience wrapper around `smarts_match_atoms` that accepts raw SMILES
2459
+ * instead of a `MolHandle`. Returns the same JSON format: `[[0,1],[3,4]]`.
2460
+ * Returns a JS error on SMILES or SMARTS parse failure.
2461
+ * @param {string} smiles
2462
+ * @param {string} smarts
2463
+ * @returns {string}
2464
+ */
2465
+ export function match_smarts_smiles(smiles, smarts) {
2466
+ let deferred4_0;
2467
+ let deferred4_1;
2468
+ try {
2469
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2470
+ const len0 = WASM_VECTOR_LEN;
2471
+ const ptr1 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2472
+ const len1 = WASM_VECTOR_LEN;
2473
+ const ret = wasm.match_smarts_smiles(ptr0, len0, ptr1, len1);
2474
+ var ptr3 = ret[0];
2475
+ var len3 = ret[1];
2476
+ if (ret[3]) {
2477
+ ptr3 = 0; len3 = 0;
2478
+ throw takeFromExternrefTable0(ret[2]);
2479
+ }
2480
+ deferred4_0 = ptr3;
2481
+ deferred4_1 = len3;
2482
+ return getStringFromWasm0(ptr3, len3);
2483
+ } finally {
2484
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2485
+ }
2486
+ }
2487
+
2488
+ /**
2489
+ * Select `n` maximally-diverse molecules (MaxMin algorithm, ECFP4 Tanimoto).
2490
+ *
2491
+ * `smiles_json` — a JSON array of SMILES strings, e.g. `["CC","c1ccccc1","CCO"]`.
2492
+ * Returns a JSON array of 0-based indices into the input array.
2493
+ * Returns a JS error if any SMILES fails to parse (indices would otherwise shift).
2494
+ * @param {string} smiles_json
2495
+ * @param {number} n
2496
+ * @returns {string}
2497
+ */
2498
+ export function maxmin_picks_ecfp4_json(smiles_json, n) {
2499
+ let deferred3_0;
2500
+ let deferred3_1;
2501
+ try {
2502
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2503
+ const len0 = WASM_VECTOR_LEN;
2504
+ const ret = wasm.maxmin_picks_ecfp4_json(ptr0, len0, n);
2505
+ var ptr2 = ret[0];
2506
+ var len2 = ret[1];
2507
+ if (ret[3]) {
2508
+ ptr2 = 0; len2 = 0;
2509
+ throw takeFromExternrefTable0(ret[2]);
2510
+ }
2511
+ deferred3_0 = ptr2;
2512
+ deferred3_1 = len2;
2513
+ return getStringFromWasm0(ptr2, len2);
2514
+ } finally {
2515
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2516
+ }
2517
+ }
2518
+
2519
+ /**
2520
+ * Maximum Common Substructure of a set of molecules, returned as a canonical SMILES string.
2521
+ *
2522
+ * `smiles_json` — a JSON array of at least 2 SMILES strings.
2523
+ * Returns the MCS SMILES, or `"null"` when no common substructure was found.
2524
+ * Returns a JS error on SMILES parse failure.
2525
+ * @param {string} smiles_json
2526
+ * @returns {string}
2527
+ */
2528
+ export function mcs_smiles_json(smiles_json) {
2529
+ let deferred3_0;
2530
+ let deferred3_1;
2531
+ try {
2532
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2533
+ const len0 = WASM_VECTOR_LEN;
2534
+ const ret = wasm.mcs_smiles_json(ptr0, len0);
2535
+ var ptr2 = ret[0];
2536
+ var len2 = ret[1];
2537
+ if (ret[3]) {
2538
+ ptr2 = 0; len2 = 0;
2539
+ throw takeFromExternrefTable0(ret[2]);
2540
+ }
2541
+ deferred3_0 = ptr2;
2542
+ deferred3_1 = len2;
2543
+ return getStringFromWasm0(ptr2, len2);
2544
+ } finally {
2545
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2546
+ }
2547
+ }
2548
+
2549
+ /**
2550
+ * MinHash fingerprint (128 hashes) as JSON.
2551
+ *
2552
+ * Returns `{"num_hashes":128,"hashes":[u64,...]}`.
2553
+ * Use `tanimoto_mhfp_smiles` for direct SMILES-to-SMILES similarity.
2554
+ * @param {MolHandle} mol
2555
+ * @returns {string}
2556
+ */
2557
+ export function mhfp_hashes_json(mol) {
2558
+ let deferred1_0;
2559
+ let deferred1_1;
2560
+ try {
2561
+ _assertClass(mol, MolHandle);
2562
+ const ret = wasm.mhfp_hashes_json(mol.__wbg_ptr);
2563
+ deferred1_0 = ret[0];
2564
+ deferred1_1 = ret[1];
2565
+ return getStringFromWasm0(ret[0], ret[1]);
2566
+ } finally {
2567
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2568
+ }
2569
+ }
2570
+
2571
+ /**
2572
+ * Optimize molecular geometry using DREIDING force field.
2573
+ *
2574
+ * Performs geometry minimization with DREIDING force field parameters.
2575
+ * Returns minimized coordinate PDB.
2576
+ *
2577
+ * # Arguments
2578
+ * * `mol` - Molecule to optimize
2579
+ *
2580
+ * # Returns
2581
+ * PDB format string with optimized coordinates
2582
+ * @param {MolHandle} mol
2583
+ * @returns {string}
2584
+ */
2585
+ export function minimize_dreiding_json(mol) {
2586
+ let deferred1_0;
2587
+ let deferred1_1;
2588
+ try {
2589
+ _assertClass(mol, MolHandle);
2590
+ const ret = wasm.minimize_dreiding_json(mol.__wbg_ptr);
2591
+ deferred1_0 = ret[0];
2592
+ deferred1_1 = ret[1];
2593
+ return getStringFromWasm0(ret[0], ret[1]);
2594
+ } finally {
2595
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2596
+ }
2597
+ }
2598
+
2599
+ /**
2600
+ * Minimize geometry using MMFF94 steepest descent (Halgren 1996 full parameters).
2601
+ * Generates 3D coords internally if needed.
2602
+ * Returns JSON: {"energy":E,"rmsd":R,"converged":true,"iterations":N} or {"error":"..."}.
2603
+ * @param {MolHandle} mol
2604
+ * @param {number} max_iter
2605
+ * @returns {string}
2606
+ */
2607
+ export function minimize_mmff94_json(mol, max_iter) {
2608
+ let deferred1_0;
2609
+ let deferred1_1;
2610
+ try {
2611
+ _assertClass(mol, MolHandle);
2612
+ const ret = wasm.minimize_mmff94_json(mol.__wbg_ptr, max_iter);
2613
+ deferred1_0 = ret[0];
2614
+ deferred1_1 = ret[1];
2615
+ return getStringFromWasm0(ret[0], ret[1]);
2616
+ } finally {
2617
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2618
+ }
2619
+ }
2620
+
2621
+ /**
2622
+ * Minimize geometry using MMFF94 L-BFGS (faster convergence than steepest descent).
2623
+ * Returns JSON: {"energy":E,"rmsd":R,"converged":true,"iterations":N} or {"error":"..."}.
2624
+ * @param {MolHandle} mol
2625
+ * @param {number} max_iter
2626
+ * @returns {string}
2627
+ */
2628
+ export function minimize_mmff94_lbfgs_json(mol, max_iter) {
2629
+ let deferred1_0;
2630
+ let deferred1_1;
2631
+ try {
2632
+ _assertClass(mol, MolHandle);
2633
+ const ret = wasm.minimize_mmff94_lbfgs_json(mol.__wbg_ptr, max_iter);
2634
+ deferred1_0 = ret[0];
2635
+ deferred1_1 = ret[1];
2636
+ return getStringFromWasm0(ret[0], ret[1]);
2637
+ } finally {
2638
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2639
+ }
2640
+ }
2641
+
2642
+ /**
2643
+ * MMFF94 partial charges (BCI table, ±0.1e accuracy) as a JSON array of f64.
2644
+ *
2645
+ * Uses Bond Charge Increment (BCI) model (Halgren 1996) for 25 common bond types.
2646
+ * Returns `[q0, q1, ..., qN]` — one value per heavy atom.
2647
+ * Total charge equals the sum of formal charges (charge conserved).
2648
+ * @param {MolHandle} mol
2649
+ * @returns {string}
2650
+ */
2651
+ export function mmff94_charges_json(mol) {
2652
+ let deferred1_0;
2653
+ let deferred1_1;
2654
+ try {
2655
+ _assertClass(mol, MolHandle);
2656
+ const ret = wasm.mmff94_charges_json(mol.__wbg_ptr);
2657
+ deferred1_0 = ret[0];
2658
+ deferred1_1 = ret[1];
2659
+ return getStringFromWasm0(ret[0], ret[1]);
2660
+ } finally {
2661
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2662
+ }
2663
+ }
2664
+
2665
+ /**
2666
+ * Compute MMFF94-style atom-typed partial charges (improved over element-pair BCI).
2667
+ * Returns JSON: {"charges":[f64,...]} or {"error":"..."}.
2668
+ * Uses atom-type classification (Csp3/Ccarbonyl/Ohydroxyl/Oester/Nar/NarH etc.)
2669
+ * for better accuracy (~±0.02e) vs element-pair BCI (~±0.05e).
2670
+ * @param {MolHandle} mol
2671
+ * @returns {string}
2672
+ */
2673
+ export function mmff94_charges_typed_json(mol) {
2674
+ let deferred1_0;
2675
+ let deferred1_1;
2676
+ try {
2677
+ _assertClass(mol, MolHandle);
2678
+ const ret = wasm.mmff94_charges_typed_json(mol.__wbg_ptr);
2679
+ deferred1_0 = ret[0];
2680
+ deferred1_1 = ret[1];
2681
+ return getStringFromWasm0(ret[0], ret[1]);
2682
+ } finally {
2683
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2684
+ }
2685
+ }
2686
+
2687
+ /**
2688
+ * Compute MMFF94 energy breakdown for current rule-based 3D geometry.
2689
+ * Returns JSON: {"bond":B,"angle":A,"torsion":T,"vdw":V,"elec":E,"total":X} or {"error":"..."}.
2690
+ * @param {MolHandle} mol
2691
+ * @returns {string}
2692
+ */
2693
+ export function mmff94_energy_breakdown_json(mol) {
2694
+ let deferred1_0;
2695
+ let deferred1_1;
2696
+ try {
2697
+ _assertClass(mol, MolHandle);
2698
+ const ret = wasm.mmff94_energy_breakdown_json(mol.__wbg_ptr);
2699
+ deferred1_0 = ret[0];
2700
+ deferred1_1 = ret[1];
2701
+ return getStringFromWasm0(ret[0], ret[1]);
2702
+ } finally {
2703
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2704
+ }
2705
+ }
2706
+
2707
+ /**
2708
+ * Compute MMFF94 partial charges using numeric atom types (Halgren 1996 eq. 15).
2709
+ * Returns JSON: {"charges":[-0.28,0.15,...]} or {"error":"..."}.
2710
+ * @param {MolHandle} mol
2711
+ * @returns {string}
2712
+ */
2713
+ export function mmff94_partial_charges_json(mol) {
2714
+ let deferred1_0;
2715
+ let deferred1_1;
2716
+ try {
2717
+ _assertClass(mol, MolHandle);
2718
+ const ret = wasm.mmff94_partial_charges_json(mol.__wbg_ptr);
2719
+ deferred1_0 = ret[0];
2720
+ deferred1_1 = ret[1];
2721
+ return getStringFromWasm0(ret[0], ret[1]);
2722
+ } finally {
2723
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2724
+ }
2725
+ }
2726
+
2727
+ /**
2728
+ * Find matched molecular pairs in a set of molecules as JSON.
2729
+ *
2730
+ * `smiles_json` — JSON array of SMILES strings to analyze.
2731
+ *
2732
+ * Returns a JSON array of matched pairs:
2733
+ * ```json
2734
+ * [
2735
+ * {
2736
+ * "mol_a": "CC(=O)Oc1ccccc1",
2737
+ * "mol_b": "CC(=O)Nc1ccccc1",
2738
+ * "core": "c1ccccc1[*]",
2739
+ * "fragment_a": "[*]OC(C)=O",
2740
+ * "fragment_b": "[*]NC(C)=O"
2741
+ * }
2742
+ * ]
2743
+ * ```
2744
+ *
2745
+ * Each pair represents molecules that share a common core scaffold but differ
2746
+ * by exactly one structural fragment at a single BRICS-breakable bond cut.
2747
+ *
2748
+ * Returns a JS error if any SMILES fails to parse.
2749
+ * @param {string} smiles_json
2750
+ * @returns {string}
2751
+ */
2752
+ export function mmp_pairs_json(smiles_json) {
2753
+ let deferred3_0;
2754
+ let deferred3_1;
2755
+ try {
2756
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2757
+ const len0 = WASM_VECTOR_LEN;
2758
+ const ret = wasm.mmp_pairs_json(ptr0, len0);
2759
+ var ptr2 = ret[0];
2760
+ var len2 = ret[1];
2761
+ if (ret[3]) {
2762
+ ptr2 = 0; len2 = 0;
2763
+ throw takeFromExternrefTable0(ret[2]);
2764
+ }
2765
+ deferred3_0 = ptr2;
2766
+ deferred3_1 = len2;
2767
+ return getStringFromWasm0(ptr2, len2);
2768
+ } finally {
2769
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2770
+ }
2771
+ }
2772
+
2773
+ /**
2774
+ * Parse a Tripos MOL2 string and return SMILES.
2775
+ *
2776
+ * Returns `"error:<msg>"` on failure.
2777
+ * @param {string} mol2_str
2778
+ * @returns {string}
2779
+ */
2780
+ export function mol2_to_smiles(mol2_str) {
2781
+ let deferred2_0;
2782
+ let deferred2_1;
2783
+ try {
2784
+ const ptr0 = passStringToWasm0(mol2_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2785
+ const len0 = WASM_VECTOR_LEN;
2786
+ const ret = wasm.mol2_to_smiles(ptr0, len0);
2787
+ deferred2_0 = ret[0];
2788
+ deferred2_1 = ret[1];
2789
+ return getStringFromWasm0(ret[0], ret[1]);
2790
+ } finally {
2791
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2792
+ }
2793
+ }
2794
+
2795
+ /**
2796
+ * Parse a MOL V2000 string and return 2D coordinates as a JSON array.
2797
+ *
2798
+ * Returns `[[x0,y0],[x1,y1],...]` in atom-insertion order.
2799
+ * Coordinates are in Ångström as stored in the MOL file.
2800
+ * @param {string} mol_block
2801
+ * @returns {string}
2802
+ */
2803
+ export function mol_block_coords_json(mol_block) {
2804
+ let deferred3_0;
2805
+ let deferred3_1;
2806
+ try {
2807
+ const ptr0 = passStringToWasm0(mol_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2808
+ const len0 = WASM_VECTOR_LEN;
2809
+ const ret = wasm.mol_block_coords_json(ptr0, len0);
2810
+ var ptr2 = ret[0];
2811
+ var len2 = ret[1];
2812
+ if (ret[3]) {
2813
+ ptr2 = 0; len2 = 0;
2814
+ throw takeFromExternrefTable0(ret[2]);
2815
+ }
2816
+ deferred3_0 = ptr2;
2817
+ deferred3_1 = len2;
2818
+ return getStringFromWasm0(ptr2, len2);
2819
+ } finally {
2820
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2821
+ }
2822
+ }
2823
+
2824
+ /**
2825
+ * Serialize a SMILES string directly to a MOL V2000 block with 2D coordinates.
2826
+ *
2827
+ * Returns a JS error on SMILES parse failure.
2828
+ * @param {string} smiles
2829
+ * @returns {string}
2830
+ */
2831
+ export function mol_block_from_smiles(smiles) {
2832
+ let deferred3_0;
2833
+ let deferred3_1;
2834
+ try {
2835
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2836
+ const len0 = WASM_VECTOR_LEN;
2837
+ const ret = wasm.mol_block_from_smiles(ptr0, len0);
2838
+ var ptr2 = ret[0];
2839
+ var len2 = ret[1];
2840
+ if (ret[3]) {
2841
+ ptr2 = 0; len2 = 0;
2842
+ throw takeFromExternrefTable0(ret[2]);
2843
+ }
2844
+ deferred3_0 = ptr2;
2845
+ deferred3_1 = len2;
2846
+ return getStringFromWasm0(ptr2, len2);
2847
+ } finally {
2848
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2849
+ }
2850
+ }
2851
+
2852
+ /**
2853
+ * Parse a ChemDraw XML (CDXML) string into a `MolHandle`.
2854
+ *
2855
+ * Only the first molecular fragment in the document is returned.
2856
+ * Returns a JS error if the document cannot be parsed.
2857
+ * @param {string} cdxml
2858
+ * @returns {MolHandle}
2859
+ */
2860
+ export function mol_from_cdxml(cdxml) {
2861
+ const ptr0 = passStringToWasm0(cdxml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2862
+ const len0 = WASM_VECTOR_LEN;
2863
+ const ret = wasm.mol_from_cdxml(ptr0, len0);
2864
+ if (ret[2]) {
2865
+ throw takeFromExternrefTable0(ret[1]);
2866
+ }
2867
+ return MolHandle.__wrap(ret[0]);
2868
+ }
2869
+
2870
+ /**
2871
+ * Parse a CML string into a `MolHandle`.
2872
+ *
2873
+ * Returns a JS error if the CML is invalid (unknown element, bad bond, etc.).
2874
+ * @param {string} cml
2875
+ * @returns {MolHandle}
2876
+ */
2877
+ export function mol_from_cml(cml) {
2878
+ const ptr0 = passStringToWasm0(cml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2879
+ const len0 = WASM_VECTOR_LEN;
2880
+ const ret = wasm.mol_from_cml(ptr0, len0);
2881
+ if (ret[2]) {
2882
+ throw takeFromExternrefTable0(ret[1]);
2883
+ }
2884
+ return MolHandle.__wrap(ret[0]);
2885
+ }
2886
+
2887
+ /**
2888
+ * Parse a PDB file and return a `MolHandle` (topology only; coordinates are discarded).
2889
+ *
2890
+ * Uses CONECT records for connectivity if present; otherwise infers bonds from
2891
+ * atom distances (the same heuristic as the internal `pdb_to_molecule` function).
2892
+ * @param {string} pdb
2893
+ * @returns {MolHandle}
2894
+ */
2895
+ export function mol_from_pdb(pdb) {
2896
+ const ptr0 = passStringToWasm0(pdb, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2897
+ const len0 = WASM_VECTOR_LEN;
2898
+ const ret = wasm.mol_from_pdb(ptr0, len0);
2899
+ return MolHandle.__wrap(ret);
2900
+ }
2901
+
2902
+ /**
2903
+ * Parse a MOL V2000 block and return a `MolHandle`.
2904
+ *
2905
+ * Returns a JS error string on parse failure.
2906
+ * @param {string} block
2907
+ * @returns {MolHandle}
2908
+ */
2909
+ export function mol_from_sdf_block(block) {
2910
+ const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2911
+ const len0 = WASM_VECTOR_LEN;
2912
+ const ret = wasm.mol_from_sdf_block(ptr0, len0);
2913
+ if (ret[2]) {
2914
+ throw takeFromExternrefTable0(ret[1]);
2915
+ }
2916
+ return MolHandle.__wrap(ret[0]);
2917
+ }
2918
+
2919
+ /**
2920
+ * Parse a MOL V3000 block and return a `MolHandle`.
2921
+ *
2922
+ * Returns a JS error string on parse failure.
2923
+ * @param {string} block
2924
+ * @returns {MolHandle}
2925
+ */
2926
+ export function mol_from_v3000_block(block) {
2927
+ const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2928
+ const len0 = WASM_VECTOR_LEN;
2929
+ const ret = wasm.mol_from_v3000_block(ptr0, len0);
2930
+ if (ret[2]) {
2931
+ throw takeFromExternrefTable0(ret[1]);
2932
+ }
2933
+ return MolHandle.__wrap(ret[0]);
2934
+ }
2935
+
2936
+ /**
2937
+ * Parse an XYZ file and return a `MolHandle` (topology only; coordinates are discarded).
2938
+ *
2939
+ * Returns a JS error on parse failure.
2940
+ * @param {string} xyz
2941
+ * @returns {MolHandle}
2942
+ */
2943
+ export function mol_from_xyz(xyz) {
2944
+ const ptr0 = passStringToWasm0(xyz, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2945
+ const len0 = WASM_VECTOR_LEN;
2946
+ const ret = wasm.mol_from_xyz(ptr0, len0);
2947
+ if (ret[2]) {
2948
+ throw takeFromExternrefTable0(ret[1]);
2949
+ }
2950
+ return MolHandle.__wrap(ret[0]);
2951
+ }
2952
+
2953
+ /**
2954
+ * Return the index that would be assigned to an atom appended to `mol`.
2955
+ * @param {MolHandle} mol
2956
+ * @returns {number}
2957
+ */
2958
+ export function mol_next_atom_idx(mol) {
2959
+ _assertClass(mol, MolHandle);
2960
+ const ret = wasm.mol_next_atom_idx(mol.__wbg_ptr);
2961
+ return ret >>> 0;
2962
+ }
2963
+
2964
+ /**
2965
+ * Return a new `MolHandle` with one atom appended.
2966
+ *
2967
+ * The second return value is the new atom's index (as a JS number).
2968
+ * Use `with_atom_added_idx` to retrieve the index.
2969
+ * @param {MolHandle} mol
2970
+ * @param {string} element_symbol
2971
+ * @returns {MolHandle}
2972
+ */
2973
+ export function mol_with_atom_added(mol, element_symbol) {
2974
+ _assertClass(mol, MolHandle);
2975
+ const ptr0 = passStringToWasm0(element_symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2976
+ const len0 = WASM_VECTOR_LEN;
2977
+ const ret = wasm.mol_with_atom_added(mol.__wbg_ptr, ptr0, len0);
2978
+ if (ret[2]) {
2979
+ throw takeFromExternrefTable0(ret[1]);
2980
+ }
2981
+ return MolHandle.__wrap(ret[0]);
2982
+ }
2983
+
2984
+ /**
2985
+ * Return a new `MolHandle` with the formal charge of atom `idx` changed.
2986
+ *
2987
+ * Returns a JS error if `idx` is out of range.
2988
+ * @param {MolHandle} mol
2989
+ * @param {number} idx
2990
+ * @param {number} charge
2991
+ * @returns {MolHandle}
2992
+ */
2993
+ export function mol_with_atom_charge(mol, idx, charge) {
2994
+ _assertClass(mol, MolHandle);
2995
+ const ret = wasm.mol_with_atom_charge(mol.__wbg_ptr, idx, charge);
2996
+ if (ret[2]) {
2997
+ throw takeFromExternrefTable0(ret[1]);
2998
+ }
2999
+ return MolHandle.__wrap(ret[0]);
3000
+ }
3001
+
3002
+ /**
3003
+ * Return a new `MolHandle` with the element of atom `idx` changed.
3004
+ *
3005
+ * `element_symbol` — periodic-table symbol, e.g. `"N"`, `"O"`, `"Cl"`.
3006
+ * Returns a JS error if `idx` is out of range or the symbol is unknown.
3007
+ * @param {MolHandle} mol
3008
+ * @param {number} idx
3009
+ * @param {string} element_symbol
3010
+ * @returns {MolHandle}
3011
+ */
3012
+ export function mol_with_atom_element(mol, idx, element_symbol) {
3013
+ _assertClass(mol, MolHandle);
3014
+ const ptr0 = passStringToWasm0(element_symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3015
+ const len0 = WASM_VECTOR_LEN;
3016
+ const ret = wasm.mol_with_atom_element(mol.__wbg_ptr, idx, ptr0, len0);
3017
+ if (ret[2]) {
3018
+ throw takeFromExternrefTable0(ret[1]);
3019
+ }
3020
+ return MolHandle.__wrap(ret[0]);
3021
+ }
3022
+
3023
+ /**
3024
+ * Return a new `MolHandle` with atom `idx` and all its bonds removed.
3025
+ *
3026
+ * Atom indices above `idx` shift down by 1. Returns a JS error if `idx`
3027
+ * is out of range.
3028
+ * @param {MolHandle} mol
3029
+ * @param {number} idx
3030
+ * @returns {MolHandle}
3031
+ */
3032
+ export function mol_with_atom_removed(mol, idx) {
3033
+ _assertClass(mol, MolHandle);
3034
+ const ret = wasm.mol_with_atom_removed(mol.__wbg_ptr, idx);
3035
+ if (ret[2]) {
3036
+ throw takeFromExternrefTable0(ret[1]);
3037
+ }
3038
+ return MolHandle.__wrap(ret[0]);
3039
+ }
3040
+
3041
+ /**
3042
+ * Return a new `MolHandle` with one bond added between `a` and `b`.
3043
+ *
3044
+ * `order` — 1 = single, 2 = double, 3 = triple.
3045
+ * Returns a JS error if the bond already exists or `a == b`.
3046
+ * @param {MolHandle} mol
3047
+ * @param {number} a
3048
+ * @param {number} b
3049
+ * @param {number} order
3050
+ * @returns {MolHandle}
3051
+ */
3052
+ export function mol_with_bond_added(mol, a, b, order) {
3053
+ _assertClass(mol, MolHandle);
3054
+ const ret = wasm.mol_with_bond_added(mol.__wbg_ptr, a, b, order);
3055
+ if (ret[2]) {
3056
+ throw takeFromExternrefTable0(ret[1]);
3057
+ }
3058
+ return MolHandle.__wrap(ret[0]);
3059
+ }
3060
+
3061
+ /**
3062
+ * Return a new `MolHandle` with bond `idx` removed.
3063
+ *
3064
+ * Atom indices are unchanged; bond indices above `idx` shift down.
3065
+ * Returns a JS error if `idx` is out of range.
3066
+ * @param {MolHandle} mol
3067
+ * @param {number} idx
3068
+ * @returns {MolHandle}
3069
+ */
3070
+ export function mol_with_bond_removed(mol, idx) {
3071
+ _assertClass(mol, MolHandle);
3072
+ const ret = wasm.mol_with_bond_removed(mol.__wbg_ptr, idx);
3073
+ if (ret[2]) {
3074
+ throw takeFromExternrefTable0(ret[1]);
3075
+ }
3076
+ return MolHandle.__wrap(ret[0]);
3077
+ }
3078
+
3079
+ /**
3080
+ * Generate a complete molecular report (JSON string) from a SMILES.
3081
+ * Returns the JSON representation of a `MoleculeReport` struct.
3082
+ *
3083
+ * # Example (JS)
3084
+ * ```javascript
3085
+ * const json = module.molecule_report_json("CC(=O)Oc1ccccc1C(=O)O");
3086
+ * const report = JSON.parse(json);
3087
+ * console.log(report.canonical_smiles, report.descriptors.tpsa);
3088
+ * ```
3089
+ * @param {string} smiles
3090
+ * @returns {string}
3091
+ */
3092
+ export function molecule_report_json(smiles) {
3093
+ let deferred3_0;
3094
+ let deferred3_1;
3095
+ try {
3096
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3097
+ const len0 = WASM_VECTOR_LEN;
3098
+ const ret = wasm.molecule_report_json(ptr0, len0);
3099
+ var ptr2 = ret[0];
3100
+ var len2 = ret[1];
3101
+ if (ret[3]) {
3102
+ ptr2 = 0; len2 = 0;
3103
+ throw takeFromExternrefTable0(ret[2]);
3104
+ }
3105
+ deferred3_0 = ptr2;
3106
+ deferred3_1 = len2;
3107
+ return getStringFromWasm0(ptr2, len2);
3108
+ } finally {
3109
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3110
+ }
3111
+ }
3112
+
3113
+ /**
3114
+ * MQN descriptor (42 integer values: Molecular Quantum Numbers).
3115
+ * @param {MolHandle} mol
3116
+ * @returns {string}
3117
+ */
3118
+ export function mqn_json(mol) {
3119
+ let deferred1_0;
3120
+ let deferred1_1;
3121
+ try {
3122
+ _assertClass(mol, MolHandle);
3123
+ const ret = wasm.mqn_json(mol.__wbg_ptr);
3124
+ deferred1_0 = ret[0];
3125
+ deferred1_1 = ret[1];
3126
+ return getStringFromWasm0(ret[0], ret[1]);
3127
+ } finally {
3128
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3129
+ }
3130
+ }
3131
+
3132
+ /**
3133
+ * Per-atom molar refractivity contributions as a JSON array of f64.
3134
+ * @param {MolHandle} mol
3135
+ * @returns {string}
3136
+ */
3137
+ export function mr_per_atom_json(mol) {
3138
+ let deferred1_0;
3139
+ let deferred1_1;
3140
+ try {
3141
+ _assertClass(mol, MolHandle);
3142
+ const ret = wasm.mr_per_atom_json(mol.__wbg_ptr);
3143
+ deferred1_0 = ret[0];
3144
+ deferred1_1 = ret[1];
3145
+ return getStringFromWasm0(ret[0], ret[1]);
3146
+ } finally {
3147
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3148
+ }
3149
+ }
3150
+
3151
+ /**
3152
+ * Murcko scaffold of `mol` — the ring system plus linkers, side-chains removed.
3153
+ *
3154
+ * Returns a new `MolHandle`. For acyclic molecules returns an empty molecule.
3155
+ * @param {MolHandle} mol
3156
+ * @returns {MolHandle}
3157
+ */
3158
+ export function murcko_scaffold(mol) {
3159
+ _assertClass(mol, MolHandle);
3160
+ const ret = wasm.murcko_scaffold(mol.__wbg_ptr);
3161
+ return MolHandle.__wrap(ret);
3162
+ }
3163
+
3164
+ /**
3165
+ * Find the k nearest neighbours of a query SMILES in a list of db SMILES.
3166
+ *
3167
+ * `db_smiles_json`: JSON array of SMILES strings, e.g. `["CC","c1ccccc1"]`.
3168
+ * Returns JSON: `[{"index":0,"tanimoto":0.95},...]` sorted by descending Tanimoto.
3169
+ * Returns `"error:<msg>"` on parse failure.
3170
+ * @param {string} query_smiles
3171
+ * @param {string} db_smiles_json
3172
+ * @param {number} k
3173
+ * @returns {string}
3174
+ */
3175
+ export function nearest_neighbors_json(query_smiles, db_smiles_json, k) {
3176
+ let deferred3_0;
3177
+ let deferred3_1;
3178
+ try {
3179
+ const ptr0 = passStringToWasm0(query_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3180
+ const len0 = WASM_VECTOR_LEN;
3181
+ const ptr1 = passStringToWasm0(db_smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3182
+ const len1 = WASM_VECTOR_LEN;
3183
+ const ret = wasm.nearest_neighbors_json(ptr0, len0, ptr1, len1, k);
3184
+ deferred3_0 = ret[0];
3185
+ deferred3_1 = ret[1];
3186
+ return getStringFromWasm0(ret[0], ret[1]);
3187
+ } finally {
3188
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3189
+ }
3190
+ }
3191
+
3192
+ /**
3193
+ * Neutralize formal charges on `mol` by proton addition/removal.
3194
+ *
3195
+ * Returns a new `MolHandle` with all formal charges set to zero where possible.
3196
+ * @param {MolHandle} mol
3197
+ * @returns {MolHandle}
3198
+ */
3199
+ export function neutralize_charges(mol) {
3200
+ _assertClass(mol, MolHandle);
3201
+ const ret = wasm.neutralize_charges(mol.__wbg_ptr);
3202
+ return MolHandle.__wrap(ret);
3203
+ }
3204
+
3205
+ /**
3206
+ * Parse and re-serialize CXSMILES, preserving supported CX metadata.
3207
+ * Returns error if atom count exceeds 10,000.
3208
+ * @param {string} s
3209
+ * @returns {string}
3210
+ */
3211
+ export function normalize_cxsmiles(s) {
3212
+ let deferred3_0;
3213
+ let deferred3_1;
3214
+ try {
3215
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3216
+ const len0 = WASM_VECTOR_LEN;
3217
+ const ret = wasm.normalize_cxsmiles(ptr0, len0);
3218
+ var ptr2 = ret[0];
3219
+ var len2 = ret[1];
3220
+ if (ret[3]) {
3221
+ ptr2 = 0; len2 = 0;
3222
+ throw takeFromExternrefTable0(ret[2]);
3223
+ }
3224
+ deferred3_0 = ptr2;
3225
+ deferred3_1 = len2;
3226
+ return getStringFromWasm0(ptr2, len2);
3227
+ } finally {
3228
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3229
+ }
3230
+ }
3231
+
3232
+ /**
3233
+ * Parse and re-serialise a reaction SMILES string, returning the normalised form.
3234
+ *
3235
+ * Useful for validating reaction SMILES and obtaining a canonical representation.
3236
+ * Returns a JS error on parse failure.
3237
+ * @param {string} rxn_smiles
3238
+ * @returns {string}
3239
+ */
3240
+ export function normalize_reaction_smiles(rxn_smiles) {
3241
+ let deferred3_0;
3242
+ let deferred3_1;
3243
+ try {
3244
+ const ptr0 = passStringToWasm0(rxn_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3245
+ const len0 = WASM_VECTOR_LEN;
3246
+ const ret = wasm.normalize_reaction_smiles(ptr0, len0);
3247
+ var ptr2 = ret[0];
3248
+ var len2 = ret[1];
3249
+ if (ret[3]) {
3250
+ ptr2 = 0; len2 = 0;
3251
+ throw takeFromExternrefTable0(ret[2]);
3252
+ }
3253
+ deferred3_0 = ptr2;
3254
+ deferred3_1 = len2;
3255
+ return getStringFromWasm0(ptr2, len2);
3256
+ } finally {
3257
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3258
+ }
3259
+ }
3260
+
3261
+ /**
3262
+ * PAINS structural alert names matched by `mol` as a JSON array.
3263
+ *
3264
+ * Returns `[]` when no alerts fire, or e.g. `["ene_six_het_A(483)"]`.
3265
+ * Use alongside `pains_passes()` to know *which* alerts triggered.
3266
+ * @param {MolHandle} mol
3267
+ * @returns {string}
3268
+ */
3269
+ export function pains_matches_json(mol) {
3270
+ let deferred1_0;
3271
+ let deferred1_1;
3272
+ try {
3273
+ _assertClass(mol, MolHandle);
3274
+ const ret = wasm.pains_matches_json(mol.__wbg_ptr);
3275
+ deferred1_0 = ret[0];
3276
+ deferred1_1 = ret[1];
3277
+ return getStringFromWasm0(ret[0], ret[1]);
3278
+ } finally {
3279
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3280
+ }
3281
+ }
3282
+
3283
+ /**
3284
+ * Parse CXSMARTS and return preserved metadata as JSON.
3285
+ * Returns error if atom count exceeds 10,000.
3286
+ * @param {string} s
3287
+ * @returns {string}
3288
+ */
3289
+ export function parse_cxsmarts_json(s) {
3290
+ let deferred3_0;
3291
+ let deferred3_1;
3292
+ try {
3293
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3294
+ const len0 = WASM_VECTOR_LEN;
3295
+ const ret = wasm.parse_cxsmarts_json(ptr0, len0);
3296
+ var ptr2 = ret[0];
3297
+ var len2 = ret[1];
3298
+ if (ret[3]) {
3299
+ ptr2 = 0; len2 = 0;
3300
+ throw takeFromExternrefTable0(ret[2]);
3301
+ }
3302
+ deferred3_0 = ptr2;
3303
+ deferred3_1 = len2;
3304
+ return getStringFromWasm0(ptr2, len2);
3305
+ } finally {
3306
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3307
+ }
3308
+ }
3309
+
3310
+ /**
3311
+ * Parse CXSMILES and return preserved metadata as JSON.
3312
+ *
3313
+ * Supported CX fields: atom labels (`$...$`), `atomProp`, atom radicals (`^n:`),
3314
+ * and zero-order bonds (`Z:`). The `cxsmiles` field is a re-serialized
3315
+ * round-trip form using the supported fields.
3316
+ * Returns error if atom count exceeds 10,000.
3317
+ * @param {string} s
3318
+ * @returns {string}
3319
+ */
3320
+ export function parse_cxsmiles_json(s) {
3321
+ let deferred3_0;
3322
+ let deferred3_1;
3323
+ try {
3324
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3325
+ const len0 = WASM_VECTOR_LEN;
3326
+ const ret = wasm.parse_cxsmiles_json(ptr0, len0);
3327
+ var ptr2 = ret[0];
3328
+ var len2 = ret[1];
3329
+ if (ret[3]) {
3330
+ ptr2 = 0; len2 = 0;
3331
+ throw takeFromExternrefTable0(ret[2]);
3332
+ }
3333
+ deferred3_0 = ptr2;
3334
+ deferred3_1 = len2;
3335
+ return getStringFromWasm0(ptr2, len2);
3336
+ } finally {
3337
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3338
+ }
3339
+ }
3340
+
3341
+ /**
3342
+ * Parse a SMILES string into a `MolHandle`.
3343
+ *
3344
+ * Returns a JS error string on parse failure or if atom count exceeds 10,000.
3345
+ * @param {string} s
3346
+ * @returns {MolHandle}
3347
+ */
3348
+ export function parse_smiles(s) {
3349
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3350
+ const len0 = WASM_VECTOR_LEN;
3351
+ const ret = wasm.parse_smiles(ptr0, len0);
3352
+ if (ret[2]) {
3353
+ throw takeFromExternrefTable0(ret[1]);
3354
+ }
3355
+ return MolHandle.__wrap(ret[0]);
3356
+ }
3357
+
3358
+ /**
3359
+ * PEOE_VSA descriptors (14 bins) as a JSON array.
3360
+ * @param {MolHandle} mol
3361
+ * @returns {string}
3362
+ */
3363
+ export function peoe_vsa_json(mol) {
3364
+ let deferred1_0;
3365
+ let deferred1_1;
3366
+ try {
3367
+ _assertClass(mol, MolHandle);
3368
+ const ret = wasm.peoe_vsa_json(mol.__wbg_ptr);
3369
+ deferred1_0 = ret[0];
3370
+ deferred1_1 = ret[1];
3371
+ return getStringFromWasm0(ret[0], ret[1]);
3372
+ } finally {
3373
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3374
+ }
3375
+ }
3376
+
3377
+ /**
3378
+ * Detect pharmacophore features for virtual screening and lead optimization.
3379
+ * Returns JSON array of features: [{type, atom_idx, neighbor_count}, ...]
3380
+ * @param {MolHandle} mol
3381
+ * @returns {string}
3382
+ */
3383
+ export function pharmacophore_features_json(mol) {
3384
+ let deferred1_0;
3385
+ let deferred1_1;
3386
+ try {
3387
+ _assertClass(mol, MolHandle);
3388
+ const ret = wasm.pharmacophore_features_json(mol.__wbg_ptr);
3389
+ deferred1_0 = ret[0];
3390
+ deferred1_1 = ret[1];
3391
+ return getStringFromWasm0(ret[0], ret[1]);
3392
+ } finally {
3393
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3394
+ }
3395
+ }
3396
+
3397
+ /**
3398
+ * Compute 2D pharmacophore fingerprint (2048 bits) as a JSON feature count summary.
3399
+ * Returns simplified JSON with feature type counts: {Donor, Acceptor, Aromatic, Hydrophobic, Positive, Negative}
3400
+ * @param {MolHandle} mol
3401
+ * @returns {string}
3402
+ */
3403
+ export function pharmacophore_fp_2d_summary(mol) {
3404
+ let deferred1_0;
3405
+ let deferred1_1;
3406
+ try {
3407
+ _assertClass(mol, MolHandle);
3408
+ const ret = wasm.pharmacophore_fp_2d_summary(mol.__wbg_ptr);
3409
+ deferred1_0 = ret[0];
3410
+ deferred1_1 = ret[1];
3411
+ return getStringFromWasm0(ret[0], ret[1]);
3412
+ } finally {
3413
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3414
+ }
3415
+ }
3416
+
3417
+ /**
3418
+ * Compute 3D pharmacophore fingerprint from generated 3D coordinates.
3419
+ * Returns simplified JSON with feature type counts (3D-aware version).
3420
+ * @param {MolHandle} mol
3421
+ * @returns {string}
3422
+ */
3423
+ export function pharmacophore_fp_3d_summary(mol) {
3424
+ let deferred1_0;
3425
+ let deferred1_1;
3426
+ try {
3427
+ _assertClass(mol, MolHandle);
3428
+ const ret = wasm.pharmacophore_fp_3d_summary(mol.__wbg_ptr);
3429
+ deferred1_0 = ret[0];
3430
+ deferred1_1 = ret[1];
3431
+ return getStringFromWasm0(ret[0], ret[1]);
3432
+ } finally {
3433
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3434
+ }
3435
+ }
3436
+
3437
+ /**
3438
+ * Generate `count` random SMILES from a SMILES string using the given seed.
3439
+ * Atoms are permuted based on xorshift64 RNG. Each variant should parse back
3440
+ * to the same molecule. Returns a JSON array of SMILES strings.
3441
+ *
3442
+ * # Arguments
3443
+ * - `smiles`: input SMILES string
3444
+ * - `count`: number of variants to generate (capped at 100)
3445
+ * - `seed`: xorshift64 seed
3446
+ *
3447
+ * # Example
3448
+ * ```javascript
3449
+ * const variants = random_smiles_json("CC(C)O", 5, 42);
3450
+ * // variants: ["CC(C)O", "C(C)(O)C", ...]
3451
+ * ```
3452
+ * @param {string} smiles
3453
+ * @param {number} count
3454
+ * @param {bigint} seed
3455
+ * @returns {string}
3456
+ */
3457
+ export function random_smiles_json(smiles, count, seed) {
3458
+ let deferred3_0;
3459
+ let deferred3_1;
3460
+ try {
3461
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3462
+ const len0 = WASM_VECTOR_LEN;
3463
+ const ret = wasm.random_smiles_json(ptr0, len0, count, seed);
3464
+ var ptr2 = ret[0];
3465
+ var len2 = ret[1];
3466
+ if (ret[3]) {
3467
+ ptr2 = 0; len2 = 0;
3468
+ throw takeFromExternrefTable0(ret[2]);
3469
+ }
3470
+ deferred3_0 = ptr2;
3471
+ deferred3_1 = len2;
3472
+ return getStringFromWasm0(ptr2, len2);
3473
+ } finally {
3474
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3475
+ }
3476
+ }
3477
+
3478
+ /**
3479
+ * Return a copy of the molecule with all explicit hydrogen atoms removed.
3480
+ * @param {MolHandle} mol
3481
+ * @returns {MolHandle}
3482
+ */
3483
+ export function remove_hydrogens(mol) {
3484
+ _assertClass(mol, MolHandle);
3485
+ const ret = wasm.remove_hydrogens(mol.__wbg_ptr);
3486
+ return MolHandle.__wrap(ret);
3487
+ }
3488
+
3489
+ /**
3490
+ * Decompose a set of molecules against a core SMARTS, returning R-group SMILES.
3491
+ *
3492
+ * `smiles_json` — JSON array of SMILES strings.
3493
+ * `core_smarts` — SMARTS pattern with `*` (wildcard) atoms marking R-group
3494
+ * attachment points. For example `c1ccc(*)cc1` for para-substituted benzene.
3495
+ *
3496
+ * Returns a JSON array with one entry per input molecule:
3497
+ * ```json
3498
+ * [
3499
+ * {"matched":true, "r1":"C"},
3500
+ * {"matched":true, "r1":"CC"},
3501
+ * {"matched":false}
3502
+ * ]
3503
+ * ```
3504
+ * R-group keys are `"r1"`, `"r2"`, … in the order the `*` atoms appear in
3505
+ * the SMARTS pattern. A molecule that does not contain the core gets
3506
+ * `"matched": false` and no R-group keys.
3507
+ *
3508
+ * Returns a JS error if the SMARTS fails to parse or any SMILES is invalid.
3509
+ * @param {string} smiles_json
3510
+ * @param {string} core_smarts
3511
+ * @returns {string}
3512
+ */
3513
+ export function rgroup_decompose_json(smiles_json, core_smarts) {
3514
+ let deferred4_0;
3515
+ let deferred4_1;
3516
+ try {
3517
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3518
+ const len0 = WASM_VECTOR_LEN;
3519
+ const ptr1 = passStringToWasm0(core_smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3520
+ const len1 = WASM_VECTOR_LEN;
3521
+ const ret = wasm.rgroup_decompose_json(ptr0, len0, ptr1, len1);
3522
+ var ptr3 = ret[0];
3523
+ var len3 = ret[1];
3524
+ if (ret[3]) {
3525
+ ptr3 = 0; len3 = 0;
3526
+ throw takeFromExternrefTable0(ret[2]);
3527
+ }
3528
+ deferred4_0 = ptr3;
3529
+ deferred4_1 = len3;
3530
+ return getStringFromWasm0(ptr3, len3);
3531
+ } finally {
3532
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
3533
+ }
3534
+ }
3535
+
3536
+ /**
3537
+ * Ring family classification and detection as JSON.
3538
+ * Returns an array of ring families with their atoms, ring indices, and topology kind.
3539
+ * @param {MolHandle} mol
3540
+ * @returns {string}
3541
+ */
3542
+ export function ring_families_json(mol) {
3543
+ let deferred2_0;
3544
+ let deferred2_1;
3545
+ try {
3546
+ _assertClass(mol, MolHandle);
3547
+ const ret = wasm.ring_families_json(mol.__wbg_ptr);
3548
+ var ptr1 = ret[0];
3549
+ var len1 = ret[1];
3550
+ if (ret[3]) {
3551
+ ptr1 = 0; len1 = 0;
3552
+ throw takeFromExternrefTable0(ret[2]);
3553
+ }
3554
+ deferred2_0 = ptr1;
3555
+ deferred2_1 = len1;
3556
+ return getStringFromWasm0(ptr1, len1);
3557
+ } finally {
3558
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
3559
+ }
3560
+ }
3561
+
3562
+ /**
3563
+ * Run molecular dynamics simulation and return trajectory as JSON.
3564
+ *
3565
+ * Returns JSON object with trajectory frames: `{ "frames": [{ "step": N, "potential": E, "kinetic": K, "temp": T }, …] }`
3566
+ * Uses NVT ensemble (Berendsen thermostat) at 300 K by default.
3567
+ * Note: Limited to molecules with ~50 atoms or fewer for practical WASM performance.
3568
+ * @param {MolHandle} mol
3569
+ * @param {number} steps
3570
+ * @param {number} temp_k
3571
+ * @returns {string}
3572
+ */
3573
+ export function run_md_json(mol, steps, temp_k) {
3574
+ let deferred1_0;
3575
+ let deferred1_1;
3576
+ try {
3577
+ _assertClass(mol, MolHandle);
3578
+ const ret = wasm.run_md_json(mol.__wbg_ptr, steps, temp_k);
3579
+ deferred1_0 = ret[0];
3580
+ deferred1_1 = ret[1];
3581
+ return getStringFromWasm0(ret[0], ret[1]);
3582
+ } finally {
3583
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3584
+ }
3585
+ }
3586
+
3587
+ /**
3588
+ * Apply a SMIRKS reaction template and return product SMILES as a JSON string.
3589
+ *
3590
+ * `reactants_smiles`: pipe-separated SMILES, one per reactant slot in the SMIRKS.
3591
+ * Returns a JSON array of arrays: `[["product_smi", …], …]`.
3592
+ * Returns a JS error on parse failure or arity mismatch.
3593
+ * @param {string} smirks
3594
+ * @param {string} reactants_smiles
3595
+ * @returns {string}
3596
+ */
3597
+ export function run_reactants(smirks, reactants_smiles) {
3598
+ let deferred4_0;
3599
+ let deferred4_1;
3600
+ try {
3601
+ const ptr0 = passStringToWasm0(smirks, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3602
+ const len0 = WASM_VECTOR_LEN;
3603
+ const ptr1 = passStringToWasm0(reactants_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3604
+ const len1 = WASM_VECTOR_LEN;
3605
+ const ret = wasm.run_reactants(ptr0, len0, ptr1, len1);
3606
+ var ptr3 = ret[0];
3607
+ var len3 = ret[1];
3608
+ if (ret[3]) {
3609
+ ptr3 = 0; len3 = 0;
3610
+ throw takeFromExternrefTable0(ret[2]);
3611
+ }
3612
+ deferred4_0 = ptr3;
3613
+ deferred4_1 = len3;
3614
+ return getStringFromWasm0(ptr3, len3);
3615
+ } finally {
3616
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
3617
+ }
3618
+ }
3619
+
3620
+ /**
3621
+ * Synthetic Accessibility Score (1 = easy, 10 = hard).
3622
+ * @param {MolHandle} mol
3623
+ * @returns {number}
3624
+ */
3625
+ export function sa_score(mol) {
3626
+ _assertClass(mol, MolHandle);
3627
+ const ret = wasm.sa_score(mol.__wbg_ptr);
3628
+ return ret;
3629
+ }
3630
+
3631
+ /**
3632
+ * Screen a batch of SMILES strings (JSON string output).
3633
+ * Returns per-record results including pass/fail with error details.
3634
+ * Includes MaxMin diversity picking and Butina clustering by default.
3635
+ *
3636
+ * # Example (JS)
3637
+ * ```javascript
3638
+ * const smilesList = "c1ccccc1\nCC\nCCC";
3639
+ * const json = module.screen_smiles_json(smilesList, "\n");
3640
+ * const report = JSON.parse(json);
3641
+ * console.log(report.records); // Array of ScreeningRecord
3642
+ * console.log(report.maxmin_picks); // Diversity-selected indices
3643
+ * console.log(report.butina_clusters); // Clustering result
3644
+ * ```
3645
+ * @param {string} smiles_batch
3646
+ * @param {string} delimiter
3647
+ * @returns {string}
3648
+ */
3649
+ export function screen_smiles_json(smiles_batch, delimiter) {
3650
+ let deferred3_0;
3651
+ let deferred3_1;
3652
+ try {
3653
+ const ptr0 = passStringToWasm0(smiles_batch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3654
+ const len0 = WASM_VECTOR_LEN;
3655
+ const ptr1 = passStringToWasm0(delimiter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3656
+ const len1 = WASM_VECTOR_LEN;
3657
+ const ret = wasm.screen_smiles_json(ptr0, len0, ptr1, len1);
3658
+ deferred3_0 = ret[0];
3659
+ deferred3_1 = ret[1];
3660
+ return getStringFromWasm0(ret[0], ret[1]);
3661
+ } finally {
3662
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3663
+ }
3664
+ }
3665
+
3666
+ /**
3667
+ * Serialize multiple molecules with properties to an SDF string.
3668
+ *
3669
+ * # Arguments
3670
+ * * `smiles_json` — JSON array of SMILES strings, e.g. `["CC(=O)O","c1ccccc1"]`
3671
+ * * `names_json` — JSON array of molecule names (same length as `smiles_json`)
3672
+ * * `props_json` — JSON array where each element encodes one molecule's SD data fields
3673
+ * as `"key1\tvalue1\nkey2\tvalue2"` (tab-separated key/value, `\n`-separated pairs;
3674
+ * pass `""` for a molecule with no properties)
3675
+ *
3676
+ * Returns the SDF string, or a JS error if any SMILES fails to parse or the
3677
+ * arrays have mismatched lengths.
3678
+ *
3679
+ * The `\n` and `\t` sequences in `props_json` are JSON-escaped — they are
3680
+ * decoded to the actual characters before SDF formatting.
3681
+ * @param {string} smiles_json
3682
+ * @param {string} names_json
3683
+ * @param {string} props_json
3684
+ * @returns {string}
3685
+ */
3686
+ export function sdf_from_records_json(smiles_json, names_json, props_json) {
3687
+ let deferred5_0;
3688
+ let deferred5_1;
3689
+ try {
3690
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3691
+ const len0 = WASM_VECTOR_LEN;
3692
+ const ptr1 = passStringToWasm0(names_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3693
+ const len1 = WASM_VECTOR_LEN;
3694
+ const ptr2 = passStringToWasm0(props_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3695
+ const len2 = WASM_VECTOR_LEN;
3696
+ const ret = wasm.sdf_from_records_json(ptr0, len0, ptr1, len1, ptr2, len2);
3697
+ var ptr4 = ret[0];
3698
+ var len4 = ret[1];
3699
+ if (ret[3]) {
3700
+ ptr4 = 0; len4 = 0;
3701
+ throw takeFromExternrefTable0(ret[2]);
3702
+ }
3703
+ deferred5_0 = ptr4;
3704
+ deferred5_1 = len4;
3705
+ return getStringFromWasm0(ptr4, len4);
3706
+ } finally {
3707
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
3708
+ }
3709
+ }
3710
+
3711
+ /**
3712
+ * Parse an SDF string and return a JSON array of record objects.
3713
+ *
3714
+ * Each record has the shape:
3715
+ * ```json
3716
+ * {"smiles":"CC(=O)O","name":"aspirin","properties":{"MW":"180.2","Activity":"high"}}
3717
+ * ```
3718
+ *
3719
+ * Invalid records are represented as `null`. SD data fields are included in
3720
+ * `properties`; multi-line values are joined with `\n`.
3721
+ * @param {string} sdf
3722
+ * @returns {string}
3723
+ */
3724
+ export function sdf_to_records_json(sdf) {
3725
+ let deferred2_0;
3726
+ let deferred2_1;
3727
+ try {
3728
+ const ptr0 = passStringToWasm0(sdf, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3729
+ const len0 = WASM_VECTOR_LEN;
3730
+ const ret = wasm.sdf_to_records_json(ptr0, len0);
3731
+ deferred2_0 = ret[0];
3732
+ deferred2_1 = ret[1];
3733
+ return getStringFromWasm0(ret[0], ret[1]);
3734
+ } finally {
3735
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
3736
+ }
3737
+ }
3738
+
3739
+ /**
3740
+ * Parse an SDF string and return a JSON array of canonical SMILES strings.
3741
+ *
3742
+ * Invalid records are represented as `null` in the array.
3743
+ * @param {string} sdf
3744
+ * @returns {string}
3745
+ */
3746
+ export function sdf_to_smiles_json(sdf) {
3747
+ let deferred2_0;
3748
+ let deferred2_1;
3749
+ try {
3750
+ const ptr0 = passStringToWasm0(sdf, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3751
+ const len0 = WASM_VECTOR_LEN;
3752
+ const ret = wasm.sdf_to_smiles_json(ptr0, len0);
3753
+ deferred2_0 = ret[0];
3754
+ deferred2_1 = ret[1];
3755
+ return getStringFromWasm0(ret[0], ret[1]);
3756
+ } finally {
3757
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
3758
+ }
3759
+ }
3760
+
3761
+ /**
3762
+ * Set dihedral angle A—B—C—D and return PDB block with modified coordinates.
3763
+ * Rotates the D-side subtree around the B—C bond.
3764
+ * Returns a JS error if parsing fails or atom indices are invalid.
3765
+ *
3766
+ * # Arguments
3767
+ * - `smiles`: SMILES string
3768
+ * - `a`, `b`, `c`, `d`: atom indices
3769
+ * - `angle_deg`: target dihedral angle in degrees
3770
+ *
3771
+ * # Example
3772
+ * ```javascript
3773
+ * const pdbBlock = set_dihedral_json("CCCC", 0, 1, 2, 3, 120.0);
3774
+ * ```
3775
+ * @param {string} smiles
3776
+ * @param {number} a
3777
+ * @param {number} b
3778
+ * @param {number} c
3779
+ * @param {number} d
3780
+ * @param {number} angle_deg
3781
+ * @returns {string}
3782
+ */
3783
+ export function set_dihedral_json(smiles, a, b, c, d, angle_deg) {
3784
+ let deferred3_0;
3785
+ let deferred3_1;
3786
+ try {
3787
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3788
+ const len0 = WASM_VECTOR_LEN;
3789
+ const ret = wasm.set_dihedral_json(ptr0, len0, a, b, c, d, angle_deg);
3790
+ var ptr2 = ret[0];
3791
+ var len2 = ret[1];
3792
+ if (ret[3]) {
3793
+ ptr2 = 0; len2 = 0;
3794
+ throw takeFromExternrefTable0(ret[2]);
3795
+ }
3796
+ deferred3_0 = ptr2;
3797
+ deferred3_1 = len2;
3798
+ return getStringFromWasm0(ptr2, len2);
3799
+ } finally {
3800
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3801
+ }
3802
+ }
3803
+
3804
+ /**
3805
+ * 3D shape descriptors as a JSON object.
3806
+ *
3807
+ * Keys: `pmi1`, `pmi2`, `pmi3`, `npr1`, `npr2`, `asphericity`, `eccentricity`,
3808
+ * `radiusOfGyration`, `planeOfBestFit`. Non-finite values (e.g. single-atom
3809
+ * molecules where pmi3 = 0) are serialised as JSON `null`.
3810
+ * @param {MolHandle} mol
3811
+ * @returns {string}
3812
+ */
3813
+ export function shape_descriptors_json(mol) {
3814
+ let deferred1_0;
3815
+ let deferred1_1;
3816
+ try {
3817
+ _assertClass(mol, MolHandle);
3818
+ const ret = wasm.shape_descriptors_json(mol.__wbg_ptr);
3819
+ deferred1_0 = ret[0];
3820
+ deferred1_1 = ret[1];
3821
+ return getStringFromWasm0(ret[0], ret[1]);
3822
+ } finally {
3823
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3824
+ }
3825
+ }
3826
+
3827
+ /**
3828
+ * SlogP_VSA descriptors (12 bins) as a JSON array.
3829
+ * @param {MolHandle} mol
3830
+ * @returns {string}
3831
+ */
3832
+ export function slogp_vsa_json(mol) {
3833
+ let deferred1_0;
3834
+ let deferred1_1;
3835
+ try {
3836
+ _assertClass(mol, MolHandle);
3837
+ const ret = wasm.slogp_vsa_json(mol.__wbg_ptr);
3838
+ deferred1_0 = ret[0];
3839
+ deferred1_1 = ret[1];
3840
+ return getStringFromWasm0(ret[0], ret[1]);
3841
+ } finally {
3842
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3843
+ }
3844
+ }
3845
+
3846
+ /**
3847
+ * Find all substructure matches of a SMARTS pattern in `mol`.
3848
+ *
3849
+ * Returns JSON array of arrays of atom indices (sorted, 0-based).
3850
+ * Example: `[[0,1,2],[3,4,5]]` — two matches.
3851
+ * Returns `"[]"` if no match. Returns a JS error on invalid SMARTS.
3852
+ * @param {string} smarts
3853
+ * @param {MolHandle} mol
3854
+ * @returns {string}
3855
+ */
3856
+ export function smarts_match_atoms(smarts, mol) {
3857
+ let deferred3_0;
3858
+ let deferred3_1;
3859
+ try {
3860
+ const ptr0 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3861
+ const len0 = WASM_VECTOR_LEN;
3862
+ _assertClass(mol, MolHandle);
3863
+ const ret = wasm.smarts_match_atoms(ptr0, len0, mol.__wbg_ptr);
3864
+ var ptr2 = ret[0];
3865
+ var len2 = ret[1];
3866
+ if (ret[3]) {
3867
+ ptr2 = 0; len2 = 0;
3868
+ throw takeFromExternrefTable0(ret[2]);
3869
+ }
3870
+ deferred3_0 = ptr2;
3871
+ deferred3_1 = len2;
3872
+ return getStringFromWasm0(ptr2, len2);
3873
+ } finally {
3874
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3875
+ }
3876
+ }
3877
+
3878
+ /**
3879
+ * Like `smarts_match_atoms` but with explicit chirality matching control.
3880
+ *
3881
+ * When `use_chirality=true`, SMARTS chirality primitives `[@]` and `[@@]` are
3882
+ * matched against the target molecule's stereochemistry. When `false`, chirality
3883
+ * is ignored (RDKit default).
3884
+ * @param {string} smarts
3885
+ * @param {MolHandle} mol
3886
+ * @param {boolean} use_chirality
3887
+ * @returns {string}
3888
+ */
3889
+ export function smarts_match_atoms_with_chirality(smarts, mol, use_chirality) {
3890
+ let deferred3_0;
3891
+ let deferred3_1;
3892
+ try {
3893
+ const ptr0 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3894
+ const len0 = WASM_VECTOR_LEN;
3895
+ _assertClass(mol, MolHandle);
3896
+ const ret = wasm.smarts_match_atoms_with_chirality(ptr0, len0, mol.__wbg_ptr, use_chirality);
3897
+ var ptr2 = ret[0];
3898
+ var len2 = ret[1];
3899
+ if (ret[3]) {
3900
+ ptr2 = 0; len2 = 0;
3901
+ throw takeFromExternrefTable0(ret[2]);
3902
+ }
3903
+ deferred3_0 = ptr2;
3904
+ deferred3_1 = len2;
3905
+ return getStringFromWasm0(ptr2, len2);
3906
+ } finally {
3907
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3908
+ }
3909
+ }
3910
+
3911
+ /**
3912
+ * Serialise a JSON array of SMILES to an SDF string.
3913
+ *
3914
+ * Generates 2D coordinates for each molecule. Property data can be
3915
+ * included by using `sdf_from_records_json` instead.
3916
+ * @param {string} smiles_json
3917
+ * @returns {string}
3918
+ */
3919
+ export function smiles_array_to_sdf(smiles_json) {
3920
+ let deferred3_0;
3921
+ let deferred3_1;
3922
+ try {
3923
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3924
+ const len0 = WASM_VECTOR_LEN;
3925
+ const ret = wasm.smiles_array_to_sdf(ptr0, len0);
3926
+ var ptr2 = ret[0];
3927
+ var len2 = ret[1];
3928
+ if (ret[3]) {
3929
+ ptr2 = 0; len2 = 0;
3930
+ throw takeFromExternrefTable0(ret[2]);
3931
+ }
3932
+ deferred3_0 = ptr2;
3933
+ deferred3_1 = len2;
3934
+ return getStringFromWasm0(ptr2, len2);
3935
+ } finally {
3936
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3937
+ }
3938
+ }
3939
+
3940
+ /**
3941
+ * Convert a SMILES to a minimal Tripos MOL2 string (no 3D coordinates).
3942
+ *
3943
+ * Returns `"error:<msg>"` on parse failure.
3944
+ * @param {string} smiles
3945
+ * @returns {string}
3946
+ */
3947
+ export function smiles_to_mol2(smiles) {
3948
+ let deferred2_0;
3949
+ let deferred2_1;
3950
+ try {
3951
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3952
+ const len0 = WASM_VECTOR_LEN;
3953
+ const ret = wasm.smiles_to_mol2(ptr0, len0);
3954
+ deferred2_0 = ret[0];
3955
+ deferred2_1 = ret[1];
3956
+ return getStringFromWasm0(ret[0], ret[1]);
3957
+ } finally {
3958
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
3959
+ }
3960
+ }
3961
+
3962
+ /**
3963
+ * Render a highlighted SVG from a SMILES string in one call.
3964
+ *
3965
+ * `atoms` — 0-based atom indices to highlight (Uint32Array in JS).
3966
+ * `bonds` — 0-based bond indices to highlight (Uint32Array in JS).
3967
+ * `color` — CSS color for highlights (e.g. `"#ef4444"`); empty string uses default yellow.
3968
+ *
3969
+ * Returns a JS error on SMILES parse failure.
3970
+ * @param {string} smiles
3971
+ * @param {Uint32Array} atoms
3972
+ * @param {Uint32Array} bonds
3973
+ * @param {string} color
3974
+ * @returns {string}
3975
+ */
3976
+ export function smiles_to_svg_highlighted(smiles, atoms, bonds, color) {
3977
+ let deferred6_0;
3978
+ let deferred6_1;
3979
+ try {
3980
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3981
+ const len0 = WASM_VECTOR_LEN;
3982
+ const ptr1 = passArray32ToWasm0(atoms, wasm.__wbindgen_malloc);
3983
+ const len1 = WASM_VECTOR_LEN;
3984
+ const ptr2 = passArray32ToWasm0(bonds, wasm.__wbindgen_malloc);
3985
+ const len2 = WASM_VECTOR_LEN;
3986
+ const ptr3 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3987
+ const len3 = WASM_VECTOR_LEN;
3988
+ const ret = wasm.smiles_to_svg_highlighted(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
3989
+ var ptr5 = ret[0];
3990
+ var len5 = ret[1];
3991
+ if (ret[3]) {
3992
+ ptr5 = 0; len5 = 0;
3993
+ throw takeFromExternrefTable0(ret[2]);
3994
+ }
3995
+ deferred6_0 = ptr5;
3996
+ deferred6_1 = len5;
3997
+ return getStringFromWasm0(ptr5, len5);
3998
+ } finally {
3999
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
4000
+ }
4001
+ }
4002
+
4003
+ /**
4004
+ * SMR_VSA descriptors (10 bins) as a JSON array.
4005
+ * @param {MolHandle} mol
4006
+ * @returns {string}
4007
+ */
4008
+ export function smr_vsa_json(mol) {
4009
+ let deferred1_0;
4010
+ let deferred1_1;
4011
+ try {
4012
+ _assertClass(mol, MolHandle);
4013
+ const ret = wasm.smr_vsa_json(mol.__wbg_ptr);
4014
+ deferred1_0 = ret[0];
4015
+ deferred1_1 = ret[1];
4016
+ return getStringFromWasm0(ret[0], ret[1]);
4017
+ } finally {
4018
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4019
+ }
4020
+ }
4021
+
4022
+ /**
4023
+ * Smallest Set of Smallest Rings (SSSR) as a JSON array of atom-index arrays.
4024
+ *
4025
+ * Example return value for naphthalene:
4026
+ * `[[0,1,2,3,4,5],[5,6,7,8,9,4]]`
4027
+ * @param {MolHandle} mol
4028
+ * @returns {string}
4029
+ */
4030
+ export function sssr_rings_json(mol) {
4031
+ let deferred1_0;
4032
+ let deferred1_1;
4033
+ try {
4034
+ _assertClass(mol, MolHandle);
4035
+ const ret = wasm.sssr_rings_json(mol.__wbg_ptr);
4036
+ deferred1_0 = ret[0];
4037
+ deferred1_1 = ret[1];
4038
+ return getStringFromWasm0(ret[0], ret[1]);
4039
+ } finally {
4040
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4041
+ }
4042
+ }
4043
+
4044
+ /**
4045
+ * Standardize a SMILES string and return the canonical SMILES of the result.
4046
+ *
4047
+ * Applies: largest fragment extraction → charge neutralization.
4048
+ * Returns `"error:<msg>"` on parse failure.
4049
+ * @param {string} smiles
4050
+ * @returns {string}
4051
+ */
4052
+ export function standardize_smiles(smiles) {
4053
+ let deferred2_0;
4054
+ let deferred2_1;
4055
+ try {
4056
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4057
+ const len0 = WASM_VECTOR_LEN;
4058
+ const ret = wasm.standardize_smiles(ptr0, len0);
4059
+ deferred2_0 = ret[0];
4060
+ deferred2_1 = ret[1];
4061
+ return getStringFromWasm0(ret[0], ret[1]);
4062
+ } finally {
4063
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
4064
+ }
4065
+ }
4066
+
4067
+ /**
4068
+ * Standardize a SMILES string and return result SMILES plus an audit report as JSON.
4069
+ *
4070
+ * Boolean flags map directly to `StandardizeOptions`.
4071
+ * Returns `"error:<msg>"` on parse or serialization failure.
4072
+ * @param {string} smiles
4073
+ * @param {boolean} largest_fragment_only
4074
+ * @param {boolean} neutralize_charges
4075
+ * @param {boolean} remove_explicit_h
4076
+ * @param {boolean} canonical_tautomer
4077
+ * @returns {string}
4078
+ */
4079
+ export function standardize_smiles_report_json(smiles, largest_fragment_only, neutralize_charges, remove_explicit_h, canonical_tautomer) {
4080
+ let deferred2_0;
4081
+ let deferred2_1;
4082
+ try {
4083
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4084
+ const len0 = WASM_VECTOR_LEN;
4085
+ const ret = wasm.standardize_smiles_report_json(ptr0, len0, largest_fragment_only, neutralize_charges, remove_explicit_h, canonical_tautomer);
4086
+ deferred2_0 = ret[0];
4087
+ deferred2_1 = ret[1];
4088
+ return getStringFromWasm0(ret[0], ret[1]);
4089
+ } finally {
4090
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
4091
+ }
4092
+ }
4093
+
4094
+ export function start() {
4095
+ wasm.start();
4096
+ }
4097
+
4098
+ /**
4099
+ * Tanimoto similarity between two molecules using AtomPair fingerprints.
4100
+ * @param {MolHandle} a
4101
+ * @param {MolHandle} b
4102
+ * @returns {number}
4103
+ */
4104
+ export function tanimoto_atom_pair(a, b) {
4105
+ _assertClass(a, MolHandle);
4106
+ _assertClass(b, MolHandle);
4107
+ const ret = wasm.tanimoto_atom_pair(a.__wbg_ptr, b.__wbg_ptr);
4108
+ return ret;
4109
+ }
4110
+
4111
+ /**
4112
+ * Tanimoto similarity between two molecules using ECFP4 fingerprints.
4113
+ * @param {MolHandle} a
4114
+ * @param {MolHandle} b
4115
+ * @returns {number}
4116
+ */
4117
+ export function tanimoto_ecfp4(a, b) {
4118
+ _assertClass(a, MolHandle);
4119
+ _assertClass(b, MolHandle);
4120
+ const ret = wasm.tanimoto_ecfp4(a.__wbg_ptr, b.__wbg_ptr);
4121
+ return ret;
4122
+ }
4123
+
4124
+ /**
4125
+ * Tanimoto similarity between `a` and `b` using ECFP6 fingerprints.
4126
+ * @param {MolHandle} a
4127
+ * @param {MolHandle} b
4128
+ * @returns {number}
4129
+ */
4130
+ export function tanimoto_ecfp6(a, b) {
4131
+ _assertClass(a, MolHandle);
4132
+ _assertClass(b, MolHandle);
4133
+ const ret = wasm.tanimoto_ecfp6(a.__wbg_ptr, b.__wbg_ptr);
4134
+ return ret;
4135
+ }
4136
+
4137
+ /**
4138
+ * Tanimoto similarity between two molecules using FCFP4 fingerprints (pharmacophore-based).
4139
+ * @param {MolHandle} a
4140
+ * @param {MolHandle} b
4141
+ * @returns {number}
4142
+ */
4143
+ export function tanimoto_fcfp4(a, b) {
4144
+ _assertClass(a, MolHandle);
4145
+ _assertClass(b, MolHandle);
4146
+ const ret = wasm.tanimoto_fcfp4(a.__wbg_ptr, b.__wbg_ptr);
4147
+ return ret;
4148
+ }
4149
+
4150
+ /**
4151
+ * Tanimoto similarity between `a` and `b` using FCFP6 (radius-3 pharmacophore) fingerprints.
4152
+ * @param {MolHandle} a
4153
+ * @param {MolHandle} b
4154
+ * @returns {number}
4155
+ */
4156
+ export function tanimoto_fcfp6(a, b) {
4157
+ _assertClass(a, MolHandle);
4158
+ _assertClass(b, MolHandle);
4159
+ const ret = wasm.tanimoto_fcfp6(a.__wbg_ptr, b.__wbg_ptr);
4160
+ return ret;
4161
+ }
4162
+
4163
+ /**
4164
+ * Tanimoto similarity between `a` and `b` using MACCS 166-bit fingerprints.
4165
+ * @param {MolHandle} a
4166
+ * @param {MolHandle} b
4167
+ * @returns {number}
4168
+ */
4169
+ export function tanimoto_maccs(a, b) {
4170
+ _assertClass(a, MolHandle);
4171
+ _assertClass(b, MolHandle);
4172
+ const ret = wasm.tanimoto_maccs(a.__wbg_ptr, b.__wbg_ptr);
4173
+ return ret;
4174
+ }
4175
+
4176
+ /**
4177
+ * Tanimoto-like similarity between two SMILES via MHFP (MinHash Jaccard approximation).
4178
+ * @param {string} smi1
4179
+ * @param {string} smi2
4180
+ * @returns {number}
4181
+ */
4182
+ export function tanimoto_mhfp_smiles(smi1, smi2) {
4183
+ const ptr0 = passStringToWasm0(smi1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4184
+ const len0 = WASM_VECTOR_LEN;
4185
+ const ptr1 = passStringToWasm0(smi2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4186
+ const len1 = WASM_VECTOR_LEN;
4187
+ const ret = wasm.tanimoto_mhfp_smiles(ptr0, len0, ptr1, len1);
4188
+ if (ret[2]) {
4189
+ throw takeFromExternrefTable0(ret[1]);
4190
+ }
4191
+ return ret[0];
4192
+ }
4193
+
4194
+ /**
4195
+ * Compute ECFP4 Tanimoto similarity from one query SMILES to all db SMILES (dense output).
4196
+ *
4197
+ * `db_smiles_json`: JSON array of SMILES strings (max 1024 via WASM_MAX_BATCH_ITEMS).
4198
+ *
4199
+ * Returns a flat JSON array of f32 scores, one per db entry, e.g. `[0.12,0.0,0.85]`.
4200
+ * No zero-filtering: the length always equals the number of db entries.
4201
+ * Returns `"error:<msg>"` on parse failure or oversized input.
4202
+ * @param {string} query_smi
4203
+ * @param {string} db_smiles_json
4204
+ * @returns {string}
4205
+ */
4206
+ export function tanimoto_row_json(query_smi, db_smiles_json) {
4207
+ let deferred3_0;
4208
+ let deferred3_1;
4209
+ try {
4210
+ const ptr0 = passStringToWasm0(query_smi, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4211
+ const len0 = WASM_VECTOR_LEN;
4212
+ const ptr1 = passStringToWasm0(db_smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4213
+ const len1 = WASM_VECTOR_LEN;
4214
+ const ret = wasm.tanimoto_row_json(ptr0, len0, ptr1, len1);
4215
+ deferred3_0 = ret[0];
4216
+ deferred3_1 = ret[1];
4217
+ return getStringFromWasm0(ret[0], ret[1]);
4218
+ } finally {
4219
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4220
+ }
4221
+ }
4222
+
4223
+ /**
4224
+ * Tanimoto similarity between two molecules given only SMILES strings (ECFP4).
4225
+ *
4226
+ * Returns a JS error on parse failure.
4227
+ * @param {string} smiles1
4228
+ * @param {string} smiles2
4229
+ * @returns {number}
4230
+ */
4231
+ export function tanimoto_smiles(smiles1, smiles2) {
4232
+ const ptr0 = passStringToWasm0(smiles1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4233
+ const len0 = WASM_VECTOR_LEN;
4234
+ const ptr1 = passStringToWasm0(smiles2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4235
+ const len1 = WASM_VECTOR_LEN;
4236
+ const ret = wasm.tanimoto_smiles(ptr0, len0, ptr1, len1);
4237
+ if (ret[2]) {
4238
+ throw takeFromExternrefTable0(ret[1]);
4239
+ }
4240
+ return ret[0];
4241
+ }
4242
+
4243
+ /**
4244
+ * Tanimoto similarity between two molecules using topological path fingerprints.
4245
+ * @param {MolHandle} a
4246
+ * @param {MolHandle} b
4247
+ * @returns {number}
4248
+ */
4249
+ export function tanimoto_topo_path(a, b) {
4250
+ _assertClass(a, MolHandle);
4251
+ _assertClass(b, MolHandle);
4252
+ const ret = wasm.tanimoto_topo_path(a.__wbg_ptr, b.__wbg_ptr);
4253
+ return ret;
4254
+ }
4255
+
4256
+ /**
4257
+ * Tanimoto similarity between two molecules using Topological Torsion fingerprints.
4258
+ * @param {MolHandle} a
4259
+ * @param {MolHandle} b
4260
+ * @returns {number}
4261
+ */
4262
+ export function tanimoto_torsion(a, b) {
4263
+ _assertClass(a, MolHandle);
4264
+ _assertClass(b, MolHandle);
4265
+ const ret = wasm.tanimoto_torsion(a.__wbg_ptr, b.__wbg_ptr);
4266
+ return ret;
4267
+ }
4268
+
4269
+ /**
4270
+ * Serialise a `MolHandle` to a CML string with 2D coordinates.
4271
+ *
4272
+ * Coordinates are generated using the same 2D layout engine as `to_mol_block`.
4273
+ * @param {MolHandle} mol
4274
+ * @returns {string}
4275
+ */
4276
+ export function to_cml(mol) {
4277
+ let deferred1_0;
4278
+ let deferred1_1;
4279
+ try {
4280
+ _assertClass(mol, MolHandle);
4281
+ const ret = wasm.to_cml(mol.__wbg_ptr);
4282
+ deferred1_0 = ret[0];
4283
+ deferred1_1 = ret[1];
4284
+ return getStringFromWasm0(ret[0], ret[1]);
4285
+ } finally {
4286
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4287
+ }
4288
+ }
4289
+
4290
+ /**
4291
+ * Serialize a molecule to a MOL V2000 block with 2D coordinates.
4292
+ *
4293
+ * Atom positions are computed via the same layout engine used for SVG depiction
4294
+ * and converted to Ångström units (`1.5 Å` per bond).
4295
+ * @param {MolHandle} mol
4296
+ * @returns {string}
4297
+ */
4298
+ export function to_mol_block(mol) {
4299
+ let deferred1_0;
4300
+ let deferred1_1;
4301
+ try {
4302
+ _assertClass(mol, MolHandle);
4303
+ const ret = wasm.to_mol_block(mol.__wbg_ptr);
4304
+ deferred1_0 = ret[0];
4305
+ deferred1_1 = ret[1];
4306
+ return getStringFromWasm0(ret[0], ret[1]);
4307
+ } finally {
4308
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4309
+ }
4310
+ }
4311
+
4312
+ /**
4313
+ * Serialise a `MolHandle` to MOL V3000 format with 2D coordinates.
4314
+ * @param {MolHandle} mol
4315
+ * @returns {string}
4316
+ */
4317
+ export function to_mol_v3000_block(mol) {
4318
+ let deferred1_0;
4319
+ let deferred1_1;
4320
+ try {
4321
+ _assertClass(mol, MolHandle);
4322
+ const ret = wasm.to_mol_v3000_block(mol.__wbg_ptr);
4323
+ deferred1_0 = ret[0];
4324
+ deferred1_1 = ret[1];
4325
+ return getStringFromWasm0(ret[0], ret[1]);
4326
+ } finally {
4327
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4328
+ }
4329
+ }
4330
+
4331
+ /**
4332
+ * Serialize a molecule to XYZ format.
4333
+ *
4334
+ * 3D coordinates are generated via distance-geometry placement.
4335
+ * @param {MolHandle} mol
4336
+ * @returns {string}
4337
+ */
4338
+ export function to_xyz(mol) {
4339
+ let deferred1_0;
4340
+ let deferred1_1;
4341
+ try {
4342
+ _assertClass(mol, MolHandle);
4343
+ const ret = wasm.to_xyz(mol.__wbg_ptr);
4344
+ deferred1_0 = ret[0];
4345
+ deferred1_1 = ret[1];
4346
+ return getStringFromWasm0(ret[0], ret[1]);
4347
+ } finally {
4348
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4349
+ }
4350
+ }
4351
+
4352
+ /**
4353
+ * Torsion fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
4354
+ * @param {MolHandle} mol
4355
+ * @returns {Uint8Array}
4356
+ */
4357
+ export function torsion_bitvec(mol) {
4358
+ _assertClass(mol, MolHandle);
4359
+ const ret = wasm.torsion_bitvec(mol.__wbg_ptr);
4360
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
4361
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
4362
+ return v1;
4363
+ }
4364
+
4365
+ /**
4366
+ * Scan a torsion dihedral i-j-k-l from 0° to 360° in `steps` increments.
4367
+ * Returns JSON array: [{"angle":0.0,"energy":E},...] or {"error":"..."}.
4368
+ * @param {MolHandle} mol
4369
+ * @param {number} i
4370
+ * @param {number} j
4371
+ * @param {number} k
4372
+ * @param {number} l
4373
+ * @param {number} steps
4374
+ * @returns {string}
4375
+ */
4376
+ export function torsion_scan_json(mol, i, j, k, l, steps) {
4377
+ let deferred1_0;
4378
+ let deferred1_1;
4379
+ try {
4380
+ _assertClass(mol, MolHandle);
4381
+ const ret = wasm.torsion_scan_json(mol.__wbg_ptr, i, j, k, l, steps);
4382
+ deferred1_0 = ret[0];
4383
+ deferred1_1 = ret[1];
4384
+ return getStringFromWasm0(ret[0], ret[1]);
4385
+ } finally {
4386
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4387
+ }
4388
+ }
4389
+
4390
+ /**
4391
+ * Virtual screen a query SMILES against a database of SMILES using ECFP4 Tanimoto.
4392
+ *
4393
+ * `db_smiles_json`: JSON array of SMILES strings (max 1024 via WASM_MAX_BATCH_ITEMS).
4394
+ * `k`: number of top hits to return; clamped to db size if larger.
4395
+ *
4396
+ * Returns JSON: `{"results":[{"rank":1,"score":0.85,"smiles":"CCO","idx":42},...]}`.
4397
+ * Returns `"error:<msg>"` on any parse failure or oversized input.
4398
+ * @param {string} query_smi
4399
+ * @param {string} db_smiles_json
4400
+ * @param {number} k
4401
+ * @returns {string}
4402
+ */
4403
+ export function virtual_screen_ecfp4_json(query_smi, db_smiles_json, k) {
4404
+ let deferred3_0;
4405
+ let deferred3_1;
4406
+ try {
4407
+ const ptr0 = passStringToWasm0(query_smi, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4408
+ const len0 = WASM_VECTOR_LEN;
4409
+ const ptr1 = passStringToWasm0(db_smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4410
+ const len1 = WASM_VECTOR_LEN;
4411
+ const ret = wasm.virtual_screen_ecfp4_json(ptr0, len0, ptr1, len1, k);
4412
+ deferred3_0 = ret[0];
4413
+ deferred3_1 = ret[1];
4414
+ return getStringFromWasm0(ret[0], ret[1]);
4415
+ } finally {
4416
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4417
+ }
4418
+ }
4419
+
4420
+ /**
4421
+ * Compute WHIM descriptors (Weighted Holistic Invariant Molecular) from 3D coordinates.
4422
+ * Returns JSON array of 10 values: [L1, L2, L3, P1, P2, P3, ALPHA, BETA, GAMMA, DELTA]
4423
+ * where L* = inertia tensor eigenvalues, P* = principal moments, ALPHA = sum of moments,
4424
+ * BETA = average pairwise interaction, GAMMA = geometric mean, DELTA = anisotropy.
4425
+ * @param {MolHandle} mol
4426
+ * @returns {string}
4427
+ */
4428
+ export function whim_descriptors_json(mol) {
4429
+ let deferred1_0;
4430
+ let deferred1_1;
4431
+ try {
4432
+ _assertClass(mol, MolHandle);
4433
+ const ret = wasm.whim_descriptors_json(mol.__wbg_ptr);
4434
+ deferred1_0 = ret[0];
4435
+ deferred1_1 = ret[1];
4436
+ return getStringFromWasm0(ret[0], ret[1]);
4437
+ } finally {
4438
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4439
+ }
4440
+ }
4441
+
4442
+ /**
4443
+ * Compute combined WHIM + GETAWAY descriptors (19 values total) as JSON array.
4444
+ * Useful for ML pipelines requiring both shape and topologic features.
4445
+ * @param {MolHandle} mol
4446
+ * @returns {string}
4447
+ */
4448
+ export function whim_getaway_combined_json(mol) {
4449
+ let deferred1_0;
4450
+ let deferred1_1;
4451
+ try {
4452
+ _assertClass(mol, MolHandle);
4453
+ const ret = wasm.whim_getaway_combined_json(mol.__wbg_ptr);
4454
+ deferred1_0 = ret[0];
4455
+ deferred1_1 = ret[1];
4456
+ return getStringFromWasm0(ret[0], ret[1]);
4457
+ } finally {
4458
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4459
+ }
4460
+ }
4461
+
4462
+ /**
4463
+ * Non-canonical SMILES for `mol`.
4464
+ *
4465
+ * Unlike `canonical_smiles`, the output depends on the internal atom ordering
4466
+ * and is not normalised. Useful when round-trip fidelity (preserving atom
4467
+ * order) matters more than a canonical form.
4468
+ * @param {MolHandle} mol
4469
+ * @returns {string}
4470
+ */
4471
+ export function write_smiles(mol) {
4472
+ let deferred1_0;
4473
+ let deferred1_1;
4474
+ try {
4475
+ _assertClass(mol, MolHandle);
4476
+ const ret = wasm.write_smiles(mol.__wbg_ptr);
4477
+ deferred1_0 = ret[0];
4478
+ deferred1_1 = ret[1];
4479
+ return getStringFromWasm0(ret[0], ret[1]);
4480
+ } finally {
4481
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4482
+ }
4483
+ }
4484
+ function __wbg_get_imports() {
4485
+ const import0 = {
4486
+ __proto__: null,
4487
+ __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
4488
+ const obj = arg1;
4489
+ const ret = typeof(obj) === 'string' ? obj : undefined;
4490
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4491
+ var len1 = WASM_VECTOR_LEN;
4492
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4493
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4494
+ },
4495
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
4496
+ throw new Error(getStringFromWasm0(arg0, arg1));
4497
+ },
4498
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
4499
+ let deferred0_0;
4500
+ let deferred0_1;
4501
+ try {
4502
+ deferred0_0 = arg0;
4503
+ deferred0_1 = arg1;
4504
+ console.error(getStringFromWasm0(arg0, arg1));
4505
+ } finally {
4506
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
4507
+ }
4508
+ },
4509
+ __wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
4510
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
4511
+ }, arguments); },
4512
+ __wbg_new_227d7c05414eb861: function() {
4513
+ const ret = new Error();
4514
+ return ret;
4515
+ },
4516
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
4517
+ const ret = arg1.stack;
4518
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4519
+ const len1 = WASM_VECTOR_LEN;
4520
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4521
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4522
+ },
4523
+ __wbindgen_cast_0000000000000001: function(arg0) {
4524
+ // Cast intrinsic for `F64 -> Externref`.
4525
+ const ret = arg0;
4526
+ return ret;
4527
+ },
4528
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
4529
+ // Cast intrinsic for `Ref(String) -> Externref`.
4530
+ const ret = getStringFromWasm0(arg0, arg1);
4531
+ return ret;
4532
+ },
4533
+ __wbindgen_init_externref_table: function() {
4534
+ const table = wasm.__wbindgen_externrefs;
4535
+ const offset = table.grow(4);
4536
+ table.set(0, undefined);
4537
+ table.set(offset + 0, undefined);
4538
+ table.set(offset + 1, null);
4539
+ table.set(offset + 2, true);
4540
+ table.set(offset + 3, false);
4541
+ },
4542
+ };
4543
+ return {
4544
+ __proto__: null,
4545
+ "./chematic_wasm_bg.js": import0,
4546
+ };
4547
+ }
4548
+
4549
+ const ConformerHandleFinalization = (typeof FinalizationRegistry === 'undefined')
4550
+ ? { register: () => {}, unregister: () => {} }
4551
+ : new FinalizationRegistry(ptr => wasm.__wbg_conformerhandle_free(ptr, 1));
4552
+ const DepictOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
4553
+ ? { register: () => {}, unregister: () => {} }
4554
+ : new FinalizationRegistry(ptr => wasm.__wbg_depictoptions_free(ptr, 1));
4555
+ const MhfpLshHandleFinalization = (typeof FinalizationRegistry === 'undefined')
4556
+ ? { register: () => {}, unregister: () => {} }
4557
+ : new FinalizationRegistry(ptr => wasm.__wbg_mhfplshhandle_free(ptr, 1));
4558
+ const MolHandleFinalization = (typeof FinalizationRegistry === 'undefined')
4559
+ ? { register: () => {}, unregister: () => {} }
4560
+ : new FinalizationRegistry(ptr => wasm.__wbg_molhandle_free(ptr, 1));
4561
+
4562
+ function addToExternrefTable0(obj) {
4563
+ const idx = wasm.__externref_table_alloc();
4564
+ wasm.__wbindgen_externrefs.set(idx, obj);
4565
+ return idx;
4566
+ }
4567
+
4568
+ function _assertClass(instance, klass) {
4569
+ if (!(instance instanceof klass)) {
4570
+ throw new Error(`expected instance of ${klass.name}`);
4571
+ }
4572
+ }
4573
+
4574
+ function getArrayU8FromWasm0(ptr, len) {
4575
+ ptr = ptr >>> 0;
4576
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4577
+ }
4578
+
4579
+ let cachedDataViewMemory0 = null;
4580
+ function getDataViewMemory0() {
4581
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
4582
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
4583
+ }
4584
+ return cachedDataViewMemory0;
4585
+ }
4586
+
4587
+ function getStringFromWasm0(ptr, len) {
4588
+ return decodeText(ptr >>> 0, len);
4589
+ }
4590
+
4591
+ let cachedUint32ArrayMemory0 = null;
4592
+ function getUint32ArrayMemory0() {
4593
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
4594
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
4595
+ }
4596
+ return cachedUint32ArrayMemory0;
4597
+ }
4598
+
4599
+ let cachedUint8ArrayMemory0 = null;
4600
+ function getUint8ArrayMemory0() {
4601
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
4602
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
4603
+ }
4604
+ return cachedUint8ArrayMemory0;
4605
+ }
4606
+
4607
+ function handleError(f, args) {
4608
+ try {
4609
+ return f.apply(this, args);
4610
+ } catch (e) {
4611
+ const idx = addToExternrefTable0(e);
4612
+ wasm.__wbindgen_exn_store(idx);
4613
+ }
4614
+ }
4615
+
4616
+ function isLikeNone(x) {
4617
+ return x === undefined || x === null;
4618
+ }
4619
+
4620
+ function passArray32ToWasm0(arg, malloc) {
4621
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
4622
+ getUint32ArrayMemory0().set(arg, ptr / 4);
4623
+ WASM_VECTOR_LEN = arg.length;
4624
+ return ptr;
4625
+ }
4626
+
4627
+ function passStringToWasm0(arg, malloc, realloc) {
4628
+ if (realloc === undefined) {
4629
+ const buf = cachedTextEncoder.encode(arg);
4630
+ const ptr = malloc(buf.length, 1) >>> 0;
4631
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
4632
+ WASM_VECTOR_LEN = buf.length;
4633
+ return ptr;
4634
+ }
4635
+
4636
+ let len = arg.length;
4637
+ let ptr = malloc(len, 1) >>> 0;
4638
+
4639
+ const mem = getUint8ArrayMemory0();
4640
+
4641
+ let offset = 0;
4642
+
4643
+ for (; offset < len; offset++) {
4644
+ const code = arg.charCodeAt(offset);
4645
+ if (code > 0x7F) break;
4646
+ mem[ptr + offset] = code;
4647
+ }
4648
+ if (offset !== len) {
4649
+ if (offset !== 0) {
4650
+ arg = arg.slice(offset);
4651
+ }
4652
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
4653
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
4654
+ const ret = cachedTextEncoder.encodeInto(arg, view);
4655
+
4656
+ offset += ret.written;
4657
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
4658
+ }
4659
+
4660
+ WASM_VECTOR_LEN = offset;
4661
+ return ptr;
4662
+ }
4663
+
4664
+ function takeFromExternrefTable0(idx) {
4665
+ const value = wasm.__wbindgen_externrefs.get(idx);
4666
+ wasm.__externref_table_dealloc(idx);
4667
+ return value;
4668
+ }
4669
+
4670
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4671
+ cachedTextDecoder.decode();
4672
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
4673
+ let numBytesDecoded = 0;
4674
+ function decodeText(ptr, len) {
4675
+ numBytesDecoded += len;
4676
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
4677
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4678
+ cachedTextDecoder.decode();
4679
+ numBytesDecoded = len;
4680
+ }
4681
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
4682
+ }
4683
+
4684
+ const cachedTextEncoder = new TextEncoder();
4685
+
4686
+ if (!('encodeInto' in cachedTextEncoder)) {
4687
+ cachedTextEncoder.encodeInto = function (arg, view) {
4688
+ const buf = cachedTextEncoder.encode(arg);
4689
+ view.set(buf);
4690
+ return {
4691
+ read: arg.length,
4692
+ written: buf.length
4693
+ };
4694
+ };
4695
+ }
4696
+
4697
+ let WASM_VECTOR_LEN = 0;
4698
+
4699
+ let wasmModule, wasmInstance, wasm;
4700
+ function __wbg_finalize_init(instance, module) {
4701
+ wasmInstance = instance;
4702
+ wasm = instance.exports;
4703
+ wasmModule = module;
4704
+ cachedDataViewMemory0 = null;
4705
+ cachedUint32ArrayMemory0 = null;
4706
+ cachedUint8ArrayMemory0 = null;
4707
+ wasm.__wbindgen_start();
4708
+ return wasm;
4709
+ }
4710
+
4711
+ async function __wbg_load(module, imports) {
4712
+ if (typeof Response === 'function' && module instanceof Response) {
4713
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
4714
+ try {
4715
+ return await WebAssembly.instantiateStreaming(module, imports);
4716
+ } catch (e) {
4717
+ const validResponse = module.ok && expectedResponseType(module.type);
4718
+
4719
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
4720
+ 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);
4721
+
4722
+ } else { throw e; }
4723
+ }
4724
+ }
4725
+
4726
+ const bytes = await module.arrayBuffer();
4727
+ return await WebAssembly.instantiate(bytes, imports);
4728
+ } else {
4729
+ const instance = await WebAssembly.instantiate(module, imports);
4730
+
4731
+ if (instance instanceof WebAssembly.Instance) {
4732
+ return { instance, module };
4733
+ } else {
4734
+ return instance;
4735
+ }
4736
+ }
4737
+
4738
+ function expectedResponseType(type) {
4739
+ switch (type) {
4740
+ case 'basic': case 'cors': case 'default': return true;
4741
+ }
4742
+ return false;
4743
+ }
4744
+ }
4745
+
4746
+ function initSync(module) {
4747
+ if (wasm !== undefined) return wasm;
4748
+
4749
+
4750
+ if (module !== undefined) {
4751
+ if (Object.getPrototypeOf(module) === Object.prototype) {
4752
+ ({module} = module)
4753
+ } else {
4754
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
4755
+ }
4756
+ }
4757
+
4758
+ const imports = __wbg_get_imports();
4759
+ if (!(module instanceof WebAssembly.Module)) {
4760
+ module = new WebAssembly.Module(module);
4761
+ }
4762
+ const instance = new WebAssembly.Instance(module, imports);
4763
+ return __wbg_finalize_init(instance, module);
4764
+ }
4765
+
4766
+ async function __wbg_init(module_or_path) {
4767
+ if (wasm !== undefined) return wasm;
4768
+
4769
+
4770
+ if (module_or_path !== undefined) {
4771
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
4772
+ ({module_or_path} = module_or_path)
4773
+ } else {
4774
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
4775
+ }
4776
+ }
4777
+
4778
+ if (module_or_path === undefined) {
4779
+ module_or_path = new URL('chematic_wasm_bg.wasm', import.meta.url);
4780
+ }
4781
+ const imports = __wbg_get_imports();
4782
+
4783
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
4784
+ module_or_path = fetch(module_or_path);
4785
+ }
4786
+
4787
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
4788
+
4789
+ return __wbg_finalize_init(instance, module);
4790
+ }
4791
+
4792
+ export { initSync, __wbg_init as default };