@kent-tokyo/chematic 0.14.0 → 0.14.1

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.
@@ -861,6 +861,23 @@ export function erg_vec_json(mol: MolHandle): string;
861
861
  */
862
862
  export function estate_indices_json(mol: MolHandle): string;
863
863
 
864
+ /**
865
+ * Extract an extxyz frame's coordinates, cell, per-atom properties and
866
+ * frame metadata as JSON, in the SAME atom order [`mol_from_extxyz`]
867
+ * returns topology for (both read the identical frame via
868
+ * `chematic_mol::parse_extxyz`, so atom-index correspondence between the
869
+ * two calls is structural, not just conventional).
870
+ *
871
+ * Returns JSON `{"coords":[[x,y,z],...],
872
+ * "lattice":[9 numbers]|null,
873
+ * "properties":{"name":[[...atom values...], ...], ...},
874
+ * "info":{"key":"value", ...}}`.
875
+ *
876
+ * Returns a JS error on parse failure or if the frame exceeds the WASM
877
+ * atom-count limit.
878
+ */
879
+ export function extxyz_frame_json(text: string): string;
880
+
864
881
  /**
865
882
  * FCFP4 (pharmacophore, radius-2) fingerprint as a bit-packed byte vector (256 bytes).
866
883
  */
@@ -1331,6 +1348,19 @@ export function mol_from_cdxml(cdxml: string): MolHandle;
1331
1348
  */
1332
1349
  export function mol_from_cml(cml: string): MolHandle;
1333
1350
 
1351
+ /**
1352
+ * Parse an Extended XYZ (extxyz) frame and return a `MolHandle` (topology +
1353
+ * element/position only; use [`extxyz_frame_json`] to recover coordinates,
1354
+ * cell, per-atom properties and frame metadata in the SAME atom order).
1355
+ *
1356
+ * A plain XYZ file (free-form comment, no `Lattice=`/`Properties=`) parses
1357
+ * too. Only the first frame of a multi-frame file is read.
1358
+ *
1359
+ * Returns a JS error on parse failure or if the frame exceeds the WASM
1360
+ * atom-count limit.
1361
+ */
1362
+ export function mol_from_extxyz(text: string): MolHandle;
1363
+
1334
1364
  /**
1335
1365
  * Parse a MolJSON string into a `MolHandle`.
1336
1366
  *
@@ -1951,6 +1981,26 @@ export function tanimoto_torsion(a: MolHandle, b: MolHandle): number;
1951
1981
  */
1952
1982
  export function to_cml(mol: MolHandle): string;
1953
1983
 
1984
+ /**
1985
+ * Write a molecule + coordinates as an Extended XYZ (extxyz) frame.
1986
+ *
1987
+ * `coords_json`: `[[x,y,z],...]` (Å), same order and length as `mol`'s
1988
+ * atoms.
1989
+ *
1990
+ * `options_json`: an optional JSON object,
1991
+ * `{"lattice":[9 numbers]|null,"properties":{"name":[[...]],...},"info":{"key":"value",...}}`
1992
+ * -- pass `"{}"` for a plain (non-extended) frame. Only real-valued
1993
+ * per-atom `properties` columns are supported from this binding (matches
1994
+ * the Python `to_extxyz` binding's scope); build a
1995
+ * `chematic_mol::XyzProperty` directly from Rust for integer/string/logical
1996
+ * columns.
1997
+ *
1998
+ * Returns a JS error if `coords_json`/`options_json` are malformed, if
1999
+ * `coords_json`'s length doesn't match `mol`'s atom count, or if a
2000
+ * `properties` column's row count doesn't match it.
2001
+ */
2002
+ export function to_extxyz_json(mol: MolHandle, coords_json: string, options_json: string): string;
2003
+
1954
2004
  /**
1955
2005
  * Serialize a molecule to a MOL V2000 block with 2D coordinates.
1956
2006
  *
@@ -2103,6 +2153,7 @@ export interface InitOutput {
2103
2153
  readonly enumerate_tautomers_json: (a: number) => [number, number];
2104
2154
  readonly erg_vec_json: (a: number) => [number, number];
2105
2155
  readonly estate_indices_json: (a: number) => [number, number];
2156
+ readonly extxyz_frame_json: (a: number, b: number) => [number, number, number, number];
2106
2157
  readonly fcfp4_bitvec: (a: number) => [number, number];
2107
2158
  readonly fcfp6_bitvec: (a: number) => [number, number];
2108
2159
  readonly find_reaction_center_json: (a: number, b: number) => [number, number];
@@ -2159,6 +2210,7 @@ export interface InitOutput {
2159
2210
  readonly mol_block_stereo_diagnostics_json: (a: number, b: number) => [number, number, number, number];
2160
2211
  readonly mol_from_cdxml: (a: number, b: number) => [number, number, number];
2161
2212
  readonly mol_from_cml: (a: number, b: number) => [number, number, number];
2213
+ readonly mol_from_extxyz: (a: number, b: number) => [number, number, number];
2162
2214
  readonly mol_from_moljson: (a: number, b: number) => [number, number, number];
2163
2215
  readonly mol_from_pdb: (a: number, b: number) => number;
2164
2216
  readonly mol_from_sdf_block: (a: number, b: number) => [number, number, number];
@@ -2302,6 +2354,7 @@ export interface InitOutput {
2302
2354
  readonly tanimoto_topo_path: (a: number, b: number) => number;
2303
2355
  readonly tanimoto_torsion: (a: number, b: number) => number;
2304
2356
  readonly to_cml: (a: number) => [number, number];
2357
+ readonly to_extxyz_json: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
2305
2358
  readonly to_mol_block: (a: number) => [number, number];
2306
2359
  readonly to_mol_v3000_block: (a: number) => [number, number];
2307
2360
  readonly to_moljson: (a: number) => [number, number];
package/chematic_wasm.js CHANGED
@@ -2063,6 +2063,44 @@ export function estate_indices_json(mol) {
2063
2063
  }
2064
2064
  }
2065
2065
 
2066
+ /**
2067
+ * Extract an extxyz frame's coordinates, cell, per-atom properties and
2068
+ * frame metadata as JSON, in the SAME atom order [`mol_from_extxyz`]
2069
+ * returns topology for (both read the identical frame via
2070
+ * `chematic_mol::parse_extxyz`, so atom-index correspondence between the
2071
+ * two calls is structural, not just conventional).
2072
+ *
2073
+ * Returns JSON `{"coords":[[x,y,z],...],
2074
+ * "lattice":[9 numbers]|null,
2075
+ * "properties":{"name":[[...atom values...], ...], ...},
2076
+ * "info":{"key":"value", ...}}`.
2077
+ *
2078
+ * Returns a JS error on parse failure or if the frame exceeds the WASM
2079
+ * atom-count limit.
2080
+ * @param {string} text
2081
+ * @returns {string}
2082
+ */
2083
+ export function extxyz_frame_json(text) {
2084
+ let deferred3_0;
2085
+ let deferred3_1;
2086
+ try {
2087
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2088
+ const len0 = WASM_VECTOR_LEN;
2089
+ const ret = wasm.extxyz_frame_json(ptr0, len0);
2090
+ var ptr2 = ret[0];
2091
+ var len2 = ret[1];
2092
+ if (ret[3]) {
2093
+ ptr2 = 0; len2 = 0;
2094
+ throw takeFromExternrefTable0(ret[2]);
2095
+ }
2096
+ deferred3_0 = ptr2;
2097
+ deferred3_1 = len2;
2098
+ return getStringFromWasm0(ptr2, len2);
2099
+ } finally {
2100
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2101
+ }
2102
+ }
2103
+
2066
2104
  /**
2067
2105
  * FCFP4 (pharmacophore, radius-2) fingerprint as a bit-packed byte vector (256 bytes).
2068
2106
  * @param {MolHandle} mol
@@ -3283,6 +3321,29 @@ export function mol_from_cml(cml) {
3283
3321
  return MolHandle.__wrap(ret[0]);
3284
3322
  }
3285
3323
 
3324
+ /**
3325
+ * Parse an Extended XYZ (extxyz) frame and return a `MolHandle` (topology +
3326
+ * element/position only; use [`extxyz_frame_json`] to recover coordinates,
3327
+ * cell, per-atom properties and frame metadata in the SAME atom order).
3328
+ *
3329
+ * A plain XYZ file (free-form comment, no `Lattice=`/`Properties=`) parses
3330
+ * too. Only the first frame of a multi-frame file is read.
3331
+ *
3332
+ * Returns a JS error on parse failure or if the frame exceeds the WASM
3333
+ * atom-count limit.
3334
+ * @param {string} text
3335
+ * @returns {MolHandle}
3336
+ */
3337
+ export function mol_from_extxyz(text) {
3338
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3339
+ const len0 = WASM_VECTOR_LEN;
3340
+ const ret = wasm.mol_from_extxyz(ptr0, len0);
3341
+ if (ret[2]) {
3342
+ throw takeFromExternrefTable0(ret[1]);
3343
+ }
3344
+ return MolHandle.__wrap(ret[0]);
3345
+ }
3346
+
3286
3347
  /**
3287
3348
  * Parse a MolJSON string into a `MolHandle`.
3288
3349
  *
@@ -4964,6 +5025,52 @@ export function to_cml(mol) {
4964
5025
  }
4965
5026
  }
4966
5027
 
5028
+ /**
5029
+ * Write a molecule + coordinates as an Extended XYZ (extxyz) frame.
5030
+ *
5031
+ * `coords_json`: `[[x,y,z],...]` (Å), same order and length as `mol`'s
5032
+ * atoms.
5033
+ *
5034
+ * `options_json`: an optional JSON object,
5035
+ * `{"lattice":[9 numbers]|null,"properties":{"name":[[...]],...},"info":{"key":"value",...}}`
5036
+ * -- pass `"{}"` for a plain (non-extended) frame. Only real-valued
5037
+ * per-atom `properties` columns are supported from this binding (matches
5038
+ * the Python `to_extxyz` binding's scope); build a
5039
+ * `chematic_mol::XyzProperty` directly from Rust for integer/string/logical
5040
+ * columns.
5041
+ *
5042
+ * Returns a JS error if `coords_json`/`options_json` are malformed, if
5043
+ * `coords_json`'s length doesn't match `mol`'s atom count, or if a
5044
+ * `properties` column's row count doesn't match it.
5045
+ * @param {MolHandle} mol
5046
+ * @param {string} coords_json
5047
+ * @param {string} options_json
5048
+ * @returns {string}
5049
+ */
5050
+ export function to_extxyz_json(mol, coords_json, options_json) {
5051
+ let deferred4_0;
5052
+ let deferred4_1;
5053
+ try {
5054
+ _assertClass(mol, MolHandle);
5055
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5056
+ const len0 = WASM_VECTOR_LEN;
5057
+ const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5058
+ const len1 = WASM_VECTOR_LEN;
5059
+ const ret = wasm.to_extxyz_json(mol.__wbg_ptr, ptr0, len0, ptr1, len1);
5060
+ var ptr3 = ret[0];
5061
+ var len3 = ret[1];
5062
+ if (ret[3]) {
5063
+ ptr3 = 0; len3 = 0;
5064
+ throw takeFromExternrefTable0(ret[2]);
5065
+ }
5066
+ deferred4_0 = ptr3;
5067
+ deferred4_1 = len3;
5068
+ return getStringFromWasm0(ptr3, len3);
5069
+ } finally {
5070
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
5071
+ }
5072
+ }
5073
+
4967
5074
  /**
4968
5075
  * Serialize a molecule to a MOL V2000 block with 2D coordinates.
4969
5076
  *
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.14.0",
8
+ "version": "0.14.1",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",