@kent-tokyo/chematic 0.1.23 → 0.1.36

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
@@ -731,6 +731,38 @@ export class MolHandle {
731
731
  const ret = wasm.molhandle_sum_estate(this.__wbg_ptr);
732
732
  return ret;
733
733
  }
734
+ /**
735
+ * InChI string representation of the molecule.
736
+ * @returns {string}
737
+ */
738
+ to_inchi() {
739
+ let deferred1_0;
740
+ let deferred1_1;
741
+ try {
742
+ const ret = wasm.molhandle_to_inchi(this.__wbg_ptr);
743
+ deferred1_0 = ret[0];
744
+ deferred1_1 = ret[1];
745
+ return getStringFromWasm0(ret[0], ret[1]);
746
+ } finally {
747
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
748
+ }
749
+ }
750
+ /**
751
+ * InChIKey (27-character identifier) for the molecule.
752
+ * @returns {string}
753
+ */
754
+ to_inchikey() {
755
+ let deferred1_0;
756
+ let deferred1_1;
757
+ try {
758
+ const ret = wasm.molhandle_to_inchikey(this.__wbg_ptr);
759
+ deferred1_0 = ret[0];
760
+ deferred1_1 = ret[1];
761
+ return getStringFromWasm0(ret[0], ret[1]);
762
+ } finally {
763
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
764
+ }
765
+ }
734
766
  /**
735
767
  * Topological polar surface area (Ų).
736
768
  * @returns {number}
@@ -783,6 +815,29 @@ export function atom_pair_bitvec(mol) {
783
815
  return v1;
784
816
  }
785
817
 
818
+ /**
819
+ * Check whether a reaction SMILES is atom-balanced.
820
+ *
821
+ * Returns JSON: `{ "balanced": true|false, "diff": ["C: 1 reactant vs 2 product", ...] }`
822
+ * Returns `"error:<msg>"` on parse failure.
823
+ * @param {string} reaction_smiles
824
+ * @returns {string}
825
+ */
826
+ export function balance_check_json(reaction_smiles) {
827
+ let deferred2_0;
828
+ let deferred2_1;
829
+ try {
830
+ const ptr0 = passStringToWasm0(reaction_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
831
+ const len0 = WASM_VECTOR_LEN;
832
+ const ret = wasm.balance_check_json(ptr0, len0);
833
+ deferred2_0 = ret[0];
834
+ deferred2_1 = ret[1];
835
+ return getStringFromWasm0(ret[0], ret[1]);
836
+ } finally {
837
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
838
+ }
839
+ }
840
+
786
841
  /**
787
842
  * Number of BRICS fragments produced by fragmenting the molecule.
788
843
  *
@@ -922,6 +977,111 @@ export function cip_assignments_json(mol) {
922
977
  }
923
978
  }
924
979
 
980
+ /**
981
+ * Compare multiple SMILES strings (up to 256 by default).
982
+ * Accepts a delimiter-separated list (e.g., newline or comma).
983
+ *
984
+ * # Example (JS)
985
+ * ```javascript
986
+ * const smilesList = "c1ccccc1\nCc1ccccc1\nCCc1ccccc1";
987
+ * const json = module.compare_molecules_batch_json(smilesList, "\n");
988
+ * const comparison = JSON.parse(json);
989
+ * ```
990
+ * @param {string} smiles_batch
991
+ * @param {string} delimiter
992
+ * @returns {string}
993
+ */
994
+ export function compare_molecules_batch_json(smiles_batch, delimiter) {
995
+ let deferred4_0;
996
+ let deferred4_1;
997
+ try {
998
+ const ptr0 = passStringToWasm0(smiles_batch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
999
+ const len0 = WASM_VECTOR_LEN;
1000
+ const ptr1 = passStringToWasm0(delimiter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1001
+ const len1 = WASM_VECTOR_LEN;
1002
+ const ret = wasm.compare_molecules_batch_json(ptr0, len0, ptr1, len1);
1003
+ var ptr3 = ret[0];
1004
+ var len3 = ret[1];
1005
+ if (ret[3]) {
1006
+ ptr3 = 0; len3 = 0;
1007
+ throw takeFromExternrefTable0(ret[2]);
1008
+ }
1009
+ deferred4_0 = ptr3;
1010
+ deferred4_1 = len3;
1011
+ return getStringFromWasm0(ptr3, len3);
1012
+ } finally {
1013
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1014
+ }
1015
+ }
1016
+
1017
+ /**
1018
+ * Compare two or more SMILES strings (JSON string output).
1019
+ * Returns the JSON representation of a `MoleculeComparison` struct.
1020
+ *
1021
+ * # Example (JS)
1022
+ * ```javascript
1023
+ * const json = module.compare_molecules_json("c1ccccc1", "Cc1ccccc1");
1024
+ * const comparison = JSON.parse(json);
1025
+ * console.log(comparison.pairwise[0].similarities.ecfp4_tanimoto);
1026
+ * ```
1027
+ * @param {string} smiles1
1028
+ * @param {string} smiles2
1029
+ * @returns {string}
1030
+ */
1031
+ export function compare_molecules_json(smiles1, smiles2) {
1032
+ let deferred4_0;
1033
+ let deferred4_1;
1034
+ try {
1035
+ const ptr0 = passStringToWasm0(smiles1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1036
+ const len0 = WASM_VECTOR_LEN;
1037
+ const ptr1 = passStringToWasm0(smiles2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1038
+ const len1 = WASM_VECTOR_LEN;
1039
+ const ret = wasm.compare_molecules_json(ptr0, len0, ptr1, len1);
1040
+ var ptr3 = ret[0];
1041
+ var len3 = ret[1];
1042
+ if (ret[3]) {
1043
+ ptr3 = 0; len3 = 0;
1044
+ throw takeFromExternrefTable0(ret[2]);
1045
+ }
1046
+ deferred4_0 = ptr3;
1047
+ deferred4_1 = len3;
1048
+ return getStringFromWasm0(ptr3, len3);
1049
+ } finally {
1050
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1051
+ }
1052
+ }
1053
+
1054
+ /**
1055
+ * Compute direct Coulomb energy for a molecule with Gasteiger partial charges.
1056
+ *
1057
+ * Returns JSON object: `{ "coulomb_energy": E, "unit": "kcal/mol" }`
1058
+ *
1059
+ * # Arguments
1060
+ * * `mol` - Molecule to evaluate
1061
+ *
1062
+ * # Example (JavaScript)
1063
+ * ```js
1064
+ * const mol = parse_smiles("CCO");
1065
+ * const result = coulomb_energy_json(mol);
1066
+ * // { "coulomb_energy": -12.34, "unit": "kcal/mol" }
1067
+ * ```
1068
+ * @param {MolHandle} mol
1069
+ * @returns {string}
1070
+ */
1071
+ export function coulomb_energy_json(mol) {
1072
+ let deferred1_0;
1073
+ let deferred1_1;
1074
+ try {
1075
+ _assertClass(mol, MolHandle);
1076
+ const ret = wasm.coulomb_energy_json(mol.__wbg_ptr);
1077
+ deferred1_0 = ret[0];
1078
+ deferred1_1 = ret[1];
1079
+ return getStringFromWasm0(ret[0], ret[1]);
1080
+ } finally {
1081
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1082
+ }
1083
+ }
1084
+
925
1085
  /**
926
1086
  * Return the CPK color (CSS hex string) for the given element symbol.
927
1087
  *
@@ -1168,6 +1328,24 @@ export function ecfp4_bitvec(mol) {
1168
1328
  return v1;
1169
1329
  }
1170
1330
 
1331
+ /**
1332
+ * Like `ecfp4_bitvec` but with explicit chirality control.
1333
+ *
1334
+ * When `use_chirality=true`, tetrahedral stereochemistry is included in the
1335
+ * initial atom hash, making enantiomers have different fingerprints.
1336
+ * When `false` (default), chirality is ignored.
1337
+ * @param {MolHandle} mol
1338
+ * @param {boolean} use_chirality
1339
+ * @returns {Uint8Array}
1340
+ */
1341
+ export function ecfp4_bitvec_with_chirality(mol, use_chirality) {
1342
+ _assertClass(mol, MolHandle);
1343
+ const ret = wasm.ecfp4_bitvec_with_chirality(mol.__wbg_ptr, use_chirality);
1344
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1345
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1346
+ return v1;
1347
+ }
1348
+
1171
1349
  /**
1172
1350
  * ECFP6 (radius-3) fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
1173
1351
  * @param {MolHandle} mol
@@ -1181,6 +1359,24 @@ export function ecfp6_bitvec(mol) {
1181
1359
  return v1;
1182
1360
  }
1183
1361
 
1362
+ /**
1363
+ * Like `ecfp6_bitvec` but with explicit chirality control.
1364
+ *
1365
+ * When `use_chirality=true`, tetrahedral stereochemistry is included in the
1366
+ * initial atom hash, making enantiomers have different fingerprints.
1367
+ * When `false` (default), chirality is ignored.
1368
+ * @param {MolHandle} mol
1369
+ * @param {boolean} use_chirality
1370
+ * @returns {Uint8Array}
1371
+ */
1372
+ export function ecfp6_bitvec_with_chirality(mol, use_chirality) {
1373
+ _assertClass(mol, MolHandle);
1374
+ const ret = wasm.ecfp6_bitvec_with_chirality(mol.__wbg_ptr, use_chirality);
1375
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1376
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1377
+ return v1;
1378
+ }
1379
+
1184
1380
  /**
1185
1381
  * Compute a fingerprint bit-vector with configurable ECFP radius and bit width.
1186
1382
  *
@@ -1190,14 +1386,19 @@ export function ecfp6_bitvec(mol) {
1190
1386
  *
1191
1387
  * The hash modulo is applied at fingerprint-generation time (`id % nbits`),
1192
1388
  * so no post-processing fold is needed.
1389
+ * Compute a custom ECFP (Extended Connectivity FingerPrint) with specified radius and bit count.
1390
+ *
1391
+ * When `use_chirality=true`, tetrahedral stereochemistry is included in the initial
1392
+ * atom hash. When `false` (default), chirality is ignored.
1193
1393
  * @param {MolHandle} mol
1194
1394
  * @param {number} radius
1195
1395
  * @param {number} nbits
1396
+ * @param {boolean} use_chirality
1196
1397
  * @returns {Uint8Array}
1197
1398
  */
1198
- export function ecfp_bitvec_custom(mol, radius, nbits) {
1399
+ export function ecfp_bitvec_custom(mol, radius, nbits, use_chirality) {
1199
1400
  _assertClass(mol, MolHandle);
1200
- const ret = wasm.ecfp_bitvec_custom(mol.__wbg_ptr, radius, nbits);
1401
+ const ret = wasm.ecfp_bitvec_custom(mol.__wbg_ptr, radius, nbits, use_chirality);
1201
1402
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1202
1403
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1203
1404
  return v1;
@@ -1304,6 +1505,30 @@ export function fcfp6_bitvec(mol) {
1304
1505
  return v1;
1305
1506
  }
1306
1507
 
1508
+ /**
1509
+ * Analyze a reaction SMILES and return the reaction center as JSON.
1510
+ *
1511
+ * JSON schema: `{ broken: [[a1,a2],...], formed: [[a1,a2],...], changed: [a,...] }`
1512
+ * where atom indices are 0-based within the first reactant molecule.
1513
+ * Returns an error string prefixed with `"error:"` on failure.
1514
+ * @param {string} reaction_smiles
1515
+ * @returns {string}
1516
+ */
1517
+ export function find_reaction_center_json(reaction_smiles) {
1518
+ let deferred2_0;
1519
+ let deferred2_1;
1520
+ try {
1521
+ const ptr0 = passStringToWasm0(reaction_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1522
+ const len0 = WASM_VECTOR_LEN;
1523
+ const ret = wasm.find_reaction_center_json(ptr0, len0);
1524
+ deferred2_0 = ret[0];
1525
+ deferred2_1 = ret[1];
1526
+ return getStringFromWasm0(ret[0], ret[1]);
1527
+ } finally {
1528
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1529
+ }
1530
+ }
1531
+
1307
1532
  /**
1308
1533
  * Gasteiger-Marsili PEOE partial charges as a JSON array of f64.
1309
1534
  * @param {MolHandle} mol
@@ -1323,6 +1548,39 @@ export function gasteiger_charges_json(mol) {
1323
1548
  }
1324
1549
  }
1325
1550
 
1551
+ /**
1552
+ * Generate 3D coordinates from SMILES (raw distance geometry, no minimization).
1553
+ * Returns PDB format string with atoms positioned in 3D space.
1554
+ *
1555
+ * # Example (JS)
1556
+ * ```javascript
1557
+ * const pdbStr = module.generate_3d_from_smiles("c1ccccc1");
1558
+ * console.log(pdbStr); // PDB file content
1559
+ * ```
1560
+ * @param {string} smiles
1561
+ * @returns {string}
1562
+ */
1563
+ export function generate_3d_from_smiles(smiles) {
1564
+ let deferred3_0;
1565
+ let deferred3_1;
1566
+ try {
1567
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1568
+ const len0 = WASM_VECTOR_LEN;
1569
+ const ret = wasm.generate_3d_from_smiles(ptr0, len0);
1570
+ var ptr2 = ret[0];
1571
+ var len2 = ret[1];
1572
+ if (ret[3]) {
1573
+ ptr2 = 0; len2 = 0;
1574
+ throw takeFromExternrefTable0(ret[2]);
1575
+ }
1576
+ deferred3_0 = ptr2;
1577
+ deferred3_1 = len2;
1578
+ return getStringFromWasm0(ptr2, len2);
1579
+ } finally {
1580
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1581
+ }
1582
+ }
1583
+
1326
1584
  /**
1327
1585
  * Generate energy-minimized 3D coordinates and return a PDB string.
1328
1586
  *
@@ -1346,6 +1604,40 @@ export function generate_3d_minimized_pdb(mol) {
1346
1604
  }
1347
1605
  }
1348
1606
 
1607
+ /**
1608
+ * Generate 3D coordinates and minimize from SMILES string.
1609
+ * Pipeline: distance geometry → DREIDING minimization.
1610
+ * Better geometry quality than raw DG; suitable for graphics.
1611
+ *
1612
+ * # Example (JS)
1613
+ * ```javascript
1614
+ * const pdbStr = module.generate_3d_optimized_pdb("c1ccccc1");
1615
+ * console.log(pdbStr); // PDB file with optimized geometry
1616
+ * ```
1617
+ * @param {string} smiles
1618
+ * @returns {string}
1619
+ */
1620
+ export function generate_3d_optimized_pdb(smiles) {
1621
+ let deferred3_0;
1622
+ let deferred3_1;
1623
+ try {
1624
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1625
+ const len0 = WASM_VECTOR_LEN;
1626
+ const ret = wasm.generate_3d_optimized_pdb(ptr0, len0);
1627
+ var ptr2 = ret[0];
1628
+ var len2 = ret[1];
1629
+ if (ret[3]) {
1630
+ ptr2 = 0; len2 = 0;
1631
+ throw takeFromExternrefTable0(ret[2]);
1632
+ }
1633
+ deferred3_0 = ptr2;
1634
+ deferred3_1 = len2;
1635
+ return getStringFromWasm0(ptr2, len2);
1636
+ } finally {
1637
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1638
+ }
1639
+ }
1640
+
1349
1641
  /**
1350
1642
  * Generate 3D coordinates for the molecule and return a PDB string.
1351
1643
  *
@@ -1504,6 +1796,68 @@ export function identify_functional_groups(mol) {
1504
1796
  }
1505
1797
  }
1506
1798
 
1799
+ /**
1800
+ * Generate InChI string from SMILES.
1801
+ *
1802
+ * Returns `"error:<msg>"` on parse failure.
1803
+ * @param {string} smiles
1804
+ * @returns {string}
1805
+ */
1806
+ export function inchi_from_smiles(smiles) {
1807
+ let deferred2_0;
1808
+ let deferred2_1;
1809
+ try {
1810
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1811
+ const len0 = WASM_VECTOR_LEN;
1812
+ const ret = wasm.inchi_from_smiles(ptr0, len0);
1813
+ deferred2_0 = ret[0];
1814
+ deferred2_1 = ret[1];
1815
+ return getStringFromWasm0(ret[0], ret[1]);
1816
+ } finally {
1817
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1818
+ }
1819
+ }
1820
+
1821
+ /**
1822
+ * Generate InChIKey from SMILES (27-character identifier).
1823
+ *
1824
+ * Returns `"error:<msg>"` on parse failure.
1825
+ * @param {string} smiles
1826
+ * @returns {string}
1827
+ */
1828
+ export function inchikey_from_smiles(smiles) {
1829
+ let deferred2_0;
1830
+ let deferred2_1;
1831
+ try {
1832
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1833
+ const len0 = WASM_VECTOR_LEN;
1834
+ const ret = wasm.inchikey_from_smiles(ptr0, len0);
1835
+ deferred2_0 = ret[0];
1836
+ deferred2_1 = ret[1];
1837
+ return getStringFromWasm0(ret[0], ret[1]);
1838
+ } finally {
1839
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1840
+ }
1841
+ }
1842
+
1843
+ /**
1844
+ * Invert the stereochemistry of a tetrahedral stereocenter (U/D wedge bonds).
1845
+ *
1846
+ * If the atom has no wedge/dash bonds, returns an unchanged copy.
1847
+ * Returns error if atom_idx is invalid.
1848
+ * @param {MolHandle} mol
1849
+ * @param {number} atom_idx
1850
+ * @returns {MolHandle}
1851
+ */
1852
+ export function invert_stereocenter_at(mol, atom_idx) {
1853
+ _assertClass(mol, MolHandle);
1854
+ const ret = wasm.invert_stereocenter_at(mol.__wbg_ptr, atom_idx);
1855
+ if (ret[2]) {
1856
+ throw takeFromExternrefTable0(ret[1]);
1857
+ }
1858
+ return MolHandle.__wrap(ret[0]);
1859
+ }
1860
+
1507
1861
  /**
1508
1862
  * Returns `true` if the SMILES string can be parsed without error.
1509
1863
  * @param {string} s
@@ -1676,7 +2030,35 @@ export function mcs_smiles_json(smiles_json) {
1676
2030
  deferred3_1 = len2;
1677
2031
  return getStringFromWasm0(ptr2, len2);
1678
2032
  } finally {
1679
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2033
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2034
+ }
2035
+ }
2036
+
2037
+ /**
2038
+ * Optimize molecular geometry using DREIDING force field.
2039
+ *
2040
+ * Performs geometry minimization with DREIDING force field parameters.
2041
+ * Returns minimized coordinate PDB.
2042
+ *
2043
+ * # Arguments
2044
+ * * `mol` - Molecule to optimize
2045
+ *
2046
+ * # Returns
2047
+ * PDB format string with optimized coordinates
2048
+ * @param {MolHandle} mol
2049
+ * @returns {string}
2050
+ */
2051
+ export function minimize_dreiding_json(mol) {
2052
+ let deferred1_0;
2053
+ let deferred1_1;
2054
+ try {
2055
+ _assertClass(mol, MolHandle);
2056
+ const ret = wasm.minimize_dreiding_json(mol.__wbg_ptr);
2057
+ deferred1_0 = ret[0];
2058
+ deferred1_1 = ret[1];
2059
+ return getStringFromWasm0(ret[0], ret[1]);
2060
+ } finally {
2061
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1680
2062
  }
1681
2063
  }
1682
2064
 
@@ -1726,6 +2108,28 @@ export function mmp_pairs_json(smiles_json) {
1726
2108
  }
1727
2109
  }
1728
2110
 
2111
+ /**
2112
+ * Parse a Tripos MOL2 string and return SMILES.
2113
+ *
2114
+ * Returns `"error:<msg>"` on failure.
2115
+ * @param {string} mol2_str
2116
+ * @returns {string}
2117
+ */
2118
+ export function mol2_to_smiles(mol2_str) {
2119
+ let deferred2_0;
2120
+ let deferred2_1;
2121
+ try {
2122
+ const ptr0 = passStringToWasm0(mol2_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2123
+ const len0 = WASM_VECTOR_LEN;
2124
+ const ret = wasm.mol2_to_smiles(ptr0, len0);
2125
+ deferred2_0 = ret[0];
2126
+ deferred2_1 = ret[1];
2127
+ return getStringFromWasm0(ret[0], ret[1]);
2128
+ } finally {
2129
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2130
+ }
2131
+ }
2132
+
1729
2133
  /**
1730
2134
  * Parse a MOL V2000 string and return 2D coordinates as a JSON array.
1731
2135
  *
@@ -2010,6 +2414,40 @@ export function mol_with_bond_removed(mol, idx) {
2010
2414
  return MolHandle.__wrap(ret[0]);
2011
2415
  }
2012
2416
 
2417
+ /**
2418
+ * Generate a complete molecular report (JSON string) from a SMILES.
2419
+ * Returns the JSON representation of a `MoleculeReport` struct.
2420
+ *
2421
+ * # Example (JS)
2422
+ * ```javascript
2423
+ * const json = module.molecule_report_json("CC(=O)Oc1ccccc1C(=O)O");
2424
+ * const report = JSON.parse(json);
2425
+ * console.log(report.canonical_smiles, report.descriptors.tpsa);
2426
+ * ```
2427
+ * @param {string} smiles
2428
+ * @returns {string}
2429
+ */
2430
+ export function molecule_report_json(smiles) {
2431
+ let deferred3_0;
2432
+ let deferred3_1;
2433
+ try {
2434
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2435
+ const len0 = WASM_VECTOR_LEN;
2436
+ const ret = wasm.molecule_report_json(ptr0, len0);
2437
+ var ptr2 = ret[0];
2438
+ var len2 = ret[1];
2439
+ if (ret[3]) {
2440
+ ptr2 = 0; len2 = 0;
2441
+ throw takeFromExternrefTable0(ret[2]);
2442
+ }
2443
+ deferred3_0 = ptr2;
2444
+ deferred3_1 = len2;
2445
+ return getStringFromWasm0(ptr2, len2);
2446
+ } finally {
2447
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2448
+ }
2449
+ }
2450
+
2013
2451
  /**
2014
2452
  * Per-atom molar refractivity contributions as a JSON array of f64.
2015
2453
  * @param {MolHandle} mol
@@ -2042,6 +2480,34 @@ export function murcko_scaffold(mol) {
2042
2480
  return MolHandle.__wrap(ret);
2043
2481
  }
2044
2482
 
2483
+ /**
2484
+ * Find the k nearest neighbours of a query SMILES in a list of db SMILES.
2485
+ *
2486
+ * `db_smiles_json`: JSON array of SMILES strings, e.g. `["CC","c1ccccc1"]`.
2487
+ * Returns JSON: `[{"index":0,"tanimoto":0.95},...]` sorted by descending Tanimoto.
2488
+ * Returns `"error:<msg>"` on parse failure.
2489
+ * @param {string} query_smiles
2490
+ * @param {string} db_smiles_json
2491
+ * @param {number} k
2492
+ * @returns {string}
2493
+ */
2494
+ export function nearest_neighbors_json(query_smiles, db_smiles_json, k) {
2495
+ let deferred3_0;
2496
+ let deferred3_1;
2497
+ try {
2498
+ const ptr0 = passStringToWasm0(query_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2499
+ const len0 = WASM_VECTOR_LEN;
2500
+ const ptr1 = passStringToWasm0(db_smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2501
+ const len1 = WASM_VECTOR_LEN;
2502
+ const ret = wasm.nearest_neighbors_json(ptr0, len0, ptr1, len1, k);
2503
+ deferred3_0 = ret[0];
2504
+ deferred3_1 = ret[1];
2505
+ return getStringFromWasm0(ret[0], ret[1]);
2506
+ } finally {
2507
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2508
+ }
2509
+ }
2510
+
2045
2511
  /**
2046
2512
  * Neutralize formal charges on `mol` by proton addition/removal.
2047
2513
  *
@@ -2055,6 +2521,33 @@ export function neutralize_charges(mol) {
2055
2521
  return MolHandle.__wrap(ret);
2056
2522
  }
2057
2523
 
2524
+ /**
2525
+ * Parse and re-serialize CXSMILES, preserving supported CX metadata.
2526
+ * Returns error if atom count exceeds 10,000.
2527
+ * @param {string} s
2528
+ * @returns {string}
2529
+ */
2530
+ export function normalize_cxsmiles(s) {
2531
+ let deferred3_0;
2532
+ let deferred3_1;
2533
+ try {
2534
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2535
+ const len0 = WASM_VECTOR_LEN;
2536
+ const ret = wasm.normalize_cxsmiles(ptr0, len0);
2537
+ var ptr2 = ret[0];
2538
+ var len2 = ret[1];
2539
+ if (ret[3]) {
2540
+ ptr2 = 0; len2 = 0;
2541
+ throw takeFromExternrefTable0(ret[2]);
2542
+ }
2543
+ deferred3_0 = ptr2;
2544
+ deferred3_1 = len2;
2545
+ return getStringFromWasm0(ptr2, len2);
2546
+ } finally {
2547
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2548
+ }
2549
+ }
2550
+
2058
2551
  /**
2059
2552
  * Parse and re-serialise a reaction SMILES string, returning the normalised form.
2060
2553
  *
@@ -2106,10 +2599,68 @@ export function pains_matches_json(mol) {
2106
2599
  }
2107
2600
  }
2108
2601
 
2602
+ /**
2603
+ * Parse CXSMARTS and return preserved metadata as JSON.
2604
+ * Returns error if atom count exceeds 10,000.
2605
+ * @param {string} s
2606
+ * @returns {string}
2607
+ */
2608
+ export function parse_cxsmarts_json(s) {
2609
+ let deferred3_0;
2610
+ let deferred3_1;
2611
+ try {
2612
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2613
+ const len0 = WASM_VECTOR_LEN;
2614
+ const ret = wasm.parse_cxsmarts_json(ptr0, len0);
2615
+ var ptr2 = ret[0];
2616
+ var len2 = ret[1];
2617
+ if (ret[3]) {
2618
+ ptr2 = 0; len2 = 0;
2619
+ throw takeFromExternrefTable0(ret[2]);
2620
+ }
2621
+ deferred3_0 = ptr2;
2622
+ deferred3_1 = len2;
2623
+ return getStringFromWasm0(ptr2, len2);
2624
+ } finally {
2625
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2626
+ }
2627
+ }
2628
+
2629
+ /**
2630
+ * Parse CXSMILES and return preserved metadata as JSON.
2631
+ *
2632
+ * Supported CX fields: atom labels (`$...$`), `atomProp`, atom radicals (`^n:`),
2633
+ * and zero-order bonds (`Z:`). The `cxsmiles` field is a re-serialized
2634
+ * round-trip form using the supported fields.
2635
+ * Returns error if atom count exceeds 10,000.
2636
+ * @param {string} s
2637
+ * @returns {string}
2638
+ */
2639
+ export function parse_cxsmiles_json(s) {
2640
+ let deferred3_0;
2641
+ let deferred3_1;
2642
+ try {
2643
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2644
+ const len0 = WASM_VECTOR_LEN;
2645
+ const ret = wasm.parse_cxsmiles_json(ptr0, len0);
2646
+ var ptr2 = ret[0];
2647
+ var len2 = ret[1];
2648
+ if (ret[3]) {
2649
+ ptr2 = 0; len2 = 0;
2650
+ throw takeFromExternrefTable0(ret[2]);
2651
+ }
2652
+ deferred3_0 = ptr2;
2653
+ deferred3_1 = len2;
2654
+ return getStringFromWasm0(ptr2, len2);
2655
+ } finally {
2656
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2657
+ }
2658
+ }
2659
+
2109
2660
  /**
2110
2661
  * Parse a SMILES string into a `MolHandle`.
2111
2662
  *
2112
- * Returns a JS error string on parse failure.
2663
+ * Returns a JS error string on parse failure or if atom count exceeds 10,000.
2113
2664
  * @param {string} s
2114
2665
  * @returns {MolHandle}
2115
2666
  */
@@ -2200,6 +2751,31 @@ export function rgroup_decompose_json(smiles_json, core_smarts) {
2200
2751
  }
2201
2752
  }
2202
2753
 
2754
+ /**
2755
+ * Run molecular dynamics simulation and return trajectory as JSON.
2756
+ *
2757
+ * Returns JSON object with trajectory frames: `{ "frames": [{ "step": N, "potential": E, "kinetic": K, "temp": T }, …] }`
2758
+ * Uses NVT ensemble (Berendsen thermostat) at 300 K by default.
2759
+ * Note: Limited to molecules with ~50 atoms or fewer for practical WASM performance.
2760
+ * @param {MolHandle} mol
2761
+ * @param {number} steps
2762
+ * @param {number} temp_k
2763
+ * @returns {string}
2764
+ */
2765
+ export function run_md_json(mol, steps, temp_k) {
2766
+ let deferred1_0;
2767
+ let deferred1_1;
2768
+ try {
2769
+ _assertClass(mol, MolHandle);
2770
+ const ret = wasm.run_md_json(mol.__wbg_ptr, steps, temp_k);
2771
+ deferred1_0 = ret[0];
2772
+ deferred1_1 = ret[1];
2773
+ return getStringFromWasm0(ret[0], ret[1]);
2774
+ } finally {
2775
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2776
+ }
2777
+ }
2778
+
2203
2779
  /**
2204
2780
  * Apply a SMIRKS reaction template and return product SMILES as a JSON string.
2205
2781
  *
@@ -2244,6 +2820,41 @@ export function sa_score(mol) {
2244
2820
  return ret;
2245
2821
  }
2246
2822
 
2823
+ /**
2824
+ * Screen a batch of SMILES strings (JSON string output).
2825
+ * Returns per-record results including pass/fail with error details.
2826
+ * Includes MaxMin diversity picking and Butina clustering by default.
2827
+ *
2828
+ * # Example (JS)
2829
+ * ```javascript
2830
+ * const smilesList = "c1ccccc1\nCC\nCCC";
2831
+ * const json = module.screen_smiles_json(smilesList, "\n");
2832
+ * const report = JSON.parse(json);
2833
+ * console.log(report.records); // Array of ScreeningRecord
2834
+ * console.log(report.maxmin_picks); // Diversity-selected indices
2835
+ * console.log(report.butina_clusters); // Clustering result
2836
+ * ```
2837
+ * @param {string} smiles_batch
2838
+ * @param {string} delimiter
2839
+ * @returns {string}
2840
+ */
2841
+ export function screen_smiles_json(smiles_batch, delimiter) {
2842
+ let deferred3_0;
2843
+ let deferred3_1;
2844
+ try {
2845
+ const ptr0 = passStringToWasm0(smiles_batch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2846
+ const len0 = WASM_VECTOR_LEN;
2847
+ const ptr1 = passStringToWasm0(delimiter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2848
+ const len1 = WASM_VECTOR_LEN;
2849
+ const ret = wasm.screen_smiles_json(ptr0, len0, ptr1, len1);
2850
+ deferred3_0 = ret[0];
2851
+ deferred3_1 = ret[1];
2852
+ return getStringFromWasm0(ret[0], ret[1]);
2853
+ } finally {
2854
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2855
+ }
2856
+ }
2857
+
2247
2858
  /**
2248
2859
  * Serialize multiple molecules with properties to an SDF string.
2249
2860
  *
@@ -2413,6 +3024,39 @@ export function smarts_match_atoms(smarts, mol) {
2413
3024
  }
2414
3025
  }
2415
3026
 
3027
+ /**
3028
+ * Like `smarts_match_atoms` but with explicit chirality matching control.
3029
+ *
3030
+ * When `use_chirality=true`, SMARTS chirality primitives `[@]` and `[@@]` are
3031
+ * matched against the target molecule's stereochemistry. When `false`, chirality
3032
+ * is ignored (RDKit default).
3033
+ * @param {string} smarts
3034
+ * @param {MolHandle} mol
3035
+ * @param {boolean} use_chirality
3036
+ * @returns {string}
3037
+ */
3038
+ export function smarts_match_atoms_with_chirality(smarts, mol, use_chirality) {
3039
+ let deferred3_0;
3040
+ let deferred3_1;
3041
+ try {
3042
+ const ptr0 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3043
+ const len0 = WASM_VECTOR_LEN;
3044
+ _assertClass(mol, MolHandle);
3045
+ const ret = wasm.smarts_match_atoms_with_chirality(ptr0, len0, mol.__wbg_ptr, use_chirality);
3046
+ var ptr2 = ret[0];
3047
+ var len2 = ret[1];
3048
+ if (ret[3]) {
3049
+ ptr2 = 0; len2 = 0;
3050
+ throw takeFromExternrefTable0(ret[2]);
3051
+ }
3052
+ deferred3_0 = ptr2;
3053
+ deferred3_1 = len2;
3054
+ return getStringFromWasm0(ptr2, len2);
3055
+ } finally {
3056
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3057
+ }
3058
+ }
3059
+
2416
3060
  /**
2417
3061
  * Serialise a JSON array of SMILES to an SDF string.
2418
3062
  *
@@ -2442,6 +3086,28 @@ export function smiles_array_to_sdf(smiles_json) {
2442
3086
  }
2443
3087
  }
2444
3088
 
3089
+ /**
3090
+ * Convert a SMILES to a minimal Tripos MOL2 string (no 3D coordinates).
3091
+ *
3092
+ * Returns `"error:<msg>"` on parse failure.
3093
+ * @param {string} smiles
3094
+ * @returns {string}
3095
+ */
3096
+ export function smiles_to_mol2(smiles) {
3097
+ let deferred2_0;
3098
+ let deferred2_1;
3099
+ try {
3100
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3101
+ const len0 = WASM_VECTOR_LEN;
3102
+ const ret = wasm.smiles_to_mol2(ptr0, len0);
3103
+ deferred2_0 = ret[0];
3104
+ deferred2_1 = ret[1];
3105
+ return getStringFromWasm0(ret[0], ret[1]);
3106
+ } finally {
3107
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
3108
+ }
3109
+ }
3110
+
2445
3111
  /**
2446
3112
  * Render a highlighted SVG from a SMILES string in one call.
2447
3113
  *
@@ -2524,6 +3190,56 @@ export function sssr_rings_json(mol) {
2524
3190
  }
2525
3191
  }
2526
3192
 
3193
+ /**
3194
+ * Standardize a SMILES string and return the canonical SMILES of the result.
3195
+ *
3196
+ * Applies: largest fragment extraction → charge neutralization.
3197
+ * Returns `"error:<msg>"` on parse failure.
3198
+ * @param {string} smiles
3199
+ * @returns {string}
3200
+ */
3201
+ export function standardize_smiles(smiles) {
3202
+ let deferred2_0;
3203
+ let deferred2_1;
3204
+ try {
3205
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3206
+ const len0 = WASM_VECTOR_LEN;
3207
+ const ret = wasm.standardize_smiles(ptr0, len0);
3208
+ deferred2_0 = ret[0];
3209
+ deferred2_1 = ret[1];
3210
+ return getStringFromWasm0(ret[0], ret[1]);
3211
+ } finally {
3212
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
3213
+ }
3214
+ }
3215
+
3216
+ /**
3217
+ * Standardize a SMILES string and return result SMILES plus an audit report as JSON.
3218
+ *
3219
+ * Boolean flags map directly to `StandardizeOptions`.
3220
+ * Returns `"error:<msg>"` on parse or serialization failure.
3221
+ * @param {string} smiles
3222
+ * @param {boolean} largest_fragment_only
3223
+ * @param {boolean} neutralize_charges
3224
+ * @param {boolean} remove_explicit_h
3225
+ * @param {boolean} canonical_tautomer
3226
+ * @returns {string}
3227
+ */
3228
+ export function standardize_smiles_report_json(smiles, largest_fragment_only, neutralize_charges, remove_explicit_h, canonical_tautomer) {
3229
+ let deferred2_0;
3230
+ let deferred2_1;
3231
+ try {
3232
+ const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3233
+ const len0 = WASM_VECTOR_LEN;
3234
+ const ret = wasm.standardize_smiles_report_json(ptr0, len0, largest_fragment_only, neutralize_charges, remove_explicit_h, canonical_tautomer);
3235
+ deferred2_0 = ret[0];
3236
+ deferred2_1 = ret[1];
3237
+ return getStringFromWasm0(ret[0], ret[1]);
3238
+ } finally {
3239
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
3240
+ }
3241
+ }
3242
+
2527
3243
  export function start() {
2528
3244
  wasm.start();
2529
3245
  }
@@ -2773,6 +3489,14 @@ export function write_smiles(mol) {
2773
3489
  function __wbg_get_imports() {
2774
3490
  const import0 = {
2775
3491
  __proto__: null,
3492
+ __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
3493
+ const obj = arg1;
3494
+ const ret = typeof(obj) === 'string' ? obj : undefined;
3495
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3496
+ var len1 = WASM_VECTOR_LEN;
3497
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3498
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3499
+ },
2776
3500
  __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
2777
3501
  throw new Error(getStringFromWasm0(arg0, arg1));
2778
3502
  },
@@ -2787,6 +3511,9 @@ function __wbg_get_imports() {
2787
3511
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2788
3512
  }
2789
3513
  },
3514
+ __wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
3515
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
3516
+ }, arguments); },
2790
3517
  __wbg_new_227d7c05414eb861: function() {
2791
3518
  const ret = new Error();
2792
3519
  return ret;
@@ -2829,6 +3556,12 @@ const MolHandleFinalization = (typeof FinalizationRegistry === 'undefined')
2829
3556
  ? { register: () => {}, unregister: () => {} }
2830
3557
  : new FinalizationRegistry(ptr => wasm.__wbg_molhandle_free(ptr, 1));
2831
3558
 
3559
+ function addToExternrefTable0(obj) {
3560
+ const idx = wasm.__externref_table_alloc();
3561
+ wasm.__wbindgen_externrefs.set(idx, obj);
3562
+ return idx;
3563
+ }
3564
+
2832
3565
  function _assertClass(instance, klass) {
2833
3566
  if (!(instance instanceof klass)) {
2834
3567
  throw new Error(`expected instance of ${klass.name}`);
@@ -2868,6 +3601,19 @@ function getUint8ArrayMemory0() {
2868
3601
  return cachedUint8ArrayMemory0;
2869
3602
  }
2870
3603
 
3604
+ function handleError(f, args) {
3605
+ try {
3606
+ return f.apply(this, args);
3607
+ } catch (e) {
3608
+ const idx = addToExternrefTable0(e);
3609
+ wasm.__wbindgen_exn_store(idx);
3610
+ }
3611
+ }
3612
+
3613
+ function isLikeNone(x) {
3614
+ return x === undefined || x === null;
3615
+ }
3616
+
2871
3617
  function passArray32ToWasm0(arg, malloc) {
2872
3618
  const ptr = malloc(arg.length * 4, 4) >>> 0;
2873
3619
  getUint32ArrayMemory0().set(arg, ptr / 4);