@kent-tokyo/chematic 0.1.25 → 0.1.37
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.d.ts +363 -4
- package/chematic_wasm.js +890 -4
- package/chematic_wasm_bg.wasm +0 -0
- package/package.json +2 -2
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
|
*
|
|
@@ -1462,6 +1754,31 @@ export function get_bond_info(mol, idx) {
|
|
|
1462
1754
|
}
|
|
1463
1755
|
}
|
|
1464
1756
|
|
|
1757
|
+
/**
|
|
1758
|
+
* Get bond length in Ångströms between two atoms from a SMILES string.
|
|
1759
|
+
* Returns -1.0 if parsing fails or atom indices are out of range.
|
|
1760
|
+
*
|
|
1761
|
+
* # Arguments
|
|
1762
|
+
* - `smiles`: SMILES string
|
|
1763
|
+
* - `a`: first atom index
|
|
1764
|
+
* - `b`: second atom index
|
|
1765
|
+
*
|
|
1766
|
+
* # Example
|
|
1767
|
+
* ```javascript
|
|
1768
|
+
* const len = get_bond_length_json("CC", 0, 1); // C-C single bond ≈ 1.54 Å
|
|
1769
|
+
* ```
|
|
1770
|
+
* @param {string} smiles
|
|
1771
|
+
* @param {number} a
|
|
1772
|
+
* @param {number} b
|
|
1773
|
+
* @returns {number}
|
|
1774
|
+
*/
|
|
1775
|
+
export function get_bond_length_json(smiles, a, b) {
|
|
1776
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1777
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1778
|
+
const ret = wasm.get_bond_length_json(ptr0, len0, a, b);
|
|
1779
|
+
return ret;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1465
1782
|
/**
|
|
1466
1783
|
* All scalar molecular descriptors as a single JSON object.
|
|
1467
1784
|
*
|
|
@@ -1484,6 +1801,32 @@ export function get_descriptors_json(mol) {
|
|
|
1484
1801
|
}
|
|
1485
1802
|
}
|
|
1486
1803
|
|
|
1804
|
+
/**
|
|
1805
|
+
* Get dihedral angle A—B—C—D in degrees from a SMILES string.
|
|
1806
|
+
* Returns null (JSON null) if any atom index is out of range or atoms are collinear.
|
|
1807
|
+
*
|
|
1808
|
+
* # Arguments
|
|
1809
|
+
* - `smiles`: SMILES string
|
|
1810
|
+
* - `a`, `b`, `c`, `d`: atom indices
|
|
1811
|
+
*
|
|
1812
|
+
* # Example
|
|
1813
|
+
* ```javascript
|
|
1814
|
+
* const dihedral = get_dihedral_json("CCCC", 0, 1, 2, 3); // A-B-C-D
|
|
1815
|
+
* ```
|
|
1816
|
+
* @param {string} smiles
|
|
1817
|
+
* @param {number} a
|
|
1818
|
+
* @param {number} b
|
|
1819
|
+
* @param {number} c
|
|
1820
|
+
* @param {number} d
|
|
1821
|
+
* @returns {any}
|
|
1822
|
+
*/
|
|
1823
|
+
export function get_dihedral_json(smiles, a, b, c, d) {
|
|
1824
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1825
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1826
|
+
const ret = wasm.get_dihedral_json(ptr0, len0, a, b, c, d);
|
|
1827
|
+
return ret;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1487
1830
|
/**
|
|
1488
1831
|
* Identify functional groups. Returns a JSON array of objects:
|
|
1489
1832
|
* `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
|
|
@@ -1504,6 +1847,68 @@ export function identify_functional_groups(mol) {
|
|
|
1504
1847
|
}
|
|
1505
1848
|
}
|
|
1506
1849
|
|
|
1850
|
+
/**
|
|
1851
|
+
* Generate InChI string from SMILES.
|
|
1852
|
+
*
|
|
1853
|
+
* Returns `"error:<msg>"` on parse failure.
|
|
1854
|
+
* @param {string} smiles
|
|
1855
|
+
* @returns {string}
|
|
1856
|
+
*/
|
|
1857
|
+
export function inchi_from_smiles(smiles) {
|
|
1858
|
+
let deferred2_0;
|
|
1859
|
+
let deferred2_1;
|
|
1860
|
+
try {
|
|
1861
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1862
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1863
|
+
const ret = wasm.inchi_from_smiles(ptr0, len0);
|
|
1864
|
+
deferred2_0 = ret[0];
|
|
1865
|
+
deferred2_1 = ret[1];
|
|
1866
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1867
|
+
} finally {
|
|
1868
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
/**
|
|
1873
|
+
* Generate InChIKey from SMILES (27-character identifier).
|
|
1874
|
+
*
|
|
1875
|
+
* Returns `"error:<msg>"` on parse failure.
|
|
1876
|
+
* @param {string} smiles
|
|
1877
|
+
* @returns {string}
|
|
1878
|
+
*/
|
|
1879
|
+
export function inchikey_from_smiles(smiles) {
|
|
1880
|
+
let deferred2_0;
|
|
1881
|
+
let deferred2_1;
|
|
1882
|
+
try {
|
|
1883
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1884
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1885
|
+
const ret = wasm.inchikey_from_smiles(ptr0, len0);
|
|
1886
|
+
deferred2_0 = ret[0];
|
|
1887
|
+
deferred2_1 = ret[1];
|
|
1888
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1889
|
+
} finally {
|
|
1890
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
/**
|
|
1895
|
+
* Invert the stereochemistry of a tetrahedral stereocenter (U/D wedge bonds).
|
|
1896
|
+
*
|
|
1897
|
+
* If the atom has no wedge/dash bonds, returns an unchanged copy.
|
|
1898
|
+
* Returns error if atom_idx is invalid.
|
|
1899
|
+
* @param {MolHandle} mol
|
|
1900
|
+
* @param {number} atom_idx
|
|
1901
|
+
* @returns {MolHandle}
|
|
1902
|
+
*/
|
|
1903
|
+
export function invert_stereocenter_at(mol, atom_idx) {
|
|
1904
|
+
_assertClass(mol, MolHandle);
|
|
1905
|
+
const ret = wasm.invert_stereocenter_at(mol.__wbg_ptr, atom_idx);
|
|
1906
|
+
if (ret[2]) {
|
|
1907
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1908
|
+
}
|
|
1909
|
+
return MolHandle.__wrap(ret[0]);
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1507
1912
|
/**
|
|
1508
1913
|
* Returns `true` if the SMILES string can be parsed without error.
|
|
1509
1914
|
* @param {string} s
|
|
@@ -1680,6 +2085,34 @@ export function mcs_smiles_json(smiles_json) {
|
|
|
1680
2085
|
}
|
|
1681
2086
|
}
|
|
1682
2087
|
|
|
2088
|
+
/**
|
|
2089
|
+
* Optimize molecular geometry using DREIDING force field.
|
|
2090
|
+
*
|
|
2091
|
+
* Performs geometry minimization with DREIDING force field parameters.
|
|
2092
|
+
* Returns minimized coordinate PDB.
|
|
2093
|
+
*
|
|
2094
|
+
* # Arguments
|
|
2095
|
+
* * `mol` - Molecule to optimize
|
|
2096
|
+
*
|
|
2097
|
+
* # Returns
|
|
2098
|
+
* PDB format string with optimized coordinates
|
|
2099
|
+
* @param {MolHandle} mol
|
|
2100
|
+
* @returns {string}
|
|
2101
|
+
*/
|
|
2102
|
+
export function minimize_dreiding_json(mol) {
|
|
2103
|
+
let deferred1_0;
|
|
2104
|
+
let deferred1_1;
|
|
2105
|
+
try {
|
|
2106
|
+
_assertClass(mol, MolHandle);
|
|
2107
|
+
const ret = wasm.minimize_dreiding_json(mol.__wbg_ptr);
|
|
2108
|
+
deferred1_0 = ret[0];
|
|
2109
|
+
deferred1_1 = ret[1];
|
|
2110
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2111
|
+
} finally {
|
|
2112
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
|
|
1683
2116
|
/**
|
|
1684
2117
|
* Find matched molecular pairs in a set of molecules as JSON.
|
|
1685
2118
|
*
|
|
@@ -1726,6 +2159,28 @@ export function mmp_pairs_json(smiles_json) {
|
|
|
1726
2159
|
}
|
|
1727
2160
|
}
|
|
1728
2161
|
|
|
2162
|
+
/**
|
|
2163
|
+
* Parse a Tripos MOL2 string and return SMILES.
|
|
2164
|
+
*
|
|
2165
|
+
* Returns `"error:<msg>"` on failure.
|
|
2166
|
+
* @param {string} mol2_str
|
|
2167
|
+
* @returns {string}
|
|
2168
|
+
*/
|
|
2169
|
+
export function mol2_to_smiles(mol2_str) {
|
|
2170
|
+
let deferred2_0;
|
|
2171
|
+
let deferred2_1;
|
|
2172
|
+
try {
|
|
2173
|
+
const ptr0 = passStringToWasm0(mol2_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2174
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2175
|
+
const ret = wasm.mol2_to_smiles(ptr0, len0);
|
|
2176
|
+
deferred2_0 = ret[0];
|
|
2177
|
+
deferred2_1 = ret[1];
|
|
2178
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2179
|
+
} finally {
|
|
2180
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
|
|
1729
2184
|
/**
|
|
1730
2185
|
* Parse a MOL V2000 string and return 2D coordinates as a JSON array.
|
|
1731
2186
|
*
|
|
@@ -2010,6 +2465,40 @@ export function mol_with_bond_removed(mol, idx) {
|
|
|
2010
2465
|
return MolHandle.__wrap(ret[0]);
|
|
2011
2466
|
}
|
|
2012
2467
|
|
|
2468
|
+
/**
|
|
2469
|
+
* Generate a complete molecular report (JSON string) from a SMILES.
|
|
2470
|
+
* Returns the JSON representation of a `MoleculeReport` struct.
|
|
2471
|
+
*
|
|
2472
|
+
* # Example (JS)
|
|
2473
|
+
* ```javascript
|
|
2474
|
+
* const json = module.molecule_report_json("CC(=O)Oc1ccccc1C(=O)O");
|
|
2475
|
+
* const report = JSON.parse(json);
|
|
2476
|
+
* console.log(report.canonical_smiles, report.descriptors.tpsa);
|
|
2477
|
+
* ```
|
|
2478
|
+
* @param {string} smiles
|
|
2479
|
+
* @returns {string}
|
|
2480
|
+
*/
|
|
2481
|
+
export function molecule_report_json(smiles) {
|
|
2482
|
+
let deferred3_0;
|
|
2483
|
+
let deferred3_1;
|
|
2484
|
+
try {
|
|
2485
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2486
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2487
|
+
const ret = wasm.molecule_report_json(ptr0, len0);
|
|
2488
|
+
var ptr2 = ret[0];
|
|
2489
|
+
var len2 = ret[1];
|
|
2490
|
+
if (ret[3]) {
|
|
2491
|
+
ptr2 = 0; len2 = 0;
|
|
2492
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2493
|
+
}
|
|
2494
|
+
deferred3_0 = ptr2;
|
|
2495
|
+
deferred3_1 = len2;
|
|
2496
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2497
|
+
} finally {
|
|
2498
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2013
2502
|
/**
|
|
2014
2503
|
* Per-atom molar refractivity contributions as a JSON array of f64.
|
|
2015
2504
|
* @param {MolHandle} mol
|
|
@@ -2042,6 +2531,34 @@ export function murcko_scaffold(mol) {
|
|
|
2042
2531
|
return MolHandle.__wrap(ret);
|
|
2043
2532
|
}
|
|
2044
2533
|
|
|
2534
|
+
/**
|
|
2535
|
+
* Find the k nearest neighbours of a query SMILES in a list of db SMILES.
|
|
2536
|
+
*
|
|
2537
|
+
* `db_smiles_json`: JSON array of SMILES strings, e.g. `["CC","c1ccccc1"]`.
|
|
2538
|
+
* Returns JSON: `[{"index":0,"tanimoto":0.95},...]` sorted by descending Tanimoto.
|
|
2539
|
+
* Returns `"error:<msg>"` on parse failure.
|
|
2540
|
+
* @param {string} query_smiles
|
|
2541
|
+
* @param {string} db_smiles_json
|
|
2542
|
+
* @param {number} k
|
|
2543
|
+
* @returns {string}
|
|
2544
|
+
*/
|
|
2545
|
+
export function nearest_neighbors_json(query_smiles, db_smiles_json, k) {
|
|
2546
|
+
let deferred3_0;
|
|
2547
|
+
let deferred3_1;
|
|
2548
|
+
try {
|
|
2549
|
+
const ptr0 = passStringToWasm0(query_smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2550
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2551
|
+
const ptr1 = passStringToWasm0(db_smiles_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2552
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2553
|
+
const ret = wasm.nearest_neighbors_json(ptr0, len0, ptr1, len1, k);
|
|
2554
|
+
deferred3_0 = ret[0];
|
|
2555
|
+
deferred3_1 = ret[1];
|
|
2556
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2557
|
+
} finally {
|
|
2558
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2045
2562
|
/**
|
|
2046
2563
|
* Neutralize formal charges on `mol` by proton addition/removal.
|
|
2047
2564
|
*
|
|
@@ -2055,6 +2572,33 @@ export function neutralize_charges(mol) {
|
|
|
2055
2572
|
return MolHandle.__wrap(ret);
|
|
2056
2573
|
}
|
|
2057
2574
|
|
|
2575
|
+
/**
|
|
2576
|
+
* Parse and re-serialize CXSMILES, preserving supported CX metadata.
|
|
2577
|
+
* Returns error if atom count exceeds 10,000.
|
|
2578
|
+
* @param {string} s
|
|
2579
|
+
* @returns {string}
|
|
2580
|
+
*/
|
|
2581
|
+
export function normalize_cxsmiles(s) {
|
|
2582
|
+
let deferred3_0;
|
|
2583
|
+
let deferred3_1;
|
|
2584
|
+
try {
|
|
2585
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2586
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2587
|
+
const ret = wasm.normalize_cxsmiles(ptr0, len0);
|
|
2588
|
+
var ptr2 = ret[0];
|
|
2589
|
+
var len2 = ret[1];
|
|
2590
|
+
if (ret[3]) {
|
|
2591
|
+
ptr2 = 0; len2 = 0;
|
|
2592
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2593
|
+
}
|
|
2594
|
+
deferred3_0 = ptr2;
|
|
2595
|
+
deferred3_1 = len2;
|
|
2596
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2597
|
+
} finally {
|
|
2598
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2058
2602
|
/**
|
|
2059
2603
|
* Parse and re-serialise a reaction SMILES string, returning the normalised form.
|
|
2060
2604
|
*
|
|
@@ -2106,10 +2650,68 @@ export function pains_matches_json(mol) {
|
|
|
2106
2650
|
}
|
|
2107
2651
|
}
|
|
2108
2652
|
|
|
2653
|
+
/**
|
|
2654
|
+
* Parse CXSMARTS and return preserved metadata as JSON.
|
|
2655
|
+
* Returns error if atom count exceeds 10,000.
|
|
2656
|
+
* @param {string} s
|
|
2657
|
+
* @returns {string}
|
|
2658
|
+
*/
|
|
2659
|
+
export function parse_cxsmarts_json(s) {
|
|
2660
|
+
let deferred3_0;
|
|
2661
|
+
let deferred3_1;
|
|
2662
|
+
try {
|
|
2663
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2664
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2665
|
+
const ret = wasm.parse_cxsmarts_json(ptr0, len0);
|
|
2666
|
+
var ptr2 = ret[0];
|
|
2667
|
+
var len2 = ret[1];
|
|
2668
|
+
if (ret[3]) {
|
|
2669
|
+
ptr2 = 0; len2 = 0;
|
|
2670
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2671
|
+
}
|
|
2672
|
+
deferred3_0 = ptr2;
|
|
2673
|
+
deferred3_1 = len2;
|
|
2674
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2675
|
+
} finally {
|
|
2676
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
/**
|
|
2681
|
+
* Parse CXSMILES and return preserved metadata as JSON.
|
|
2682
|
+
*
|
|
2683
|
+
* Supported CX fields: atom labels (`$...$`), `atomProp`, atom radicals (`^n:`),
|
|
2684
|
+
* and zero-order bonds (`Z:`). The `cxsmiles` field is a re-serialized
|
|
2685
|
+
* round-trip form using the supported fields.
|
|
2686
|
+
* Returns error if atom count exceeds 10,000.
|
|
2687
|
+
* @param {string} s
|
|
2688
|
+
* @returns {string}
|
|
2689
|
+
*/
|
|
2690
|
+
export function parse_cxsmiles_json(s) {
|
|
2691
|
+
let deferred3_0;
|
|
2692
|
+
let deferred3_1;
|
|
2693
|
+
try {
|
|
2694
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2695
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2696
|
+
const ret = wasm.parse_cxsmiles_json(ptr0, len0);
|
|
2697
|
+
var ptr2 = ret[0];
|
|
2698
|
+
var len2 = ret[1];
|
|
2699
|
+
if (ret[3]) {
|
|
2700
|
+
ptr2 = 0; len2 = 0;
|
|
2701
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2702
|
+
}
|
|
2703
|
+
deferred3_0 = ptr2;
|
|
2704
|
+
deferred3_1 = len2;
|
|
2705
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2706
|
+
} finally {
|
|
2707
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2109
2711
|
/**
|
|
2110
2712
|
* Parse a SMILES string into a `MolHandle`.
|
|
2111
2713
|
*
|
|
2112
|
-
* Returns a JS error string on parse failure.
|
|
2714
|
+
* Returns a JS error string on parse failure or if atom count exceeds 10,000.
|
|
2113
2715
|
* @param {string} s
|
|
2114
2716
|
* @returns {MolHandle}
|
|
2115
2717
|
*/
|
|
@@ -2142,6 +2744,47 @@ export function peoe_vsa_json(mol) {
|
|
|
2142
2744
|
}
|
|
2143
2745
|
}
|
|
2144
2746
|
|
|
2747
|
+
/**
|
|
2748
|
+
* Generate `count` random SMILES from a SMILES string using the given seed.
|
|
2749
|
+
* Atoms are permuted based on xorshift64 RNG. Each variant should parse back
|
|
2750
|
+
* to the same molecule. Returns a JSON array of SMILES strings.
|
|
2751
|
+
*
|
|
2752
|
+
* # Arguments
|
|
2753
|
+
* - `smiles`: input SMILES string
|
|
2754
|
+
* - `count`: number of variants to generate (capped at 100)
|
|
2755
|
+
* - `seed`: xorshift64 seed
|
|
2756
|
+
*
|
|
2757
|
+
* # Example
|
|
2758
|
+
* ```javascript
|
|
2759
|
+
* const variants = random_smiles_json("CC(C)O", 5, 42);
|
|
2760
|
+
* // variants: ["CC(C)O", "C(C)(O)C", ...]
|
|
2761
|
+
* ```
|
|
2762
|
+
* @param {string} smiles
|
|
2763
|
+
* @param {number} count
|
|
2764
|
+
* @param {bigint} seed
|
|
2765
|
+
* @returns {string}
|
|
2766
|
+
*/
|
|
2767
|
+
export function random_smiles_json(smiles, count, seed) {
|
|
2768
|
+
let deferred3_0;
|
|
2769
|
+
let deferred3_1;
|
|
2770
|
+
try {
|
|
2771
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2772
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2773
|
+
const ret = wasm.random_smiles_json(ptr0, len0, count, seed);
|
|
2774
|
+
var ptr2 = ret[0];
|
|
2775
|
+
var len2 = ret[1];
|
|
2776
|
+
if (ret[3]) {
|
|
2777
|
+
ptr2 = 0; len2 = 0;
|
|
2778
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2779
|
+
}
|
|
2780
|
+
deferred3_0 = ptr2;
|
|
2781
|
+
deferred3_1 = len2;
|
|
2782
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2783
|
+
} finally {
|
|
2784
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2145
2788
|
/**
|
|
2146
2789
|
* Return a copy of the molecule with all explicit hydrogen atoms removed.
|
|
2147
2790
|
* @param {MolHandle} mol
|
|
@@ -2200,6 +2843,31 @@ export function rgroup_decompose_json(smiles_json, core_smarts) {
|
|
|
2200
2843
|
}
|
|
2201
2844
|
}
|
|
2202
2845
|
|
|
2846
|
+
/**
|
|
2847
|
+
* Run molecular dynamics simulation and return trajectory as JSON.
|
|
2848
|
+
*
|
|
2849
|
+
* Returns JSON object with trajectory frames: `{ "frames": [{ "step": N, "potential": E, "kinetic": K, "temp": T }, …] }`
|
|
2850
|
+
* Uses NVT ensemble (Berendsen thermostat) at 300 K by default.
|
|
2851
|
+
* Note: Limited to molecules with ~50 atoms or fewer for practical WASM performance.
|
|
2852
|
+
* @param {MolHandle} mol
|
|
2853
|
+
* @param {number} steps
|
|
2854
|
+
* @param {number} temp_k
|
|
2855
|
+
* @returns {string}
|
|
2856
|
+
*/
|
|
2857
|
+
export function run_md_json(mol, steps, temp_k) {
|
|
2858
|
+
let deferred1_0;
|
|
2859
|
+
let deferred1_1;
|
|
2860
|
+
try {
|
|
2861
|
+
_assertClass(mol, MolHandle);
|
|
2862
|
+
const ret = wasm.run_md_json(mol.__wbg_ptr, steps, temp_k);
|
|
2863
|
+
deferred1_0 = ret[0];
|
|
2864
|
+
deferred1_1 = ret[1];
|
|
2865
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2866
|
+
} finally {
|
|
2867
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2203
2871
|
/**
|
|
2204
2872
|
* Apply a SMIRKS reaction template and return product SMILES as a JSON string.
|
|
2205
2873
|
*
|
|
@@ -2244,6 +2912,41 @@ export function sa_score(mol) {
|
|
|
2244
2912
|
return ret;
|
|
2245
2913
|
}
|
|
2246
2914
|
|
|
2915
|
+
/**
|
|
2916
|
+
* Screen a batch of SMILES strings (JSON string output).
|
|
2917
|
+
* Returns per-record results including pass/fail with error details.
|
|
2918
|
+
* Includes MaxMin diversity picking and Butina clustering by default.
|
|
2919
|
+
*
|
|
2920
|
+
* # Example (JS)
|
|
2921
|
+
* ```javascript
|
|
2922
|
+
* const smilesList = "c1ccccc1\nCC\nCCC";
|
|
2923
|
+
* const json = module.screen_smiles_json(smilesList, "\n");
|
|
2924
|
+
* const report = JSON.parse(json);
|
|
2925
|
+
* console.log(report.records); // Array of ScreeningRecord
|
|
2926
|
+
* console.log(report.maxmin_picks); // Diversity-selected indices
|
|
2927
|
+
* console.log(report.butina_clusters); // Clustering result
|
|
2928
|
+
* ```
|
|
2929
|
+
* @param {string} smiles_batch
|
|
2930
|
+
* @param {string} delimiter
|
|
2931
|
+
* @returns {string}
|
|
2932
|
+
*/
|
|
2933
|
+
export function screen_smiles_json(smiles_batch, delimiter) {
|
|
2934
|
+
let deferred3_0;
|
|
2935
|
+
let deferred3_1;
|
|
2936
|
+
try {
|
|
2937
|
+
const ptr0 = passStringToWasm0(smiles_batch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2938
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2939
|
+
const ptr1 = passStringToWasm0(delimiter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2940
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2941
|
+
const ret = wasm.screen_smiles_json(ptr0, len0, ptr1, len1);
|
|
2942
|
+
deferred3_0 = ret[0];
|
|
2943
|
+
deferred3_1 = ret[1];
|
|
2944
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2945
|
+
} finally {
|
|
2946
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2247
2950
|
/**
|
|
2248
2951
|
* Serialize multiple molecules with properties to an SDF string.
|
|
2249
2952
|
*
|
|
@@ -2339,6 +3042,49 @@ export function sdf_to_smiles_json(sdf) {
|
|
|
2339
3042
|
}
|
|
2340
3043
|
}
|
|
2341
3044
|
|
|
3045
|
+
/**
|
|
3046
|
+
* Set dihedral angle A—B—C—D and return PDB block with modified coordinates.
|
|
3047
|
+
* Rotates the D-side subtree around the B—C bond.
|
|
3048
|
+
* Returns a JS error if parsing fails or atom indices are invalid.
|
|
3049
|
+
*
|
|
3050
|
+
* # Arguments
|
|
3051
|
+
* - `smiles`: SMILES string
|
|
3052
|
+
* - `a`, `b`, `c`, `d`: atom indices
|
|
3053
|
+
* - `angle_deg`: target dihedral angle in degrees
|
|
3054
|
+
*
|
|
3055
|
+
* # Example
|
|
3056
|
+
* ```javascript
|
|
3057
|
+
* const pdbBlock = set_dihedral_json("CCCC", 0, 1, 2, 3, 120.0);
|
|
3058
|
+
* ```
|
|
3059
|
+
* @param {string} smiles
|
|
3060
|
+
* @param {number} a
|
|
3061
|
+
* @param {number} b
|
|
3062
|
+
* @param {number} c
|
|
3063
|
+
* @param {number} d
|
|
3064
|
+
* @param {number} angle_deg
|
|
3065
|
+
* @returns {string}
|
|
3066
|
+
*/
|
|
3067
|
+
export function set_dihedral_json(smiles, a, b, c, d, angle_deg) {
|
|
3068
|
+
let deferred3_0;
|
|
3069
|
+
let deferred3_1;
|
|
3070
|
+
try {
|
|
3071
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3072
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3073
|
+
const ret = wasm.set_dihedral_json(ptr0, len0, a, b, c, d, angle_deg);
|
|
3074
|
+
var ptr2 = ret[0];
|
|
3075
|
+
var len2 = ret[1];
|
|
3076
|
+
if (ret[3]) {
|
|
3077
|
+
ptr2 = 0; len2 = 0;
|
|
3078
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3079
|
+
}
|
|
3080
|
+
deferred3_0 = ptr2;
|
|
3081
|
+
deferred3_1 = len2;
|
|
3082
|
+
return getStringFromWasm0(ptr2, len2);
|
|
3083
|
+
} finally {
|
|
3084
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
|
|
2342
3088
|
/**
|
|
2343
3089
|
* 3D shape descriptors as a JSON object.
|
|
2344
3090
|
*
|
|
@@ -2413,6 +3159,39 @@ export function smarts_match_atoms(smarts, mol) {
|
|
|
2413
3159
|
}
|
|
2414
3160
|
}
|
|
2415
3161
|
|
|
3162
|
+
/**
|
|
3163
|
+
* Like `smarts_match_atoms` but with explicit chirality matching control.
|
|
3164
|
+
*
|
|
3165
|
+
* When `use_chirality=true`, SMARTS chirality primitives `[@]` and `[@@]` are
|
|
3166
|
+
* matched against the target molecule's stereochemistry. When `false`, chirality
|
|
3167
|
+
* is ignored (RDKit default).
|
|
3168
|
+
* @param {string} smarts
|
|
3169
|
+
* @param {MolHandle} mol
|
|
3170
|
+
* @param {boolean} use_chirality
|
|
3171
|
+
* @returns {string}
|
|
3172
|
+
*/
|
|
3173
|
+
export function smarts_match_atoms_with_chirality(smarts, mol, use_chirality) {
|
|
3174
|
+
let deferred3_0;
|
|
3175
|
+
let deferred3_1;
|
|
3176
|
+
try {
|
|
3177
|
+
const ptr0 = passStringToWasm0(smarts, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3178
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3179
|
+
_assertClass(mol, MolHandle);
|
|
3180
|
+
const ret = wasm.smarts_match_atoms_with_chirality(ptr0, len0, mol.__wbg_ptr, use_chirality);
|
|
3181
|
+
var ptr2 = ret[0];
|
|
3182
|
+
var len2 = ret[1];
|
|
3183
|
+
if (ret[3]) {
|
|
3184
|
+
ptr2 = 0; len2 = 0;
|
|
3185
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3186
|
+
}
|
|
3187
|
+
deferred3_0 = ptr2;
|
|
3188
|
+
deferred3_1 = len2;
|
|
3189
|
+
return getStringFromWasm0(ptr2, len2);
|
|
3190
|
+
} finally {
|
|
3191
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
|
|
2416
3195
|
/**
|
|
2417
3196
|
* Serialise a JSON array of SMILES to an SDF string.
|
|
2418
3197
|
*
|
|
@@ -2442,6 +3221,28 @@ export function smiles_array_to_sdf(smiles_json) {
|
|
|
2442
3221
|
}
|
|
2443
3222
|
}
|
|
2444
3223
|
|
|
3224
|
+
/**
|
|
3225
|
+
* Convert a SMILES to a minimal Tripos MOL2 string (no 3D coordinates).
|
|
3226
|
+
*
|
|
3227
|
+
* Returns `"error:<msg>"` on parse failure.
|
|
3228
|
+
* @param {string} smiles
|
|
3229
|
+
* @returns {string}
|
|
3230
|
+
*/
|
|
3231
|
+
export function smiles_to_mol2(smiles) {
|
|
3232
|
+
let deferred2_0;
|
|
3233
|
+
let deferred2_1;
|
|
3234
|
+
try {
|
|
3235
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3236
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3237
|
+
const ret = wasm.smiles_to_mol2(ptr0, len0);
|
|
3238
|
+
deferred2_0 = ret[0];
|
|
3239
|
+
deferred2_1 = ret[1];
|
|
3240
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
3241
|
+
} finally {
|
|
3242
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
|
|
2445
3246
|
/**
|
|
2446
3247
|
* Render a highlighted SVG from a SMILES string in one call.
|
|
2447
3248
|
*
|
|
@@ -2524,6 +3325,56 @@ export function sssr_rings_json(mol) {
|
|
|
2524
3325
|
}
|
|
2525
3326
|
}
|
|
2526
3327
|
|
|
3328
|
+
/**
|
|
3329
|
+
* Standardize a SMILES string and return the canonical SMILES of the result.
|
|
3330
|
+
*
|
|
3331
|
+
* Applies: largest fragment extraction → charge neutralization.
|
|
3332
|
+
* Returns `"error:<msg>"` on parse failure.
|
|
3333
|
+
* @param {string} smiles
|
|
3334
|
+
* @returns {string}
|
|
3335
|
+
*/
|
|
3336
|
+
export function standardize_smiles(smiles) {
|
|
3337
|
+
let deferred2_0;
|
|
3338
|
+
let deferred2_1;
|
|
3339
|
+
try {
|
|
3340
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3341
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3342
|
+
const ret = wasm.standardize_smiles(ptr0, len0);
|
|
3343
|
+
deferred2_0 = ret[0];
|
|
3344
|
+
deferred2_1 = ret[1];
|
|
3345
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
3346
|
+
} finally {
|
|
3347
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
/**
|
|
3352
|
+
* Standardize a SMILES string and return result SMILES plus an audit report as JSON.
|
|
3353
|
+
*
|
|
3354
|
+
* Boolean flags map directly to `StandardizeOptions`.
|
|
3355
|
+
* Returns `"error:<msg>"` on parse or serialization failure.
|
|
3356
|
+
* @param {string} smiles
|
|
3357
|
+
* @param {boolean} largest_fragment_only
|
|
3358
|
+
* @param {boolean} neutralize_charges
|
|
3359
|
+
* @param {boolean} remove_explicit_h
|
|
3360
|
+
* @param {boolean} canonical_tautomer
|
|
3361
|
+
* @returns {string}
|
|
3362
|
+
*/
|
|
3363
|
+
export function standardize_smiles_report_json(smiles, largest_fragment_only, neutralize_charges, remove_explicit_h, canonical_tautomer) {
|
|
3364
|
+
let deferred2_0;
|
|
3365
|
+
let deferred2_1;
|
|
3366
|
+
try {
|
|
3367
|
+
const ptr0 = passStringToWasm0(smiles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3368
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3369
|
+
const ret = wasm.standardize_smiles_report_json(ptr0, len0, largest_fragment_only, neutralize_charges, remove_explicit_h, canonical_tautomer);
|
|
3370
|
+
deferred2_0 = ret[0];
|
|
3371
|
+
deferred2_1 = ret[1];
|
|
3372
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
3373
|
+
} finally {
|
|
3374
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
|
|
2527
3378
|
export function start() {
|
|
2528
3379
|
wasm.start();
|
|
2529
3380
|
}
|
|
@@ -2773,6 +3624,14 @@ export function write_smiles(mol) {
|
|
|
2773
3624
|
function __wbg_get_imports() {
|
|
2774
3625
|
const import0 = {
|
|
2775
3626
|
__proto__: null,
|
|
3627
|
+
__wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
|
|
3628
|
+
const obj = arg1;
|
|
3629
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
3630
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3631
|
+
var len1 = WASM_VECTOR_LEN;
|
|
3632
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
3633
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
3634
|
+
},
|
|
2776
3635
|
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
2777
3636
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
2778
3637
|
},
|
|
@@ -2787,6 +3646,9 @@ function __wbg_get_imports() {
|
|
|
2787
3646
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
2788
3647
|
}
|
|
2789
3648
|
},
|
|
3649
|
+
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
3650
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
3651
|
+
}, arguments); },
|
|
2790
3652
|
__wbg_new_227d7c05414eb861: function() {
|
|
2791
3653
|
const ret = new Error();
|
|
2792
3654
|
return ret;
|
|
@@ -2798,7 +3660,12 @@ function __wbg_get_imports() {
|
|
|
2798
3660
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
2799
3661
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
2800
3662
|
},
|
|
2801
|
-
__wbindgen_cast_0000000000000001: function(arg0
|
|
3663
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
3664
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
3665
|
+
const ret = arg0;
|
|
3666
|
+
return ret;
|
|
3667
|
+
},
|
|
3668
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2802
3669
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
2803
3670
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
2804
3671
|
return ret;
|
|
@@ -2829,6 +3696,12 @@ const MolHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
2829
3696
|
? { register: () => {}, unregister: () => {} }
|
|
2830
3697
|
: new FinalizationRegistry(ptr => wasm.__wbg_molhandle_free(ptr, 1));
|
|
2831
3698
|
|
|
3699
|
+
function addToExternrefTable0(obj) {
|
|
3700
|
+
const idx = wasm.__externref_table_alloc();
|
|
3701
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
3702
|
+
return idx;
|
|
3703
|
+
}
|
|
3704
|
+
|
|
2832
3705
|
function _assertClass(instance, klass) {
|
|
2833
3706
|
if (!(instance instanceof klass)) {
|
|
2834
3707
|
throw new Error(`expected instance of ${klass.name}`);
|
|
@@ -2868,6 +3741,19 @@ function getUint8ArrayMemory0() {
|
|
|
2868
3741
|
return cachedUint8ArrayMemory0;
|
|
2869
3742
|
}
|
|
2870
3743
|
|
|
3744
|
+
function handleError(f, args) {
|
|
3745
|
+
try {
|
|
3746
|
+
return f.apply(this, args);
|
|
3747
|
+
} catch (e) {
|
|
3748
|
+
const idx = addToExternrefTable0(e);
|
|
3749
|
+
wasm.__wbindgen_exn_store(idx);
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
function isLikeNone(x) {
|
|
3754
|
+
return x === undefined || x === null;
|
|
3755
|
+
}
|
|
3756
|
+
|
|
2871
3757
|
function passArray32ToWasm0(arg, malloc) {
|
|
2872
3758
|
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
2873
3759
|
getUint32ArrayMemory0().set(arg, ptr / 4);
|