@kent-tokyo/chematic 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/chematic_wasm.js CHANGED
@@ -1,5 +1,126 @@
1
1
  /* @ts-self-types="./chematic_wasm.d.ts" */
2
2
 
3
+ /**
4
+ * A conformer ensemble: one molecule geometry with multiple 3D coordinate sets.
5
+ *
6
+ * Create with `new(smiles)`, then add conformers with `add_generated_conformer`
7
+ * or `add_minimized_conformer`. Retrieve coordinates as PDB strings via
8
+ * `get_conformer_pdb(idx)`. Compare conformers with `conformer_rmsd`.
9
+ */
10
+ export class ConformerHandle {
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ ConformerHandleFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_conformerhandle_free(ptr, 0);
20
+ }
21
+ /**
22
+ * Generate a new 3D conformer using distance-geometry and add it to the ensemble.
23
+ *
24
+ * Returns the index of the newly added conformer.
25
+ * @returns {number}
26
+ */
27
+ add_generated_conformer() {
28
+ const ret = wasm.conformerhandle_add_generated_conformer(this.__wbg_ptr);
29
+ return ret >>> 0;
30
+ }
31
+ /**
32
+ * Generate a new 3D conformer, run force-field minimization, and add it.
33
+ *
34
+ * Returns the index of the newly added conformer.
35
+ * @returns {number}
36
+ */
37
+ add_minimized_conformer() {
38
+ const ret = wasm.conformerhandle_add_minimized_conformer(this.__wbg_ptr);
39
+ return ret >>> 0;
40
+ }
41
+ /**
42
+ * Number of conformers currently stored.
43
+ * @returns {number}
44
+ */
45
+ conformer_count() {
46
+ const ret = wasm.conformerhandle_conformer_count(this.__wbg_ptr);
47
+ return ret >>> 0;
48
+ }
49
+ /**
50
+ * Kabsch-aligned RMSD (Å) between conformers `a` and `b`.
51
+ *
52
+ * Returns `NaN` if either index is out of range.
53
+ * @param {number} a
54
+ * @param {number} b
55
+ * @returns {number}
56
+ */
57
+ conformer_rmsd(a, b) {
58
+ const ret = wasm.conformerhandle_conformer_rmsd(this.__wbg_ptr, a, b);
59
+ return ret;
60
+ }
61
+ /**
62
+ * Un-aligned (translation + rotation NOT removed) RMSD (Å) between conformers `a` and `b`.
63
+ *
64
+ * Returns `NaN` if either index is out of range.
65
+ * @param {number} a
66
+ * @param {number} b
67
+ * @returns {number}
68
+ */
69
+ conformer_rmsd_no_align(a, b) {
70
+ const ret = wasm.conformerhandle_conformer_rmsd_no_align(this.__wbg_ptr, a, b);
71
+ return ret;
72
+ }
73
+ /**
74
+ * Return conformer `idx` as a PDB string, or `null` if `idx` is out of range.
75
+ * @param {number} idx
76
+ * @returns {string | undefined}
77
+ */
78
+ get_conformer_pdb(idx) {
79
+ const ret = wasm.conformerhandle_get_conformer_pdb(this.__wbg_ptr, idx);
80
+ let v1;
81
+ if (ret[0] !== 0) {
82
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
83
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
84
+ }
85
+ return v1;
86
+ }
87
+ /**
88
+ * The ensemble's molecule as a `MolHandle`.
89
+ * @returns {MolHandle}
90
+ */
91
+ mol() {
92
+ const ret = wasm.conformerhandle_mol(this.__wbg_ptr);
93
+ return MolHandle.__wrap(ret);
94
+ }
95
+ /**
96
+ * Create a new empty ensemble for the molecule given by `smiles`.
97
+ *
98
+ * Returns a JS error on SMILES parse failure.
99
+ * @param {string} smiles
100
+ */
101
+ constructor(smiles) {
102
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
103
+ const len0 = WASM_VECTOR_LEN;
104
+ const ret = wasm.conformerhandle_new(ptr0, len0);
105
+ if (ret[2]) {
106
+ throw takeFromExternrefTable0(ret[1]);
107
+ }
108
+ this.__wbg_ptr = ret[0];
109
+ ConformerHandleFinalization.register(this, this.__wbg_ptr, this);
110
+ return this;
111
+ }
112
+ /**
113
+ * Remove conformer `idx` and return `true`, or `false` if `idx` is out of range.
114
+ * @param {number} idx
115
+ * @returns {boolean}
116
+ */
117
+ remove_conformer(idx) {
118
+ const ret = wasm.conformerhandle_remove_conformer(this.__wbg_ptr, idx);
119
+ return ret !== 0;
120
+ }
121
+ }
122
+ if (Symbol.dispose) ConformerHandle.prototype[Symbol.dispose] = ConformerHandle.prototype.free;
123
+
3
124
  /**
4
125
  * Style options for [`MolHandle::depict_svg_opts`].
5
126
  *
@@ -490,6 +611,14 @@ export class MolHandle {
490
611
  const ret = wasm.molhandle_num_aliphatic_heterocycles(this.__wbg_ptr);
491
612
  return ret >>> 0;
492
613
  }
614
+ /**
615
+ * Count of aliphatic (non-aromatic) rings in the SSSR.
616
+ * @returns {number}
617
+ */
618
+ num_aliphatic_rings() {
619
+ const ret = wasm.molhandle_num_aliphatic_rings(this.__wbg_ptr);
620
+ return ret >>> 0;
621
+ }
493
622
  /**
494
623
  * Number of aromatic rings containing at least one heteroatom (N, O, S, …).
495
624
  * @returns {number}
@@ -522,6 +651,14 @@ export class MolHandle {
522
651
  const ret = wasm.molhandle_num_saturated_heterocycles(this.__wbg_ptr);
523
652
  return ret >>> 0;
524
653
  }
654
+ /**
655
+ * Count of fully saturated rings in the SSSR.
656
+ * @returns {number}
657
+ */
658
+ num_saturated_rings() {
659
+ const ret = wasm.molhandle_num_saturated_rings(this.__wbg_ptr);
660
+ return ret >>> 0;
661
+ }
525
662
  /**
526
663
  * Number of spiro atoms (sole shared atom between exactly 2 rings).
527
664
  * @returns {number}
@@ -538,6 +675,14 @@ export class MolHandle {
538
675
  const ret = wasm.molhandle_num_stereocenters(this.__wbg_ptr);
539
676
  return ret >>> 0;
540
677
  }
678
+ /**
679
+ * Count of tetrahedral stereocenters with unspecified configuration.
680
+ * @returns {number}
681
+ */
682
+ num_unspecified_stereocenters() {
683
+ const ret = wasm.molhandle_num_unspecified_stereocenters(this.__wbg_ptr);
684
+ return ret >>> 0;
685
+ }
541
686
  /**
542
687
  * Returns `true` if the molecule has no PAINS structural alerts.
543
688
  * @returns {boolean}
@@ -625,6 +770,19 @@ export function add_hydrogens(mol) {
625
770
  return MolHandle.__wrap(ret);
626
771
  }
627
772
 
773
+ /**
774
+ * AtomPair fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
775
+ * @param {MolHandle} mol
776
+ * @returns {Uint8Array}
777
+ */
778
+ export function atom_pair_bitvec(mol) {
779
+ _assertClass(mol, MolHandle);
780
+ const ret = wasm.atom_pair_bitvec(mol.__wbg_ptr);
781
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
782
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
783
+ return v1;
784
+ }
785
+
628
786
  /**
629
787
  * Number of BRICS fragments produced by fragmenting the molecule.
630
788
  *
@@ -639,20 +797,49 @@ export function brics_fragment_count(mol) {
639
797
  }
640
798
 
641
799
  /**
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.
800
+ * BRICS fragment SMILES as a JSON array.
644
801
  *
645
- * Returns a self-contained SVG string. Returns a JS error on invalid input.
646
- * @param {string} rxn_smiles
802
+ * Applies the BRICS fragmentation rules and returns the canonical SMILES of
803
+ * every resulting fragment. Returns `[]` for molecules with no BRICS-breakable
804
+ * bonds (e.g. benzene).
805
+ *
806
+ * The count of fragments equals `brics_fragment_count`.
807
+ * @param {MolHandle} mol
647
808
  * @returns {string}
648
809
  */
649
- export function depict_reaction_svg(rxn_smiles) {
810
+ export function brics_fragments_json(mol) {
811
+ let deferred1_0;
812
+ let deferred1_1;
813
+ try {
814
+ _assertClass(mol, MolHandle);
815
+ const ret = wasm.brics_fragments_json(mol.__wbg_ptr);
816
+ deferred1_0 = ret[0];
817
+ deferred1_1 = ret[1];
818
+ return getStringFromWasm0(ret[0], ret[1]);
819
+ } finally {
820
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
821
+ }
822
+ }
823
+
824
+ /**
825
+ * Cluster molecules by structural similarity (Butina algorithm, ECFP4 Tanimoto).
826
+ *
827
+ * `smiles_json` — a JSON array of SMILES strings.
828
+ * `cutoff` — Tanimoto similarity threshold (0.0–1.0); molecules within this
829
+ * distance of a cluster centre are assigned to that cluster.
830
+ * Returns a JSON array of clusters, each cluster being an array of 0-based input indices.
831
+ * Returns a JS error if any SMILES fails to parse.
832
+ * @param {string} smiles_json
833
+ * @param {number} cutoff
834
+ * @returns {string}
835
+ */
836
+ export function butina_cluster_ecfp4_json(smiles_json, cutoff) {
650
837
  let deferred3_0;
651
838
  let deferred3_1;
652
839
  try {
653
- const ptr0 = passStringToWasm0(rxn_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
840
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
654
841
  const len0 = WASM_VECTOR_LEN;
655
- const ret = wasm.depict_reaction_svg(ptr0, len0);
842
+ const ret = wasm.butina_cluster_ecfp4_json(ptr0, len0, cutoff);
656
843
  var ptr2 = ret[0];
657
844
  var len2 = ret[1];
658
845
  if (ret[3]) {
@@ -668,45 +855,65 @@ export function depict_reaction_svg(rxn_smiles) {
668
855
  }
669
856
 
670
857
  /**
671
- * Render a grid SVG from newline-separated SMILES (one per line).
858
+ * Canonical tautomer of `mol`.
672
859
  *
673
- * Lines that fail to parse are silently skipped.
674
- * `cols` controls the number of columns (each cell is 200×200 px).
675
- * @param {string} smiles_block
676
- * @param {number} cols
860
+ * Applies a rule-based tautomer normalisation and returns the canonical form
861
+ * as a new `MolHandle`.
862
+ * @param {MolHandle} mol
863
+ * @returns {MolHandle}
864
+ */
865
+ export function canonical_tautomer(mol) {
866
+ _assertClass(mol, MolHandle);
867
+ const ret = wasm.canonical_tautomer(mol.__wbg_ptr);
868
+ return MolHandle.__wrap(ret);
869
+ }
870
+
871
+ /**
872
+ * Parse all molecular fragments from a CDXML string.
873
+ *
874
+ * Returns a JSON array of SMILES strings, one per fragment:
875
+ * `["CC","c1ccccc1"]`
876
+ *
877
+ * Stereochemistry (wedge/dash bonds) is read from the `Display` attribute
878
+ * of bond elements.
879
+ * @param {string} cdxml
677
880
  * @returns {string}
678
881
  */
679
- export function depict_svg_grid(smiles_block, cols) {
680
- let deferred2_0;
681
- let deferred2_1;
882
+ export function cdxml_to_smiles_json(cdxml) {
883
+ let deferred3_0;
884
+ let deferred3_1;
682
885
  try {
683
- const ptr0 = passStringToWasm0(smiles_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
886
+ const ptr0 = passStringToWasm0(cdxml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
684
887
  const len0 = WASM_VECTOR_LEN;
685
- const ret = wasm.depict_svg_grid(ptr0, len0, cols);
686
- deferred2_0 = ret[0];
687
- deferred2_1 = ret[1];
688
- return getStringFromWasm0(ret[0], ret[1]);
888
+ const ret = wasm.cdxml_to_smiles_json(ptr0, len0);
889
+ var ptr2 = ret[0];
890
+ var len2 = ret[1];
891
+ if (ret[3]) {
892
+ ptr2 = 0; len2 = 0;
893
+ throw takeFromExternrefTable0(ret[2]);
894
+ }
895
+ deferred3_0 = ptr2;
896
+ deferred3_1 = len2;
897
+ return getStringFromWasm0(ptr2, len2);
689
898
  } finally {
690
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
899
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
691
900
  }
692
901
  }
693
902
 
694
903
  /**
695
- * Detect named functional groups in `mol`.
904
+ * CIP stereo assignments as a JSON array of `{atomIdx, cipCode}` objects.
696
905
  *
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.
906
+ * `cipCode` is one of `"R"`, `"S"`, `"E"`, or `"Z"`.
907
+ * Returns `[]` for molecules with no specified stereocenters.
701
908
  * @param {MolHandle} mol
702
909
  * @returns {string}
703
910
  */
704
- export function detect_functional_groups(mol) {
911
+ export function cip_assignments_json(mol) {
705
912
  let deferred1_0;
706
913
  let deferred1_1;
707
914
  try {
708
915
  _assertClass(mol, MolHandle);
709
- const ret = wasm.detect_functional_groups(mol.__wbg_ptr);
916
+ const ret = wasm.cip_assignments_json(mol.__wbg_ptr);
710
917
  deferred1_0 = ret[0];
711
918
  deferred1_1 = ret[1];
712
919
  return getStringFromWasm0(ret[0], ret[1]);
@@ -716,50 +923,56 @@ export function detect_functional_groups(mol) {
716
923
  }
717
924
 
718
925
  /**
719
- * Compute the ECFP4 fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
720
- * @param {MolHandle} mol
721
- * @returns {Uint8Array}
722
- */
723
- export function ecfp4_bitvec(mol) {
724
- _assertClass(mol, MolHandle);
725
- const ret = wasm.ecfp4_bitvec(mol.__wbg_ptr);
726
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
727
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
728
- return v1;
729
- }
730
-
731
- /**
732
- * Per-atom EState values as a JSON array of f64.
926
+ * Return the CPK color (CSS hex string) for the given element symbol.
733
927
  *
734
- * Indices match `mol.atoms()` order. Hydrogen atoms get 0.0.
735
- * @param {MolHandle} mol
928
+ * Returns `"#000000"` (black) for carbon and unknown elements.
929
+ * @param {string} element_symbol
736
930
  * @returns {string}
737
931
  */
738
- export function estate_indices_json(mol) {
739
- let deferred1_0;
740
- let deferred1_1;
932
+ export function cpk_color(element_symbol) {
933
+ let deferred2_0;
934
+ let deferred2_1;
741
935
  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];
936
+ const ptr0 = passStringToWasm0(element_symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
937
+ const len0 = WASM_VECTOR_LEN;
938
+ const ret = wasm.cpk_color(ptr0, len0);
939
+ deferred2_0 = ret[0];
940
+ deferred2_1 = ret[1];
746
941
  return getStringFromWasm0(ret[0], ret[1]);
747
942
  } finally {
748
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
943
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
749
944
  }
750
945
  }
751
946
 
752
947
  /**
753
- * Gasteiger-Marsili PEOE partial charges as a JSON array of f64.
948
+ * Compute structured depiction data for `mol` as a JSON object.
949
+ *
950
+ * Returns:
951
+ * ```json
952
+ * {
953
+ * "atoms": [
954
+ * {"idx": 0, "element": "C", "x": 1.5, "y": 0.0, "charge": 0,
955
+ * "label": null, "color": "#000000"},
956
+ * ...
957
+ * ],
958
+ * "bonds": [
959
+ * {"idx": 0, "atom1": 0, "atom2": 1, "kind": "Single"},
960
+ * ...
961
+ * ]
962
+ * }
963
+ * ```
964
+ *
965
+ * `label` is `null` for carbon atoms in skeletal structures (label suppressed).
966
+ * `kind` is one of `"Single"`, `"Double"`, `"Triple"`, `"Aromatic"`, `"Up"`, `"Down"`.
754
967
  * @param {MolHandle} mol
755
968
  * @returns {string}
756
969
  */
757
- export function gasteiger_charges_json(mol) {
970
+ export function depict_data_json(mol) {
758
971
  let deferred1_0;
759
972
  let deferred1_1;
760
973
  try {
761
974
  _assertClass(mol, MolHandle);
762
- const ret = wasm.gasteiger_charges_json(mol.__wbg_ptr);
975
+ const ret = wasm.depict_data_json(mol.__wbg_ptr);
763
976
  deferred1_0 = ret[0];
764
977
  deferred1_1 = ret[1];
765
978
  return getStringFromWasm0(ret[0], ret[1]);
@@ -769,73 +982,132 @@ export function gasteiger_charges_json(mol) {
769
982
  }
770
983
 
771
984
  /**
772
- * Generate 3D coordinates for the molecule and return a PDB string.
985
+ * Compute structured depiction data using caller-supplied 2D coordinates.
773
986
  *
774
- * Coordinates are generated using distance-geometry placement with ring templates.
775
- * Returns heavy-atom PDB (HETATM records, no explicit H).
987
+ * `coords_json` JSON array of `[x, y]` pairs, one per atom in order.
988
+ *
989
+ * Returns the same JSON format as `depict_data_json`.
776
990
  * @param {MolHandle} mol
991
+ * @param {string} coords_json
777
992
  * @returns {string}
778
993
  */
779
- export function generate_3d_pdb(mol) {
780
- let deferred1_0;
781
- let deferred1_1;
994
+ export function depict_data_with_coords_json(mol, coords_json) {
995
+ let deferred2_0;
996
+ let deferred2_1;
782
997
  try {
783
998
  _assertClass(mol, MolHandle);
784
- const ret = wasm.generate_3d_pdb(mol.__wbg_ptr);
785
- deferred1_0 = ret[0];
786
- deferred1_1 = ret[1];
999
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1000
+ const len0 = WASM_VECTOR_LEN;
1001
+ const ret = wasm.depict_data_with_coords_json(mol.__wbg_ptr, ptr0, len0);
1002
+ deferred2_0 = ret[0];
1003
+ deferred2_1 = ret[1];
787
1004
  return getStringFromWasm0(ret[0], ret[1]);
788
1005
  } finally {
789
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1006
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
790
1007
  }
791
1008
  }
792
1009
 
793
1010
  /**
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.
1011
+ * Render a reaction SMILES string (e.g. `"CC(=O)O.CCO>>CC(=O)OCC.O"`) as a
1012
+ * single SVG showing reactants → products with `+` separators.
798
1013
  *
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
1014
+ * Returns a self-contained SVG string. Returns a JS error on invalid input.
1015
+ * @param {string} rxn_smiles
805
1016
  * @returns {string}
806
1017
  */
807
- export function get_atom_info(mol, idx) {
808
- let deferred1_0;
809
- let deferred1_1;
1018
+ export function depict_reaction_svg(rxn_smiles) {
1019
+ let deferred3_0;
1020
+ let deferred3_1;
810
1021
  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]);
1022
+ const ptr0 = passStringToWasm0(rxn_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1023
+ const len0 = WASM_VECTOR_LEN;
1024
+ const ret = wasm.depict_reaction_svg(ptr0, len0);
1025
+ var ptr2 = ret[0];
1026
+ var len2 = ret[1];
1027
+ if (ret[3]) {
1028
+ ptr2 = 0; len2 = 0;
1029
+ throw takeFromExternrefTable0(ret[2]);
1030
+ }
1031
+ deferred3_0 = ptr2;
1032
+ deferred3_1 = len2;
1033
+ return getStringFromWasm0(ptr2, len2);
816
1034
  } finally {
817
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1035
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
818
1036
  }
819
1037
  }
820
1038
 
821
1039
  /**
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.
1040
+ * Render a grid SVG from newline-separated SMILES (one per line).
826
1041
  *
827
- * Fields: same as `get_bond_info` plus `bondIdx` (u32).
828
- * @param {MolHandle} mol
829
- * @param {number} atom1
830
- * @param {number} atom2
1042
+ * Lines that fail to parse are silently skipped.
1043
+ * `cols` controls the number of columns (each cell is 200×200 px).
1044
+ * @param {string} smiles_block
1045
+ * @param {number} cols
831
1046
  * @returns {string}
832
1047
  */
833
- export function get_bond_between(mol, atom1, atom2) {
1048
+ export function depict_svg_grid(smiles_block, cols) {
1049
+ let deferred2_0;
1050
+ let deferred2_1;
1051
+ try {
1052
+ const ptr0 = passStringToWasm0(smiles_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1053
+ const len0 = WASM_VECTOR_LEN;
1054
+ const ret = wasm.depict_svg_grid(ptr0, len0, cols);
1055
+ deferred2_0 = ret[0];
1056
+ deferred2_1 = ret[1];
1057
+ return getStringFromWasm0(ret[0], ret[1]);
1058
+ } finally {
1059
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1060
+ }
1061
+ }
1062
+
1063
+ /**
1064
+ * Render a molecule grid with SMARTS-based atom highlighting.
1065
+ *
1066
+ * `smiles_block` — newline-separated SMILES strings (same format as `depict_svg_grid`).
1067
+ * `cols` — number of grid columns.
1068
+ * `match_smarts` — SMARTS pattern; matched atoms in each molecule are highlighted.
1069
+ * Pass an empty string `""` to render without any highlighting.
1070
+ *
1071
+ * Invalid SMILES are rendered as empty cells; SMARTS parse failure returns an
1072
+ * unhighlighted grid (the SMARTS is silently ignored).
1073
+ * @param {string} smiles_block
1074
+ * @param {number} cols
1075
+ * @param {string} match_smarts
1076
+ * @returns {string}
1077
+ */
1078
+ export function depict_svg_grid_highlighted(smiles_block, cols, match_smarts) {
1079
+ let deferred3_0;
1080
+ let deferred3_1;
1081
+ try {
1082
+ const ptr0 = passStringToWasm0(smiles_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1083
+ const len0 = WASM_VECTOR_LEN;
1084
+ const ptr1 = passStringToWasm0(match_smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1085
+ const len1 = WASM_VECTOR_LEN;
1086
+ const ret = wasm.depict_svg_grid_highlighted(ptr0, len0, cols, ptr1, len1);
1087
+ deferred3_0 = ret[0];
1088
+ deferred3_1 = ret[1];
1089
+ return getStringFromWasm0(ret[0], ret[1]);
1090
+ } finally {
1091
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1092
+ }
1093
+ }
1094
+
1095
+ /**
1096
+ * Detect named functional groups in `mol`.
1097
+ *
1098
+ * Returns a JSON array of `{"name":"hydroxyl","atoms":[3]}` objects.
1099
+ * Multiple matches of the same group (e.g. two hydroxyl groups) each appear
1100
+ * as a separate entry. Overlapping groups (carboxylic acid → "carboxyl" +
1101
+ * "hydroxyl" + "carbonyl") are all returned.
1102
+ * @param {MolHandle} mol
1103
+ * @returns {string}
1104
+ */
1105
+ export function detect_functional_groups(mol) {
834
1106
  let deferred1_0;
835
1107
  let deferred1_1;
836
1108
  try {
837
1109
  _assertClass(mol, MolHandle);
838
- const ret = wasm.get_bond_between(mol.__wbg_ptr, atom1, atom2);
1110
+ const ret = wasm.detect_functional_groups(mol.__wbg_ptr);
839
1111
  deferred1_0 = ret[0];
840
1112
  deferred1_1 = ret[1];
841
1113
  return getStringFromWasm0(ret[0], ret[1]);
@@ -845,23 +1117,138 @@ export function get_bond_between(mol, atom1, atom2) {
845
1117
  }
846
1118
 
847
1119
  /**
848
- * Return bond information as a JSON object, looked up by bond index.
1120
+ * Dice similarity between `a` and `b` using ECFP4 fingerprints.
1121
+ * @param {MolHandle} a
1122
+ * @param {MolHandle} b
1123
+ * @returns {number}
1124
+ */
1125
+ export function dice_ecfp4(a, b) {
1126
+ _assertClass(a, MolHandle);
1127
+ _assertClass(b, MolHandle);
1128
+ const ret = wasm.dice_ecfp4(a.__wbg_ptr, b.__wbg_ptr);
1129
+ return ret;
1130
+ }
1131
+
1132
+ /**
1133
+ * Dice similarity between `a` and `b` using ECFP6 fingerprints.
1134
+ * @param {MolHandle} a
1135
+ * @param {MolHandle} b
1136
+ * @returns {number}
1137
+ */
1138
+ export function dice_ecfp6(a, b) {
1139
+ _assertClass(a, MolHandle);
1140
+ _assertClass(b, MolHandle);
1141
+ const ret = wasm.dice_ecfp6(a.__wbg_ptr, b.__wbg_ptr);
1142
+ return ret;
1143
+ }
1144
+
1145
+ /**
1146
+ * Dice similarity between `a` and `b` using MACCS 166-bit fingerprints.
1147
+ * @param {MolHandle} a
1148
+ * @param {MolHandle} b
1149
+ * @returns {number}
1150
+ */
1151
+ export function dice_maccs(a, b) {
1152
+ _assertClass(a, MolHandle);
1153
+ _assertClass(b, MolHandle);
1154
+ const ret = wasm.dice_maccs(a.__wbg_ptr, b.__wbg_ptr);
1155
+ return ret;
1156
+ }
1157
+
1158
+ /**
1159
+ * Compute the ECFP4 fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
1160
+ * @param {MolHandle} mol
1161
+ * @returns {Uint8Array}
1162
+ */
1163
+ export function ecfp4_bitvec(mol) {
1164
+ _assertClass(mol, MolHandle);
1165
+ const ret = wasm.ecfp4_bitvec(mol.__wbg_ptr);
1166
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1167
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1168
+ return v1;
1169
+ }
1170
+
1171
+ /**
1172
+ * ECFP6 (radius-3) fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
1173
+ * @param {MolHandle} mol
1174
+ * @returns {Uint8Array}
1175
+ */
1176
+ export function ecfp6_bitvec(mol) {
1177
+ _assertClass(mol, MolHandle);
1178
+ const ret = wasm.ecfp6_bitvec(mol.__wbg_ptr);
1179
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1180
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1181
+ return v1;
1182
+ }
1183
+
1184
+ /**
1185
+ * Compute a fingerprint bit-vector with configurable ECFP radius and bit width.
849
1186
  *
850
- * `idx` is the 0-based bond index (order matches `mol.bonds()` iteration).
851
- * Returns `"null"` if `idx` is out of range.
1187
+ * `radius` Morgan radius (1 = ECFP2, 2 = ECFP4, 3 = ECFP6).
1188
+ * `nbits` bit width; must be one of 256, 512, 1024, or 2048.
1189
+ * Returns a `Uint8Array` of `nbits/8` bytes.
852
1190
  *
853
- * Fields: `bondOrder` (1.0/1.5/2.0/3.0), `isAromatic` (bool),
854
- * `isInRing` (bool), `atomFrom` (u32), `atomTo` (u32).
1191
+ * The hash modulo is applied at fingerprint-generation time (`id % nbits`),
1192
+ * so no post-processing fold is needed.
1193
+ * @param {MolHandle} mol
1194
+ * @param {number} radius
1195
+ * @param {number} nbits
1196
+ * @returns {Uint8Array}
1197
+ */
1198
+ export function ecfp_bitvec_custom(mol, radius, nbits) {
1199
+ _assertClass(mol, MolHandle);
1200
+ const ret = wasm.ecfp_bitvec_custom(mol.__wbg_ptr, radius, nbits);
1201
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1202
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1203
+ return v1;
1204
+ }
1205
+
1206
+ /**
1207
+ * Enumerate all stereoisomers arising from unspecified tetrahedral stereocenters.
1208
+ *
1209
+ * Only considers carbon stereocenters without explicit `@`/`@@` annotation.
1210
+ * Already-specified centers and E/Z double-bond geometry are unchanged.
1211
+ * Returns a JSON array of canonical SMILES strings.
1212
+ *
1213
+ * At most 2^6 = 64 combinations are enumerated; if more than 6 unspecified
1214
+ * centers are present this function returns a JS error to avoid combinatorial
1215
+ * explosion.
855
1216
  * @param {MolHandle} mol
856
- * @param {number} idx
857
1217
  * @returns {string}
858
1218
  */
859
- export function get_bond_info(mol, idx) {
1219
+ export function enumerate_stereo_isomers_json(mol) {
1220
+ let deferred2_0;
1221
+ let deferred2_1;
1222
+ try {
1223
+ _assertClass(mol, MolHandle);
1224
+ const ret = wasm.enumerate_stereo_isomers_json(mol.__wbg_ptr);
1225
+ var ptr1 = ret[0];
1226
+ var len1 = ret[1];
1227
+ if (ret[3]) {
1228
+ ptr1 = 0; len1 = 0;
1229
+ throw takeFromExternrefTable0(ret[2]);
1230
+ }
1231
+ deferred2_0 = ptr1;
1232
+ deferred2_1 = len1;
1233
+ return getStringFromWasm0(ptr1, len1);
1234
+ } finally {
1235
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1236
+ }
1237
+ }
1238
+
1239
+ /**
1240
+ * All enumerated tautomers of `mol` as a JSON array of canonical SMILES strings.
1241
+ *
1242
+ * Example return value: `["Oc1cccc2ccccc12","O=C1C=CC=Cc2ccccc21"]`
1243
+ * @param {MolHandle} mol
1244
+ * @returns {string}
1245
+ */
1246
+ export function enumerate_tautomers_json(mol) {
860
1247
  let deferred1_0;
861
1248
  let deferred1_1;
862
1249
  try {
863
1250
  _assertClass(mol, MolHandle);
864
- const ret = wasm.get_bond_info(mol.__wbg_ptr, idx);
1251
+ const ret = wasm.enumerate_tautomers_json(mol.__wbg_ptr);
865
1252
  deferred1_0 = ret[0];
866
1253
  deferred1_1 = ret[1];
867
1254
  return getStringFromWasm0(ret[0], ret[1]);
@@ -871,17 +1258,18 @@ export function get_bond_info(mol, idx) {
871
1258
  }
872
1259
 
873
1260
  /**
874
- * Identify functional groups. Returns a JSON array of objects:
875
- * `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
1261
+ * Per-atom EState values as a JSON array of f64.
1262
+ *
1263
+ * Indices match `mol.atoms()` order. Hydrogen atoms get 0.0.
876
1264
  * @param {MolHandle} mol
877
1265
  * @returns {string}
878
1266
  */
879
- export function identify_functional_groups(mol) {
1267
+ export function estate_indices_json(mol) {
880
1268
  let deferred1_0;
881
1269
  let deferred1_1;
882
1270
  try {
883
1271
  _assertClass(mol, MolHandle);
884
- const ret = wasm.identify_functional_groups(mol.__wbg_ptr);
1272
+ const ret = wasm.estate_indices_json(mol.__wbg_ptr);
885
1273
  deferred1_0 = ret[0];
886
1274
  deferred1_1 = ret[1];
887
1275
  return getStringFromWasm0(ret[0], ret[1]);
@@ -891,65 +1279,797 @@ export function identify_functional_groups(mol) {
891
1279
  }
892
1280
 
893
1281
  /**
894
- * Returns `true` if the SMILES string can be parsed without error.
895
- * @param {string} s
896
- * @returns {boolean}
1282
+ * FCFP4 (pharmacophore, radius-2) fingerprint as a bit-packed byte vector (256 bytes).
1283
+ * @param {MolHandle} mol
1284
+ * @returns {Uint8Array}
897
1285
  */
898
- export function is_valid_smiles(s) {
899
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
900
- const len0 = WASM_VECTOR_LEN;
901
- const ret = wasm.is_valid_smiles(ptr0, len0);
902
- return ret !== 0;
1286
+ export function fcfp4_bitvec(mol) {
1287
+ _assertClass(mol, MolHandle);
1288
+ const ret = wasm.fcfp4_bitvec(mol.__wbg_ptr);
1289
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1290
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1291
+ return v1;
903
1292
  }
904
1293
 
905
1294
  /**
906
- * Find all SMARTS matches in a molecule given only SMILES strings.
1295
+ * FCFP6 (pharmacophore, radius-3) fingerprint as a bit-packed byte vector (256 bytes).
1296
+ * @param {MolHandle} mol
1297
+ * @returns {Uint8Array}
1298
+ */
1299
+ export function fcfp6_bitvec(mol) {
1300
+ _assertClass(mol, MolHandle);
1301
+ const ret = wasm.fcfp6_bitvec(mol.__wbg_ptr);
1302
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1303
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1304
+ return v1;
1305
+ }
1306
+
1307
+ /**
1308
+ * Gasteiger-Marsili PEOE partial charges as a JSON array of f64.
1309
+ * @param {MolHandle} mol
1310
+ * @returns {string}
1311
+ */
1312
+ export function gasteiger_charges_json(mol) {
1313
+ let deferred1_0;
1314
+ let deferred1_1;
1315
+ try {
1316
+ _assertClass(mol, MolHandle);
1317
+ const ret = wasm.gasteiger_charges_json(mol.__wbg_ptr);
1318
+ deferred1_0 = ret[0];
1319
+ deferred1_1 = ret[1];
1320
+ return getStringFromWasm0(ret[0], ret[1]);
1321
+ } finally {
1322
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1323
+ }
1324
+ }
1325
+
1326
+ /**
1327
+ * Generate energy-minimized 3D coordinates and return a PDB string.
907
1328
  *
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
1329
+ * Runs distance-geometry placement followed by gradient-descent force-field
1330
+ * minimization. Geometry quality is better than `generate_3d_pdb` for
1331
+ * flexible molecules; the force field is approximate (not MMFF94/UFF).
1332
+ * @param {MolHandle} mol
913
1333
  * @returns {string}
914
1334
  */
915
- export function match_smarts_smiles(smiles, smarts) {
916
- let deferred4_0;
917
- let deferred4_1;
1335
+ export function generate_3d_minimized_pdb(mol) {
1336
+ let deferred1_0;
1337
+ let deferred1_1;
918
1338
  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);
1339
+ _assertClass(mol, MolHandle);
1340
+ const ret = wasm.generate_3d_minimized_pdb(mol.__wbg_ptr);
1341
+ deferred1_0 = ret[0];
1342
+ deferred1_1 = ret[1];
1343
+ return getStringFromWasm0(ret[0], ret[1]);
933
1344
  } finally {
934
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1345
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
935
1346
  }
936
1347
  }
937
1348
 
938
1349
  /**
939
- * Serialize a SMILES string directly to a MOL V2000 block.
1350
+ * Generate 3D coordinates for the molecule and return a PDB string.
940
1351
  *
941
- * Convenience wrapper; all atom coordinates are 0.0.
942
- * Returns a JS error on SMILES parse failure.
943
- * @param {string} smiles
1352
+ * Coordinates are generated using distance-geometry placement with ring templates.
1353
+ * Returns heavy-atom PDB (HETATM records, no explicit H).
1354
+ * @param {MolHandle} mol
1355
+ * @returns {string}
1356
+ */
1357
+ export function generate_3d_pdb(mol) {
1358
+ let deferred1_0;
1359
+ let deferred1_1;
1360
+ try {
1361
+ _assertClass(mol, MolHandle);
1362
+ const ret = wasm.generate_3d_pdb(mol.__wbg_ptr);
1363
+ deferred1_0 = ret[0];
1364
+ deferred1_1 = ret[1];
1365
+ return getStringFromWasm0(ret[0], ret[1]);
1366
+ } finally {
1367
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1368
+ }
1369
+ }
1370
+
1371
+ /**
1372
+ * Generic (atom-type-erased) Murcko scaffold of `mol`.
1373
+ *
1374
+ * All atoms become carbon and all bonds become single bonds, giving the pure
1375
+ * graph topology of the scaffold.
1376
+ * @param {MolHandle} mol
1377
+ * @returns {MolHandle}
1378
+ */
1379
+ export function generic_murcko_scaffold(mol) {
1380
+ _assertClass(mol, MolHandle);
1381
+ const ret = wasm.generic_murcko_scaffold(mol.__wbg_ptr);
1382
+ return MolHandle.__wrap(ret);
1383
+ }
1384
+
1385
+ /**
1386
+ * Return information about a single atom as a JSON object.
1387
+ *
1388
+ * `idx` is the 0-based atom index (matching `atoms()` order).
1389
+ * Returns `"null"` if `idx` is out of range.
1390
+ *
1391
+ * Fields: `element` (symbol), `hybridization` ("sp"/"sp2"/"sp3"),
1392
+ * `charge` (formal charge integer), `isAromatic` (bool),
1393
+ * `totalHydrogens` (explicit + implicit H count, integer).
1394
+ * sp3d/sp3d2 (hypervalent P/S) are not distinguished from sp3/sp2.
1395
+ * @param {MolHandle} mol
1396
+ * @param {number} idx
1397
+ * @returns {string}
1398
+ */
1399
+ export function get_atom_info(mol, idx) {
1400
+ let deferred1_0;
1401
+ let deferred1_1;
1402
+ try {
1403
+ _assertClass(mol, MolHandle);
1404
+ const ret = wasm.get_atom_info(mol.__wbg_ptr, idx);
1405
+ deferred1_0 = ret[0];
1406
+ deferred1_1 = ret[1];
1407
+ return getStringFromWasm0(ret[0], ret[1]);
1408
+ } finally {
1409
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1410
+ }
1411
+ }
1412
+
1413
+ /**
1414
+ * Return bond information as a JSON object, looked up by the two bonded atom indices.
1415
+ *
1416
+ * Useful when you know the atom indices from SMARTS matching or `data-atom-idx` SVG
1417
+ * attributes but not the bond index. Returns `"null"` if no bond exists between them.
1418
+ *
1419
+ * Fields: same as `get_bond_info` plus `bondIdx` (u32).
1420
+ * @param {MolHandle} mol
1421
+ * @param {number} atom1
1422
+ * @param {number} atom2
1423
+ * @returns {string}
1424
+ */
1425
+ export function get_bond_between(mol, atom1, atom2) {
1426
+ let deferred1_0;
1427
+ let deferred1_1;
1428
+ try {
1429
+ _assertClass(mol, MolHandle);
1430
+ const ret = wasm.get_bond_between(mol.__wbg_ptr, atom1, atom2);
1431
+ deferred1_0 = ret[0];
1432
+ deferred1_1 = ret[1];
1433
+ return getStringFromWasm0(ret[0], ret[1]);
1434
+ } finally {
1435
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1436
+ }
1437
+ }
1438
+
1439
+ /**
1440
+ * Return bond information as a JSON object, looked up by bond index.
1441
+ *
1442
+ * `idx` is the 0-based bond index (order matches `mol.bonds()` iteration).
1443
+ * Returns `"null"` if `idx` is out of range.
1444
+ *
1445
+ * Fields: `bondOrder` (1.0/1.5/2.0/3.0), `isAromatic` (bool),
1446
+ * `isInRing` (bool), `atomFrom` (u32), `atomTo` (u32).
1447
+ * @param {MolHandle} mol
1448
+ * @param {number} idx
1449
+ * @returns {string}
1450
+ */
1451
+ export function get_bond_info(mol, idx) {
1452
+ let deferred1_0;
1453
+ let deferred1_1;
1454
+ try {
1455
+ _assertClass(mol, MolHandle);
1456
+ const ret = wasm.get_bond_info(mol.__wbg_ptr, idx);
1457
+ deferred1_0 = ret[0];
1458
+ deferred1_1 = ret[1];
1459
+ return getStringFromWasm0(ret[0], ret[1]);
1460
+ } finally {
1461
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1462
+ }
1463
+ }
1464
+
1465
+ /**
1466
+ * All scalar molecular descriptors as a single JSON object.
1467
+ *
1468
+ * Keys use camelCase and match the individual `MolHandle` method names.
1469
+ * Drug-likeness rule outcomes are included as boolean fields.
1470
+ * @param {MolHandle} mol
1471
+ * @returns {string}
1472
+ */
1473
+ export function get_descriptors_json(mol) {
1474
+ let deferred1_0;
1475
+ let deferred1_1;
1476
+ try {
1477
+ _assertClass(mol, MolHandle);
1478
+ const ret = wasm.get_descriptors_json(mol.__wbg_ptr);
1479
+ deferred1_0 = ret[0];
1480
+ deferred1_1 = ret[1];
1481
+ return getStringFromWasm0(ret[0], ret[1]);
1482
+ } finally {
1483
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1484
+ }
1485
+ }
1486
+
1487
+ /**
1488
+ * Identify functional groups. Returns a JSON array of objects:
1489
+ * `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
1490
+ * @param {MolHandle} mol
1491
+ * @returns {string}
1492
+ */
1493
+ export function identify_functional_groups(mol) {
1494
+ let deferred1_0;
1495
+ let deferred1_1;
1496
+ try {
1497
+ _assertClass(mol, MolHandle);
1498
+ const ret = wasm.identify_functional_groups(mol.__wbg_ptr);
1499
+ deferred1_0 = ret[0];
1500
+ deferred1_1 = ret[1];
1501
+ return getStringFromWasm0(ret[0], ret[1]);
1502
+ } finally {
1503
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1504
+ }
1505
+ }
1506
+
1507
+ /**
1508
+ * Returns `true` if the SMILES string can be parsed without error.
1509
+ * @param {string} s
1510
+ * @returns {boolean}
1511
+ */
1512
+ export function is_valid_smiles(s) {
1513
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1514
+ const len0 = WASM_VECTOR_LEN;
1515
+ const ret = wasm.is_valid_smiles(ptr0, len0);
1516
+ return ret !== 0;
1517
+ }
1518
+
1519
+ /**
1520
+ * Per-atom Labute approximate surface area contributions as a JSON array of f64.
1521
+ *
1522
+ * Non-finite values (single-atom molecules etc.) are emitted as JSON `null`.
1523
+ * @param {MolHandle} mol
1524
+ * @returns {string}
1525
+ */
1526
+ export function labute_asa_per_atom_json(mol) {
1527
+ let deferred1_0;
1528
+ let deferred1_1;
1529
+ try {
1530
+ _assertClass(mol, MolHandle);
1531
+ const ret = wasm.labute_asa_per_atom_json(mol.__wbg_ptr);
1532
+ deferred1_0 = ret[0];
1533
+ deferred1_1 = ret[1];
1534
+ return getStringFromWasm0(ret[0], ret[1]);
1535
+ } finally {
1536
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1537
+ }
1538
+ }
1539
+
1540
+ /**
1541
+ * Return the largest fragment of `mol` (salt/solvent stripping).
1542
+ *
1543
+ * For single-component molecules returns a copy of the same molecule.
1544
+ * @param {MolHandle} mol
1545
+ * @returns {MolHandle}
1546
+ */
1547
+ export function largest_fragment(mol) {
1548
+ _assertClass(mol, MolHandle);
1549
+ const ret = wasm.largest_fragment(mol.__wbg_ptr);
1550
+ return MolHandle.__wrap(ret);
1551
+ }
1552
+
1553
+ /**
1554
+ * Per-atom Crippen LogP contributions as a JSON array of f64.
1555
+ *
1556
+ * Index `i` corresponds to atom `i` in `mol.atoms()` order.
1557
+ * @param {MolHandle} mol
1558
+ * @returns {string}
1559
+ */
1560
+ export function logp_per_atom_json(mol) {
1561
+ let deferred1_0;
1562
+ let deferred1_1;
1563
+ try {
1564
+ _assertClass(mol, MolHandle);
1565
+ const ret = wasm.logp_per_atom_json(mol.__wbg_ptr);
1566
+ deferred1_0 = ret[0];
1567
+ deferred1_1 = ret[1];
1568
+ return getStringFromWasm0(ret[0], ret[1]);
1569
+ } finally {
1570
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1571
+ }
1572
+ }
1573
+
1574
+ /**
1575
+ * MACCS 166-bit structural keys fingerprint as a byte array (21 bytes, LSB-first).
1576
+ *
1577
+ * Bit `i` (0-indexed) corresponds to MACCS key `i+1`.
1578
+ * @param {MolHandle} mol
1579
+ * @returns {Uint8Array}
1580
+ */
1581
+ export function maccs_bitvec(mol) {
1582
+ _assertClass(mol, MolHandle);
1583
+ const ret = wasm.maccs_bitvec(mol.__wbg_ptr);
1584
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1585
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1586
+ return v1;
1587
+ }
1588
+
1589
+ /**
1590
+ * Find all SMARTS matches in a molecule given only SMILES strings.
1591
+ *
1592
+ * Convenience wrapper around `smarts_match_atoms` that accepts raw SMILES
1593
+ * instead of a `MolHandle`. Returns the same JSON format: `[[0,1],[3,4]]`.
1594
+ * Returns a JS error on SMILES or SMARTS parse failure.
1595
+ * @param {string} smiles
1596
+ * @param {string} smarts
1597
+ * @returns {string}
1598
+ */
1599
+ export function match_smarts_smiles(smiles, smarts) {
1600
+ let deferred4_0;
1601
+ let deferred4_1;
1602
+ try {
1603
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1604
+ const len0 = WASM_VECTOR_LEN;
1605
+ const ptr1 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1606
+ const len1 = WASM_VECTOR_LEN;
1607
+ const ret = wasm.match_smarts_smiles(ptr0, len0, ptr1, len1);
1608
+ var ptr3 = ret[0];
1609
+ var len3 = ret[1];
1610
+ if (ret[3]) {
1611
+ ptr3 = 0; len3 = 0;
1612
+ throw takeFromExternrefTable0(ret[2]);
1613
+ }
1614
+ deferred4_0 = ptr3;
1615
+ deferred4_1 = len3;
1616
+ return getStringFromWasm0(ptr3, len3);
1617
+ } finally {
1618
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1619
+ }
1620
+ }
1621
+
1622
+ /**
1623
+ * Select `n` maximally-diverse molecules (MaxMin algorithm, ECFP4 Tanimoto).
1624
+ *
1625
+ * `smiles_json` — a JSON array of SMILES strings, e.g. `["CC","c1ccccc1","CCO"]`.
1626
+ * Returns a JSON array of 0-based indices into the input array.
1627
+ * Returns a JS error if any SMILES fails to parse (indices would otherwise shift).
1628
+ * @param {string} smiles_json
1629
+ * @param {number} n
1630
+ * @returns {string}
1631
+ */
1632
+ export function maxmin_picks_ecfp4_json(smiles_json, n) {
1633
+ let deferred3_0;
1634
+ let deferred3_1;
1635
+ try {
1636
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1637
+ const len0 = WASM_VECTOR_LEN;
1638
+ const ret = wasm.maxmin_picks_ecfp4_json(ptr0, len0, n);
1639
+ var ptr2 = ret[0];
1640
+ var len2 = ret[1];
1641
+ if (ret[3]) {
1642
+ ptr2 = 0; len2 = 0;
1643
+ throw takeFromExternrefTable0(ret[2]);
1644
+ }
1645
+ deferred3_0 = ptr2;
1646
+ deferred3_1 = len2;
1647
+ return getStringFromWasm0(ptr2, len2);
1648
+ } finally {
1649
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1650
+ }
1651
+ }
1652
+
1653
+ /**
1654
+ * Maximum Common Substructure of a set of molecules, returned as a canonical SMILES string.
1655
+ *
1656
+ * `smiles_json` — a JSON array of at least 2 SMILES strings.
1657
+ * Returns the MCS SMILES, or `"null"` when no common substructure was found.
1658
+ * Returns a JS error on SMILES parse failure.
1659
+ * @param {string} smiles_json
1660
+ * @returns {string}
1661
+ */
1662
+ export function mcs_smiles_json(smiles_json) {
1663
+ let deferred3_0;
1664
+ let deferred3_1;
1665
+ try {
1666
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1667
+ const len0 = WASM_VECTOR_LEN;
1668
+ const ret = wasm.mcs_smiles_json(ptr0, len0);
1669
+ var ptr2 = ret[0];
1670
+ var len2 = ret[1];
1671
+ if (ret[3]) {
1672
+ ptr2 = 0; len2 = 0;
1673
+ throw takeFromExternrefTable0(ret[2]);
1674
+ }
1675
+ deferred3_0 = ptr2;
1676
+ deferred3_1 = len2;
1677
+ return getStringFromWasm0(ptr2, len2);
1678
+ } finally {
1679
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1680
+ }
1681
+ }
1682
+
1683
+ /**
1684
+ * Find matched molecular pairs in a set of molecules as JSON.
1685
+ *
1686
+ * `smiles_json` — JSON array of SMILES strings to analyze.
1687
+ *
1688
+ * Returns a JSON array of matched pairs:
1689
+ * ```json
1690
+ * [
1691
+ * {
1692
+ * "mol_a": "CC(=O)Oc1ccccc1",
1693
+ * "mol_b": "CC(=O)Nc1ccccc1",
1694
+ * "core": "c1ccccc1[*]",
1695
+ * "fragment_a": "[*]OC(C)=O",
1696
+ * "fragment_b": "[*]NC(C)=O"
1697
+ * }
1698
+ * ]
1699
+ * ```
1700
+ *
1701
+ * Each pair represents molecules that share a common core scaffold but differ
1702
+ * by exactly one structural fragment at a single BRICS-breakable bond cut.
1703
+ *
1704
+ * Returns a JS error if any SMILES fails to parse.
1705
+ * @param {string} smiles_json
1706
+ * @returns {string}
1707
+ */
1708
+ export function mmp_pairs_json(smiles_json) {
1709
+ let deferred3_0;
1710
+ let deferred3_1;
1711
+ try {
1712
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1713
+ const len0 = WASM_VECTOR_LEN;
1714
+ const ret = wasm.mmp_pairs_json(ptr0, len0);
1715
+ var ptr2 = ret[0];
1716
+ var len2 = ret[1];
1717
+ if (ret[3]) {
1718
+ ptr2 = 0; len2 = 0;
1719
+ throw takeFromExternrefTable0(ret[2]);
1720
+ }
1721
+ deferred3_0 = ptr2;
1722
+ deferred3_1 = len2;
1723
+ return getStringFromWasm0(ptr2, len2);
1724
+ } finally {
1725
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1726
+ }
1727
+ }
1728
+
1729
+ /**
1730
+ * Parse a MOL V2000 string and return 2D coordinates as a JSON array.
1731
+ *
1732
+ * Returns `[[x0,y0],[x1,y1],...]` in atom-insertion order.
1733
+ * Coordinates are in Ångström as stored in the MOL file.
1734
+ * @param {string} mol_block
1735
+ * @returns {string}
1736
+ */
1737
+ export function mol_block_coords_json(mol_block) {
1738
+ let deferred3_0;
1739
+ let deferred3_1;
1740
+ try {
1741
+ const ptr0 = passStringToWasm0(mol_block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1742
+ const len0 = WASM_VECTOR_LEN;
1743
+ const ret = wasm.mol_block_coords_json(ptr0, len0);
1744
+ var ptr2 = ret[0];
1745
+ var len2 = ret[1];
1746
+ if (ret[3]) {
1747
+ ptr2 = 0; len2 = 0;
1748
+ throw takeFromExternrefTable0(ret[2]);
1749
+ }
1750
+ deferred3_0 = ptr2;
1751
+ deferred3_1 = len2;
1752
+ return getStringFromWasm0(ptr2, len2);
1753
+ } finally {
1754
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1755
+ }
1756
+ }
1757
+
1758
+ /**
1759
+ * Serialize a SMILES string directly to a MOL V2000 block with 2D coordinates.
1760
+ *
1761
+ * Returns a JS error on SMILES parse failure.
1762
+ * @param {string} smiles
1763
+ * @returns {string}
1764
+ */
1765
+ export function mol_block_from_smiles(smiles) {
1766
+ let deferred3_0;
1767
+ let deferred3_1;
1768
+ try {
1769
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1770
+ const len0 = WASM_VECTOR_LEN;
1771
+ const ret = wasm.mol_block_from_smiles(ptr0, len0);
1772
+ var ptr2 = ret[0];
1773
+ var len2 = ret[1];
1774
+ if (ret[3]) {
1775
+ ptr2 = 0; len2 = 0;
1776
+ throw takeFromExternrefTable0(ret[2]);
1777
+ }
1778
+ deferred3_0 = ptr2;
1779
+ deferred3_1 = len2;
1780
+ return getStringFromWasm0(ptr2, len2);
1781
+ } finally {
1782
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1783
+ }
1784
+ }
1785
+
1786
+ /**
1787
+ * Parse a ChemDraw XML (CDXML) string into a `MolHandle`.
1788
+ *
1789
+ * Only the first molecular fragment in the document is returned.
1790
+ * Returns a JS error if the document cannot be parsed.
1791
+ * @param {string} cdxml
1792
+ * @returns {MolHandle}
1793
+ */
1794
+ export function mol_from_cdxml(cdxml) {
1795
+ const ptr0 = passStringToWasm0(cdxml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1796
+ const len0 = WASM_VECTOR_LEN;
1797
+ const ret = wasm.mol_from_cdxml(ptr0, len0);
1798
+ if (ret[2]) {
1799
+ throw takeFromExternrefTable0(ret[1]);
1800
+ }
1801
+ return MolHandle.__wrap(ret[0]);
1802
+ }
1803
+
1804
+ /**
1805
+ * Parse a CML string into a `MolHandle`.
1806
+ *
1807
+ * Returns a JS error if the CML is invalid (unknown element, bad bond, etc.).
1808
+ * @param {string} cml
1809
+ * @returns {MolHandle}
1810
+ */
1811
+ export function mol_from_cml(cml) {
1812
+ const ptr0 = passStringToWasm0(cml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1813
+ const len0 = WASM_VECTOR_LEN;
1814
+ const ret = wasm.mol_from_cml(ptr0, len0);
1815
+ if (ret[2]) {
1816
+ throw takeFromExternrefTable0(ret[1]);
1817
+ }
1818
+ return MolHandle.__wrap(ret[0]);
1819
+ }
1820
+
1821
+ /**
1822
+ * Parse a PDB file and return a `MolHandle` (topology only; coordinates are discarded).
1823
+ *
1824
+ * Uses CONECT records for connectivity if present; otherwise infers bonds from
1825
+ * atom distances (the same heuristic as the internal `pdb_to_molecule` function).
1826
+ * @param {string} pdb
1827
+ * @returns {MolHandle}
1828
+ */
1829
+ export function mol_from_pdb(pdb) {
1830
+ const ptr0 = passStringToWasm0(pdb, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1831
+ const len0 = WASM_VECTOR_LEN;
1832
+ const ret = wasm.mol_from_pdb(ptr0, len0);
1833
+ return MolHandle.__wrap(ret);
1834
+ }
1835
+
1836
+ /**
1837
+ * Parse a MOL V2000 block and return a `MolHandle`.
1838
+ *
1839
+ * Returns a JS error string on parse failure.
1840
+ * @param {string} block
1841
+ * @returns {MolHandle}
1842
+ */
1843
+ export function mol_from_sdf_block(block) {
1844
+ const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1845
+ const len0 = WASM_VECTOR_LEN;
1846
+ const ret = wasm.mol_from_sdf_block(ptr0, len0);
1847
+ if (ret[2]) {
1848
+ throw takeFromExternrefTable0(ret[1]);
1849
+ }
1850
+ return MolHandle.__wrap(ret[0]);
1851
+ }
1852
+
1853
+ /**
1854
+ * Parse a MOL V3000 block and return a `MolHandle`.
1855
+ *
1856
+ * Returns a JS error string on parse failure.
1857
+ * @param {string} block
1858
+ * @returns {MolHandle}
1859
+ */
1860
+ export function mol_from_v3000_block(block) {
1861
+ const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1862
+ const len0 = WASM_VECTOR_LEN;
1863
+ const ret = wasm.mol_from_v3000_block(ptr0, len0);
1864
+ if (ret[2]) {
1865
+ throw takeFromExternrefTable0(ret[1]);
1866
+ }
1867
+ return MolHandle.__wrap(ret[0]);
1868
+ }
1869
+
1870
+ /**
1871
+ * Parse an XYZ file and return a `MolHandle` (topology only; coordinates are discarded).
1872
+ *
1873
+ * Returns a JS error on parse failure.
1874
+ * @param {string} xyz
1875
+ * @returns {MolHandle}
1876
+ */
1877
+ export function mol_from_xyz(xyz) {
1878
+ const ptr0 = passStringToWasm0(xyz, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1879
+ const len0 = WASM_VECTOR_LEN;
1880
+ const ret = wasm.mol_from_xyz(ptr0, len0);
1881
+ if (ret[2]) {
1882
+ throw takeFromExternrefTable0(ret[1]);
1883
+ }
1884
+ return MolHandle.__wrap(ret[0]);
1885
+ }
1886
+
1887
+ /**
1888
+ * Return the index that would be assigned to an atom appended to `mol`.
1889
+ * @param {MolHandle} mol
1890
+ * @returns {number}
1891
+ */
1892
+ export function mol_next_atom_idx(mol) {
1893
+ _assertClass(mol, MolHandle);
1894
+ const ret = wasm.mol_next_atom_idx(mol.__wbg_ptr);
1895
+ return ret >>> 0;
1896
+ }
1897
+
1898
+ /**
1899
+ * Return a new `MolHandle` with one atom appended.
1900
+ *
1901
+ * The second return value is the new atom's index (as a JS number).
1902
+ * Use `with_atom_added_idx` to retrieve the index.
1903
+ * @param {MolHandle} mol
1904
+ * @param {string} element_symbol
1905
+ * @returns {MolHandle}
1906
+ */
1907
+ export function mol_with_atom_added(mol, element_symbol) {
1908
+ _assertClass(mol, MolHandle);
1909
+ const ptr0 = passStringToWasm0(element_symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1910
+ const len0 = WASM_VECTOR_LEN;
1911
+ const ret = wasm.mol_with_atom_added(mol.__wbg_ptr, ptr0, len0);
1912
+ if (ret[2]) {
1913
+ throw takeFromExternrefTable0(ret[1]);
1914
+ }
1915
+ return MolHandle.__wrap(ret[0]);
1916
+ }
1917
+
1918
+ /**
1919
+ * Return a new `MolHandle` with the formal charge of atom `idx` changed.
1920
+ *
1921
+ * Returns a JS error if `idx` is out of range.
1922
+ * @param {MolHandle} mol
1923
+ * @param {number} idx
1924
+ * @param {number} charge
1925
+ * @returns {MolHandle}
1926
+ */
1927
+ export function mol_with_atom_charge(mol, idx, charge) {
1928
+ _assertClass(mol, MolHandle);
1929
+ const ret = wasm.mol_with_atom_charge(mol.__wbg_ptr, idx, charge);
1930
+ if (ret[2]) {
1931
+ throw takeFromExternrefTable0(ret[1]);
1932
+ }
1933
+ return MolHandle.__wrap(ret[0]);
1934
+ }
1935
+
1936
+ /**
1937
+ * Return a new `MolHandle` with the element of atom `idx` changed.
1938
+ *
1939
+ * `element_symbol` — periodic-table symbol, e.g. `"N"`, `"O"`, `"Cl"`.
1940
+ * Returns a JS error if `idx` is out of range or the symbol is unknown.
1941
+ * @param {MolHandle} mol
1942
+ * @param {number} idx
1943
+ * @param {string} element_symbol
1944
+ * @returns {MolHandle}
1945
+ */
1946
+ export function mol_with_atom_element(mol, idx, element_symbol) {
1947
+ _assertClass(mol, MolHandle);
1948
+ const ptr0 = passStringToWasm0(element_symbol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1949
+ const len0 = WASM_VECTOR_LEN;
1950
+ const ret = wasm.mol_with_atom_element(mol.__wbg_ptr, idx, ptr0, len0);
1951
+ if (ret[2]) {
1952
+ throw takeFromExternrefTable0(ret[1]);
1953
+ }
1954
+ return MolHandle.__wrap(ret[0]);
1955
+ }
1956
+
1957
+ /**
1958
+ * Return a new `MolHandle` with atom `idx` and all its bonds removed.
1959
+ *
1960
+ * Atom indices above `idx` shift down by 1. Returns a JS error if `idx`
1961
+ * is out of range.
1962
+ * @param {MolHandle} mol
1963
+ * @param {number} idx
1964
+ * @returns {MolHandle}
1965
+ */
1966
+ export function mol_with_atom_removed(mol, idx) {
1967
+ _assertClass(mol, MolHandle);
1968
+ const ret = wasm.mol_with_atom_removed(mol.__wbg_ptr, idx);
1969
+ if (ret[2]) {
1970
+ throw takeFromExternrefTable0(ret[1]);
1971
+ }
1972
+ return MolHandle.__wrap(ret[0]);
1973
+ }
1974
+
1975
+ /**
1976
+ * Return a new `MolHandle` with one bond added between `a` and `b`.
1977
+ *
1978
+ * `order` — 1 = single, 2 = double, 3 = triple.
1979
+ * Returns a JS error if the bond already exists or `a == b`.
1980
+ * @param {MolHandle} mol
1981
+ * @param {number} a
1982
+ * @param {number} b
1983
+ * @param {number} order
1984
+ * @returns {MolHandle}
1985
+ */
1986
+ export function mol_with_bond_added(mol, a, b, order) {
1987
+ _assertClass(mol, MolHandle);
1988
+ const ret = wasm.mol_with_bond_added(mol.__wbg_ptr, a, b, order);
1989
+ if (ret[2]) {
1990
+ throw takeFromExternrefTable0(ret[1]);
1991
+ }
1992
+ return MolHandle.__wrap(ret[0]);
1993
+ }
1994
+
1995
+ /**
1996
+ * Return a new `MolHandle` with bond `idx` removed.
1997
+ *
1998
+ * Atom indices are unchanged; bond indices above `idx` shift down.
1999
+ * Returns a JS error if `idx` is out of range.
2000
+ * @param {MolHandle} mol
2001
+ * @param {number} idx
2002
+ * @returns {MolHandle}
2003
+ */
2004
+ export function mol_with_bond_removed(mol, idx) {
2005
+ _assertClass(mol, MolHandle);
2006
+ const ret = wasm.mol_with_bond_removed(mol.__wbg_ptr, idx);
2007
+ if (ret[2]) {
2008
+ throw takeFromExternrefTable0(ret[1]);
2009
+ }
2010
+ return MolHandle.__wrap(ret[0]);
2011
+ }
2012
+
2013
+ /**
2014
+ * Per-atom molar refractivity contributions as a JSON array of f64.
2015
+ * @param {MolHandle} mol
2016
+ * @returns {string}
2017
+ */
2018
+ export function mr_per_atom_json(mol) {
2019
+ let deferred1_0;
2020
+ let deferred1_1;
2021
+ try {
2022
+ _assertClass(mol, MolHandle);
2023
+ const ret = wasm.mr_per_atom_json(mol.__wbg_ptr);
2024
+ deferred1_0 = ret[0];
2025
+ deferred1_1 = ret[1];
2026
+ return getStringFromWasm0(ret[0], ret[1]);
2027
+ } finally {
2028
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2029
+ }
2030
+ }
2031
+
2032
+ /**
2033
+ * Murcko scaffold of `mol` — the ring system plus linkers, side-chains removed.
2034
+ *
2035
+ * Returns a new `MolHandle`. For acyclic molecules returns an empty molecule.
2036
+ * @param {MolHandle} mol
2037
+ * @returns {MolHandle}
2038
+ */
2039
+ export function murcko_scaffold(mol) {
2040
+ _assertClass(mol, MolHandle);
2041
+ const ret = wasm.murcko_scaffold(mol.__wbg_ptr);
2042
+ return MolHandle.__wrap(ret);
2043
+ }
2044
+
2045
+ /**
2046
+ * Neutralize formal charges on `mol` by proton addition/removal.
2047
+ *
2048
+ * Returns a new `MolHandle` with all formal charges set to zero where possible.
2049
+ * @param {MolHandle} mol
2050
+ * @returns {MolHandle}
2051
+ */
2052
+ export function neutralize_charges(mol) {
2053
+ _assertClass(mol, MolHandle);
2054
+ const ret = wasm.neutralize_charges(mol.__wbg_ptr);
2055
+ return MolHandle.__wrap(ret);
2056
+ }
2057
+
2058
+ /**
2059
+ * Parse and re-serialise a reaction SMILES string, returning the normalised form.
2060
+ *
2061
+ * Useful for validating reaction SMILES and obtaining a canonical representation.
2062
+ * Returns a JS error on parse failure.
2063
+ * @param {string} rxn_smiles
944
2064
  * @returns {string}
945
2065
  */
946
- export function mol_block_from_smiles(smiles) {
2066
+ export function normalize_reaction_smiles(rxn_smiles) {
947
2067
  let deferred3_0;
948
2068
  let deferred3_1;
949
2069
  try {
950
- const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2070
+ const ptr0 = passStringToWasm0(rxn_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
951
2071
  const len0 = WASM_VECTOR_LEN;
952
- const ret = wasm.mol_block_from_smiles(ptr0, len0);
2072
+ const ret = wasm.normalize_reaction_smiles(ptr0, len0);
953
2073
  var ptr2 = ret[0];
954
2074
  var len2 = ret[1];
955
2075
  if (ret[3]) {
@@ -965,20 +2085,25 @@ export function mol_block_from_smiles(smiles) {
965
2085
  }
966
2086
 
967
2087
  /**
968
- * Parse a MOL V2000 block and return a `MolHandle`.
2088
+ * PAINS structural alert names matched by `mol` as a JSON array.
969
2089
  *
970
- * Returns a JS error string on parse failure.
971
- * @param {string} block
972
- * @returns {MolHandle}
2090
+ * Returns `[]` when no alerts fire, or e.g. `["ene_six_het_A(483)"]`.
2091
+ * Use alongside `pains_passes()` to know *which* alerts triggered.
2092
+ * @param {MolHandle} mol
2093
+ * @returns {string}
973
2094
  */
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]);
2095
+ export function pains_matches_json(mol) {
2096
+ let deferred1_0;
2097
+ let deferred1_1;
2098
+ try {
2099
+ _assertClass(mol, MolHandle);
2100
+ const ret = wasm.pains_matches_json(mol.__wbg_ptr);
2101
+ deferred1_0 = ret[0];
2102
+ deferred1_1 = ret[1];
2103
+ return getStringFromWasm0(ret[0], ret[1]);
2104
+ } finally {
2105
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
980
2106
  }
981
- return MolHandle.__wrap(ret[0]);
982
2107
  }
983
2108
 
984
2109
  /**
@@ -1028,6 +2153,53 @@ export function remove_hydrogens(mol) {
1028
2153
  return MolHandle.__wrap(ret);
1029
2154
  }
1030
2155
 
2156
+ /**
2157
+ * Decompose a set of molecules against a core SMARTS, returning R-group SMILES.
2158
+ *
2159
+ * `smiles_json` — JSON array of SMILES strings.
2160
+ * `core_smarts` — SMARTS pattern with `*` (wildcard) atoms marking R-group
2161
+ * attachment points. For example `c1ccc(*)cc1` for para-substituted benzene.
2162
+ *
2163
+ * Returns a JSON array with one entry per input molecule:
2164
+ * ```json
2165
+ * [
2166
+ * {"matched":true, "r1":"C"},
2167
+ * {"matched":true, "r1":"CC"},
2168
+ * {"matched":false}
2169
+ * ]
2170
+ * ```
2171
+ * R-group keys are `"r1"`, `"r2"`, … in the order the `*` atoms appear in
2172
+ * the SMARTS pattern. A molecule that does not contain the core gets
2173
+ * `"matched": false` and no R-group keys.
2174
+ *
2175
+ * Returns a JS error if the SMARTS fails to parse or any SMILES is invalid.
2176
+ * @param {string} smiles_json
2177
+ * @param {string} core_smarts
2178
+ * @returns {string}
2179
+ */
2180
+ export function rgroup_decompose_json(smiles_json, core_smarts) {
2181
+ let deferred4_0;
2182
+ let deferred4_1;
2183
+ try {
2184
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2185
+ const len0 = WASM_VECTOR_LEN;
2186
+ const ptr1 = passStringToWasm0(core_smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2187
+ const len1 = WASM_VECTOR_LEN;
2188
+ const ret = wasm.rgroup_decompose_json(ptr0, len0, ptr1, len1);
2189
+ var ptr3 = ret[0];
2190
+ var len3 = ret[1];
2191
+ if (ret[3]) {
2192
+ ptr3 = 0; len3 = 0;
2193
+ throw takeFromExternrefTable0(ret[2]);
2194
+ }
2195
+ deferred4_0 = ptr3;
2196
+ deferred4_1 = len3;
2197
+ return getStringFromWasm0(ptr3, len3);
2198
+ } finally {
2199
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2200
+ }
2201
+ }
2202
+
1031
2203
  /**
1032
2204
  * Apply a SMIRKS reaction template and return product SMILES as a JSON string.
1033
2205
  *
@@ -1072,6 +2244,79 @@ export function sa_score(mol) {
1072
2244
  return ret;
1073
2245
  }
1074
2246
 
2247
+ /**
2248
+ * Serialize multiple molecules with properties to an SDF string.
2249
+ *
2250
+ * # Arguments
2251
+ * * `smiles_json` — JSON array of SMILES strings, e.g. `["CC(=O)O","c1ccccc1"]`
2252
+ * * `names_json` — JSON array of molecule names (same length as `smiles_json`)
2253
+ * * `props_json` — JSON array where each element encodes one molecule's SD data fields
2254
+ * as `"key1\tvalue1\nkey2\tvalue2"` (tab-separated key/value, `\n`-separated pairs;
2255
+ * pass `""` for a molecule with no properties)
2256
+ *
2257
+ * Returns the SDF string, or a JS error if any SMILES fails to parse or the
2258
+ * arrays have mismatched lengths.
2259
+ *
2260
+ * The `\n` and `\t` sequences in `props_json` are JSON-escaped — they are
2261
+ * decoded to the actual characters before SDF formatting.
2262
+ * @param {string} smiles_json
2263
+ * @param {string} names_json
2264
+ * @param {string} props_json
2265
+ * @returns {string}
2266
+ */
2267
+ export function sdf_from_records_json(smiles_json, names_json, props_json) {
2268
+ let deferred5_0;
2269
+ let deferred5_1;
2270
+ try {
2271
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2272
+ const len0 = WASM_VECTOR_LEN;
2273
+ const ptr1 = passStringToWasm0(names_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2274
+ const len1 = WASM_VECTOR_LEN;
2275
+ const ptr2 = passStringToWasm0(props_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2276
+ const len2 = WASM_VECTOR_LEN;
2277
+ const ret = wasm.sdf_from_records_json(ptr0, len0, ptr1, len1, ptr2, len2);
2278
+ var ptr4 = ret[0];
2279
+ var len4 = ret[1];
2280
+ if (ret[3]) {
2281
+ ptr4 = 0; len4 = 0;
2282
+ throw takeFromExternrefTable0(ret[2]);
2283
+ }
2284
+ deferred5_0 = ptr4;
2285
+ deferred5_1 = len4;
2286
+ return getStringFromWasm0(ptr4, len4);
2287
+ } finally {
2288
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
2289
+ }
2290
+ }
2291
+
2292
+ /**
2293
+ * Parse an SDF string and return a JSON array of record objects.
2294
+ *
2295
+ * Each record has the shape:
2296
+ * ```json
2297
+ * {"smiles":"CC(=O)O","name":"aspirin","properties":{"MW":"180.2","Activity":"high"}}
2298
+ * ```
2299
+ *
2300
+ * Invalid records are represented as `null`. SD data fields are included in
2301
+ * `properties`; multi-line values are joined with `\n`.
2302
+ * @param {string} sdf
2303
+ * @returns {string}
2304
+ */
2305
+ export function sdf_to_records_json(sdf) {
2306
+ let deferred2_0;
2307
+ let deferred2_1;
2308
+ try {
2309
+ const ptr0 = passStringToWasm0(sdf, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2310
+ const len0 = WASM_VECTOR_LEN;
2311
+ const ret = wasm.sdf_to_records_json(ptr0, len0);
2312
+ deferred2_0 = ret[0];
2313
+ deferred2_1 = ret[1];
2314
+ return getStringFromWasm0(ret[0], ret[1]);
2315
+ } finally {
2316
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2317
+ }
2318
+ }
2319
+
1075
2320
  /**
1076
2321
  * Parse an SDF string and return a JSON array of canonical SMILES strings.
1077
2322
  *
@@ -1094,6 +2339,29 @@ export function sdf_to_smiles_json(sdf) {
1094
2339
  }
1095
2340
  }
1096
2341
 
2342
+ /**
2343
+ * 3D shape descriptors as a JSON object.
2344
+ *
2345
+ * Keys: `pmi1`, `pmi2`, `pmi3`, `npr1`, `npr2`, `asphericity`, `eccentricity`,
2346
+ * `radiusOfGyration`, `planeOfBestFit`. Non-finite values (e.g. single-atom
2347
+ * molecules where pmi3 = 0) are serialised as JSON `null`.
2348
+ * @param {MolHandle} mol
2349
+ * @returns {string}
2350
+ */
2351
+ export function shape_descriptors_json(mol) {
2352
+ let deferred1_0;
2353
+ let deferred1_1;
2354
+ try {
2355
+ _assertClass(mol, MolHandle);
2356
+ const ret = wasm.shape_descriptors_json(mol.__wbg_ptr);
2357
+ deferred1_0 = ret[0];
2358
+ deferred1_1 = ret[1];
2359
+ return getStringFromWasm0(ret[0], ret[1]);
2360
+ } finally {
2361
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2362
+ }
2363
+ }
2364
+
1097
2365
  /**
1098
2366
  * SlogP_VSA descriptors (12 bins) as a JSON array.
1099
2367
  * @param {MolHandle} mol
@@ -1145,6 +2413,35 @@ export function smarts_match_atoms(smarts, mol) {
1145
2413
  }
1146
2414
  }
1147
2415
 
2416
+ /**
2417
+ * Serialise a JSON array of SMILES to an SDF string.
2418
+ *
2419
+ * Generates 2D coordinates for each molecule. Property data can be
2420
+ * included by using `sdf_from_records_json` instead.
2421
+ * @param {string} smiles_json
2422
+ * @returns {string}
2423
+ */
2424
+ export function smiles_array_to_sdf(smiles_json) {
2425
+ let deferred3_0;
2426
+ let deferred3_1;
2427
+ try {
2428
+ const ptr0 = passStringToWasm0(smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2429
+ const len0 = WASM_VECTOR_LEN;
2430
+ const ret = wasm.smiles_array_to_sdf(ptr0, len0);
2431
+ var ptr2 = ret[0];
2432
+ var len2 = ret[1];
2433
+ if (ret[3]) {
2434
+ ptr2 = 0; len2 = 0;
2435
+ throw takeFromExternrefTable0(ret[2]);
2436
+ }
2437
+ deferred3_0 = ptr2;
2438
+ deferred3_1 = len2;
2439
+ return getStringFromWasm0(ptr2, len2);
2440
+ } finally {
2441
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2442
+ }
2443
+ }
2444
+
1148
2445
  /**
1149
2446
  * Render a highlighted SVG from a SMILES string in one call.
1150
2447
  *
@@ -1205,6 +2502,28 @@ export function smr_vsa_json(mol) {
1205
2502
  }
1206
2503
  }
1207
2504
 
2505
+ /**
2506
+ * Smallest Set of Smallest Rings (SSSR) as a JSON array of atom-index arrays.
2507
+ *
2508
+ * Example return value for naphthalene:
2509
+ * `[[0,1,2,3,4,5],[5,6,7,8,9,4]]`
2510
+ * @param {MolHandle} mol
2511
+ * @returns {string}
2512
+ */
2513
+ export function sssr_rings_json(mol) {
2514
+ let deferred1_0;
2515
+ let deferred1_1;
2516
+ try {
2517
+ _assertClass(mol, MolHandle);
2518
+ const ret = wasm.sssr_rings_json(mol.__wbg_ptr);
2519
+ deferred1_0 = ret[0];
2520
+ deferred1_1 = ret[1];
2521
+ return getStringFromWasm0(ret[0], ret[1]);
2522
+ } finally {
2523
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2524
+ }
2525
+ }
2526
+
1208
2527
  export function start() {
1209
2528
  wasm.start();
1210
2529
  }
@@ -1235,6 +2554,19 @@ export function tanimoto_ecfp4(a, b) {
1235
2554
  return ret;
1236
2555
  }
1237
2556
 
2557
+ /**
2558
+ * Tanimoto similarity between `a` and `b` using ECFP6 fingerprints.
2559
+ * @param {MolHandle} a
2560
+ * @param {MolHandle} b
2561
+ * @returns {number}
2562
+ */
2563
+ export function tanimoto_ecfp6(a, b) {
2564
+ _assertClass(a, MolHandle);
2565
+ _assertClass(b, MolHandle);
2566
+ const ret = wasm.tanimoto_ecfp6(a.__wbg_ptr, b.__wbg_ptr);
2567
+ return ret;
2568
+ }
2569
+
1238
2570
  /**
1239
2571
  * Tanimoto similarity between two molecules using FCFP4 fingerprints (pharmacophore-based).
1240
2572
  * @param {MolHandle} a
@@ -1248,6 +2580,32 @@ export function tanimoto_fcfp4(a, b) {
1248
2580
  return ret;
1249
2581
  }
1250
2582
 
2583
+ /**
2584
+ * Tanimoto similarity between `a` and `b` using FCFP6 (radius-3 pharmacophore) fingerprints.
2585
+ * @param {MolHandle} a
2586
+ * @param {MolHandle} b
2587
+ * @returns {number}
2588
+ */
2589
+ export function tanimoto_fcfp6(a, b) {
2590
+ _assertClass(a, MolHandle);
2591
+ _assertClass(b, MolHandle);
2592
+ const ret = wasm.tanimoto_fcfp6(a.__wbg_ptr, b.__wbg_ptr);
2593
+ return ret;
2594
+ }
2595
+
2596
+ /**
2597
+ * Tanimoto similarity between `a` and `b` using MACCS 166-bit fingerprints.
2598
+ * @param {MolHandle} a
2599
+ * @param {MolHandle} b
2600
+ * @returns {number}
2601
+ */
2602
+ export function tanimoto_maccs(a, b) {
2603
+ _assertClass(a, MolHandle);
2604
+ _assertClass(b, MolHandle);
2605
+ const ret = wasm.tanimoto_maccs(a.__wbg_ptr, b.__wbg_ptr);
2606
+ return ret;
2607
+ }
2608
+
1251
2609
  /**
1252
2610
  * Tanimoto similarity between two molecules given only SMILES strings (ECFP4).
1253
2611
  *
@@ -1295,10 +2653,31 @@ export function tanimoto_torsion(a, b) {
1295
2653
  }
1296
2654
 
1297
2655
  /**
1298
- * Serialize a molecule to a MOL V2000 block.
2656
+ * Serialise a `MolHandle` to a CML string with 2D coordinates.
2657
+ *
2658
+ * Coordinates are generated using the same 2D layout engine as `to_mol_block`.
2659
+ * @param {MolHandle} mol
2660
+ * @returns {string}
2661
+ */
2662
+ export function to_cml(mol) {
2663
+ let deferred1_0;
2664
+ let deferred1_1;
2665
+ try {
2666
+ _assertClass(mol, MolHandle);
2667
+ const ret = wasm.to_cml(mol.__wbg_ptr);
2668
+ deferred1_0 = ret[0];
2669
+ deferred1_1 = ret[1];
2670
+ return getStringFromWasm0(ret[0], ret[1]);
2671
+ } finally {
2672
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2673
+ }
2674
+ }
2675
+
2676
+ /**
2677
+ * Serialize a molecule to a MOL V2000 block with 2D coordinates.
1299
2678
  *
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).
2679
+ * Atom positions are computed via the same layout engine used for SVG depiction
2680
+ * and converted to Ångström units (`1.5 Å` per bond).
1302
2681
  * @param {MolHandle} mol
1303
2682
  * @returns {string}
1304
2683
  */
@@ -1315,6 +2694,82 @@ export function to_mol_block(mol) {
1315
2694
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1316
2695
  }
1317
2696
  }
2697
+
2698
+ /**
2699
+ * Serialise a `MolHandle` to MOL V3000 format with 2D coordinates.
2700
+ * @param {MolHandle} mol
2701
+ * @returns {string}
2702
+ */
2703
+ export function to_mol_v3000_block(mol) {
2704
+ let deferred1_0;
2705
+ let deferred1_1;
2706
+ try {
2707
+ _assertClass(mol, MolHandle);
2708
+ const ret = wasm.to_mol_v3000_block(mol.__wbg_ptr);
2709
+ deferred1_0 = ret[0];
2710
+ deferred1_1 = ret[1];
2711
+ return getStringFromWasm0(ret[0], ret[1]);
2712
+ } finally {
2713
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2714
+ }
2715
+ }
2716
+
2717
+ /**
2718
+ * Serialize a molecule to XYZ format.
2719
+ *
2720
+ * 3D coordinates are generated via distance-geometry placement.
2721
+ * @param {MolHandle} mol
2722
+ * @returns {string}
2723
+ */
2724
+ export function to_xyz(mol) {
2725
+ let deferred1_0;
2726
+ let deferred1_1;
2727
+ try {
2728
+ _assertClass(mol, MolHandle);
2729
+ const ret = wasm.to_xyz(mol.__wbg_ptr);
2730
+ deferred1_0 = ret[0];
2731
+ deferred1_1 = ret[1];
2732
+ return getStringFromWasm0(ret[0], ret[1]);
2733
+ } finally {
2734
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2735
+ }
2736
+ }
2737
+
2738
+ /**
2739
+ * Torsion fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
2740
+ * @param {MolHandle} mol
2741
+ * @returns {Uint8Array}
2742
+ */
2743
+ export function torsion_bitvec(mol) {
2744
+ _assertClass(mol, MolHandle);
2745
+ const ret = wasm.torsion_bitvec(mol.__wbg_ptr);
2746
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2747
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2748
+ return v1;
2749
+ }
2750
+
2751
+ /**
2752
+ * Non-canonical SMILES for `mol`.
2753
+ *
2754
+ * Unlike `canonical_smiles`, the output depends on the internal atom ordering
2755
+ * and is not normalised. Useful when round-trip fidelity (preserving atom
2756
+ * order) matters more than a canonical form.
2757
+ * @param {MolHandle} mol
2758
+ * @returns {string}
2759
+ */
2760
+ export function write_smiles(mol) {
2761
+ let deferred1_0;
2762
+ let deferred1_1;
2763
+ try {
2764
+ _assertClass(mol, MolHandle);
2765
+ const ret = wasm.write_smiles(mol.__wbg_ptr);
2766
+ deferred1_0 = ret[0];
2767
+ deferred1_1 = ret[1];
2768
+ return getStringFromWasm0(ret[0], ret[1]);
2769
+ } finally {
2770
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2771
+ }
2772
+ }
1318
2773
  function __wbg_get_imports() {
1319
2774
  const import0 = {
1320
2775
  __proto__: null,
@@ -1364,6 +2819,9 @@ function __wbg_get_imports() {
1364
2819
  };
1365
2820
  }
1366
2821
 
2822
+ const ConformerHandleFinalization = (typeof FinalizationRegistry === 'undefined')
2823
+ ? { register: () => {}, unregister: () => {} }
2824
+ : new FinalizationRegistry(ptr => wasm.__wbg_conformerhandle_free(ptr, 1));
1367
2825
  const DepictOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
1368
2826
  ? { register: () => {}, unregister: () => {} }
1369
2827
  : new FinalizationRegistry(ptr => wasm.__wbg_depictoptions_free(ptr, 1));