@kent-tokyo/chematic 0.4.19 → 0.4.28

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.
@@ -106,17 +106,6 @@ export class DepictOptions {
106
106
  set_width(w: number): void;
107
107
  }
108
108
 
109
- /**
110
- * MinHash LSH index: insert MHFP fingerprints and query by approximate similarity.
111
- *
112
- * ```js
113
- * const idx = new MhfpLshHandle(128);
114
- * const i0 = idx.add_smiles("c1ccccc1"); // benzene → index 0
115
- * const i1 = idx.add_smiles("Cc1ccccc1"); // toluene → index 1
116
- * const hits = JSON.parse(idx.query_json("c1ccccc1", 0.5));
117
- * // hits: [{index:0,similarity:1.0}, {index:1,similarity:0.xxx}]
118
- * ```
119
- */
120
109
  export class MhfpLshHandle {
121
110
  free(): void;
122
111
  [Symbol.dispose](): void;
@@ -514,6 +503,29 @@ export function autocorr_3d_json(mol: MolHandle): string;
514
503
  */
515
504
  export function balance_check_json(reaction_smiles: string): string;
516
505
 
506
+ /**
507
+ * MinHash LSH index: insert MHFP fingerprints and query by approximate similarity.
508
+ *
509
+ * ```js
510
+ * const idx = new MhfpLshHandle(128);
511
+ * const i0 = idx.add_smiles("c1ccccc1"); // benzene → index 0
512
+ * const i1 = idx.add_smiles("Cc1ccccc1"); // toluene → index 1
513
+ * const hits = JSON.parse(idx.query_json("c1ccccc1", 0.5));
514
+ * // hits: [{index:0,similarity:1.0}, {index:1,similarity:0.xxx}]
515
+ * ```
516
+ * Generate a self-contained HTML report for a newline-separated list of SMILES.
517
+ *
518
+ * Empty lines and invalid SMILES are silently skipped.
519
+ * Returns the same card-grid HTML as Python's `chematic.report()`.
520
+ *
521
+ * ```js
522
+ * const html = mod.batch_report_html("CCO\nc1ccccc1\nCC(=O)O");
523
+ * const blob = new Blob([html], {type:'text/html'});
524
+ * const url = URL.createObjectURL(blob);
525
+ * ```
526
+ */
527
+ export function batch_report_html(smiles_lines: string): string;
528
+
517
529
  /**
518
530
  * Predict GI absorption and BBB penetration using the BOILED-Egg method
519
531
  * (Daina & Zoete 2016).
@@ -990,6 +1002,21 @@ export function get_dihedral_json(smiles: string, a: number, b: number, c: numbe
990
1002
  */
991
1003
  export function getaway_descriptors_json(mol: MolHandle): string;
992
1004
 
1005
+ /**
1006
+ * Parse a ChemDraw XML (CDXML) string into a `MolHandle`.
1007
+ *
1008
+ * Compute an HDF fingerprint and return it as a JSON array of float32 values.
1009
+ *
1010
+ * Returns a unit-norm vector of length `dim` as a JSON number array.
1011
+ * Use cosine dot product for similarity: `a · b = sum(a[i]*b[i])`.
1012
+ *
1013
+ * ```js
1014
+ * const fp = JSON.parse(hdf_json(mol)); // float[] of length 1024
1015
+ * const sim = fp.reduce((s, v, i) => s + v * fp2[i], 0); // cosine similarity
1016
+ * ```
1017
+ */
1018
+ export function hdf_json(mol: MolHandle, dim: number, radius: number, seed: bigint): string;
1019
+
993
1020
  /**
994
1021
  * Identify functional groups. Returns a JSON array of objects:
995
1022
  * `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
@@ -1211,8 +1238,6 @@ export function mol_block_coords_json(mol_block: string): string;
1211
1238
  export function mol_block_from_smiles(smiles: string): string;
1212
1239
 
1213
1240
  /**
1214
- * Parse a ChemDraw XML (CDXML) string into a `MolHandle`.
1215
- *
1216
1241
  * Only the first molecular fragment in the document is returned.
1217
1242
  * Returns a JS error if the document cannot be parsed.
1218
1243
  */
@@ -1225,6 +1250,14 @@ export function mol_from_cdxml(cdxml: string): MolHandle;
1225
1250
  */
1226
1251
  export function mol_from_cml(cml: string): MolHandle;
1227
1252
 
1253
+ /**
1254
+ * Parse a MolJSON string into a `MolHandle`.
1255
+ *
1256
+ * MolJSON is a JSON-based molecular representation designed for LLM
1257
+ * (large language model) compatibility. Returns a JS error on invalid input.
1258
+ */
1259
+ export function mol_from_moljson(json: string): MolHandle;
1260
+
1228
1261
  /**
1229
1262
  * Parse a PDB file and return a `MolHandle` (topology only; coordinates are discarded).
1230
1263
  *
@@ -1750,6 +1783,14 @@ export function to_mol_block(mol: MolHandle): string;
1750
1783
  */
1751
1784
  export function to_mol_v3000_block(mol: MolHandle): string;
1752
1785
 
1786
+ /**
1787
+ * Serialise a `MolHandle` to a MolJSON string (pretty-printed).
1788
+ *
1789
+ * Atom IDs are assigned as `"a1"`, `"a2"`, … in molecule atom order.
1790
+ * The `hydrogens` field reflects computed implicit H count.
1791
+ */
1792
+ export function to_moljson(mol: MolHandle): string;
1793
+
1753
1794
  /**
1754
1795
  * Serialize a molecule to XYZ format.
1755
1796
  *
@@ -1823,6 +1864,7 @@ export interface InitOutput {
1823
1864
  readonly autocorr_2d_json: (a: number) => [number, number];
1824
1865
  readonly autocorr_3d_json: (a: number) => [number, number];
1825
1866
  readonly balance_check_json: (a: number, b: number) => [number, number];
1867
+ readonly batch_report_html: (a: number, b: number) => [number, number];
1826
1868
  readonly boiled_egg_json: (a: number, b: number) => [number, number];
1827
1869
  readonly brics_fragment_count: (a: number) => number;
1828
1870
  readonly brics_fragments_json: (a: number) => [number, number];
@@ -1897,6 +1939,7 @@ export interface InitOutput {
1897
1939
  readonly get_descriptors_json: (a: number) => [number, number];
1898
1940
  readonly get_dihedral_json: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
1899
1941
  readonly getaway_descriptors_json: (a: number) => [number, number];
1942
+ readonly hdf_json: (a: number, b: number, c: number, d: bigint) => [number, number];
1900
1943
  readonly identify_functional_groups: (a: number) => [number, number];
1901
1944
  readonly inchi_from_smiles: (a: number, b: number) => [number, number];
1902
1945
  readonly inchikey_from_smiles: (a: number, b: number) => [number, number];
@@ -1930,6 +1973,7 @@ export interface InitOutput {
1930
1973
  readonly mol_block_from_smiles: (a: number, b: number) => [number, number, number, number];
1931
1974
  readonly mol_from_cdxml: (a: number, b: number) => [number, number, number];
1932
1975
  readonly mol_from_cml: (a: number, b: number) => [number, number, number];
1976
+ readonly mol_from_moljson: (a: number, b: number) => [number, number, number];
1933
1977
  readonly mol_from_pdb: (a: number, b: number) => number;
1934
1978
  readonly mol_from_sdf_block: (a: number, b: number) => [number, number, number];
1935
1979
  readonly mol_from_v3000_block: (a: number, b: number) => [number, number, number];
@@ -1944,7 +1988,6 @@ export interface InitOutput {
1944
1988
  readonly molecule_report_json: (a: number, b: number) => [number, number, number, number];
1945
1989
  readonly molhandle_aromatic_ring_count: (a: number) => number;
1946
1990
  readonly molhandle_assign_cip_json: (a: number) => [number, number];
1947
- readonly molhandle_atom_count: (a: number) => number;
1948
1991
  readonly molhandle_bbb_passes: (a: number) => number;
1949
1992
  readonly molhandle_bbb_score: (a: number) => number;
1950
1993
  readonly molhandle_bertz_ct: (a: number) => number;
@@ -2054,7 +2097,6 @@ export interface InitOutput {
2054
2097
  readonly sssr_rings_json: (a: number) => [number, number];
2055
2098
  readonly standardize_smiles: (a: number, b: number) => [number, number];
2056
2099
  readonly standardize_smiles_report_json: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
2057
- readonly start: () => void;
2058
2100
  readonly tanimoto_atom_pair: (a: number, b: number) => number;
2059
2101
  readonly tanimoto_ecfp4: (a: number, b: number) => number;
2060
2102
  readonly tanimoto_ecfp6: (a: number, b: number) => number;
@@ -2069,6 +2111,7 @@ export interface InitOutput {
2069
2111
  readonly to_cml: (a: number) => [number, number];
2070
2112
  readonly to_mol_block: (a: number) => [number, number];
2071
2113
  readonly to_mol_v3000_block: (a: number) => [number, number];
2114
+ readonly to_moljson: (a: number) => [number, number];
2072
2115
  readonly to_xyz: (a: number) => [number, number];
2073
2116
  readonly torsion_bitvec: (a: number) => [number, number];
2074
2117
  readonly virtual_screen_ecfp4_json: (a: number, b: number, c: number, d: number, e: number) => [number, number];
@@ -2077,6 +2120,8 @@ export interface InitOutput {
2077
2120
  readonly write_smiles: (a: number) => [number, number];
2078
2121
  readonly xlogp3_json: (a: number) => [number, number];
2079
2122
  readonly xlogp3_per_atom_json: (a: number) => [number, number];
2123
+ readonly molhandle_atom_count: (a: number) => number;
2124
+ readonly start: () => void;
2080
2125
  readonly __wbindgen_malloc: (a: number, b: number) => number;
2081
2126
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
2082
2127
  readonly __wbindgen_externrefs: WebAssembly.Table;
package/chematic_wasm.js CHANGED
@@ -264,17 +264,6 @@ export class DepictOptions {
264
264
  }
265
265
  if (Symbol.dispose) DepictOptions.prototype[Symbol.dispose] = DepictOptions.prototype.free;
266
266
 
267
- /**
268
- * MinHash LSH index: insert MHFP fingerprints and query by approximate similarity.
269
- *
270
- * ```js
271
- * const idx = new MhfpLshHandle(128);
272
- * const i0 = idx.add_smiles("c1ccccc1"); // benzene → index 0
273
- * const i1 = idx.add_smiles("Cc1ccccc1"); // toluene → index 1
274
- * const hits = JSON.parse(idx.query_json("c1ccccc1", 0.5));
275
- * // hits: [{index:0,similarity:1.0}, {index:1,similarity:0.xxx}]
276
- * ```
277
- */
278
267
  export class MhfpLshHandle {
279
268
  __destroy_into_raw() {
280
269
  const ptr = this.__wbg_ptr;
@@ -1203,6 +1192,44 @@ export function balance_check_json(reaction_smiles) {
1203
1192
  }
1204
1193
  }
1205
1194
 
1195
+ /**
1196
+ * MinHash LSH index: insert MHFP fingerprints and query by approximate similarity.
1197
+ *
1198
+ * ```js
1199
+ * const idx = new MhfpLshHandle(128);
1200
+ * const i0 = idx.add_smiles("c1ccccc1"); // benzene → index 0
1201
+ * const i1 = idx.add_smiles("Cc1ccccc1"); // toluene → index 1
1202
+ * const hits = JSON.parse(idx.query_json("c1ccccc1", 0.5));
1203
+ * // hits: [{index:0,similarity:1.0}, {index:1,similarity:0.xxx}]
1204
+ * ```
1205
+ * Generate a self-contained HTML report for a newline-separated list of SMILES.
1206
+ *
1207
+ * Empty lines and invalid SMILES are silently skipped.
1208
+ * Returns the same card-grid HTML as Python's `chematic.report()`.
1209
+ *
1210
+ * ```js
1211
+ * const html = mod.batch_report_html("CCO\nc1ccccc1\nCC(=O)O");
1212
+ * const blob = new Blob([html], {type:'text/html'});
1213
+ * const url = URL.createObjectURL(blob);
1214
+ * ```
1215
+ * @param {string} smiles_lines
1216
+ * @returns {string}
1217
+ */
1218
+ export function batch_report_html(smiles_lines) {
1219
+ let deferred2_0;
1220
+ let deferred2_1;
1221
+ try {
1222
+ const ptr0 = passStringToWasm0(smiles_lines, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1223
+ const len0 = WASM_VECTOR_LEN;
1224
+ const ret = wasm.batch_report_html(ptr0, len0);
1225
+ deferred2_0 = ret[0];
1226
+ deferred2_1 = ret[1];
1227
+ return getStringFromWasm0(ret[0], ret[1]);
1228
+ } finally {
1229
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1230
+ }
1231
+ }
1232
+
1206
1233
  /**
1207
1234
  * Predict GI absorption and BBB penetration using the BOILED-Egg method
1208
1235
  * (Daina & Zoete 2016).
@@ -2403,6 +2430,38 @@ export function getaway_descriptors_json(mol) {
2403
2430
  }
2404
2431
  }
2405
2432
 
2433
+ /**
2434
+ * Parse a ChemDraw XML (CDXML) string into a `MolHandle`.
2435
+ *
2436
+ * Compute an HDF fingerprint and return it as a JSON array of float32 values.
2437
+ *
2438
+ * Returns a unit-norm vector of length `dim` as a JSON number array.
2439
+ * Use cosine dot product for similarity: `a · b = sum(a[i]*b[i])`.
2440
+ *
2441
+ * ```js
2442
+ * const fp = JSON.parse(hdf_json(mol)); // float[] of length 1024
2443
+ * const sim = fp.reduce((s, v, i) => s + v * fp2[i], 0); // cosine similarity
2444
+ * ```
2445
+ * @param {MolHandle} mol
2446
+ * @param {number} dim
2447
+ * @param {number} radius
2448
+ * @param {bigint} seed
2449
+ * @returns {string}
2450
+ */
2451
+ export function hdf_json(mol, dim, radius, seed) {
2452
+ let deferred1_0;
2453
+ let deferred1_1;
2454
+ try {
2455
+ _assertClass(mol, MolHandle);
2456
+ const ret = wasm.hdf_json(mol.__wbg_ptr, dim, radius, seed);
2457
+ deferred1_0 = ret[0];
2458
+ deferred1_1 = ret[1];
2459
+ return getStringFromWasm0(ret[0], ret[1]);
2460
+ } finally {
2461
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2462
+ }
2463
+ }
2464
+
2406
2465
  /**
2407
2466
  * Identify functional groups. Returns a JSON array of objects:
2408
2467
  * `[{"atoms":[0,2,3],"type":"C,N,O"}, …]`
@@ -3028,8 +3087,6 @@ export function mol_block_from_smiles(smiles) {
3028
3087
  }
3029
3088
 
3030
3089
  /**
3031
- * Parse a ChemDraw XML (CDXML) string into a `MolHandle`.
3032
- *
3033
3090
  * Only the first molecular fragment in the document is returned.
3034
3091
  * Returns a JS error if the document cannot be parsed.
3035
3092
  * @param {string} cdxml
@@ -3062,6 +3119,24 @@ export function mol_from_cml(cml) {
3062
3119
  return MolHandle.__wrap(ret[0]);
3063
3120
  }
3064
3121
 
3122
+ /**
3123
+ * Parse a MolJSON string into a `MolHandle`.
3124
+ *
3125
+ * MolJSON is a JSON-based molecular representation designed for LLM
3126
+ * (large language model) compatibility. Returns a JS error on invalid input.
3127
+ * @param {string} json
3128
+ * @returns {MolHandle}
3129
+ */
3130
+ export function mol_from_moljson(json) {
3131
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3132
+ const len0 = WASM_VECTOR_LEN;
3133
+ const ret = wasm.mol_from_moljson(ptr0, len0);
3134
+ if (ret[2]) {
3135
+ throw takeFromExternrefTable0(ret[1]);
3136
+ }
3137
+ return MolHandle.__wrap(ret[0]);
3138
+ }
3139
+
3065
3140
  /**
3066
3141
  * Parse a PDB file and return a `MolHandle` (topology only; coordinates are discarded).
3067
3142
  *
@@ -4540,6 +4615,28 @@ export function to_mol_v3000_block(mol) {
4540
4615
  }
4541
4616
  }
4542
4617
 
4618
+ /**
4619
+ * Serialise a `MolHandle` to a MolJSON string (pretty-printed).
4620
+ *
4621
+ * Atom IDs are assigned as `"a1"`, `"a2"`, … in molecule atom order.
4622
+ * The `hydrogens` field reflects computed implicit H count.
4623
+ * @param {MolHandle} mol
4624
+ * @returns {string}
4625
+ */
4626
+ export function to_moljson(mol) {
4627
+ let deferred1_0;
4628
+ let deferred1_1;
4629
+ try {
4630
+ _assertClass(mol, MolHandle);
4631
+ const ret = wasm.to_moljson(mol.__wbg_ptr);
4632
+ deferred1_0 = ret[0];
4633
+ deferred1_1 = ret[1];
4634
+ return getStringFromWasm0(ret[0], ret[1]);
4635
+ } finally {
4636
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4637
+ }
4638
+ }
4639
+
4543
4640
  /**
4544
4641
  * Serialize a molecule to XYZ format.
4545
4642
  *
@@ -4712,7 +4809,7 @@ export function xlogp3_per_atom_json(mol) {
4712
4809
  function __wbg_get_imports() {
4713
4810
  const import0 = {
4714
4811
  __proto__: null,
4715
- __wbg___wbindgen_string_get_71bb4348194e31f0: function(arg0, arg1) {
4812
+ __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
4716
4813
  const obj = arg1;
4717
4814
  const ret = typeof(obj) === 'string' ? obj : undefined;
4718
4815
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -4720,10 +4817,10 @@ function __wbg_get_imports() {
4720
4817
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4721
4818
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4722
4819
  },
4723
- __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
4820
+ __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
4724
4821
  throw new Error(getStringFromWasm0(arg0, arg1));
4725
4822
  },
4726
- __wbg_error_933f449d72fef598: function(arg0) {
4823
+ __wbg_error_744744ff0c9861e6: function(arg0) {
4727
4824
  console.error(arg0);
4728
4825
  },
4729
4826
  __wbindgen_cast_0000000000000001: function(arg0) {
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "kent-tokyo <kent-tokyo@users.noreply.github.com>"
6
6
  ],
7
7
  "description": "WebAssembly bindings for chematic — use chematic from JavaScript/TypeScript",
8
- "version": "0.4.19",
8
+ "version": "0.4.28",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",