@kent-tokyo/chematic 0.1.9 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -3
- package/chematic_wasm.d.ts +224 -2
- package/chematic_wasm.js +601 -0
- package/chematic_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,11 +13,23 @@ npm install @kent-tokyo/chematic
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
15
|
- Parse SMILES strings into molecule handles
|
|
16
|
-
- Molecular descriptors: MW, TPSA, LogP, Fsp3, QED, exact mass, rotatable bonds, HBD/HBA, aromatic ring count
|
|
17
|
-
- Lipinski
|
|
16
|
+
- Molecular descriptors: MW, TPSA, LogP, Fsp3, QED, exact mass, rotatable bonds, HBD/HBA, aromatic ring count, Labute ASA
|
|
17
|
+
- Drug-likeness filters: Lipinski, Veber, Egan, REOS, Ghose
|
|
18
|
+
- EState indices (Hall & Kier 1991): per-atom values, sum/max/min
|
|
19
|
+
- Gasteiger-Marsili PEOE partial charges: per-heavy-atom charges
|
|
20
|
+
- VSA descriptors: SlogP_VSA (×12), SMR_VSA (×10), PEOE_VSA (×14)
|
|
21
|
+
- SA score: synthetic accessibility estimate [1, 10]
|
|
22
|
+
- Functional group identification (Ertl 2017 IFG)
|
|
18
23
|
- Canonical SMILES generation
|
|
19
|
-
- ECFP4, AtomPair, and
|
|
24
|
+
- ECFP4/6, AtomPair, Torsion, and path fingerprints with Tanimoto similarity
|
|
20
25
|
- BRICS fragment count
|
|
26
|
+
- SDF/MOL block parsing
|
|
27
|
+
- Topological descriptors: Wiener index, Hall-Kier κ, χ connectivity indices, Bertz CT
|
|
28
|
+
- Shape descriptors (with 3D coordinates): PMI, NPR, radius of gyration, asphericity
|
|
29
|
+
- 2D SVG depiction with CPK colors and atom/bond highlighting
|
|
30
|
+
- SVG grid layout for multiple molecules
|
|
31
|
+
- Reaction SMILES/SMIRKS parsing and transform
|
|
32
|
+
- Add/remove explicit hydrogens
|
|
21
33
|
|
|
22
34
|
## Usage
|
|
23
35
|
|
|
@@ -28,6 +40,11 @@ import init, {
|
|
|
28
40
|
tanimoto_atom_pair,
|
|
29
41
|
tanimoto_torsion,
|
|
30
42
|
brics_fragment_count,
|
|
43
|
+
gasteiger_charges_json,
|
|
44
|
+
slogp_vsa_json,
|
|
45
|
+
smr_vsa_json,
|
|
46
|
+
peoe_vsa_json,
|
|
47
|
+
identify_functional_groups,
|
|
31
48
|
} from '@kent-tokyo/chematic';
|
|
32
49
|
|
|
33
50
|
await init();
|
|
@@ -60,6 +77,25 @@ console.log(tanimoto_atom_pair(mol, caffeine)); // AtomPair Tanimoto
|
|
|
60
77
|
console.log(tanimoto_torsion(mol, caffeine)); // Torsion Tanimoto
|
|
61
78
|
```
|
|
62
79
|
|
|
80
|
+
```js
|
|
81
|
+
// Sprint Q: New descriptors (v0.1.15)
|
|
82
|
+
console.log(mol.sa_score()); // synthetic accessibility [1,10]
|
|
83
|
+
console.log(mol.labute_asa()); // Labute approx. surface area (Ų)
|
|
84
|
+
|
|
85
|
+
// Gasteiger partial charges (per heavy atom)
|
|
86
|
+
const charges = JSON.parse(gasteiger_charges_json(mol));
|
|
87
|
+
console.log(charges); // [-0.08, 0.12, -0.43, ...]
|
|
88
|
+
|
|
89
|
+
// VSA descriptor bins
|
|
90
|
+
const slogpVsa = JSON.parse(slogp_vsa_json(mol));
|
|
91
|
+
const smrVsa = JSON.parse(smr_vsa_json(mol));
|
|
92
|
+
const peoeVsa = JSON.parse(peoe_vsa_json(mol));
|
|
93
|
+
|
|
94
|
+
// Functional group identification
|
|
95
|
+
const ifg = JSON.parse(identify_functional_groups(mol));
|
|
96
|
+
console.log(ifg); // [{"atoms":[1,2,3],"types":"OC=O"}, ...]
|
|
97
|
+
```
|
|
98
|
+
|
|
63
99
|
## Building from source
|
|
64
100
|
|
|
65
101
|
```sh
|
package/chematic_wasm.d.ts
CHANGED
|
@@ -17,13 +17,22 @@ export class DepictOptions {
|
|
|
17
17
|
free(): void;
|
|
18
18
|
[Symbol.dispose](): void;
|
|
19
19
|
constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Set a per-atom color override (CSS color string). Calling multiple times
|
|
22
|
+
* for the same `idx` uses the last value. The atom is highlighted even if
|
|
23
|
+
* not in `set_highlight_atoms`.
|
|
24
|
+
*/
|
|
25
|
+
set_atom_color(idx: number, color: string): void;
|
|
26
|
+
set_atom_ids(v: boolean): void;
|
|
20
27
|
set_background(bg: string): void;
|
|
21
28
|
set_dark(dark: boolean): void;
|
|
22
29
|
set_height(h: number): void;
|
|
23
30
|
set_highlight_atoms(atoms: Uint32Array): void;
|
|
24
31
|
set_highlight_bonds(bonds: Uint32Array): void;
|
|
25
32
|
set_highlight_color(color: string): void;
|
|
33
|
+
set_kekulize(v: boolean): void;
|
|
26
34
|
set_padding(p: number): void;
|
|
35
|
+
set_show_atom_indices(v: boolean): void;
|
|
27
36
|
set_width(w: number): void;
|
|
28
37
|
}
|
|
29
38
|
|
|
@@ -165,6 +174,14 @@ export class MolHandle {
|
|
|
165
174
|
* Crippen–Wildman octanol/water partition coefficient (LogP).
|
|
166
175
|
*/
|
|
167
176
|
logp_crippen(): number;
|
|
177
|
+
/**
|
|
178
|
+
* Maximum EState index across all heavy atoms.
|
|
179
|
+
*/
|
|
180
|
+
max_estate(): number;
|
|
181
|
+
/**
|
|
182
|
+
* Minimum EState index across all heavy atoms.
|
|
183
|
+
*/
|
|
184
|
+
min_estate(): number;
|
|
168
185
|
/**
|
|
169
186
|
* Wildman–Crippen molar refractivity (MR).
|
|
170
187
|
*/
|
|
@@ -227,6 +244,10 @@ export class MolHandle {
|
|
|
227
244
|
* Number of rotatable bonds.
|
|
228
245
|
*/
|
|
229
246
|
rotatable_bond_count(): number;
|
|
247
|
+
/**
|
|
248
|
+
* Sum of EState indices over all heavy atoms.
|
|
249
|
+
*/
|
|
250
|
+
sum_estate(): number;
|
|
230
251
|
/**
|
|
231
252
|
* Topological polar surface area (Ų).
|
|
232
253
|
*/
|
|
@@ -254,6 +275,14 @@ export function add_hydrogens(mol: MolHandle): MolHandle;
|
|
|
254
275
|
*/
|
|
255
276
|
export function brics_fragment_count(mol: MolHandle): number;
|
|
256
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Render a reaction SMILES string (e.g. `"CC(=O)O.CCO>>CC(=O)OCC.O"`) as a
|
|
280
|
+
* single SVG showing reactants → products with `+` separators.
|
|
281
|
+
*
|
|
282
|
+
* Returns a self-contained SVG string. Returns a JS error on invalid input.
|
|
283
|
+
*/
|
|
284
|
+
export function depict_reaction_svg(rxn_smiles: string): string;
|
|
285
|
+
|
|
257
286
|
/**
|
|
258
287
|
* Render a grid SVG from newline-separated SMILES (one per line).
|
|
259
288
|
*
|
|
@@ -262,16 +291,110 @@ export function brics_fragment_count(mol: MolHandle): number;
|
|
|
262
291
|
*/
|
|
263
292
|
export function depict_svg_grid(smiles_block: string, cols: number): string;
|
|
264
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Detect named functional groups in `mol`.
|
|
296
|
+
*
|
|
297
|
+
* Returns a JSON array of `{"name":"hydroxyl","atoms":[3]}` objects.
|
|
298
|
+
* Multiple matches of the same group (e.g. two hydroxyl groups) each appear
|
|
299
|
+
* as a separate entry. Overlapping groups (carboxylic acid → "carboxyl" +
|
|
300
|
+
* "hydroxyl" + "carbonyl") are all returned.
|
|
301
|
+
*/
|
|
302
|
+
export function detect_functional_groups(mol: MolHandle): string;
|
|
303
|
+
|
|
265
304
|
/**
|
|
266
305
|
* Compute the ECFP4 fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
|
|
267
306
|
*/
|
|
268
307
|
export function ecfp4_bitvec(mol: MolHandle): Uint8Array;
|
|
269
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Per-atom EState values as a JSON array of f64.
|
|
311
|
+
*
|
|
312
|
+
* Indices match `mol.atoms()` order. Hydrogen atoms get 0.0.
|
|
313
|
+
*/
|
|
314
|
+
export function estate_indices_json(mol: MolHandle): string;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Gasteiger-Marsili PEOE partial charges as a JSON array of f64.
|
|
318
|
+
*/
|
|
319
|
+
export function gasteiger_charges_json(mol: MolHandle): string;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Generate 3D coordinates for the molecule and return a PDB string.
|
|
323
|
+
*
|
|
324
|
+
* Coordinates are generated using distance-geometry placement with ring templates.
|
|
325
|
+
* Returns heavy-atom PDB (HETATM records, no explicit H).
|
|
326
|
+
*/
|
|
327
|
+
export function generate_3d_pdb(mol: MolHandle): string;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Return information about a single atom as a JSON object.
|
|
331
|
+
*
|
|
332
|
+
* `idx` is the 0-based atom index (matching `atoms()` order).
|
|
333
|
+
* Returns `"null"` if `idx` is out of range.
|
|
334
|
+
*
|
|
335
|
+
* Fields: `element` (symbol), `hybridization` ("sp"/"sp2"/"sp3"),
|
|
336
|
+
* `charge` (formal charge integer), `isAromatic` (bool),
|
|
337
|
+
* `totalHydrogens` (explicit + implicit H count, integer).
|
|
338
|
+
* sp3d/sp3d2 (hypervalent P/S) are not distinguished from sp3/sp2.
|
|
339
|
+
*/
|
|
340
|
+
export function get_atom_info(mol: MolHandle, idx: number): string;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Return bond information as a JSON object, looked up by the two bonded atom indices.
|
|
344
|
+
*
|
|
345
|
+
* Useful when you know the atom indices from SMARTS matching or `data-atom-idx` SVG
|
|
346
|
+
* attributes but not the bond index. Returns `"null"` if no bond exists between them.
|
|
347
|
+
*
|
|
348
|
+
* Fields: same as `get_bond_info` plus `bondIdx` (u32).
|
|
349
|
+
*/
|
|
350
|
+
export function get_bond_between(mol: MolHandle, atom1: number, atom2: number): string;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Return bond information as a JSON object, looked up by bond index.
|
|
354
|
+
*
|
|
355
|
+
* `idx` is the 0-based bond index (order matches `mol.bonds()` iteration).
|
|
356
|
+
* Returns `"null"` if `idx` is out of range.
|
|
357
|
+
*
|
|
358
|
+
* Fields: `bondOrder` (1.0/1.5/2.0/3.0), `isAromatic` (bool),
|
|
359
|
+
* `isInRing` (bool), `atomFrom` (u32), `atomTo` (u32).
|
|
360
|
+
*/
|
|
361
|
+
export function get_bond_info(mol: MolHandle, idx: number): string;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Identify functional groups. Returns a JSON array of objects:
|
|
365
|
+
* `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
|
|
366
|
+
*/
|
|
367
|
+
export function identify_functional_groups(mol: MolHandle): string;
|
|
368
|
+
|
|
270
369
|
/**
|
|
271
370
|
* Returns `true` if the SMILES string can be parsed without error.
|
|
272
371
|
*/
|
|
273
372
|
export function is_valid_smiles(s: string): boolean;
|
|
274
373
|
|
|
374
|
+
/**
|
|
375
|
+
* Find all SMARTS matches in a molecule given only SMILES strings.
|
|
376
|
+
*
|
|
377
|
+
* Convenience wrapper around `smarts_match_atoms` that accepts raw SMILES
|
|
378
|
+
* instead of a `MolHandle`. Returns the same JSON format: `[[0,1],[3,4]]`.
|
|
379
|
+
* Returns a JS error on SMILES or SMARTS parse failure.
|
|
380
|
+
*/
|
|
381
|
+
export function match_smarts_smiles(smiles: string, smarts: string): string;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Serialize a SMILES string directly to a MOL V2000 block.
|
|
385
|
+
*
|
|
386
|
+
* Convenience wrapper; all atom coordinates are 0.0.
|
|
387
|
+
* Returns a JS error on SMILES parse failure.
|
|
388
|
+
*/
|
|
389
|
+
export function mol_block_from_smiles(smiles: string): string;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Parse a MOL V2000 block and return a `MolHandle`.
|
|
393
|
+
*
|
|
394
|
+
* Returns a JS error string on parse failure.
|
|
395
|
+
*/
|
|
396
|
+
export function mol_from_sdf_block(block: string): MolHandle;
|
|
397
|
+
|
|
275
398
|
/**
|
|
276
399
|
* Parse a SMILES string into a `MolHandle`.
|
|
277
400
|
*
|
|
@@ -279,6 +402,11 @@ export function is_valid_smiles(s: string): boolean;
|
|
|
279
402
|
*/
|
|
280
403
|
export function parse_smiles(s: string): MolHandle;
|
|
281
404
|
|
|
405
|
+
/**
|
|
406
|
+
* PEOE_VSA descriptors (14 bins) as a JSON array.
|
|
407
|
+
*/
|
|
408
|
+
export function peoe_vsa_json(mol: MolHandle): string;
|
|
409
|
+
|
|
282
410
|
/**
|
|
283
411
|
* Return a copy of the molecule with all explicit hydrogen atoms removed.
|
|
284
412
|
*/
|
|
@@ -293,6 +421,50 @@ export function remove_hydrogens(mol: MolHandle): MolHandle;
|
|
|
293
421
|
*/
|
|
294
422
|
export function run_reactants(smirks: string, reactants_smiles: string): string;
|
|
295
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Synthetic Accessibility Score (1 = easy, 10 = hard).
|
|
426
|
+
*/
|
|
427
|
+
export function sa_score(mol: MolHandle): number;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Parse an SDF string and return a JSON array of canonical SMILES strings.
|
|
431
|
+
*
|
|
432
|
+
* Invalid records are represented as `null` in the array.
|
|
433
|
+
*/
|
|
434
|
+
export function sdf_to_smiles_json(sdf: string): string;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* SlogP_VSA descriptors (12 bins) as a JSON array.
|
|
438
|
+
*/
|
|
439
|
+
export function slogp_vsa_json(mol: MolHandle): string;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Find all substructure matches of a SMARTS pattern in `mol`.
|
|
443
|
+
*
|
|
444
|
+
* Returns JSON array of arrays of atom indices (sorted, 0-based).
|
|
445
|
+
* Example: `[[0,1,2],[3,4,5]]` — two matches.
|
|
446
|
+
* Returns `"[]"` if no match. Returns a JS error on invalid SMARTS.
|
|
447
|
+
*/
|
|
448
|
+
export function smarts_match_atoms(smarts: string, mol: MolHandle): string;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Render a highlighted SVG from a SMILES string in one call.
|
|
452
|
+
*
|
|
453
|
+
* `atoms` — 0-based atom indices to highlight (Uint32Array in JS).
|
|
454
|
+
* `bonds` — 0-based bond indices to highlight (Uint32Array in JS).
|
|
455
|
+
* `color` — CSS color for highlights (e.g. `"#ef4444"`); empty string uses default yellow.
|
|
456
|
+
*
|
|
457
|
+
* Returns a JS error on SMILES parse failure.
|
|
458
|
+
*/
|
|
459
|
+
export function smiles_to_svg_highlighted(smiles: string, atoms: Uint32Array, bonds: Uint32Array, color: string): string;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* SMR_VSA descriptors (10 bins) as a JSON array.
|
|
463
|
+
*/
|
|
464
|
+
export function smr_vsa_json(mol: MolHandle): string;
|
|
465
|
+
|
|
466
|
+
export function start(): void;
|
|
467
|
+
|
|
296
468
|
/**
|
|
297
469
|
* Tanimoto similarity between two molecules using AtomPair fingerprints.
|
|
298
470
|
*/
|
|
@@ -308,11 +480,31 @@ export function tanimoto_ecfp4(a: MolHandle, b: MolHandle): number;
|
|
|
308
480
|
*/
|
|
309
481
|
export function tanimoto_fcfp4(a: MolHandle, b: MolHandle): number;
|
|
310
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Tanimoto similarity between two molecules given only SMILES strings (ECFP4).
|
|
485
|
+
*
|
|
486
|
+
* Returns a JS error on parse failure.
|
|
487
|
+
*/
|
|
488
|
+
export function tanimoto_smiles(smiles1: string, smiles2: string): number;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Tanimoto similarity between two molecules using topological path fingerprints.
|
|
492
|
+
*/
|
|
493
|
+
export function tanimoto_topo_path(a: MolHandle, b: MolHandle): number;
|
|
494
|
+
|
|
311
495
|
/**
|
|
312
496
|
* Tanimoto similarity between two molecules using Topological Torsion fingerprints.
|
|
313
497
|
*/
|
|
314
498
|
export function tanimoto_torsion(a: MolHandle, b: MolHandle): number;
|
|
315
499
|
|
|
500
|
+
/**
|
|
501
|
+
* Serialize a molecule to a MOL V2000 block.
|
|
502
|
+
*
|
|
503
|
+
* All atom coordinates are written as 0.0 (the `Molecule` type has no 2D
|
|
504
|
+
* coordinate storage; real coordinates would require a separate layout pass).
|
|
505
|
+
*/
|
|
506
|
+
export function to_mol_block(mol: MolHandle): string;
|
|
507
|
+
|
|
316
508
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
317
509
|
|
|
318
510
|
export interface InitOutput {
|
|
@@ -321,18 +513,34 @@ export interface InitOutput {
|
|
|
321
513
|
readonly __wbg_molhandle_free: (a: number, b: number) => void;
|
|
322
514
|
readonly add_hydrogens: (a: number) => number;
|
|
323
515
|
readonly brics_fragment_count: (a: number) => number;
|
|
516
|
+
readonly depict_reaction_svg: (a: number, b: number) => [number, number, number, number];
|
|
324
517
|
readonly depict_svg_grid: (a: number, b: number, c: number) => [number, number];
|
|
325
518
|
readonly depictoptions_new: () => number;
|
|
519
|
+
readonly depictoptions_set_atom_color: (a: number, b: number, c: number, d: number) => void;
|
|
520
|
+
readonly depictoptions_set_atom_ids: (a: number, b: number) => void;
|
|
326
521
|
readonly depictoptions_set_background: (a: number, b: number, c: number) => void;
|
|
327
522
|
readonly depictoptions_set_dark: (a: number, b: number) => void;
|
|
328
523
|
readonly depictoptions_set_height: (a: number, b: number) => void;
|
|
329
524
|
readonly depictoptions_set_highlight_atoms: (a: number, b: number, c: number) => void;
|
|
330
525
|
readonly depictoptions_set_highlight_bonds: (a: number, b: number, c: number) => void;
|
|
331
526
|
readonly depictoptions_set_highlight_color: (a: number, b: number, c: number) => void;
|
|
527
|
+
readonly depictoptions_set_kekulize: (a: number, b: number) => void;
|
|
332
528
|
readonly depictoptions_set_padding: (a: number, b: number) => void;
|
|
529
|
+
readonly depictoptions_set_show_atom_indices: (a: number, b: number) => void;
|
|
333
530
|
readonly depictoptions_set_width: (a: number, b: number) => void;
|
|
531
|
+
readonly detect_functional_groups: (a: number) => [number, number];
|
|
334
532
|
readonly ecfp4_bitvec: (a: number) => [number, number];
|
|
533
|
+
readonly estate_indices_json: (a: number) => [number, number];
|
|
534
|
+
readonly gasteiger_charges_json: (a: number) => [number, number];
|
|
535
|
+
readonly generate_3d_pdb: (a: number) => [number, number];
|
|
536
|
+
readonly get_atom_info: (a: number, b: number) => [number, number];
|
|
537
|
+
readonly get_bond_between: (a: number, b: number, c: number) => [number, number];
|
|
538
|
+
readonly get_bond_info: (a: number, b: number) => [number, number];
|
|
539
|
+
readonly identify_functional_groups: (a: number) => [number, number];
|
|
335
540
|
readonly is_valid_smiles: (a: number, b: number) => number;
|
|
541
|
+
readonly match_smarts_smiles: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
542
|
+
readonly mol_block_from_smiles: (a: number, b: number) => [number, number, number, number];
|
|
543
|
+
readonly mol_from_sdf_block: (a: number, b: number) => [number, number, number];
|
|
336
544
|
readonly molhandle_aromatic_ring_count: (a: number) => number;
|
|
337
545
|
readonly molhandle_atom_count: (a: number) => number;
|
|
338
546
|
readonly molhandle_bertz_ct: (a: number) => number;
|
|
@@ -365,6 +573,8 @@ export interface InitOutput {
|
|
|
365
573
|
readonly molhandle_labute_asa: (a: number) => number;
|
|
366
574
|
readonly molhandle_lipinski_passes: (a: number) => number;
|
|
367
575
|
readonly molhandle_logp_crippen: (a: number) => number;
|
|
576
|
+
readonly molhandle_max_estate: (a: number) => number;
|
|
577
|
+
readonly molhandle_min_estate: (a: number) => number;
|
|
368
578
|
readonly molhandle_molar_refractivity: (a: number) => number;
|
|
369
579
|
readonly molhandle_molecular_weight: (a: number) => number;
|
|
370
580
|
readonly molhandle_morgan_fp_counts_json: (a: number, b: number) => [number, number];
|
|
@@ -380,20 +590,32 @@ export interface InitOutput {
|
|
|
380
590
|
readonly molhandle_reos_passes: (a: number) => number;
|
|
381
591
|
readonly molhandle_ring_count: (a: number) => number;
|
|
382
592
|
readonly molhandle_rotatable_bond_count: (a: number) => number;
|
|
593
|
+
readonly molhandle_sum_estate: (a: number) => number;
|
|
383
594
|
readonly molhandle_tpsa: (a: number) => number;
|
|
384
595
|
readonly molhandle_veber_passes: (a: number) => number;
|
|
385
596
|
readonly molhandle_wiener_index: (a: number) => number;
|
|
386
597
|
readonly parse_smiles: (a: number, b: number) => [number, number, number];
|
|
598
|
+
readonly peoe_vsa_json: (a: number) => [number, number];
|
|
387
599
|
readonly remove_hydrogens: (a: number) => number;
|
|
388
600
|
readonly run_reactants: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
601
|
+
readonly sa_score: (a: number) => number;
|
|
602
|
+
readonly sdf_to_smiles_json: (a: number, b: number) => [number, number];
|
|
603
|
+
readonly slogp_vsa_json: (a: number) => [number, number];
|
|
604
|
+
readonly smarts_match_atoms: (a: number, b: number, c: number) => [number, number, number, number];
|
|
605
|
+
readonly smiles_to_svg_highlighted: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
606
|
+
readonly smr_vsa_json: (a: number) => [number, number];
|
|
389
607
|
readonly tanimoto_atom_pair: (a: number, b: number) => number;
|
|
390
608
|
readonly tanimoto_ecfp4: (a: number, b: number) => number;
|
|
391
609
|
readonly tanimoto_fcfp4: (a: number, b: number) => number;
|
|
610
|
+
readonly tanimoto_smiles: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
611
|
+
readonly tanimoto_topo_path: (a: number, b: number) => number;
|
|
392
612
|
readonly tanimoto_torsion: (a: number, b: number) => number;
|
|
393
|
-
readonly
|
|
613
|
+
readonly to_mol_block: (a: number) => [number, number];
|
|
614
|
+
readonly start: () => void;
|
|
615
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
394
616
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
395
617
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
396
|
-
readonly
|
|
618
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
397
619
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
398
620
|
readonly __wbindgen_start: () => void;
|
|
399
621
|
}
|
package/chematic_wasm.js
CHANGED
|
@@ -29,6 +29,24 @@ export class DepictOptions {
|
|
|
29
29
|
DepictOptionsFinalization.register(this, this.__wbg_ptr, this);
|
|
30
30
|
return this;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Set a per-atom color override (CSS color string). Calling multiple times
|
|
34
|
+
* for the same `idx` uses the last value. The atom is highlighted even if
|
|
35
|
+
* not in `set_highlight_atoms`.
|
|
36
|
+
* @param {number} idx
|
|
37
|
+
* @param {string} color
|
|
38
|
+
*/
|
|
39
|
+
set_atom_color(idx, color) {
|
|
40
|
+
const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
41
|
+
const len0 = WASM_VECTOR_LEN;
|
|
42
|
+
wasm.depictoptions_set_atom_color(this.__wbg_ptr, idx, ptr0, len0);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @param {boolean} v
|
|
46
|
+
*/
|
|
47
|
+
set_atom_ids(v) {
|
|
48
|
+
wasm.depictoptions_set_atom_ids(this.__wbg_ptr, v);
|
|
49
|
+
}
|
|
32
50
|
/**
|
|
33
51
|
* @param {string} bg
|
|
34
52
|
*/
|
|
@@ -73,12 +91,24 @@ export class DepictOptions {
|
|
|
73
91
|
const len0 = WASM_VECTOR_LEN;
|
|
74
92
|
wasm.depictoptions_set_highlight_color(this.__wbg_ptr, ptr0, len0);
|
|
75
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* @param {boolean} v
|
|
96
|
+
*/
|
|
97
|
+
set_kekulize(v) {
|
|
98
|
+
wasm.depictoptions_set_kekulize(this.__wbg_ptr, v);
|
|
99
|
+
}
|
|
76
100
|
/**
|
|
77
101
|
* @param {number} p
|
|
78
102
|
*/
|
|
79
103
|
set_padding(p) {
|
|
80
104
|
wasm.depictoptions_set_padding(this.__wbg_ptr, p);
|
|
81
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* @param {boolean} v
|
|
108
|
+
*/
|
|
109
|
+
set_show_atom_indices(v) {
|
|
110
|
+
wasm.depictoptions_set_show_atom_indices(this.__wbg_ptr, v);
|
|
111
|
+
}
|
|
82
112
|
/**
|
|
83
113
|
* @param {number} w
|
|
84
114
|
*/
|
|
@@ -401,6 +431,22 @@ export class MolHandle {
|
|
|
401
431
|
const ret = wasm.molhandle_logp_crippen(this.__wbg_ptr);
|
|
402
432
|
return ret;
|
|
403
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Maximum EState index across all heavy atoms.
|
|
436
|
+
* @returns {number}
|
|
437
|
+
*/
|
|
438
|
+
max_estate() {
|
|
439
|
+
const ret = wasm.molhandle_max_estate(this.__wbg_ptr);
|
|
440
|
+
return ret;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Minimum EState index across all heavy atoms.
|
|
444
|
+
* @returns {number}
|
|
445
|
+
*/
|
|
446
|
+
min_estate() {
|
|
447
|
+
const ret = wasm.molhandle_min_estate(this.__wbg_ptr);
|
|
448
|
+
return ret;
|
|
449
|
+
}
|
|
404
450
|
/**
|
|
405
451
|
* Wildman–Crippen molar refractivity (MR).
|
|
406
452
|
* @returns {number}
|
|
@@ -532,6 +578,14 @@ export class MolHandle {
|
|
|
532
578
|
const ret = wasm.molhandle_rotatable_bond_count(this.__wbg_ptr);
|
|
533
579
|
return ret >>> 0;
|
|
534
580
|
}
|
|
581
|
+
/**
|
|
582
|
+
* Sum of EState indices over all heavy atoms.
|
|
583
|
+
* @returns {number}
|
|
584
|
+
*/
|
|
585
|
+
sum_estate() {
|
|
586
|
+
const ret = wasm.molhandle_sum_estate(this.__wbg_ptr);
|
|
587
|
+
return ret;
|
|
588
|
+
}
|
|
535
589
|
/**
|
|
536
590
|
* Topological polar surface area (Ų).
|
|
537
591
|
* @returns {number}
|
|
@@ -584,6 +638,35 @@ export function brics_fragment_count(mol) {
|
|
|
584
638
|
return ret >>> 0;
|
|
585
639
|
}
|
|
586
640
|
|
|
641
|
+
/**
|
|
642
|
+
* Render a reaction SMILES string (e.g. `"CC(=O)O.CCO>>CC(=O)OCC.O"`) as a
|
|
643
|
+
* single SVG showing reactants → products with `+` separators.
|
|
644
|
+
*
|
|
645
|
+
* Returns a self-contained SVG string. Returns a JS error on invalid input.
|
|
646
|
+
* @param {string} rxn_smiles
|
|
647
|
+
* @returns {string}
|
|
648
|
+
*/
|
|
649
|
+
export function depict_reaction_svg(rxn_smiles) {
|
|
650
|
+
let deferred3_0;
|
|
651
|
+
let deferred3_1;
|
|
652
|
+
try {
|
|
653
|
+
const ptr0 = passStringToWasm0(rxn_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
654
|
+
const len0 = WASM_VECTOR_LEN;
|
|
655
|
+
const ret = wasm.depict_reaction_svg(ptr0, len0);
|
|
656
|
+
var ptr2 = ret[0];
|
|
657
|
+
var len2 = ret[1];
|
|
658
|
+
if (ret[3]) {
|
|
659
|
+
ptr2 = 0; len2 = 0;
|
|
660
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
661
|
+
}
|
|
662
|
+
deferred3_0 = ptr2;
|
|
663
|
+
deferred3_1 = len2;
|
|
664
|
+
return getStringFromWasm0(ptr2, len2);
|
|
665
|
+
} finally {
|
|
666
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
587
670
|
/**
|
|
588
671
|
* Render a grid SVG from newline-separated SMILES (one per line).
|
|
589
672
|
*
|
|
@@ -608,6 +691,30 @@ export function depict_svg_grid(smiles_block, cols) {
|
|
|
608
691
|
}
|
|
609
692
|
}
|
|
610
693
|
|
|
694
|
+
/**
|
|
695
|
+
* Detect named functional groups in `mol`.
|
|
696
|
+
*
|
|
697
|
+
* Returns a JSON array of `{"name":"hydroxyl","atoms":[3]}` objects.
|
|
698
|
+
* Multiple matches of the same group (e.g. two hydroxyl groups) each appear
|
|
699
|
+
* as a separate entry. Overlapping groups (carboxylic acid → "carboxyl" +
|
|
700
|
+
* "hydroxyl" + "carbonyl") are all returned.
|
|
701
|
+
* @param {MolHandle} mol
|
|
702
|
+
* @returns {string}
|
|
703
|
+
*/
|
|
704
|
+
export function detect_functional_groups(mol) {
|
|
705
|
+
let deferred1_0;
|
|
706
|
+
let deferred1_1;
|
|
707
|
+
try {
|
|
708
|
+
_assertClass(mol, MolHandle);
|
|
709
|
+
const ret = wasm.detect_functional_groups(mol.__wbg_ptr);
|
|
710
|
+
deferred1_0 = ret[0];
|
|
711
|
+
deferred1_1 = ret[1];
|
|
712
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
713
|
+
} finally {
|
|
714
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
611
718
|
/**
|
|
612
719
|
* Compute the ECFP4 fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
|
|
613
720
|
* @param {MolHandle} mol
|
|
@@ -621,6 +728,168 @@ export function ecfp4_bitvec(mol) {
|
|
|
621
728
|
return v1;
|
|
622
729
|
}
|
|
623
730
|
|
|
731
|
+
/**
|
|
732
|
+
* Per-atom EState values as a JSON array of f64.
|
|
733
|
+
*
|
|
734
|
+
* Indices match `mol.atoms()` order. Hydrogen atoms get 0.0.
|
|
735
|
+
* @param {MolHandle} mol
|
|
736
|
+
* @returns {string}
|
|
737
|
+
*/
|
|
738
|
+
export function estate_indices_json(mol) {
|
|
739
|
+
let deferred1_0;
|
|
740
|
+
let deferred1_1;
|
|
741
|
+
try {
|
|
742
|
+
_assertClass(mol, MolHandle);
|
|
743
|
+
const ret = wasm.estate_indices_json(mol.__wbg_ptr);
|
|
744
|
+
deferred1_0 = ret[0];
|
|
745
|
+
deferred1_1 = ret[1];
|
|
746
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
747
|
+
} finally {
|
|
748
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Gasteiger-Marsili PEOE partial charges as a JSON array of f64.
|
|
754
|
+
* @param {MolHandle} mol
|
|
755
|
+
* @returns {string}
|
|
756
|
+
*/
|
|
757
|
+
export function gasteiger_charges_json(mol) {
|
|
758
|
+
let deferred1_0;
|
|
759
|
+
let deferred1_1;
|
|
760
|
+
try {
|
|
761
|
+
_assertClass(mol, MolHandle);
|
|
762
|
+
const ret = wasm.gasteiger_charges_json(mol.__wbg_ptr);
|
|
763
|
+
deferred1_0 = ret[0];
|
|
764
|
+
deferred1_1 = ret[1];
|
|
765
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
766
|
+
} finally {
|
|
767
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Generate 3D coordinates for the molecule and return a PDB string.
|
|
773
|
+
*
|
|
774
|
+
* Coordinates are generated using distance-geometry placement with ring templates.
|
|
775
|
+
* Returns heavy-atom PDB (HETATM records, no explicit H).
|
|
776
|
+
* @param {MolHandle} mol
|
|
777
|
+
* @returns {string}
|
|
778
|
+
*/
|
|
779
|
+
export function generate_3d_pdb(mol) {
|
|
780
|
+
let deferred1_0;
|
|
781
|
+
let deferred1_1;
|
|
782
|
+
try {
|
|
783
|
+
_assertClass(mol, MolHandle);
|
|
784
|
+
const ret = wasm.generate_3d_pdb(mol.__wbg_ptr);
|
|
785
|
+
deferred1_0 = ret[0];
|
|
786
|
+
deferred1_1 = ret[1];
|
|
787
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
788
|
+
} finally {
|
|
789
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Return information about a single atom as a JSON object.
|
|
795
|
+
*
|
|
796
|
+
* `idx` is the 0-based atom index (matching `atoms()` order).
|
|
797
|
+
* Returns `"null"` if `idx` is out of range.
|
|
798
|
+
*
|
|
799
|
+
* Fields: `element` (symbol), `hybridization` ("sp"/"sp2"/"sp3"),
|
|
800
|
+
* `charge` (formal charge integer), `isAromatic` (bool),
|
|
801
|
+
* `totalHydrogens` (explicit + implicit H count, integer).
|
|
802
|
+
* sp3d/sp3d2 (hypervalent P/S) are not distinguished from sp3/sp2.
|
|
803
|
+
* @param {MolHandle} mol
|
|
804
|
+
* @param {number} idx
|
|
805
|
+
* @returns {string}
|
|
806
|
+
*/
|
|
807
|
+
export function get_atom_info(mol, idx) {
|
|
808
|
+
let deferred1_0;
|
|
809
|
+
let deferred1_1;
|
|
810
|
+
try {
|
|
811
|
+
_assertClass(mol, MolHandle);
|
|
812
|
+
const ret = wasm.get_atom_info(mol.__wbg_ptr, idx);
|
|
813
|
+
deferred1_0 = ret[0];
|
|
814
|
+
deferred1_1 = ret[1];
|
|
815
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
816
|
+
} finally {
|
|
817
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Return bond information as a JSON object, looked up by the two bonded atom indices.
|
|
823
|
+
*
|
|
824
|
+
* Useful when you know the atom indices from SMARTS matching or `data-atom-idx` SVG
|
|
825
|
+
* attributes but not the bond index. Returns `"null"` if no bond exists between them.
|
|
826
|
+
*
|
|
827
|
+
* Fields: same as `get_bond_info` plus `bondIdx` (u32).
|
|
828
|
+
* @param {MolHandle} mol
|
|
829
|
+
* @param {number} atom1
|
|
830
|
+
* @param {number} atom2
|
|
831
|
+
* @returns {string}
|
|
832
|
+
*/
|
|
833
|
+
export function get_bond_between(mol, atom1, atom2) {
|
|
834
|
+
let deferred1_0;
|
|
835
|
+
let deferred1_1;
|
|
836
|
+
try {
|
|
837
|
+
_assertClass(mol, MolHandle);
|
|
838
|
+
const ret = wasm.get_bond_between(mol.__wbg_ptr, atom1, atom2);
|
|
839
|
+
deferred1_0 = ret[0];
|
|
840
|
+
deferred1_1 = ret[1];
|
|
841
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
842
|
+
} finally {
|
|
843
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Return bond information as a JSON object, looked up by bond index.
|
|
849
|
+
*
|
|
850
|
+
* `idx` is the 0-based bond index (order matches `mol.bonds()` iteration).
|
|
851
|
+
* Returns `"null"` if `idx` is out of range.
|
|
852
|
+
*
|
|
853
|
+
* Fields: `bondOrder` (1.0/1.5/2.0/3.0), `isAromatic` (bool),
|
|
854
|
+
* `isInRing` (bool), `atomFrom` (u32), `atomTo` (u32).
|
|
855
|
+
* @param {MolHandle} mol
|
|
856
|
+
* @param {number} idx
|
|
857
|
+
* @returns {string}
|
|
858
|
+
*/
|
|
859
|
+
export function get_bond_info(mol, idx) {
|
|
860
|
+
let deferred1_0;
|
|
861
|
+
let deferred1_1;
|
|
862
|
+
try {
|
|
863
|
+
_assertClass(mol, MolHandle);
|
|
864
|
+
const ret = wasm.get_bond_info(mol.__wbg_ptr, idx);
|
|
865
|
+
deferred1_0 = ret[0];
|
|
866
|
+
deferred1_1 = ret[1];
|
|
867
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
868
|
+
} finally {
|
|
869
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Identify functional groups. Returns a JSON array of objects:
|
|
875
|
+
* `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
|
|
876
|
+
* @param {MolHandle} mol
|
|
877
|
+
* @returns {string}
|
|
878
|
+
*/
|
|
879
|
+
export function identify_functional_groups(mol) {
|
|
880
|
+
let deferred1_0;
|
|
881
|
+
let deferred1_1;
|
|
882
|
+
try {
|
|
883
|
+
_assertClass(mol, MolHandle);
|
|
884
|
+
const ret = wasm.identify_functional_groups(mol.__wbg_ptr);
|
|
885
|
+
deferred1_0 = ret[0];
|
|
886
|
+
deferred1_1 = ret[1];
|
|
887
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
888
|
+
} finally {
|
|
889
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
624
893
|
/**
|
|
625
894
|
* Returns `true` if the SMILES string can be parsed without error.
|
|
626
895
|
* @param {string} s
|
|
@@ -633,6 +902,85 @@ export function is_valid_smiles(s) {
|
|
|
633
902
|
return ret !== 0;
|
|
634
903
|
}
|
|
635
904
|
|
|
905
|
+
/**
|
|
906
|
+
* Find all SMARTS matches in a molecule given only SMILES strings.
|
|
907
|
+
*
|
|
908
|
+
* Convenience wrapper around `smarts_match_atoms` that accepts raw SMILES
|
|
909
|
+
* instead of a `MolHandle`. Returns the same JSON format: `[[0,1],[3,4]]`.
|
|
910
|
+
* Returns a JS error on SMILES or SMARTS parse failure.
|
|
911
|
+
* @param {string} smiles
|
|
912
|
+
* @param {string} smarts
|
|
913
|
+
* @returns {string}
|
|
914
|
+
*/
|
|
915
|
+
export function match_smarts_smiles(smiles, smarts) {
|
|
916
|
+
let deferred4_0;
|
|
917
|
+
let deferred4_1;
|
|
918
|
+
try {
|
|
919
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
920
|
+
const len0 = WASM_VECTOR_LEN;
|
|
921
|
+
const ptr1 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
922
|
+
const len1 = WASM_VECTOR_LEN;
|
|
923
|
+
const ret = wasm.match_smarts_smiles(ptr0, len0, ptr1, len1);
|
|
924
|
+
var ptr3 = ret[0];
|
|
925
|
+
var len3 = ret[1];
|
|
926
|
+
if (ret[3]) {
|
|
927
|
+
ptr3 = 0; len3 = 0;
|
|
928
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
929
|
+
}
|
|
930
|
+
deferred4_0 = ptr3;
|
|
931
|
+
deferred4_1 = len3;
|
|
932
|
+
return getStringFromWasm0(ptr3, len3);
|
|
933
|
+
} finally {
|
|
934
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Serialize a SMILES string directly to a MOL V2000 block.
|
|
940
|
+
*
|
|
941
|
+
* Convenience wrapper; all atom coordinates are 0.0.
|
|
942
|
+
* Returns a JS error on SMILES parse failure.
|
|
943
|
+
* @param {string} smiles
|
|
944
|
+
* @returns {string}
|
|
945
|
+
*/
|
|
946
|
+
export function mol_block_from_smiles(smiles) {
|
|
947
|
+
let deferred3_0;
|
|
948
|
+
let deferred3_1;
|
|
949
|
+
try {
|
|
950
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
951
|
+
const len0 = WASM_VECTOR_LEN;
|
|
952
|
+
const ret = wasm.mol_block_from_smiles(ptr0, len0);
|
|
953
|
+
var ptr2 = ret[0];
|
|
954
|
+
var len2 = ret[1];
|
|
955
|
+
if (ret[3]) {
|
|
956
|
+
ptr2 = 0; len2 = 0;
|
|
957
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
958
|
+
}
|
|
959
|
+
deferred3_0 = ptr2;
|
|
960
|
+
deferred3_1 = len2;
|
|
961
|
+
return getStringFromWasm0(ptr2, len2);
|
|
962
|
+
} finally {
|
|
963
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Parse a MOL V2000 block and return a `MolHandle`.
|
|
969
|
+
*
|
|
970
|
+
* Returns a JS error string on parse failure.
|
|
971
|
+
* @param {string} block
|
|
972
|
+
* @returns {MolHandle}
|
|
973
|
+
*/
|
|
974
|
+
export function mol_from_sdf_block(block) {
|
|
975
|
+
const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
976
|
+
const len0 = WASM_VECTOR_LEN;
|
|
977
|
+
const ret = wasm.mol_from_sdf_block(ptr0, len0);
|
|
978
|
+
if (ret[2]) {
|
|
979
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
980
|
+
}
|
|
981
|
+
return MolHandle.__wrap(ret[0]);
|
|
982
|
+
}
|
|
983
|
+
|
|
636
984
|
/**
|
|
637
985
|
* Parse a SMILES string into a `MolHandle`.
|
|
638
986
|
*
|
|
@@ -650,6 +998,25 @@ export function parse_smiles(s) {
|
|
|
650
998
|
return MolHandle.__wrap(ret[0]);
|
|
651
999
|
}
|
|
652
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* PEOE_VSA descriptors (14 bins) as a JSON array.
|
|
1003
|
+
* @param {MolHandle} mol
|
|
1004
|
+
* @returns {string}
|
|
1005
|
+
*/
|
|
1006
|
+
export function peoe_vsa_json(mol) {
|
|
1007
|
+
let deferred1_0;
|
|
1008
|
+
let deferred1_1;
|
|
1009
|
+
try {
|
|
1010
|
+
_assertClass(mol, MolHandle);
|
|
1011
|
+
const ret = wasm.peoe_vsa_json(mol.__wbg_ptr);
|
|
1012
|
+
deferred1_0 = ret[0];
|
|
1013
|
+
deferred1_1 = ret[1];
|
|
1014
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1015
|
+
} finally {
|
|
1016
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
653
1020
|
/**
|
|
654
1021
|
* Return a copy of the molecule with all explicit hydrogen atoms removed.
|
|
655
1022
|
* @param {MolHandle} mol
|
|
@@ -694,6 +1061,154 @@ export function run_reactants(smirks, reactants_smiles) {
|
|
|
694
1061
|
}
|
|
695
1062
|
}
|
|
696
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* Synthetic Accessibility Score (1 = easy, 10 = hard).
|
|
1066
|
+
* @param {MolHandle} mol
|
|
1067
|
+
* @returns {number}
|
|
1068
|
+
*/
|
|
1069
|
+
export function sa_score(mol) {
|
|
1070
|
+
_assertClass(mol, MolHandle);
|
|
1071
|
+
const ret = wasm.sa_score(mol.__wbg_ptr);
|
|
1072
|
+
return ret;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Parse an SDF string and return a JSON array of canonical SMILES strings.
|
|
1077
|
+
*
|
|
1078
|
+
* Invalid records are represented as `null` in the array.
|
|
1079
|
+
* @param {string} sdf
|
|
1080
|
+
* @returns {string}
|
|
1081
|
+
*/
|
|
1082
|
+
export function sdf_to_smiles_json(sdf) {
|
|
1083
|
+
let deferred2_0;
|
|
1084
|
+
let deferred2_1;
|
|
1085
|
+
try {
|
|
1086
|
+
const ptr0 = passStringToWasm0(sdf, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1087
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1088
|
+
const ret = wasm.sdf_to_smiles_json(ptr0, len0);
|
|
1089
|
+
deferred2_0 = ret[0];
|
|
1090
|
+
deferred2_1 = ret[1];
|
|
1091
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1092
|
+
} finally {
|
|
1093
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* SlogP_VSA descriptors (12 bins) as a JSON array.
|
|
1099
|
+
* @param {MolHandle} mol
|
|
1100
|
+
* @returns {string}
|
|
1101
|
+
*/
|
|
1102
|
+
export function slogp_vsa_json(mol) {
|
|
1103
|
+
let deferred1_0;
|
|
1104
|
+
let deferred1_1;
|
|
1105
|
+
try {
|
|
1106
|
+
_assertClass(mol, MolHandle);
|
|
1107
|
+
const ret = wasm.slogp_vsa_json(mol.__wbg_ptr);
|
|
1108
|
+
deferred1_0 = ret[0];
|
|
1109
|
+
deferred1_1 = ret[1];
|
|
1110
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1111
|
+
} finally {
|
|
1112
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Find all substructure matches of a SMARTS pattern in `mol`.
|
|
1118
|
+
*
|
|
1119
|
+
* Returns JSON array of arrays of atom indices (sorted, 0-based).
|
|
1120
|
+
* Example: `[[0,1,2],[3,4,5]]` — two matches.
|
|
1121
|
+
* Returns `"[]"` if no match. Returns a JS error on invalid SMARTS.
|
|
1122
|
+
* @param {string} smarts
|
|
1123
|
+
* @param {MolHandle} mol
|
|
1124
|
+
* @returns {string}
|
|
1125
|
+
*/
|
|
1126
|
+
export function smarts_match_atoms(smarts, mol) {
|
|
1127
|
+
let deferred3_0;
|
|
1128
|
+
let deferred3_1;
|
|
1129
|
+
try {
|
|
1130
|
+
const ptr0 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1131
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1132
|
+
_assertClass(mol, MolHandle);
|
|
1133
|
+
const ret = wasm.smarts_match_atoms(ptr0, len0, mol.__wbg_ptr);
|
|
1134
|
+
var ptr2 = ret[0];
|
|
1135
|
+
var len2 = ret[1];
|
|
1136
|
+
if (ret[3]) {
|
|
1137
|
+
ptr2 = 0; len2 = 0;
|
|
1138
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1139
|
+
}
|
|
1140
|
+
deferred3_0 = ptr2;
|
|
1141
|
+
deferred3_1 = len2;
|
|
1142
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1143
|
+
} finally {
|
|
1144
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Render a highlighted SVG from a SMILES string in one call.
|
|
1150
|
+
*
|
|
1151
|
+
* `atoms` — 0-based atom indices to highlight (Uint32Array in JS).
|
|
1152
|
+
* `bonds` — 0-based bond indices to highlight (Uint32Array in JS).
|
|
1153
|
+
* `color` — CSS color for highlights (e.g. `"#ef4444"`); empty string uses default yellow.
|
|
1154
|
+
*
|
|
1155
|
+
* Returns a JS error on SMILES parse failure.
|
|
1156
|
+
* @param {string} smiles
|
|
1157
|
+
* @param {Uint32Array} atoms
|
|
1158
|
+
* @param {Uint32Array} bonds
|
|
1159
|
+
* @param {string} color
|
|
1160
|
+
* @returns {string}
|
|
1161
|
+
*/
|
|
1162
|
+
export function smiles_to_svg_highlighted(smiles, atoms, bonds, color) {
|
|
1163
|
+
let deferred6_0;
|
|
1164
|
+
let deferred6_1;
|
|
1165
|
+
try {
|
|
1166
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1167
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1168
|
+
const ptr1 = passArray32ToWasm0(atoms, wasm.__wbindgen_malloc);
|
|
1169
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1170
|
+
const ptr2 = passArray32ToWasm0(bonds, wasm.__wbindgen_malloc);
|
|
1171
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1172
|
+
const ptr3 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1173
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1174
|
+
const ret = wasm.smiles_to_svg_highlighted(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
1175
|
+
var ptr5 = ret[0];
|
|
1176
|
+
var len5 = ret[1];
|
|
1177
|
+
if (ret[3]) {
|
|
1178
|
+
ptr5 = 0; len5 = 0;
|
|
1179
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1180
|
+
}
|
|
1181
|
+
deferred6_0 = ptr5;
|
|
1182
|
+
deferred6_1 = len5;
|
|
1183
|
+
return getStringFromWasm0(ptr5, len5);
|
|
1184
|
+
} finally {
|
|
1185
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* SMR_VSA descriptors (10 bins) as a JSON array.
|
|
1191
|
+
* @param {MolHandle} mol
|
|
1192
|
+
* @returns {string}
|
|
1193
|
+
*/
|
|
1194
|
+
export function smr_vsa_json(mol) {
|
|
1195
|
+
let deferred1_0;
|
|
1196
|
+
let deferred1_1;
|
|
1197
|
+
try {
|
|
1198
|
+
_assertClass(mol, MolHandle);
|
|
1199
|
+
const ret = wasm.smr_vsa_json(mol.__wbg_ptr);
|
|
1200
|
+
deferred1_0 = ret[0];
|
|
1201
|
+
deferred1_1 = ret[1];
|
|
1202
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1203
|
+
} finally {
|
|
1204
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
export function start() {
|
|
1209
|
+
wasm.start();
|
|
1210
|
+
}
|
|
1211
|
+
|
|
697
1212
|
/**
|
|
698
1213
|
* Tanimoto similarity between two molecules using AtomPair fingerprints.
|
|
699
1214
|
* @param {MolHandle} a
|
|
@@ -733,6 +1248,39 @@ export function tanimoto_fcfp4(a, b) {
|
|
|
733
1248
|
return ret;
|
|
734
1249
|
}
|
|
735
1250
|
|
|
1251
|
+
/**
|
|
1252
|
+
* Tanimoto similarity between two molecules given only SMILES strings (ECFP4).
|
|
1253
|
+
*
|
|
1254
|
+
* Returns a JS error on parse failure.
|
|
1255
|
+
* @param {string} smiles1
|
|
1256
|
+
* @param {string} smiles2
|
|
1257
|
+
* @returns {number}
|
|
1258
|
+
*/
|
|
1259
|
+
export function tanimoto_smiles(smiles1, smiles2) {
|
|
1260
|
+
const ptr0 = passStringToWasm0(smiles1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1261
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1262
|
+
const ptr1 = passStringToWasm0(smiles2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1263
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1264
|
+
const ret = wasm.tanimoto_smiles(ptr0, len0, ptr1, len1);
|
|
1265
|
+
if (ret[2]) {
|
|
1266
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1267
|
+
}
|
|
1268
|
+
return ret[0];
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Tanimoto similarity between two molecules using topological path fingerprints.
|
|
1273
|
+
* @param {MolHandle} a
|
|
1274
|
+
* @param {MolHandle} b
|
|
1275
|
+
* @returns {number}
|
|
1276
|
+
*/
|
|
1277
|
+
export function tanimoto_topo_path(a, b) {
|
|
1278
|
+
_assertClass(a, MolHandle);
|
|
1279
|
+
_assertClass(b, MolHandle);
|
|
1280
|
+
const ret = wasm.tanimoto_topo_path(a.__wbg_ptr, b.__wbg_ptr);
|
|
1281
|
+
return ret;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
736
1284
|
/**
|
|
737
1285
|
* Tanimoto similarity between two molecules using Topological Torsion fingerprints.
|
|
738
1286
|
* @param {MolHandle} a
|
|
@@ -745,12 +1293,56 @@ export function tanimoto_torsion(a, b) {
|
|
|
745
1293
|
const ret = wasm.tanimoto_torsion(a.__wbg_ptr, b.__wbg_ptr);
|
|
746
1294
|
return ret;
|
|
747
1295
|
}
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* Serialize a molecule to a MOL V2000 block.
|
|
1299
|
+
*
|
|
1300
|
+
* All atom coordinates are written as 0.0 (the `Molecule` type has no 2D
|
|
1301
|
+
* coordinate storage; real coordinates would require a separate layout pass).
|
|
1302
|
+
* @param {MolHandle} mol
|
|
1303
|
+
* @returns {string}
|
|
1304
|
+
*/
|
|
1305
|
+
export function to_mol_block(mol) {
|
|
1306
|
+
let deferred1_0;
|
|
1307
|
+
let deferred1_1;
|
|
1308
|
+
try {
|
|
1309
|
+
_assertClass(mol, MolHandle);
|
|
1310
|
+
const ret = wasm.to_mol_block(mol.__wbg_ptr);
|
|
1311
|
+
deferred1_0 = ret[0];
|
|
1312
|
+
deferred1_1 = ret[1];
|
|
1313
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1314
|
+
} finally {
|
|
1315
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
748
1318
|
function __wbg_get_imports() {
|
|
749
1319
|
const import0 = {
|
|
750
1320
|
__proto__: null,
|
|
751
1321
|
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
752
1322
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
753
1323
|
},
|
|
1324
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
1325
|
+
let deferred0_0;
|
|
1326
|
+
let deferred0_1;
|
|
1327
|
+
try {
|
|
1328
|
+
deferred0_0 = arg0;
|
|
1329
|
+
deferred0_1 = arg1;
|
|
1330
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
1331
|
+
} finally {
|
|
1332
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1333
|
+
}
|
|
1334
|
+
},
|
|
1335
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
1336
|
+
const ret = new Error();
|
|
1337
|
+
return ret;
|
|
1338
|
+
},
|
|
1339
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
1340
|
+
const ret = arg1.stack;
|
|
1341
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1342
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1343
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1344
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1345
|
+
},
|
|
754
1346
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
755
1347
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
756
1348
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
@@ -790,6 +1382,14 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
790
1382
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
791
1383
|
}
|
|
792
1384
|
|
|
1385
|
+
let cachedDataViewMemory0 = null;
|
|
1386
|
+
function getDataViewMemory0() {
|
|
1387
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1388
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1389
|
+
}
|
|
1390
|
+
return cachedDataViewMemory0;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
793
1393
|
function getStringFromWasm0(ptr, len) {
|
|
794
1394
|
return decodeText(ptr >>> 0, len);
|
|
795
1395
|
}
|
|
@@ -894,6 +1494,7 @@ function __wbg_finalize_init(instance, module) {
|
|
|
894
1494
|
wasmInstance = instance;
|
|
895
1495
|
wasm = instance.exports;
|
|
896
1496
|
wasmModule = module;
|
|
1497
|
+
cachedDataViewMemory0 = null;
|
|
897
1498
|
cachedUint32ArrayMemory0 = null;
|
|
898
1499
|
cachedUint8ArrayMemory0 = null;
|
|
899
1500
|
wasm.__wbindgen_start();
|
package/chematic_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"kent-tokyo <kent-tokyo@users.noreply.github.com>"
|
|
6
6
|
],
|
|
7
7
|
"description": "WebAssembly bindings for chematic — use chematic from JavaScript/TypeScript",
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.19",
|
|
9
9
|
"license": "MIT OR Apache-2.0",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|