@kent-tokyo/chematic 0.17.0 → 0.19.0

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
@@ -1398,6 +1398,27 @@ export function cdxml_to_smiles_json(cdxml) {
1398
1398
  }
1399
1399
  }
1400
1400
 
1401
+ /**
1402
+ * The `chematic-wasm` crate version (matches the workspace release version).
1403
+ *
1404
+ * Lets callers (e.g. the browser playground demo) display the running
1405
+ * version without hardcoding it — `demo/index.html` previously had a
1406
+ * static version string that silently went stale across releases.
1407
+ * @returns {string}
1408
+ */
1409
+ export function chematic_version() {
1410
+ let deferred1_0;
1411
+ let deferred1_1;
1412
+ try {
1413
+ const ret = wasm.chematic_version();
1414
+ deferred1_0 = ret[0];
1415
+ deferred1_1 = ret[1];
1416
+ return getStringFromWasm0(ret[0], ret[1]);
1417
+ } finally {
1418
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1419
+ }
1420
+ }
1421
+
1401
1422
  /**
1402
1423
  * CIP stereo assignments via the accurate hierarchical-digraph engine, as a JSON
1403
1424
  * array of `{atomIdx, cipCode}` objects -- same shape as [`cip_assignments_json`],
@@ -1586,6 +1607,71 @@ export function cpk_color(element_symbol) {
1586
1607
  }
1587
1608
  }
1588
1609
 
1610
+ /**
1611
+ * Parse a Gaussian Cube file and return its full [`chematic_mol::VolumetricGrid`]
1612
+ * as JSON: `{"origin":[x,y,z],"axes":[[..],[..],[..]],"shape":[nx,ny,nz],
1613
+ * "values":[...flat, row-major third-axis-fastest...],
1614
+ * "atoms":[{"element":"C","charge":6.0,"position":[x,y,z]}],
1615
+ * "units":"bohr"|"angstrom"}`. See module docs for the perf tradeoff of a
1616
+ * full `values` JSON round trip on a large grid.
1617
+ * @param {string} text
1618
+ * @returns {string}
1619
+ */
1620
+ export function cube_grid_json(text) {
1621
+ let deferred3_0;
1622
+ let deferred3_1;
1623
+ try {
1624
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1625
+ const len0 = WASM_VECTOR_LEN;
1626
+ const ret = wasm.cube_grid_json(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
+
1641
+ /**
1642
+ * `[nx, ny, nz]` for a Gaussian Cube file's grid, as a `Uint32Array`.
1643
+ * @param {string} text
1644
+ * @returns {Uint32Array}
1645
+ */
1646
+ export function cube_shape_u32(text) {
1647
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1648
+ const len0 = WASM_VECTOR_LEN;
1649
+ const ret = wasm.cube_shape_u32(ptr0, len0);
1650
+ if (ret[2]) {
1651
+ throw takeFromExternrefTable0(ret[1]);
1652
+ }
1653
+ return takeFromExternrefTable0(ret[0]);
1654
+ }
1655
+
1656
+ /**
1657
+ * Flat `values` from a Gaussian Cube file's grid, as a `Float64Array` --
1658
+ * same data [`cube_grid_json`]'s `"values"` field carries (row-major,
1659
+ * third-axis-fastest order -- see `chematic_mol::volumetric`'s module
1660
+ * docs for the exact index formula), as a real typed array instead of a
1661
+ * JSON number array.
1662
+ * @param {string} text
1663
+ * @returns {Float64Array}
1664
+ */
1665
+ export function cube_values_f64(text) {
1666
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1667
+ const len0 = WASM_VECTOR_LEN;
1668
+ const ret = wasm.cube_values_f64(ptr0, len0);
1669
+ if (ret[2]) {
1670
+ throw takeFromExternrefTable0(ret[1]);
1671
+ }
1672
+ return takeFromExternrefTable0(ret[0]);
1673
+ }
1674
+
1589
1675
  /**
1590
1676
  * Compute structured depiction data for `mol` as a JSON object.
1591
1677
  *
@@ -2704,6 +2790,221 @@ export function labute_asa_per_atom_json(mol) {
2704
2790
  }
2705
2791
  }
2706
2792
 
2793
+ /**
2794
+ * Parse a LAMMPS data file (`read_data` format) and return every section
2795
+ * as JSON: `{"counts":[["atoms",120],["atom types",4],...],
2796
+ * "atom_style":"atomic"|"charge"|"molecular"|"full"|"<other>",
2797
+ * "simulation_box":{"lo":[x,y,z],"hi":[x,y,z],"tilt":[xy,xz,yz]|null},
2798
+ * "masses":[{"atom_type":N,"mass":N}],
2799
+ * "atoms":[{"id":N,"molecule_id":N|null,"atom_type":N,"charge":N|null,"x":N,"y":N,"z":N,"image":[ix,iy,iz]|null}],
2800
+ * "velocities":[{"atom_id":N,"vx":N,"vy":N,"vz":N}],
2801
+ * "bonds":[{"id":N,"bond_type":N,"atom1":N,"atom2":N}],
2802
+ * "unparsed_sections":[["Angles","<raw row text>"],...]}`. `atom_type`
2803
+ * must be exactly `"atomic"`/`"charge"`/`"molecular"`/`"full"` -- LAMMPS's
2804
+ * atom style is not recoverable from the file itself (see
2805
+ * [`chematic_mol::LammpsData`]'s module doc comment); any other value is
2806
+ * rejected with a JS error, matching
2807
+ * [`chematic_mol::LammpsDataError::UnsupportedAtomStyle`].
2808
+ *
2809
+ * This module has no bond-perception step of its own: `Angles`/
2810
+ * `Dihedrals`/`Impropers`/`*Coeffs`/any other section not listed above
2811
+ * are preserved verbatim (byte-for-byte, `#` comments included) in
2812
+ * `unparsed_sections`, not modeled field-by-field.
2813
+ * @param {string} text
2814
+ * @param {string} atom_style
2815
+ * @returns {string}
2816
+ */
2817
+ export function lammps_data_to_json(text, atom_style) {
2818
+ let deferred4_0;
2819
+ let deferred4_1;
2820
+ try {
2821
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2822
+ const len0 = WASM_VECTOR_LEN;
2823
+ const ptr1 = passStringToWasm0(atom_style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2824
+ const len1 = WASM_VECTOR_LEN;
2825
+ const ret = wasm.lammps_data_to_json(ptr0, len0, ptr1, len1);
2826
+ var ptr3 = ret[0];
2827
+ var len3 = ret[1];
2828
+ if (ret[3]) {
2829
+ ptr3 = 0; len3 = 0;
2830
+ throw takeFromExternrefTable0(ret[2]);
2831
+ }
2832
+ deferred4_0 = ptr3;
2833
+ deferred4_1 = len3;
2834
+ return getStringFromWasm0(ptr3, len3);
2835
+ } finally {
2836
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2837
+ }
2838
+ }
2839
+
2840
+ /**
2841
+ * Like [`lammps_dump_cartesian_positions_json`], but returns a flat
2842
+ * `Float64Array` (`[x0,y0,z0,x1,y1,z1,...]`, 3 values per atom) instead
2843
+ * of a JSON `[[x,y,z],...]` array.
2844
+ *
2845
+ * **Behavioral difference from the JSON sibling**: when the frame has no
2846
+ * recognized coordinate columns, [`lammps_dump_cartesian_positions_json`]
2847
+ * returns JSON `null`; a `Float64Array` has no `null`, so this function
2848
+ * returns `Err` instead, with a message naming the columns it looked for.
2849
+ * @param {string} frame_json
2850
+ * @returns {Float64Array}
2851
+ */
2852
+ export function lammps_dump_cartesian_positions_f64(frame_json) {
2853
+ const ptr0 = passStringToWasm0(frame_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2854
+ const len0 = WASM_VECTOR_LEN;
2855
+ const ret = wasm.lammps_dump_cartesian_positions_f64(ptr0, len0);
2856
+ if (ret[2]) {
2857
+ throw takeFromExternrefTable0(ret[1]);
2858
+ }
2859
+ return takeFromExternrefTable0(ret[0]);
2860
+ }
2861
+
2862
+ /**
2863
+ * Real Cartesian positions for a LAMMPS dump frame (in the JSON shape
2864
+ * [`lammps_dump_frame_to_json_str`] returns), resolved by delegating
2865
+ * directly to [`chematic_mol::LammpsDumpFrame::cartesian_positions`] --
2866
+ * this function does not reimplement any part of the box-bounds or
2867
+ * scaled-coordinate math itself; that method is the single place this
2868
+ * crate gets the (orthogonal or triclinic) transform right, and every
2869
+ * WASM caller must go through it rather than re-deriving the transform in
2870
+ * JS (the same reasoning behind this crate's OpenDX fail-closed unit
2871
+ * handling and QCSchema's single Bohr<->Ångström conversion point).
2872
+ *
2873
+ * - `x y z` columns: passed straight through.
2874
+ * - `xs ys zs` columns: transformed through `frame.box_bounds` (including
2875
+ * the triclinic shear terms when a tilt is present).
2876
+ * - Neither present (including an `xu yu zu`-only frame -- "unwrapped" is
2877
+ * a materially different physical quantity from a scaled coordinate,
2878
+ * never resolved by this method): returns JSON `null`, not an error and
2879
+ * not an empty array, matching
2880
+ * [`chematic_mol::LammpsDumpFrame::cartesian_positions`]'s own
2881
+ * `Option` semantics exactly.
2882
+ *
2883
+ * Returns JSON `[[x,y,z],...]` on success, in the same atom order as
2884
+ * `frame.rows`. See [`lammps_dump_cartesian_positions_f64`] for a flat
2885
+ * `Float64Array` sibling -- note its `null` case becomes an `Err` there
2886
+ * instead, a disclosed, real API-shape difference (a typed array has no
2887
+ * `null`).
2888
+ * @param {string} frame_json
2889
+ * @returns {string}
2890
+ */
2891
+ export function lammps_dump_cartesian_positions_json(frame_json) {
2892
+ let deferred3_0;
2893
+ let deferred3_1;
2894
+ try {
2895
+ const ptr0 = passStringToWasm0(frame_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2896
+ const len0 = WASM_VECTOR_LEN;
2897
+ const ret = wasm.lammps_dump_cartesian_positions_json(ptr0, len0);
2898
+ var ptr2 = ret[0];
2899
+ var len2 = ret[1];
2900
+ if (ret[3]) {
2901
+ ptr2 = 0; len2 = 0;
2902
+ throw takeFromExternrefTable0(ret[2]);
2903
+ }
2904
+ deferred3_0 = ptr2;
2905
+ deferred3_1 = len2;
2906
+ return getStringFromWasm0(ptr2, len2);
2907
+ } finally {
2908
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2909
+ }
2910
+ }
2911
+
2912
+ /**
2913
+ * Parse a single LAMMPS dump/trajectory frame and return it as JSON:
2914
+ * `{"timestep":N,"num_atoms":N,
2915
+ * "box_bounds":{"lo":[x,y,z],"hi":[x,y,z],"tilt":[xy,xz,yz]|null},
2916
+ * "boundary_flags":["pp","pp","pp"],"column_names":[...],
2917
+ * "rows":[[...values, one per column_names entry...],...]}`.
2918
+ * `box_bounds` is already the resolved TRUE simulation box (the parser
2919
+ * applies [`chematic_mol::box_bounds_to_true`] internally before
2920
+ * `LammpsDumpFrame` is ever built) -- not the file's raw
2921
+ * `xlo_bound`/`xhi_bound`/... values. `rows` is the raw per-atom column
2922
+ * data as declared by `column_names`, which may be `x y z`
2923
+ * (already-Cartesian), `xs ys zs` (box-scaled), `xu yu zu` (unwrapped), or
2924
+ * any other dump-command column -- use
2925
+ * [`lammps_dump_cartesian_positions_json`] to resolve real Cartesian
2926
+ * positions from whichever convention is present, rather than
2927
+ * reimplementing that resolution/transform in JS.
2928
+ * @param {string} text
2929
+ * @returns {string}
2930
+ */
2931
+ export function lammps_dump_frame_to_json_str(text) {
2932
+ let deferred3_0;
2933
+ let deferred3_1;
2934
+ try {
2935
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2936
+ const len0 = WASM_VECTOR_LEN;
2937
+ const ret = wasm.lammps_dump_frame_to_json_str(ptr0, len0);
2938
+ var ptr2 = ret[0];
2939
+ var len2 = ret[1];
2940
+ if (ret[3]) {
2941
+ ptr2 = 0; len2 = 0;
2942
+ throw takeFromExternrefTable0(ret[2]);
2943
+ }
2944
+ deferred3_0 = ptr2;
2945
+ deferred3_1 = len2;
2946
+ return getStringFromWasm0(ptr2, len2);
2947
+ } finally {
2948
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2949
+ }
2950
+ }
2951
+
2952
+ /**
2953
+ * Flattens a LAMMPS dump frame's `rows` (JSON shape
2954
+ * [`lammps_dump_frame_to_json_str`] returns) into a single flat
2955
+ * `Float64Array`, row-major (atom 0's `column_names.len()` values, then
2956
+ * atom 1's, ...). The caller already has `column_names` from
2957
+ * [`lammps_dump_frame_to_json_str`] and can compute the row length
2958
+ * itself (`column_names.length`); no separate row-length accessor is
2959
+ * provided here.
2960
+ * @param {string} frame_json
2961
+ * @returns {Float64Array}
2962
+ */
2963
+ export function lammps_dump_rows_f64(frame_json) {
2964
+ const ptr0 = passStringToWasm0(frame_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2965
+ const len0 = WASM_VECTOR_LEN;
2966
+ const ret = wasm.lammps_dump_rows_f64(ptr0, len0);
2967
+ if (ret[2]) {
2968
+ throw takeFromExternrefTable0(ret[1]);
2969
+ }
2970
+ return takeFromExternrefTable0(ret[0]);
2971
+ }
2972
+
2973
+ /**
2974
+ * Parse every frame of a LAMMPS dump/trajectory file and return them as a
2975
+ * JSON array (same per-frame shape as [`lammps_dump_frame_to_json_str`]).
2976
+ *
2977
+ * This reads the whole input, parses it fully, and returns every frame at
2978
+ * once -- [`chematic_mol::LammpsDumpReader`]'s per-frame streaming
2979
+ * iteration (reading one frame at a time from a `BufRead` without holding
2980
+ * the whole trajectory in memory) has no natural equivalent across the
2981
+ * JS/WASM boundary in this first pass and is deliberately not exposed
2982
+ * here, not silently dropped: a JS caller with a truly large trajectory
2983
+ * that needs bounded memory should process it server-side instead.
2984
+ * @param {string} text
2985
+ * @returns {string}
2986
+ */
2987
+ export function lammps_trajectory_to_json(text) {
2988
+ let deferred3_0;
2989
+ let deferred3_1;
2990
+ try {
2991
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2992
+ const len0 = WASM_VECTOR_LEN;
2993
+ const ret = wasm.lammps_trajectory_to_json(ptr0, len0);
2994
+ var ptr2 = ret[0];
2995
+ var len2 = ret[1];
2996
+ if (ret[3]) {
2997
+ ptr2 = 0; len2 = 0;
2998
+ throw takeFromExternrefTable0(ret[2]);
2999
+ }
3000
+ deferred3_0 = ptr2;
3001
+ deferred3_1 = len2;
3002
+ return getStringFromWasm0(ptr2, len2);
3003
+ } finally {
3004
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3005
+ }
3006
+ }
3007
+
2707
3008
  /**
2708
3009
  * Return the largest fragment of `mol` (salt/solvent stripping).
2709
3010
  *
@@ -2979,8 +3280,13 @@ export function minimize_mmff94_lbfgs_json(mol, max_iter) {
2979
3280
  * `coords_json` — JSON array of `[x,y,z]` arrays (Å), one per atom.
2980
3281
  * `max_iter` — maximum iterations (0 = default 500).
2981
3282
  *
2982
- * Returns JSON: `{"coords":[[x,y,z],...], "energy":float, "iterations":int, "converged":bool}`
2983
- * or `{"error":"<msg>"}` on failure.
3283
+ * Returns JSON: `{"coords":[[x,y,z],...], "energy":float, "iterations":int, "converged":bool, "sound":bool}`
3284
+ * or `{"error":"<msg>"}` on failure. `sound` is all-finite coordinates and
3285
+ * no bond stretched past a sane covalent-bond length — independent of
3286
+ * `converged`, since steepest descent often reports `converged:false` on
3287
+ * geometries that are perfectly fine but simply haven't hit the tight
3288
+ * RMS-gradient threshold yet. Check `sound`, not just `converged`, before
3289
+ * trusting a result.
2984
3290
  * @param {string} smiles
2985
3291
  * @param {string} coords_json
2986
3292
  * @param {number} max_iter
@@ -3003,6 +3309,66 @@ export function minimize_uff_json(smiles, coords_json, max_iter) {
3003
3309
  }
3004
3310
  }
3005
3311
 
3312
+ /**
3313
+ * Cartesian coordinates from an mmCIF file, in the SAME atom order
3314
+ * [`mol_from_mmcif`] returns topology for. Returns JSON `[[x,y,z],...]`
3315
+ * (Å).
3316
+ * @param {string} text
3317
+ * @returns {string}
3318
+ */
3319
+ export function mmcif_coords_json(text) {
3320
+ let deferred3_0;
3321
+ let deferred3_1;
3322
+ try {
3323
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3324
+ const len0 = WASM_VECTOR_LEN;
3325
+ const ret = wasm.mmcif_coords_json(ptr0, len0);
3326
+ var ptr2 = ret[0];
3327
+ var len2 = ret[1];
3328
+ if (ret[3]) {
3329
+ ptr2 = 0; len2 = 0;
3330
+ throw takeFromExternrefTable0(ret[2]);
3331
+ }
3332
+ deferred3_0 = ptr2;
3333
+ deferred3_1 = len2;
3334
+ return getStringFromWasm0(ptr2, len2);
3335
+ } finally {
3336
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3337
+ }
3338
+ }
3339
+
3340
+ /**
3341
+ * Parse an mmCIF file and return every `_atom_site` field (occupancy,
3342
+ * B-factor, chain/residue bookkeeping, formal charge, model number, ...),
3343
+ * the unit cell, space group, and any loop column this reader saw but
3344
+ * does not model, as JSON: `{"atoms":[{...}],"cell":{...}|null,
3345
+ * "space_group":"..."|null,"unhandled_columns":[...]}`. See
3346
+ * [`chematic_mol::MmcifAtomRecord`]'s doc comment for each atom field's
3347
+ * exact source column and defaulting rule.
3348
+ * @param {string} text
3349
+ * @returns {string}
3350
+ */
3351
+ export function mmcif_to_json(text) {
3352
+ let deferred3_0;
3353
+ let deferred3_1;
3354
+ try {
3355
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3356
+ const len0 = WASM_VECTOR_LEN;
3357
+ const ret = wasm.mmcif_to_json(ptr0, len0);
3358
+ var ptr2 = ret[0];
3359
+ var len2 = ret[1];
3360
+ if (ret[3]) {
3361
+ ptr2 = 0; len2 = 0;
3362
+ throw takeFromExternrefTable0(ret[2]);
3363
+ }
3364
+ deferred3_0 = ptr2;
3365
+ deferred3_1 = len2;
3366
+ return getStringFromWasm0(ptr2, len2);
3367
+ } finally {
3368
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3369
+ }
3370
+ }
3371
+
3006
3372
  /**
3007
3373
  * MMFF94 partial charges (BCI table, ±0.1e accuracy) as a JSON array of f64.
3008
3374
  *
@@ -3321,6 +3687,24 @@ export function mol_from_cml(cml) {
3321
3687
  return MolHandle.__wrap(ret[0]);
3322
3688
  }
3323
3689
 
3690
+ /**
3691
+ * Parse a Gaussian Cube file and return a `MolHandle` (topology only --
3692
+ * element list, no bonds; Cube carries no bond table). Use
3693
+ * [`cube_grid_json`] to recover coordinates, the scalar field, and the
3694
+ * grid geometry.
3695
+ * @param {string} text
3696
+ * @returns {MolHandle}
3697
+ */
3698
+ export function mol_from_cube(text) {
3699
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3700
+ const len0 = WASM_VECTOR_LEN;
3701
+ const ret = wasm.mol_from_cube(ptr0, len0);
3702
+ if (ret[2]) {
3703
+ throw takeFromExternrefTable0(ret[1]);
3704
+ }
3705
+ return MolHandle.__wrap(ret[0]);
3706
+ }
3707
+
3324
3708
  /**
3325
3709
  * Parse an Extended XYZ (extxyz) frame and return a `MolHandle` (topology +
3326
3710
  * element/position only; use [`extxyz_frame_json`] to recover coordinates,
@@ -3344,6 +3728,25 @@ export function mol_from_extxyz(text) {
3344
3728
  return MolHandle.__wrap(ret[0]);
3345
3729
  }
3346
3730
 
3731
+ /**
3732
+ * Parse an mmCIF file and return a `MolHandle` (topology only -- element
3733
+ * list, no bonds; mmCIF's `_atom_site` category carries no connectivity).
3734
+ * Includes every model's atoms if the file has more than one -- use
3735
+ * [`mmcif_to_json`] to get each atom's `model_num` for filtering. Use
3736
+ * [`mmcif_coords_json`] to recover coordinates in the same atom order.
3737
+ * @param {string} text
3738
+ * @returns {MolHandle}
3739
+ */
3740
+ export function mol_from_mmcif(text) {
3741
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3742
+ const len0 = WASM_VECTOR_LEN;
3743
+ const ret = wasm.mol_from_mmcif(ptr0, len0);
3744
+ if (ret[2]) {
3745
+ throw takeFromExternrefTable0(ret[1]);
3746
+ }
3747
+ return MolHandle.__wrap(ret[0]);
3748
+ }
3749
+
3347
3750
  /**
3348
3751
  * Parse a MolJSON string into a `MolHandle`.
3349
3752
  *
@@ -3362,6 +3765,28 @@ export function mol_from_moljson(json) {
3362
3765
  return MolHandle.__wrap(ret[0]);
3363
3766
  }
3364
3767
 
3768
+ /**
3769
+ * Parse an ORCA input file (`.inp`) and return a `MolHandle` (topology
3770
+ * only -- element list, no bonds; ORCA input carries no bond table).
3771
+ * Returns a JS error unless the file's coordinate block is an embedded
3772
+ * `* xyz ... *` block -- `xyzfile`/`gzmtfile`/`int` (Z-matrix) blocks
3773
+ * carry no atom list to convert, or none is present at all. Use
3774
+ * [`orca_input_coords_json`] to recover coordinates + charge +
3775
+ * multiplicity in the same atom order, or [`orca_input_to_json`] for the
3776
+ * full input (comments/keywords/blocks/any coordinate-block kind).
3777
+ * @param {string} text
3778
+ * @returns {MolHandle}
3779
+ */
3780
+ export function mol_from_orca_input(text) {
3781
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3782
+ const len0 = WASM_VECTOR_LEN;
3783
+ const ret = wasm.mol_from_orca_input(ptr0, len0);
3784
+ if (ret[2]) {
3785
+ throw takeFromExternrefTable0(ret[1]);
3786
+ }
3787
+ return MolHandle.__wrap(ret[0]);
3788
+ }
3789
+
3365
3790
  /**
3366
3791
  * Parse a PDB file and return a `MolHandle` (topology only; coordinates are
3367
3792
  * discarded -- use [`pdb_coords_json`] to recover them in the SAME atom
@@ -3381,16 +3806,54 @@ export function mol_from_pdb(pdb) {
3381
3806
  }
3382
3807
 
3383
3808
  /**
3384
- * Parse a MOL V2000 block and return a `MolHandle`.
3385
- *
3386
- * Returns a JS error string on parse failure.
3387
- * @param {string} block
3809
+ * Parse a PQR file and return a `MolHandle` (topology only -- element
3810
+ * list inferred per-atom, no bonds; PQR carries no connectivity). Use
3811
+ * [`pqr_coords_json`] to recover coordinates in the same atom order.
3812
+ * @param {string} text
3388
3813
  * @returns {MolHandle}
3389
3814
  */
3390
- export function mol_from_sdf_block(block) {
3391
- const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3815
+ export function mol_from_pqr(text) {
3816
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3392
3817
  const len0 = WASM_VECTOR_LEN;
3393
- const ret = wasm.mol_from_sdf_block(ptr0, len0);
3818
+ const ret = wasm.mol_from_pqr(ptr0, len0);
3819
+ if (ret[2]) {
3820
+ throw takeFromExternrefTable0(ret[1]);
3821
+ }
3822
+ return MolHandle.__wrap(ret[0]);
3823
+ }
3824
+
3825
+ /**
3826
+ * Parse a QCSchema `qcschema_molecule` JSON document and return a
3827
+ * `MolHandle` (topology + `atomic_numbers`-derived isotopes -- no bonds
3828
+ * unless the document's optional `connectivity` list is present, in which
3829
+ * case those bond orders are mapped onto the nearest
3830
+ * [`chematic_core::BondOrder`]). Use [`qcschema_molecule_coords_json`] to
3831
+ * recover coordinates (converted Bohr -> Å) plus molecular
3832
+ * charge/multiplicity, in the same atom order.
3833
+ * @param {string} json
3834
+ * @returns {MolHandle}
3835
+ */
3836
+ export function mol_from_qcschema_molecule(json) {
3837
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3838
+ const len0 = WASM_VECTOR_LEN;
3839
+ const ret = wasm.mol_from_qcschema_molecule(ptr0, len0);
3840
+ if (ret[2]) {
3841
+ throw takeFromExternrefTable0(ret[1]);
3842
+ }
3843
+ return MolHandle.__wrap(ret[0]);
3844
+ }
3845
+
3846
+ /**
3847
+ * Parse a MOL V2000 block and return a `MolHandle`.
3848
+ *
3849
+ * Returns a JS error string on parse failure.
3850
+ * @param {string} block
3851
+ * @returns {MolHandle}
3852
+ */
3853
+ export function mol_from_sdf_block(block) {
3854
+ const ptr0 = passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3855
+ const len0 = WASM_VECTOR_LEN;
3856
+ const ret = wasm.mol_from_sdf_block(ptr0, len0);
3394
3857
  if (ret[2]) {
3395
3858
  throw takeFromExternrefTable0(ret[1]);
3396
3859
  }
@@ -3766,6 +4229,162 @@ export function normalize_reaction_smiles(rxn_smiles) {
3766
4229
  }
3767
4230
  }
3768
4231
 
4232
+ /**
4233
+ * Parse an OpenDX (APBS scalar-field subset) file and return its full
4234
+ * [`chematic_mol::VolumetricGrid`] as JSON (same shape as
4235
+ * [`cube_grid_json`]; `atoms` is always empty -- OpenDX has no atom
4236
+ * section). No `mol_from_opendx` is provided: an OpenDX grid never carries
4237
+ * atoms, so a `MolHandle` from one would always be empty and is not a
4238
+ * useful binding.
4239
+ * @param {string} text
4240
+ * @returns {string}
4241
+ */
4242
+ export function opendx_grid_json(text) {
4243
+ let deferred3_0;
4244
+ let deferred3_1;
4245
+ try {
4246
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4247
+ const len0 = WASM_VECTOR_LEN;
4248
+ const ret = wasm.opendx_grid_json(ptr0, len0);
4249
+ var ptr2 = ret[0];
4250
+ var len2 = ret[1];
4251
+ if (ret[3]) {
4252
+ ptr2 = 0; len2 = 0;
4253
+ throw takeFromExternrefTable0(ret[2]);
4254
+ }
4255
+ deferred3_0 = ptr2;
4256
+ deferred3_1 = len2;
4257
+ return getStringFromWasm0(ptr2, len2);
4258
+ } finally {
4259
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4260
+ }
4261
+ }
4262
+
4263
+ /**
4264
+ * `[nx, ny, nz]` for an OpenDX file's grid, as a `Uint32Array`.
4265
+ * @param {string} text
4266
+ * @returns {Uint32Array}
4267
+ */
4268
+ export function opendx_shape_u32(text) {
4269
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4270
+ const len0 = WASM_VECTOR_LEN;
4271
+ const ret = wasm.opendx_shape_u32(ptr0, len0);
4272
+ if (ret[2]) {
4273
+ throw takeFromExternrefTable0(ret[1]);
4274
+ }
4275
+ return takeFromExternrefTable0(ret[0]);
4276
+ }
4277
+
4278
+ /**
4279
+ * Flat `values` from an OpenDX file's grid, as a `Float64Array` -- same
4280
+ * data [`opendx_grid_json`]'s `"values"` field carries.
4281
+ * @param {string} text
4282
+ * @returns {Float64Array}
4283
+ */
4284
+ export function opendx_values_f64(text) {
4285
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4286
+ const len0 = WASM_VECTOR_LEN;
4287
+ const ret = wasm.opendx_values_f64(ptr0, len0);
4288
+ if (ret[2]) {
4289
+ throw takeFromExternrefTable0(ret[1]);
4290
+ }
4291
+ return takeFromExternrefTable0(ret[0]);
4292
+ }
4293
+
4294
+ /**
4295
+ * Coordinates + charge + multiplicity from an ORCA input file's embedded
4296
+ * `* xyz ... *` block, in the SAME atom order [`mol_from_orca_input`]
4297
+ * returns topology for. Returns JSON
4298
+ * `{"coords":[[x,y,z],...],"charge":0,"multiplicity":1}`, or a JS error
4299
+ * under the same conditions as [`mol_from_orca_input`].
4300
+ * @param {string} text
4301
+ * @returns {string}
4302
+ */
4303
+ export function orca_input_coords_json(text) {
4304
+ let deferred3_0;
4305
+ let deferred3_1;
4306
+ try {
4307
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4308
+ const len0 = WASM_VECTOR_LEN;
4309
+ const ret = wasm.orca_input_coords_json(ptr0, len0);
4310
+ var ptr2 = ret[0];
4311
+ var len2 = ret[1];
4312
+ if (ret[3]) {
4313
+ ptr2 = 0; len2 = 0;
4314
+ throw takeFromExternrefTable0(ret[2]);
4315
+ }
4316
+ deferred3_0 = ptr2;
4317
+ deferred3_1 = len2;
4318
+ return getStringFromWasm0(ptr2, len2);
4319
+ } finally {
4320
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4321
+ }
4322
+ }
4323
+
4324
+ /**
4325
+ * Parse an ORCA input file and return every field as JSON:
4326
+ * `{"comments":[...],"keywords":[...],
4327
+ * "blocks":[{"name":"scf","raw":"...","has_end":true},...],
4328
+ * "coords":{"type":"xyz"|"xyzfile"|"gzmtfile"|"internal",...}|null}`.
4329
+ * See [`chematic_mol::OrcaInput`]'s doc comment for each field's meaning.
4330
+ * @param {string} text
4331
+ * @returns {string}
4332
+ */
4333
+ export function orca_input_to_json(text) {
4334
+ let deferred3_0;
4335
+ let deferred3_1;
4336
+ try {
4337
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4338
+ const len0 = WASM_VECTOR_LEN;
4339
+ const ret = wasm.orca_input_to_json(ptr0, len0);
4340
+ var ptr2 = ret[0];
4341
+ var len2 = ret[1];
4342
+ if (ret[3]) {
4343
+ ptr2 = 0; len2 = 0;
4344
+ throw takeFromExternrefTable0(ret[2]);
4345
+ }
4346
+ deferred3_0 = ptr2;
4347
+ deferred3_1 = len2;
4348
+ return getStringFromWasm0(ptr2, len2);
4349
+ } finally {
4350
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4351
+ }
4352
+ }
4353
+
4354
+ /**
4355
+ * Parse an ORCA output file (`.out`/`.log`) and return every extracted
4356
+ * field as JSON: `{"charge":N|null,"multiplicity":N|null,
4357
+ * "final_energy_hartree":N|null,
4358
+ * "trajectory":[{"elements":[...],"coords":[[x,y,z],...]},...],
4359
+ * "frequencies_cm1":[...],
4360
+ * "termination":{"kind":"normal"|"error"|"incomplete","detail":"..."?},
4361
+ * "optimization_convergence":"not_requested"|"converged"|"not_converged"|"unknown"}`.
4362
+ * No writer is provided -- an ORCA output file is a job log, not a
4363
+ * document this crate constructs.
4364
+ * @param {string} text
4365
+ * @returns {string}
4366
+ */
4367
+ export function orca_output_to_json(text) {
4368
+ let deferred3_0;
4369
+ let deferred3_1;
4370
+ try {
4371
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4372
+ const len0 = WASM_VECTOR_LEN;
4373
+ const ret = wasm.orca_output_to_json(ptr0, len0);
4374
+ var ptr2 = ret[0];
4375
+ var len2 = ret[1];
4376
+ if (ret[3]) {
4377
+ ptr2 = 0; len2 = 0;
4378
+ throw takeFromExternrefTable0(ret[2]);
4379
+ }
4380
+ deferred3_0 = ptr2;
4381
+ deferred3_1 = len2;
4382
+ return getStringFromWasm0(ptr2, len2);
4383
+ } finally {
4384
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4385
+ }
4386
+ }
4387
+
3769
4388
  /**
3770
4389
  * PAINS structural alert names matched by `mol` as a JSON array.
3771
4390
  *
@@ -3970,6 +4589,86 @@ export function pharmacophore_fp_3d_summary(mol) {
3970
4589
  }
3971
4590
  }
3972
4591
 
4592
+ /**
4593
+ * Cartesian coordinates from a PQR file, in the SAME atom order
4594
+ * [`mol_from_pqr`] returns topology for. Returns JSON `[[x,y,z],...]` (Å).
4595
+ * @param {string} text
4596
+ * @returns {string}
4597
+ */
4598
+ export function pqr_coords_json(text) {
4599
+ let deferred3_0;
4600
+ let deferred3_1;
4601
+ try {
4602
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4603
+ const len0 = WASM_VECTOR_LEN;
4604
+ const ret = wasm.pqr_coords_json(ptr0, len0);
4605
+ var ptr2 = ret[0];
4606
+ var len2 = ret[1];
4607
+ if (ret[3]) {
4608
+ ptr2 = 0; len2 = 0;
4609
+ throw takeFromExternrefTable0(ret[2]);
4610
+ }
4611
+ deferred3_0 = ptr2;
4612
+ deferred3_1 = len2;
4613
+ return getStringFromWasm0(ptr2, len2);
4614
+ } finally {
4615
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4616
+ }
4617
+ }
4618
+
4619
+ /**
4620
+ * Infer an element from a PQR atom name (see
4621
+ * [`chematic_mol::infer_element`]'s doc comment for the heuristic).
4622
+ * Returns `undefined` (JS) / `None` if no element could be inferred.
4623
+ * @param {string} group_pdb
4624
+ * @param {string} res_name
4625
+ * @param {string} atom_name
4626
+ * @returns {string | undefined}
4627
+ */
4628
+ export function pqr_infer_element(group_pdb, res_name, atom_name) {
4629
+ const ptr0 = passStringToWasm0(group_pdb, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4630
+ const len0 = WASM_VECTOR_LEN;
4631
+ const ptr1 = passStringToWasm0(res_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4632
+ const len1 = WASM_VECTOR_LEN;
4633
+ const ptr2 = passStringToWasm0(atom_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4634
+ const len2 = WASM_VECTOR_LEN;
4635
+ const ret = wasm.pqr_infer_element(ptr0, len0, ptr1, len1, ptr2, len2);
4636
+ let v4;
4637
+ if (ret[0] !== 0) {
4638
+ v4 = getStringFromWasm0(ret[0], ret[1]);
4639
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
4640
+ }
4641
+ return v4;
4642
+ }
4643
+
4644
+ /**
4645
+ * Parse a PQR file and return every field (charge, radius, chain,
4646
+ * residue, inferred element, ...) as JSON: `{"atoms":[{...}]}`. See
4647
+ * [`chematic_mol::PqrAtomRecord`]'s doc comment for each field's meaning.
4648
+ * @param {string} text
4649
+ * @returns {string}
4650
+ */
4651
+ export function pqr_to_json(text) {
4652
+ let deferred3_0;
4653
+ let deferred3_1;
4654
+ try {
4655
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4656
+ const len0 = WASM_VECTOR_LEN;
4657
+ const ret = wasm.pqr_to_json(ptr0, len0);
4658
+ var ptr2 = ret[0];
4659
+ var len2 = ret[1];
4660
+ if (ret[3]) {
4661
+ ptr2 = 0; len2 = 0;
4662
+ throw takeFromExternrefTable0(ret[2]);
4663
+ }
4664
+ deferred3_0 = ptr2;
4665
+ deferred3_1 = len2;
4666
+ return getStringFromWasm0(ptr2, len2);
4667
+ } finally {
4668
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4669
+ }
4670
+ }
4671
+
3973
4672
  /**
3974
4673
  * Predict pKa for all ionizable sites in a molecule.
3975
4674
  *
@@ -3994,6 +4693,97 @@ export function predict_pka_json(smiles) {
3994
4693
  }
3995
4694
  }
3996
4695
 
4696
+ /**
4697
+ * Coordinates (Å) plus molecular charge/multiplicity from a QCSchema
4698
+ * `qcschema_molecule` document, in the SAME atom order
4699
+ * [`mol_from_qcschema_molecule`] returns topology for. Returns JSON
4700
+ * `{"coords":[[x,y,z],...],"molecular_charge":0.0,"molecular_multiplicity":1}`.
4701
+ * @param {string} json
4702
+ * @returns {string}
4703
+ */
4704
+ export function qcschema_molecule_coords_json(json) {
4705
+ let deferred3_0;
4706
+ let deferred3_1;
4707
+ try {
4708
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4709
+ const len0 = WASM_VECTOR_LEN;
4710
+ const ret = wasm.qcschema_molecule_coords_json(ptr0, len0);
4711
+ var ptr2 = ret[0];
4712
+ var len2 = ret[1];
4713
+ if (ret[3]) {
4714
+ ptr2 = 0; len2 = 0;
4715
+ throw takeFromExternrefTable0(ret[2]);
4716
+ }
4717
+ deferred3_0 = ptr2;
4718
+ deferred3_1 = len2;
4719
+ return getStringFromWasm0(ptr2, len2);
4720
+ } finally {
4721
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4722
+ }
4723
+ }
4724
+
4725
+ /**
4726
+ * Parse a QCSchema `qcschema_input`/`qc_schema_input` JSON document
4727
+ * (molecule + driver + model + keywords) and re-emit it, validating and
4728
+ * canonicalizing field defaults in the process (e.g. a missing
4729
+ * `schema_name`/`schema_version` is filled in). Job-level fields
4730
+ * (`driver`, `model`, `keywords`, `protocols`, `extras`) are round-tripped
4731
+ * opaquely -- this binding validates/reformats the document; it does not
4732
+ * expose a separate JS-facing accessor for each field (out of scope for
4733
+ * this first pass, see module docs' "None of these formats carry a bond
4734
+ * table" section for the analogous molecule-centric scope choice made
4735
+ * elsewhere in this file).
4736
+ * @param {string} json
4737
+ * @returns {string}
4738
+ */
4739
+ export function qcschema_validate_atomic_input(json) {
4740
+ let deferred3_0;
4741
+ let deferred3_1;
4742
+ try {
4743
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4744
+ const len0 = WASM_VECTOR_LEN;
4745
+ const ret = wasm.qcschema_validate_atomic_input(ptr0, len0);
4746
+ var ptr2 = ret[0];
4747
+ var len2 = ret[1];
4748
+ if (ret[3]) {
4749
+ ptr2 = 0; len2 = 0;
4750
+ throw takeFromExternrefTable0(ret[2]);
4751
+ }
4752
+ deferred3_0 = ptr2;
4753
+ deferred3_1 = len2;
4754
+ return getStringFromWasm0(ptr2, len2);
4755
+ } finally {
4756
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4757
+ }
4758
+ }
4759
+
4760
+ /**
4761
+ * Like [`qcschema_validate_atomic_input`], for a QCSchema
4762
+ * `qcschema_output`/`qc_schema_output` (`AtomicResult`) document.
4763
+ * @param {string} json
4764
+ * @returns {string}
4765
+ */
4766
+ export function qcschema_validate_atomic_result(json) {
4767
+ let deferred3_0;
4768
+ let deferred3_1;
4769
+ try {
4770
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4771
+ const len0 = WASM_VECTOR_LEN;
4772
+ const ret = wasm.qcschema_validate_atomic_result(ptr0, len0);
4773
+ var ptr2 = ret[0];
4774
+ var len2 = ret[1];
4775
+ if (ret[3]) {
4776
+ ptr2 = 0; len2 = 0;
4777
+ throw takeFromExternrefTable0(ret[2]);
4778
+ }
4779
+ deferred3_0 = ptr2;
4780
+ deferred3_1 = len2;
4781
+ return getStringFromWasm0(ptr2, len2);
4782
+ } finally {
4783
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4784
+ }
4785
+ }
4786
+
3997
4787
  /**
3998
4788
  * Generate `count` random SMILES from a SMILES string using the given seed.
3999
4789
  * Atoms are permuted based on xorshift64 RNG. Each variant should parse back
@@ -5134,6 +5924,41 @@ export function to_moljson(mol) {
5134
5924
  }
5135
5925
  }
5136
5926
 
5927
+ /**
5928
+ * Serialize a `MolHandle` + coordinates (Å) + molecular charge/multiplicity
5929
+ * as a QCSchema `qcschema_molecule` JSON document (coordinates converted
5930
+ * to Bohr).
5931
+ *
5932
+ * `coords_json`: `[[x,y,z],...]` (Å), same order and length as `mol`'s
5933
+ * atoms.
5934
+ * @param {MolHandle} mol
5935
+ * @param {string} coords_json
5936
+ * @param {number} charge
5937
+ * @param {bigint} multiplicity
5938
+ * @returns {string}
5939
+ */
5940
+ export function to_qcschema_molecule_json(mol, coords_json, charge, multiplicity) {
5941
+ let deferred3_0;
5942
+ let deferred3_1;
5943
+ try {
5944
+ _assertClass(mol, MolHandle);
5945
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5946
+ const len0 = WASM_VECTOR_LEN;
5947
+ const ret = wasm.to_qcschema_molecule_json(mol.__wbg_ptr, ptr0, len0, charge, multiplicity);
5948
+ var ptr2 = ret[0];
5949
+ var len2 = ret[1];
5950
+ if (ret[3]) {
5951
+ ptr2 = 0; len2 = 0;
5952
+ throw takeFromExternrefTable0(ret[2]);
5953
+ }
5954
+ deferred3_0 = ptr2;
5955
+ deferred3_1 = len2;
5956
+ return getStringFromWasm0(ptr2, len2);
5957
+ } finally {
5958
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
5959
+ }
5960
+ }
5961
+
5137
5962
  /**
5138
5963
  * Serialize a molecule to XYZ format.
5139
5964
  *
@@ -5241,6 +6066,274 @@ export function whim_getaway_combined_json(mol) {
5241
6066
  }
5242
6067
  }
5243
6068
 
6069
+ /**
6070
+ * Write a grid (in the JSON shape [`cube_grid_json`] returns) as a
6071
+ * Gaussian Cube file.
6072
+ * @param {string} grid_json
6073
+ * @returns {string}
6074
+ */
6075
+ export function write_cube_json(grid_json) {
6076
+ let deferred3_0;
6077
+ let deferred3_1;
6078
+ try {
6079
+ const ptr0 = passStringToWasm0(grid_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6080
+ const len0 = WASM_VECTOR_LEN;
6081
+ const ret = wasm.write_cube_json(ptr0, len0);
6082
+ var ptr2 = ret[0];
6083
+ var len2 = ret[1];
6084
+ if (ret[3]) {
6085
+ ptr2 = 0; len2 = 0;
6086
+ throw takeFromExternrefTable0(ret[2]);
6087
+ }
6088
+ deferred3_0 = ptr2;
6089
+ deferred3_1 = len2;
6090
+ return getStringFromWasm0(ptr2, len2);
6091
+ } finally {
6092
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6093
+ }
6094
+ }
6095
+
6096
+ /**
6097
+ * Write a LAMMPS data file from the JSON shape [`lammps_data_to_json`]
6098
+ * returns.
6099
+ * @param {string} json
6100
+ * @returns {string}
6101
+ */
6102
+ export function write_lammps_data_json(json) {
6103
+ let deferred3_0;
6104
+ let deferred3_1;
6105
+ try {
6106
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6107
+ const len0 = WASM_VECTOR_LEN;
6108
+ const ret = wasm.write_lammps_data_json(ptr0, len0);
6109
+ var ptr2 = ret[0];
6110
+ var len2 = ret[1];
6111
+ if (ret[3]) {
6112
+ ptr2 = 0; len2 = 0;
6113
+ throw takeFromExternrefTable0(ret[2]);
6114
+ }
6115
+ deferred3_0 = ptr2;
6116
+ deferred3_1 = len2;
6117
+ return getStringFromWasm0(ptr2, len2);
6118
+ } finally {
6119
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6120
+ }
6121
+ }
6122
+
6123
+ /**
6124
+ * Write a single LAMMPS dump frame from the JSON shape
6125
+ * [`lammps_dump_frame_to_json_str`] returns.
6126
+ * @param {string} json
6127
+ * @returns {string}
6128
+ */
6129
+ export function write_lammps_dump_frame_json(json) {
6130
+ let deferred3_0;
6131
+ let deferred3_1;
6132
+ try {
6133
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6134
+ const len0 = WASM_VECTOR_LEN;
6135
+ const ret = wasm.write_lammps_dump_frame_json(ptr0, len0);
6136
+ var ptr2 = ret[0];
6137
+ var len2 = ret[1];
6138
+ if (ret[3]) {
6139
+ ptr2 = 0; len2 = 0;
6140
+ throw takeFromExternrefTable0(ret[2]);
6141
+ }
6142
+ deferred3_0 = ptr2;
6143
+ deferred3_1 = len2;
6144
+ return getStringFromWasm0(ptr2, len2);
6145
+ } finally {
6146
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6147
+ }
6148
+ }
6149
+
6150
+ /**
6151
+ * Write a LAMMPS trajectory (N frames concatenated back to back, matching
6152
+ * [`chematic_mol::write_lammps_trajectory`]) from a JSON array of frames
6153
+ * in the shape [`lammps_dump_frame_to_json_str`] returns.
6154
+ * @param {string} json
6155
+ * @returns {string}
6156
+ */
6157
+ export function write_lammps_trajectory_json(json) {
6158
+ let deferred3_0;
6159
+ let deferred3_1;
6160
+ try {
6161
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6162
+ const len0 = WASM_VECTOR_LEN;
6163
+ const ret = wasm.write_lammps_trajectory_json(ptr0, len0);
6164
+ var ptr2 = ret[0];
6165
+ var len2 = ret[1];
6166
+ if (ret[3]) {
6167
+ ptr2 = 0; len2 = 0;
6168
+ throw takeFromExternrefTable0(ret[2]);
6169
+ }
6170
+ deferred3_0 = ptr2;
6171
+ deferred3_1 = len2;
6172
+ return getStringFromWasm0(ptr2, len2);
6173
+ } finally {
6174
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6175
+ }
6176
+ }
6177
+
6178
+ /**
6179
+ * Write an mmCIF file from atom records in the JSON shape
6180
+ * [`mmcif_to_json`]'s `"atoms"` array uses (a full record per atom, not
6181
+ * just element+coordinates -- mmCIF has no equivalent of "build from a
6182
+ * bare `MolHandle`", since occupancy/B-factor/chain/residue fields have no
6183
+ * source in a plain [`MolHandle`]).
6184
+ *
6185
+ * `cell_json`: `"null"` or `{"a":...,"b":...,"c":...,"alpha":...,"beta":...,"gamma":...}`.
6186
+ * `space_group`: pass `""` for none.
6187
+ * @param {string} records_json
6188
+ * @param {string} cell_json
6189
+ * @param {string} space_group
6190
+ * @param {string} data_block_name
6191
+ * @returns {string}
6192
+ */
6193
+ export function write_mmcif_json(records_json, cell_json, space_group, data_block_name) {
6194
+ let deferred6_0;
6195
+ let deferred6_1;
6196
+ try {
6197
+ const ptr0 = passStringToWasm0(records_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6198
+ const len0 = WASM_VECTOR_LEN;
6199
+ const ptr1 = passStringToWasm0(cell_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6200
+ const len1 = WASM_VECTOR_LEN;
6201
+ const ptr2 = passStringToWasm0(space_group, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6202
+ const len2 = WASM_VECTOR_LEN;
6203
+ const ptr3 = passStringToWasm0(data_block_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6204
+ const len3 = WASM_VECTOR_LEN;
6205
+ const ret = wasm.write_mmcif_json(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
6206
+ var ptr5 = ret[0];
6207
+ var len5 = ret[1];
6208
+ if (ret[3]) {
6209
+ ptr5 = 0; len5 = 0;
6210
+ throw takeFromExternrefTable0(ret[2]);
6211
+ }
6212
+ deferred6_0 = ptr5;
6213
+ deferred6_1 = len5;
6214
+ return getStringFromWasm0(ptr5, len5);
6215
+ } finally {
6216
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
6217
+ }
6218
+ }
6219
+
6220
+ /**
6221
+ * Write a grid as an OpenDX file. Fails closed for a
6222
+ * [`chematic_mol::GridUnits::Bohr`]-tagged grid (OpenDX has no unit tag of
6223
+ * its own and is universally read back as Ångström -- see
6224
+ * `chematic_mol::opendx`'s module docs) and for a grid carrying any atoms
6225
+ * (OpenDX has no atom section). Use [`write_opendx_lossy_json`] to opt
6226
+ * into an explicit Bohr->Ångström conversion instead of failing.
6227
+ * @param {string} grid_json
6228
+ * @returns {string}
6229
+ */
6230
+ export function write_opendx_json(grid_json) {
6231
+ let deferred3_0;
6232
+ let deferred3_1;
6233
+ try {
6234
+ const ptr0 = passStringToWasm0(grid_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6235
+ const len0 = WASM_VECTOR_LEN;
6236
+ const ret = wasm.write_opendx_json(ptr0, len0);
6237
+ var ptr2 = ret[0];
6238
+ var len2 = ret[1];
6239
+ if (ret[3]) {
6240
+ ptr2 = 0; len2 = 0;
6241
+ throw takeFromExternrefTable0(ret[2]);
6242
+ }
6243
+ deferred3_0 = ptr2;
6244
+ deferred3_1 = len2;
6245
+ return getStringFromWasm0(ptr2, len2);
6246
+ } finally {
6247
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6248
+ }
6249
+ }
6250
+
6251
+ /**
6252
+ * Like [`write_opendx_json`], but a [`chematic_mol::GridUnits::Bohr`] grid
6253
+ * has its `origin`/`axes` explicitly converted to Ångström rather than
6254
+ * rejected (`values` -- the scalar-field samples themselves -- are never
6255
+ * rescaled; see `write_opendx_lossy`'s doc comment). Still fails for a
6256
+ * grid carrying any atoms.
6257
+ * @param {string} grid_json
6258
+ * @returns {string}
6259
+ */
6260
+ export function write_opendx_lossy_json(grid_json) {
6261
+ let deferred3_0;
6262
+ let deferred3_1;
6263
+ try {
6264
+ const ptr0 = passStringToWasm0(grid_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6265
+ const len0 = WASM_VECTOR_LEN;
6266
+ const ret = wasm.write_opendx_lossy_json(ptr0, len0);
6267
+ var ptr2 = ret[0];
6268
+ var len2 = ret[1];
6269
+ if (ret[3]) {
6270
+ ptr2 = 0; len2 = 0;
6271
+ throw takeFromExternrefTable0(ret[2]);
6272
+ }
6273
+ deferred3_0 = ptr2;
6274
+ deferred3_1 = len2;
6275
+ return getStringFromWasm0(ptr2, len2);
6276
+ } finally {
6277
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6278
+ }
6279
+ }
6280
+
6281
+ /**
6282
+ * Write an ORCA input file from the JSON shape [`orca_input_to_json`]
6283
+ * returns.
6284
+ * @param {string} json
6285
+ * @returns {string}
6286
+ */
6287
+ export function write_orca_input_json(json) {
6288
+ let deferred3_0;
6289
+ let deferred3_1;
6290
+ try {
6291
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6292
+ const len0 = WASM_VECTOR_LEN;
6293
+ const ret = wasm.write_orca_input_json(ptr0, len0);
6294
+ var ptr2 = ret[0];
6295
+ var len2 = ret[1];
6296
+ if (ret[3]) {
6297
+ ptr2 = 0; len2 = 0;
6298
+ throw takeFromExternrefTable0(ret[2]);
6299
+ }
6300
+ deferred3_0 = ptr2;
6301
+ deferred3_1 = len2;
6302
+ return getStringFromWasm0(ptr2, len2);
6303
+ } finally {
6304
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6305
+ }
6306
+ }
6307
+
6308
+ /**
6309
+ * Write a PQR file from atom records in the JSON shape [`pqr_to_json`]'s
6310
+ * `"atoms"` array uses. Each atom's `chain_id` independently controls
6311
+ * whether that line is written with or without the (optional) chain
6312
+ * column.
6313
+ * @param {string} records_json
6314
+ * @returns {string}
6315
+ */
6316
+ export function write_pqr_json(records_json) {
6317
+ let deferred3_0;
6318
+ let deferred3_1;
6319
+ try {
6320
+ const ptr0 = passStringToWasm0(records_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6321
+ const len0 = WASM_VECTOR_LEN;
6322
+ const ret = wasm.write_pqr_json(ptr0, len0);
6323
+ var ptr2 = ret[0];
6324
+ var len2 = ret[1];
6325
+ if (ret[3]) {
6326
+ ptr2 = 0; len2 = 0;
6327
+ throw takeFromExternrefTable0(ret[2]);
6328
+ }
6329
+ deferred3_0 = ptr2;
6330
+ deferred3_1 = len2;
6331
+ return getStringFromWasm0(ptr2, len2);
6332
+ } finally {
6333
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6334
+ }
6335
+ }
6336
+
5244
6337
  /**
5245
6338
  * Non-canonical SMILES for `mol`.
5246
6339
  *
@@ -5324,6 +6417,14 @@ function __wbg_get_imports() {
5324
6417
  __wbg_error_dd408a7b3cb542dd: function(arg0) {
5325
6418
  console.error(arg0);
5326
6419
  },
6420
+ __wbg_new_from_slice_8aed4f0384605526: function(arg0, arg1) {
6421
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
6422
+ return ret;
6423
+ },
6424
+ __wbg_new_from_slice_f6e95bc2809a2b07: function(arg0, arg1) {
6425
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
6426
+ return ret;
6427
+ },
5327
6428
  __wbg_now_e7c6795a7f81e10f: function(arg0) {
5328
6429
  const ret = arg0.now();
5329
6430
  return ret;
@@ -5399,6 +6500,16 @@ function _assertClass(instance, klass) {
5399
6500
  }
5400
6501
  }
5401
6502
 
6503
+ function getArrayF64FromWasm0(ptr, len) {
6504
+ ptr = ptr >>> 0;
6505
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
6506
+ }
6507
+
6508
+ function getArrayU32FromWasm0(ptr, len) {
6509
+ ptr = ptr >>> 0;
6510
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
6511
+ }
6512
+
5402
6513
  function getArrayU8FromWasm0(ptr, len) {
5403
6514
  ptr = ptr >>> 0;
5404
6515
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -5412,6 +6523,14 @@ function getDataViewMemory0() {
5412
6523
  return cachedDataViewMemory0;
5413
6524
  }
5414
6525
 
6526
+ let cachedFloat64ArrayMemory0 = null;
6527
+ function getFloat64ArrayMemory0() {
6528
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
6529
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
6530
+ }
6531
+ return cachedFloat64ArrayMemory0;
6532
+ }
6533
+
5415
6534
  function getStringFromWasm0(ptr, len) {
5416
6535
  return decodeText(ptr >>> 0, len);
5417
6536
  }
@@ -5521,6 +6640,7 @@ function __wbg_finalize_init(instance, module) {
5521
6640
  wasm = instance.exports;
5522
6641
  wasmModule = module;
5523
6642
  cachedDataViewMemory0 = null;
6643
+ cachedFloat64ArrayMemory0 = null;
5524
6644
  cachedUint32ArrayMemory0 = null;
5525
6645
  cachedUint8ArrayMemory0 = null;
5526
6646
  wasm.__wbindgen_start();