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