@kent-tokyo/chematic 0.16.0 → 0.18.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
@@ -1586,6 +1586,71 @@ export function cpk_color(element_symbol) {
1586
1586
  }
1587
1587
  }
1588
1588
 
1589
+ /**
1590
+ * Parse a Gaussian Cube file and return its full [`chematic_mol::VolumetricGrid`]
1591
+ * as JSON: `{"origin":[x,y,z],"axes":[[..],[..],[..]],"shape":[nx,ny,nz],
1592
+ * "values":[...flat, row-major third-axis-fastest...],
1593
+ * "atoms":[{"element":"C","charge":6.0,"position":[x,y,z]}],
1594
+ * "units":"bohr"|"angstrom"}`. See module docs for the perf tradeoff of a
1595
+ * full `values` JSON round trip on a large grid.
1596
+ * @param {string} text
1597
+ * @returns {string}
1598
+ */
1599
+ export function cube_grid_json(text) {
1600
+ let deferred3_0;
1601
+ let deferred3_1;
1602
+ try {
1603
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1604
+ const len0 = WASM_VECTOR_LEN;
1605
+ const ret = wasm.cube_grid_json(ptr0, len0);
1606
+ var ptr2 = ret[0];
1607
+ var len2 = ret[1];
1608
+ if (ret[3]) {
1609
+ ptr2 = 0; len2 = 0;
1610
+ throw takeFromExternrefTable0(ret[2]);
1611
+ }
1612
+ deferred3_0 = ptr2;
1613
+ deferred3_1 = len2;
1614
+ return getStringFromWasm0(ptr2, len2);
1615
+ } finally {
1616
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1617
+ }
1618
+ }
1619
+
1620
+ /**
1621
+ * `[nx, ny, nz]` for a Gaussian Cube file's grid, as a `Uint32Array`.
1622
+ * @param {string} text
1623
+ * @returns {Uint32Array}
1624
+ */
1625
+ export function cube_shape_u32(text) {
1626
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1627
+ const len0 = WASM_VECTOR_LEN;
1628
+ const ret = wasm.cube_shape_u32(ptr0, len0);
1629
+ if (ret[2]) {
1630
+ throw takeFromExternrefTable0(ret[1]);
1631
+ }
1632
+ return takeFromExternrefTable0(ret[0]);
1633
+ }
1634
+
1635
+ /**
1636
+ * Flat `values` from a Gaussian Cube file's grid, as a `Float64Array` --
1637
+ * same data [`cube_grid_json`]'s `"values"` field carries (row-major,
1638
+ * third-axis-fastest order -- see `chematic_mol::volumetric`'s module
1639
+ * docs for the exact index formula), as a real typed array instead of a
1640
+ * JSON number array.
1641
+ * @param {string} text
1642
+ * @returns {Float64Array}
1643
+ */
1644
+ export function cube_values_f64(text) {
1645
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1646
+ const len0 = WASM_VECTOR_LEN;
1647
+ const ret = wasm.cube_values_f64(ptr0, len0);
1648
+ if (ret[2]) {
1649
+ throw takeFromExternrefTable0(ret[1]);
1650
+ }
1651
+ return takeFromExternrefTable0(ret[0]);
1652
+ }
1653
+
1589
1654
  /**
1590
1655
  * Compute structured depiction data for `mol` as a JSON object.
1591
1656
  *
@@ -2704,6 +2769,221 @@ export function labute_asa_per_atom_json(mol) {
2704
2769
  }
2705
2770
  }
2706
2771
 
2772
+ /**
2773
+ * Parse a LAMMPS data file (`read_data` format) and return every section
2774
+ * as JSON: `{"counts":[["atoms",120],["atom types",4],...],
2775
+ * "atom_style":"atomic"|"charge"|"molecular"|"full"|"<other>",
2776
+ * "simulation_box":{"lo":[x,y,z],"hi":[x,y,z],"tilt":[xy,xz,yz]|null},
2777
+ * "masses":[{"atom_type":N,"mass":N}],
2778
+ * "atoms":[{"id":N,"molecule_id":N|null,"atom_type":N,"charge":N|null,"x":N,"y":N,"z":N,"image":[ix,iy,iz]|null}],
2779
+ * "velocities":[{"atom_id":N,"vx":N,"vy":N,"vz":N}],
2780
+ * "bonds":[{"id":N,"bond_type":N,"atom1":N,"atom2":N}],
2781
+ * "unparsed_sections":[["Angles","<raw row text>"],...]}`. `atom_type`
2782
+ * must be exactly `"atomic"`/`"charge"`/`"molecular"`/`"full"` -- LAMMPS's
2783
+ * atom style is not recoverable from the file itself (see
2784
+ * [`chematic_mol::LammpsData`]'s module doc comment); any other value is
2785
+ * rejected with a JS error, matching
2786
+ * [`chematic_mol::LammpsDataError::UnsupportedAtomStyle`].
2787
+ *
2788
+ * This module has no bond-perception step of its own: `Angles`/
2789
+ * `Dihedrals`/`Impropers`/`*Coeffs`/any other section not listed above
2790
+ * are preserved verbatim (byte-for-byte, `#` comments included) in
2791
+ * `unparsed_sections`, not modeled field-by-field.
2792
+ * @param {string} text
2793
+ * @param {string} atom_style
2794
+ * @returns {string}
2795
+ */
2796
+ export function lammps_data_to_json(text, atom_style) {
2797
+ let deferred4_0;
2798
+ let deferred4_1;
2799
+ try {
2800
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2801
+ const len0 = WASM_VECTOR_LEN;
2802
+ const ptr1 = passStringToWasm0(atom_style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2803
+ const len1 = WASM_VECTOR_LEN;
2804
+ const ret = wasm.lammps_data_to_json(ptr0, len0, ptr1, len1);
2805
+ var ptr3 = ret[0];
2806
+ var len3 = ret[1];
2807
+ if (ret[3]) {
2808
+ ptr3 = 0; len3 = 0;
2809
+ throw takeFromExternrefTable0(ret[2]);
2810
+ }
2811
+ deferred4_0 = ptr3;
2812
+ deferred4_1 = len3;
2813
+ return getStringFromWasm0(ptr3, len3);
2814
+ } finally {
2815
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2816
+ }
2817
+ }
2818
+
2819
+ /**
2820
+ * Like [`lammps_dump_cartesian_positions_json`], but returns a flat
2821
+ * `Float64Array` (`[x0,y0,z0,x1,y1,z1,...]`, 3 values per atom) instead
2822
+ * of a JSON `[[x,y,z],...]` array.
2823
+ *
2824
+ * **Behavioral difference from the JSON sibling**: when the frame has no
2825
+ * recognized coordinate columns, [`lammps_dump_cartesian_positions_json`]
2826
+ * returns JSON `null`; a `Float64Array` has no `null`, so this function
2827
+ * returns `Err` instead, with a message naming the columns it looked for.
2828
+ * @param {string} frame_json
2829
+ * @returns {Float64Array}
2830
+ */
2831
+ export function lammps_dump_cartesian_positions_f64(frame_json) {
2832
+ const ptr0 = passStringToWasm0(frame_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2833
+ const len0 = WASM_VECTOR_LEN;
2834
+ const ret = wasm.lammps_dump_cartesian_positions_f64(ptr0, len0);
2835
+ if (ret[2]) {
2836
+ throw takeFromExternrefTable0(ret[1]);
2837
+ }
2838
+ return takeFromExternrefTable0(ret[0]);
2839
+ }
2840
+
2841
+ /**
2842
+ * Real Cartesian positions for a LAMMPS dump frame (in the JSON shape
2843
+ * [`lammps_dump_frame_to_json_str`] returns), resolved by delegating
2844
+ * directly to [`chematic_mol::LammpsDumpFrame::cartesian_positions`] --
2845
+ * this function does not reimplement any part of the box-bounds or
2846
+ * scaled-coordinate math itself; that method is the single place this
2847
+ * crate gets the (orthogonal or triclinic) transform right, and every
2848
+ * WASM caller must go through it rather than re-deriving the transform in
2849
+ * JS (the same reasoning behind this crate's OpenDX fail-closed unit
2850
+ * handling and QCSchema's single Bohr<->Ångström conversion point).
2851
+ *
2852
+ * - `x y z` columns: passed straight through.
2853
+ * - `xs ys zs` columns: transformed through `frame.box_bounds` (including
2854
+ * the triclinic shear terms when a tilt is present).
2855
+ * - Neither present (including an `xu yu zu`-only frame -- "unwrapped" is
2856
+ * a materially different physical quantity from a scaled coordinate,
2857
+ * never resolved by this method): returns JSON `null`, not an error and
2858
+ * not an empty array, matching
2859
+ * [`chematic_mol::LammpsDumpFrame::cartesian_positions`]'s own
2860
+ * `Option` semantics exactly.
2861
+ *
2862
+ * Returns JSON `[[x,y,z],...]` on success, in the same atom order as
2863
+ * `frame.rows`. See [`lammps_dump_cartesian_positions_f64`] for a flat
2864
+ * `Float64Array` sibling -- note its `null` case becomes an `Err` there
2865
+ * instead, a disclosed, real API-shape difference (a typed array has no
2866
+ * `null`).
2867
+ * @param {string} frame_json
2868
+ * @returns {string}
2869
+ */
2870
+ export function lammps_dump_cartesian_positions_json(frame_json) {
2871
+ let deferred3_0;
2872
+ let deferred3_1;
2873
+ try {
2874
+ const ptr0 = passStringToWasm0(frame_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2875
+ const len0 = WASM_VECTOR_LEN;
2876
+ const ret = wasm.lammps_dump_cartesian_positions_json(ptr0, len0);
2877
+ var ptr2 = ret[0];
2878
+ var len2 = ret[1];
2879
+ if (ret[3]) {
2880
+ ptr2 = 0; len2 = 0;
2881
+ throw takeFromExternrefTable0(ret[2]);
2882
+ }
2883
+ deferred3_0 = ptr2;
2884
+ deferred3_1 = len2;
2885
+ return getStringFromWasm0(ptr2, len2);
2886
+ } finally {
2887
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2888
+ }
2889
+ }
2890
+
2891
+ /**
2892
+ * Parse a single LAMMPS dump/trajectory frame and return it as JSON:
2893
+ * `{"timestep":N,"num_atoms":N,
2894
+ * "box_bounds":{"lo":[x,y,z],"hi":[x,y,z],"tilt":[xy,xz,yz]|null},
2895
+ * "boundary_flags":["pp","pp","pp"],"column_names":[...],
2896
+ * "rows":[[...values, one per column_names entry...],...]}`.
2897
+ * `box_bounds` is already the resolved TRUE simulation box (the parser
2898
+ * applies [`chematic_mol::box_bounds_to_true`] internally before
2899
+ * `LammpsDumpFrame` is ever built) -- not the file's raw
2900
+ * `xlo_bound`/`xhi_bound`/... values. `rows` is the raw per-atom column
2901
+ * data as declared by `column_names`, which may be `x y z`
2902
+ * (already-Cartesian), `xs ys zs` (box-scaled), `xu yu zu` (unwrapped), or
2903
+ * any other dump-command column -- use
2904
+ * [`lammps_dump_cartesian_positions_json`] to resolve real Cartesian
2905
+ * positions from whichever convention is present, rather than
2906
+ * reimplementing that resolution/transform in JS.
2907
+ * @param {string} text
2908
+ * @returns {string}
2909
+ */
2910
+ export function lammps_dump_frame_to_json_str(text) {
2911
+ let deferred3_0;
2912
+ let deferred3_1;
2913
+ try {
2914
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2915
+ const len0 = WASM_VECTOR_LEN;
2916
+ const ret = wasm.lammps_dump_frame_to_json_str(ptr0, len0);
2917
+ var ptr2 = ret[0];
2918
+ var len2 = ret[1];
2919
+ if (ret[3]) {
2920
+ ptr2 = 0; len2 = 0;
2921
+ throw takeFromExternrefTable0(ret[2]);
2922
+ }
2923
+ deferred3_0 = ptr2;
2924
+ deferred3_1 = len2;
2925
+ return getStringFromWasm0(ptr2, len2);
2926
+ } finally {
2927
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2928
+ }
2929
+ }
2930
+
2931
+ /**
2932
+ * Flattens a LAMMPS dump frame's `rows` (JSON shape
2933
+ * [`lammps_dump_frame_to_json_str`] returns) into a single flat
2934
+ * `Float64Array`, row-major (atom 0's `column_names.len()` values, then
2935
+ * atom 1's, ...). The caller already has `column_names` from
2936
+ * [`lammps_dump_frame_to_json_str`] and can compute the row length
2937
+ * itself (`column_names.length`); no separate row-length accessor is
2938
+ * provided here.
2939
+ * @param {string} frame_json
2940
+ * @returns {Float64Array}
2941
+ */
2942
+ export function lammps_dump_rows_f64(frame_json) {
2943
+ const ptr0 = passStringToWasm0(frame_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2944
+ const len0 = WASM_VECTOR_LEN;
2945
+ const ret = wasm.lammps_dump_rows_f64(ptr0, len0);
2946
+ if (ret[2]) {
2947
+ throw takeFromExternrefTable0(ret[1]);
2948
+ }
2949
+ return takeFromExternrefTable0(ret[0]);
2950
+ }
2951
+
2952
+ /**
2953
+ * Parse every frame of a LAMMPS dump/trajectory file and return them as a
2954
+ * JSON array (same per-frame shape as [`lammps_dump_frame_to_json_str`]).
2955
+ *
2956
+ * This reads the whole input, parses it fully, and returns every frame at
2957
+ * once -- [`chematic_mol::LammpsDumpReader`]'s per-frame streaming
2958
+ * iteration (reading one frame at a time from a `BufRead` without holding
2959
+ * the whole trajectory in memory) has no natural equivalent across the
2960
+ * JS/WASM boundary in this first pass and is deliberately not exposed
2961
+ * here, not silently dropped: a JS caller with a truly large trajectory
2962
+ * that needs bounded memory should process it server-side instead.
2963
+ * @param {string} text
2964
+ * @returns {string}
2965
+ */
2966
+ export function lammps_trajectory_to_json(text) {
2967
+ let deferred3_0;
2968
+ let deferred3_1;
2969
+ try {
2970
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2971
+ const len0 = WASM_VECTOR_LEN;
2972
+ const ret = wasm.lammps_trajectory_to_json(ptr0, len0);
2973
+ var ptr2 = ret[0];
2974
+ var len2 = ret[1];
2975
+ if (ret[3]) {
2976
+ ptr2 = 0; len2 = 0;
2977
+ throw takeFromExternrefTable0(ret[2]);
2978
+ }
2979
+ deferred3_0 = ptr2;
2980
+ deferred3_1 = len2;
2981
+ return getStringFromWasm0(ptr2, len2);
2982
+ } finally {
2983
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2984
+ }
2985
+ }
2986
+
2707
2987
  /**
2708
2988
  * Return the largest fragment of `mol` (salt/solvent stripping).
2709
2989
  *
@@ -3003,6 +3283,66 @@ export function minimize_uff_json(smiles, coords_json, max_iter) {
3003
3283
  }
3004
3284
  }
3005
3285
 
3286
+ /**
3287
+ * Cartesian coordinates from an mmCIF file, in the SAME atom order
3288
+ * [`mol_from_mmcif`] returns topology for. Returns JSON `[[x,y,z],...]`
3289
+ * (Å).
3290
+ * @param {string} text
3291
+ * @returns {string}
3292
+ */
3293
+ export function mmcif_coords_json(text) {
3294
+ let deferred3_0;
3295
+ let deferred3_1;
3296
+ try {
3297
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3298
+ const len0 = WASM_VECTOR_LEN;
3299
+ const ret = wasm.mmcif_coords_json(ptr0, len0);
3300
+ var ptr2 = ret[0];
3301
+ var len2 = ret[1];
3302
+ if (ret[3]) {
3303
+ ptr2 = 0; len2 = 0;
3304
+ throw takeFromExternrefTable0(ret[2]);
3305
+ }
3306
+ deferred3_0 = ptr2;
3307
+ deferred3_1 = len2;
3308
+ return getStringFromWasm0(ptr2, len2);
3309
+ } finally {
3310
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3311
+ }
3312
+ }
3313
+
3314
+ /**
3315
+ * Parse an mmCIF file and return every `_atom_site` field (occupancy,
3316
+ * B-factor, chain/residue bookkeeping, formal charge, model number, ...),
3317
+ * the unit cell, space group, and any loop column this reader saw but
3318
+ * does not model, as JSON: `{"atoms":[{...}],"cell":{...}|null,
3319
+ * "space_group":"..."|null,"unhandled_columns":[...]}`. See
3320
+ * [`chematic_mol::MmcifAtomRecord`]'s doc comment for each atom field's
3321
+ * exact source column and defaulting rule.
3322
+ * @param {string} text
3323
+ * @returns {string}
3324
+ */
3325
+ export function mmcif_to_json(text) {
3326
+ let deferred3_0;
3327
+ let deferred3_1;
3328
+ try {
3329
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3330
+ const len0 = WASM_VECTOR_LEN;
3331
+ const ret = wasm.mmcif_to_json(ptr0, len0);
3332
+ var ptr2 = ret[0];
3333
+ var len2 = ret[1];
3334
+ if (ret[3]) {
3335
+ ptr2 = 0; len2 = 0;
3336
+ throw takeFromExternrefTable0(ret[2]);
3337
+ }
3338
+ deferred3_0 = ptr2;
3339
+ deferred3_1 = len2;
3340
+ return getStringFromWasm0(ptr2, len2);
3341
+ } finally {
3342
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3343
+ }
3344
+ }
3345
+
3006
3346
  /**
3007
3347
  * MMFF94 partial charges (BCI table, ±0.1e accuracy) as a JSON array of f64.
3008
3348
  *
@@ -3321,6 +3661,24 @@ export function mol_from_cml(cml) {
3321
3661
  return MolHandle.__wrap(ret[0]);
3322
3662
  }
3323
3663
 
3664
+ /**
3665
+ * Parse a Gaussian Cube file and return a `MolHandle` (topology only --
3666
+ * element list, no bonds; Cube carries no bond table). Use
3667
+ * [`cube_grid_json`] to recover coordinates, the scalar field, and the
3668
+ * grid geometry.
3669
+ * @param {string} text
3670
+ * @returns {MolHandle}
3671
+ */
3672
+ export function mol_from_cube(text) {
3673
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3674
+ const len0 = WASM_VECTOR_LEN;
3675
+ const ret = wasm.mol_from_cube(ptr0, len0);
3676
+ if (ret[2]) {
3677
+ throw takeFromExternrefTable0(ret[1]);
3678
+ }
3679
+ return MolHandle.__wrap(ret[0]);
3680
+ }
3681
+
3324
3682
  /**
3325
3683
  * Parse an Extended XYZ (extxyz) frame and return a `MolHandle` (topology +
3326
3684
  * element/position only; use [`extxyz_frame_json`] to recover coordinates,
@@ -3344,6 +3702,25 @@ export function mol_from_extxyz(text) {
3344
3702
  return MolHandle.__wrap(ret[0]);
3345
3703
  }
3346
3704
 
3705
+ /**
3706
+ * Parse an mmCIF file and return a `MolHandle` (topology only -- element
3707
+ * list, no bonds; mmCIF's `_atom_site` category carries no connectivity).
3708
+ * Includes every model's atoms if the file has more than one -- use
3709
+ * [`mmcif_to_json`] to get each atom's `model_num` for filtering. Use
3710
+ * [`mmcif_coords_json`] to recover coordinates in the same atom order.
3711
+ * @param {string} text
3712
+ * @returns {MolHandle}
3713
+ */
3714
+ export function mol_from_mmcif(text) {
3715
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3716
+ const len0 = WASM_VECTOR_LEN;
3717
+ const ret = wasm.mol_from_mmcif(ptr0, len0);
3718
+ if (ret[2]) {
3719
+ throw takeFromExternrefTable0(ret[1]);
3720
+ }
3721
+ return MolHandle.__wrap(ret[0]);
3722
+ }
3723
+
3347
3724
  /**
3348
3725
  * Parse a MolJSON string into a `MolHandle`.
3349
3726
  *
@@ -3362,6 +3739,28 @@ export function mol_from_moljson(json) {
3362
3739
  return MolHandle.__wrap(ret[0]);
3363
3740
  }
3364
3741
 
3742
+ /**
3743
+ * Parse an ORCA input file (`.inp`) and return a `MolHandle` (topology
3744
+ * only -- element list, no bonds; ORCA input carries no bond table).
3745
+ * Returns a JS error unless the file's coordinate block is an embedded
3746
+ * `* xyz ... *` block -- `xyzfile`/`gzmtfile`/`int` (Z-matrix) blocks
3747
+ * carry no atom list to convert, or none is present at all. Use
3748
+ * [`orca_input_coords_json`] to recover coordinates + charge +
3749
+ * multiplicity in the same atom order, or [`orca_input_to_json`] for the
3750
+ * full input (comments/keywords/blocks/any coordinate-block kind).
3751
+ * @param {string} text
3752
+ * @returns {MolHandle}
3753
+ */
3754
+ export function mol_from_orca_input(text) {
3755
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3756
+ const len0 = WASM_VECTOR_LEN;
3757
+ const ret = wasm.mol_from_orca_input(ptr0, len0);
3758
+ if (ret[2]) {
3759
+ throw takeFromExternrefTable0(ret[1]);
3760
+ }
3761
+ return MolHandle.__wrap(ret[0]);
3762
+ }
3763
+
3365
3764
  /**
3366
3765
  * Parse a PDB file and return a `MolHandle` (topology only; coordinates are
3367
3766
  * discarded -- use [`pdb_coords_json`] to recover them in the SAME atom
@@ -3380,6 +3779,44 @@ export function mol_from_pdb(pdb) {
3380
3779
  return MolHandle.__wrap(ret);
3381
3780
  }
3382
3781
 
3782
+ /**
3783
+ * Parse a PQR file and return a `MolHandle` (topology only -- element
3784
+ * list inferred per-atom, no bonds; PQR carries no connectivity). Use
3785
+ * [`pqr_coords_json`] to recover coordinates in the same atom order.
3786
+ * @param {string} text
3787
+ * @returns {MolHandle}
3788
+ */
3789
+ export function mol_from_pqr(text) {
3790
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3791
+ const len0 = WASM_VECTOR_LEN;
3792
+ const ret = wasm.mol_from_pqr(ptr0, len0);
3793
+ if (ret[2]) {
3794
+ throw takeFromExternrefTable0(ret[1]);
3795
+ }
3796
+ return MolHandle.__wrap(ret[0]);
3797
+ }
3798
+
3799
+ /**
3800
+ * Parse a QCSchema `qcschema_molecule` JSON document and return a
3801
+ * `MolHandle` (topology + `atomic_numbers`-derived isotopes -- no bonds
3802
+ * unless the document's optional `connectivity` list is present, in which
3803
+ * case those bond orders are mapped onto the nearest
3804
+ * [`chematic_core::BondOrder`]). Use [`qcschema_molecule_coords_json`] to
3805
+ * recover coordinates (converted Bohr -> Å) plus molecular
3806
+ * charge/multiplicity, in the same atom order.
3807
+ * @param {string} json
3808
+ * @returns {MolHandle}
3809
+ */
3810
+ export function mol_from_qcschema_molecule(json) {
3811
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3812
+ const len0 = WASM_VECTOR_LEN;
3813
+ const ret = wasm.mol_from_qcschema_molecule(ptr0, len0);
3814
+ if (ret[2]) {
3815
+ throw takeFromExternrefTable0(ret[1]);
3816
+ }
3817
+ return MolHandle.__wrap(ret[0]);
3818
+ }
3819
+
3383
3820
  /**
3384
3821
  * Parse a MOL V2000 block and return a `MolHandle`.
3385
3822
  *
@@ -3766,6 +4203,162 @@ export function normalize_reaction_smiles(rxn_smiles) {
3766
4203
  }
3767
4204
  }
3768
4205
 
4206
+ /**
4207
+ * Parse an OpenDX (APBS scalar-field subset) file and return its full
4208
+ * [`chematic_mol::VolumetricGrid`] as JSON (same shape as
4209
+ * [`cube_grid_json`]; `atoms` is always empty -- OpenDX has no atom
4210
+ * section). No `mol_from_opendx` is provided: an OpenDX grid never carries
4211
+ * atoms, so a `MolHandle` from one would always be empty and is not a
4212
+ * useful binding.
4213
+ * @param {string} text
4214
+ * @returns {string}
4215
+ */
4216
+ export function opendx_grid_json(text) {
4217
+ let deferred3_0;
4218
+ let deferred3_1;
4219
+ try {
4220
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4221
+ const len0 = WASM_VECTOR_LEN;
4222
+ const ret = wasm.opendx_grid_json(ptr0, len0);
4223
+ var ptr2 = ret[0];
4224
+ var len2 = ret[1];
4225
+ if (ret[3]) {
4226
+ ptr2 = 0; len2 = 0;
4227
+ throw takeFromExternrefTable0(ret[2]);
4228
+ }
4229
+ deferred3_0 = ptr2;
4230
+ deferred3_1 = len2;
4231
+ return getStringFromWasm0(ptr2, len2);
4232
+ } finally {
4233
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4234
+ }
4235
+ }
4236
+
4237
+ /**
4238
+ * `[nx, ny, nz]` for an OpenDX file's grid, as a `Uint32Array`.
4239
+ * @param {string} text
4240
+ * @returns {Uint32Array}
4241
+ */
4242
+ export function opendx_shape_u32(text) {
4243
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4244
+ const len0 = WASM_VECTOR_LEN;
4245
+ const ret = wasm.opendx_shape_u32(ptr0, len0);
4246
+ if (ret[2]) {
4247
+ throw takeFromExternrefTable0(ret[1]);
4248
+ }
4249
+ return takeFromExternrefTable0(ret[0]);
4250
+ }
4251
+
4252
+ /**
4253
+ * Flat `values` from an OpenDX file's grid, as a `Float64Array` -- same
4254
+ * data [`opendx_grid_json`]'s `"values"` field carries.
4255
+ * @param {string} text
4256
+ * @returns {Float64Array}
4257
+ */
4258
+ export function opendx_values_f64(text) {
4259
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4260
+ const len0 = WASM_VECTOR_LEN;
4261
+ const ret = wasm.opendx_values_f64(ptr0, len0);
4262
+ if (ret[2]) {
4263
+ throw takeFromExternrefTable0(ret[1]);
4264
+ }
4265
+ return takeFromExternrefTable0(ret[0]);
4266
+ }
4267
+
4268
+ /**
4269
+ * Coordinates + charge + multiplicity from an ORCA input file's embedded
4270
+ * `* xyz ... *` block, in the SAME atom order [`mol_from_orca_input`]
4271
+ * returns topology for. Returns JSON
4272
+ * `{"coords":[[x,y,z],...],"charge":0,"multiplicity":1}`, or a JS error
4273
+ * under the same conditions as [`mol_from_orca_input`].
4274
+ * @param {string} text
4275
+ * @returns {string}
4276
+ */
4277
+ export function orca_input_coords_json(text) {
4278
+ let deferred3_0;
4279
+ let deferred3_1;
4280
+ try {
4281
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4282
+ const len0 = WASM_VECTOR_LEN;
4283
+ const ret = wasm.orca_input_coords_json(ptr0, len0);
4284
+ var ptr2 = ret[0];
4285
+ var len2 = ret[1];
4286
+ if (ret[3]) {
4287
+ ptr2 = 0; len2 = 0;
4288
+ throw takeFromExternrefTable0(ret[2]);
4289
+ }
4290
+ deferred3_0 = ptr2;
4291
+ deferred3_1 = len2;
4292
+ return getStringFromWasm0(ptr2, len2);
4293
+ } finally {
4294
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4295
+ }
4296
+ }
4297
+
4298
+ /**
4299
+ * Parse an ORCA input file and return every field as JSON:
4300
+ * `{"comments":[...],"keywords":[...],
4301
+ * "blocks":[{"name":"scf","raw":"...","has_end":true},...],
4302
+ * "coords":{"type":"xyz"|"xyzfile"|"gzmtfile"|"internal",...}|null}`.
4303
+ * See [`chematic_mol::OrcaInput`]'s doc comment for each field's meaning.
4304
+ * @param {string} text
4305
+ * @returns {string}
4306
+ */
4307
+ export function orca_input_to_json(text) {
4308
+ let deferred3_0;
4309
+ let deferred3_1;
4310
+ try {
4311
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4312
+ const len0 = WASM_VECTOR_LEN;
4313
+ const ret = wasm.orca_input_to_json(ptr0, len0);
4314
+ var ptr2 = ret[0];
4315
+ var len2 = ret[1];
4316
+ if (ret[3]) {
4317
+ ptr2 = 0; len2 = 0;
4318
+ throw takeFromExternrefTable0(ret[2]);
4319
+ }
4320
+ deferred3_0 = ptr2;
4321
+ deferred3_1 = len2;
4322
+ return getStringFromWasm0(ptr2, len2);
4323
+ } finally {
4324
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4325
+ }
4326
+ }
4327
+
4328
+ /**
4329
+ * Parse an ORCA output file (`.out`/`.log`) and return every extracted
4330
+ * field as JSON: `{"charge":N|null,"multiplicity":N|null,
4331
+ * "final_energy_hartree":N|null,
4332
+ * "trajectory":[{"elements":[...],"coords":[[x,y,z],...]},...],
4333
+ * "frequencies_cm1":[...],
4334
+ * "termination":{"kind":"normal"|"error"|"incomplete","detail":"..."?},
4335
+ * "optimization_convergence":"not_requested"|"converged"|"not_converged"|"unknown"}`.
4336
+ * No writer is provided -- an ORCA output file is a job log, not a
4337
+ * document this crate constructs.
4338
+ * @param {string} text
4339
+ * @returns {string}
4340
+ */
4341
+ export function orca_output_to_json(text) {
4342
+ let deferred3_0;
4343
+ let deferred3_1;
4344
+ try {
4345
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4346
+ const len0 = WASM_VECTOR_LEN;
4347
+ const ret = wasm.orca_output_to_json(ptr0, len0);
4348
+ var ptr2 = ret[0];
4349
+ var len2 = ret[1];
4350
+ if (ret[3]) {
4351
+ ptr2 = 0; len2 = 0;
4352
+ throw takeFromExternrefTable0(ret[2]);
4353
+ }
4354
+ deferred3_0 = ptr2;
4355
+ deferred3_1 = len2;
4356
+ return getStringFromWasm0(ptr2, len2);
4357
+ } finally {
4358
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4359
+ }
4360
+ }
4361
+
3769
4362
  /**
3770
4363
  * PAINS structural alert names matched by `mol` as a JSON array.
3771
4364
  *
@@ -3970,6 +4563,86 @@ export function pharmacophore_fp_3d_summary(mol) {
3970
4563
  }
3971
4564
  }
3972
4565
 
4566
+ /**
4567
+ * Cartesian coordinates from a PQR file, in the SAME atom order
4568
+ * [`mol_from_pqr`] returns topology for. Returns JSON `[[x,y,z],...]` (Å).
4569
+ * @param {string} text
4570
+ * @returns {string}
4571
+ */
4572
+ export function pqr_coords_json(text) {
4573
+ let deferred3_0;
4574
+ let deferred3_1;
4575
+ try {
4576
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4577
+ const len0 = WASM_VECTOR_LEN;
4578
+ const ret = wasm.pqr_coords_json(ptr0, len0);
4579
+ var ptr2 = ret[0];
4580
+ var len2 = ret[1];
4581
+ if (ret[3]) {
4582
+ ptr2 = 0; len2 = 0;
4583
+ throw takeFromExternrefTable0(ret[2]);
4584
+ }
4585
+ deferred3_0 = ptr2;
4586
+ deferred3_1 = len2;
4587
+ return getStringFromWasm0(ptr2, len2);
4588
+ } finally {
4589
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4590
+ }
4591
+ }
4592
+
4593
+ /**
4594
+ * Infer an element from a PQR atom name (see
4595
+ * [`chematic_mol::infer_element`]'s doc comment for the heuristic).
4596
+ * Returns `undefined` (JS) / `None` if no element could be inferred.
4597
+ * @param {string} group_pdb
4598
+ * @param {string} res_name
4599
+ * @param {string} atom_name
4600
+ * @returns {string | undefined}
4601
+ */
4602
+ export function pqr_infer_element(group_pdb, res_name, atom_name) {
4603
+ const ptr0 = passStringToWasm0(group_pdb, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4604
+ const len0 = WASM_VECTOR_LEN;
4605
+ const ptr1 = passStringToWasm0(res_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4606
+ const len1 = WASM_VECTOR_LEN;
4607
+ const ptr2 = passStringToWasm0(atom_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4608
+ const len2 = WASM_VECTOR_LEN;
4609
+ const ret = wasm.pqr_infer_element(ptr0, len0, ptr1, len1, ptr2, len2);
4610
+ let v4;
4611
+ if (ret[0] !== 0) {
4612
+ v4 = getStringFromWasm0(ret[0], ret[1]);
4613
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
4614
+ }
4615
+ return v4;
4616
+ }
4617
+
4618
+ /**
4619
+ * Parse a PQR file and return every field (charge, radius, chain,
4620
+ * residue, inferred element, ...) as JSON: `{"atoms":[{...}]}`. See
4621
+ * [`chematic_mol::PqrAtomRecord`]'s doc comment for each field's meaning.
4622
+ * @param {string} text
4623
+ * @returns {string}
4624
+ */
4625
+ export function pqr_to_json(text) {
4626
+ let deferred3_0;
4627
+ let deferred3_1;
4628
+ try {
4629
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4630
+ const len0 = WASM_VECTOR_LEN;
4631
+ const ret = wasm.pqr_to_json(ptr0, len0);
4632
+ var ptr2 = ret[0];
4633
+ var len2 = ret[1];
4634
+ if (ret[3]) {
4635
+ ptr2 = 0; len2 = 0;
4636
+ throw takeFromExternrefTable0(ret[2]);
4637
+ }
4638
+ deferred3_0 = ptr2;
4639
+ deferred3_1 = len2;
4640
+ return getStringFromWasm0(ptr2, len2);
4641
+ } finally {
4642
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4643
+ }
4644
+ }
4645
+
3973
4646
  /**
3974
4647
  * Predict pKa for all ionizable sites in a molecule.
3975
4648
  *
@@ -3994,6 +4667,97 @@ export function predict_pka_json(smiles) {
3994
4667
  }
3995
4668
  }
3996
4669
 
4670
+ /**
4671
+ * Coordinates (Å) plus molecular charge/multiplicity from a QCSchema
4672
+ * `qcschema_molecule` document, in the SAME atom order
4673
+ * [`mol_from_qcschema_molecule`] returns topology for. Returns JSON
4674
+ * `{"coords":[[x,y,z],...],"molecular_charge":0.0,"molecular_multiplicity":1}`.
4675
+ * @param {string} json
4676
+ * @returns {string}
4677
+ */
4678
+ export function qcschema_molecule_coords_json(json) {
4679
+ let deferred3_0;
4680
+ let deferred3_1;
4681
+ try {
4682
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4683
+ const len0 = WASM_VECTOR_LEN;
4684
+ const ret = wasm.qcschema_molecule_coords_json(ptr0, len0);
4685
+ var ptr2 = ret[0];
4686
+ var len2 = ret[1];
4687
+ if (ret[3]) {
4688
+ ptr2 = 0; len2 = 0;
4689
+ throw takeFromExternrefTable0(ret[2]);
4690
+ }
4691
+ deferred3_0 = ptr2;
4692
+ deferred3_1 = len2;
4693
+ return getStringFromWasm0(ptr2, len2);
4694
+ } finally {
4695
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4696
+ }
4697
+ }
4698
+
4699
+ /**
4700
+ * Parse a QCSchema `qcschema_input`/`qc_schema_input` JSON document
4701
+ * (molecule + driver + model + keywords) and re-emit it, validating and
4702
+ * canonicalizing field defaults in the process (e.g. a missing
4703
+ * `schema_name`/`schema_version` is filled in). Job-level fields
4704
+ * (`driver`, `model`, `keywords`, `protocols`, `extras`) are round-tripped
4705
+ * opaquely -- this binding validates/reformats the document; it does not
4706
+ * expose a separate JS-facing accessor for each field (out of scope for
4707
+ * this first pass, see module docs' "None of these formats carry a bond
4708
+ * table" section for the analogous molecule-centric scope choice made
4709
+ * elsewhere in this file).
4710
+ * @param {string} json
4711
+ * @returns {string}
4712
+ */
4713
+ export function qcschema_validate_atomic_input(json) {
4714
+ let deferred3_0;
4715
+ let deferred3_1;
4716
+ try {
4717
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4718
+ const len0 = WASM_VECTOR_LEN;
4719
+ const ret = wasm.qcschema_validate_atomic_input(ptr0, len0);
4720
+ var ptr2 = ret[0];
4721
+ var len2 = ret[1];
4722
+ if (ret[3]) {
4723
+ ptr2 = 0; len2 = 0;
4724
+ throw takeFromExternrefTable0(ret[2]);
4725
+ }
4726
+ deferred3_0 = ptr2;
4727
+ deferred3_1 = len2;
4728
+ return getStringFromWasm0(ptr2, len2);
4729
+ } finally {
4730
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4731
+ }
4732
+ }
4733
+
4734
+ /**
4735
+ * Like [`qcschema_validate_atomic_input`], for a QCSchema
4736
+ * `qcschema_output`/`qc_schema_output` (`AtomicResult`) document.
4737
+ * @param {string} json
4738
+ * @returns {string}
4739
+ */
4740
+ export function qcschema_validate_atomic_result(json) {
4741
+ let deferred3_0;
4742
+ let deferred3_1;
4743
+ try {
4744
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4745
+ const len0 = WASM_VECTOR_LEN;
4746
+ const ret = wasm.qcschema_validate_atomic_result(ptr0, len0);
4747
+ var ptr2 = ret[0];
4748
+ var len2 = ret[1];
4749
+ if (ret[3]) {
4750
+ ptr2 = 0; len2 = 0;
4751
+ throw takeFromExternrefTable0(ret[2]);
4752
+ }
4753
+ deferred3_0 = ptr2;
4754
+ deferred3_1 = len2;
4755
+ return getStringFromWasm0(ptr2, len2);
4756
+ } finally {
4757
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
4758
+ }
4759
+ }
4760
+
3997
4761
  /**
3998
4762
  * Generate `count` random SMILES from a SMILES string using the given seed.
3999
4763
  * Atoms are permuted based on xorshift64 RNG. Each variant should parse back
@@ -5134,6 +5898,41 @@ export function to_moljson(mol) {
5134
5898
  }
5135
5899
  }
5136
5900
 
5901
+ /**
5902
+ * Serialize a `MolHandle` + coordinates (Å) + molecular charge/multiplicity
5903
+ * as a QCSchema `qcschema_molecule` JSON document (coordinates converted
5904
+ * to Bohr).
5905
+ *
5906
+ * `coords_json`: `[[x,y,z],...]` (Å), same order and length as `mol`'s
5907
+ * atoms.
5908
+ * @param {MolHandle} mol
5909
+ * @param {string} coords_json
5910
+ * @param {number} charge
5911
+ * @param {bigint} multiplicity
5912
+ * @returns {string}
5913
+ */
5914
+ export function to_qcschema_molecule_json(mol, coords_json, charge, multiplicity) {
5915
+ let deferred3_0;
5916
+ let deferred3_1;
5917
+ try {
5918
+ _assertClass(mol, MolHandle);
5919
+ const ptr0 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5920
+ const len0 = WASM_VECTOR_LEN;
5921
+ const ret = wasm.to_qcschema_molecule_json(mol.__wbg_ptr, ptr0, len0, charge, multiplicity);
5922
+ var ptr2 = ret[0];
5923
+ var len2 = ret[1];
5924
+ if (ret[3]) {
5925
+ ptr2 = 0; len2 = 0;
5926
+ throw takeFromExternrefTable0(ret[2]);
5927
+ }
5928
+ deferred3_0 = ptr2;
5929
+ deferred3_1 = len2;
5930
+ return getStringFromWasm0(ptr2, len2);
5931
+ } finally {
5932
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
5933
+ }
5934
+ }
5935
+
5137
5936
  /**
5138
5937
  * Serialize a molecule to XYZ format.
5139
5938
  *
@@ -5241,6 +6040,274 @@ export function whim_getaway_combined_json(mol) {
5241
6040
  }
5242
6041
  }
5243
6042
 
6043
+ /**
6044
+ * Write a grid (in the JSON shape [`cube_grid_json`] returns) as a
6045
+ * Gaussian Cube file.
6046
+ * @param {string} grid_json
6047
+ * @returns {string}
6048
+ */
6049
+ export function write_cube_json(grid_json) {
6050
+ let deferred3_0;
6051
+ let deferred3_1;
6052
+ try {
6053
+ const ptr0 = passStringToWasm0(grid_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6054
+ const len0 = WASM_VECTOR_LEN;
6055
+ const ret = wasm.write_cube_json(ptr0, len0);
6056
+ var ptr2 = ret[0];
6057
+ var len2 = ret[1];
6058
+ if (ret[3]) {
6059
+ ptr2 = 0; len2 = 0;
6060
+ throw takeFromExternrefTable0(ret[2]);
6061
+ }
6062
+ deferred3_0 = ptr2;
6063
+ deferred3_1 = len2;
6064
+ return getStringFromWasm0(ptr2, len2);
6065
+ } finally {
6066
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6067
+ }
6068
+ }
6069
+
6070
+ /**
6071
+ * Write a LAMMPS data file from the JSON shape [`lammps_data_to_json`]
6072
+ * returns.
6073
+ * @param {string} json
6074
+ * @returns {string}
6075
+ */
6076
+ export function write_lammps_data_json(json) {
6077
+ let deferred3_0;
6078
+ let deferred3_1;
6079
+ try {
6080
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6081
+ const len0 = WASM_VECTOR_LEN;
6082
+ const ret = wasm.write_lammps_data_json(ptr0, len0);
6083
+ var ptr2 = ret[0];
6084
+ var len2 = ret[1];
6085
+ if (ret[3]) {
6086
+ ptr2 = 0; len2 = 0;
6087
+ throw takeFromExternrefTable0(ret[2]);
6088
+ }
6089
+ deferred3_0 = ptr2;
6090
+ deferred3_1 = len2;
6091
+ return getStringFromWasm0(ptr2, len2);
6092
+ } finally {
6093
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6094
+ }
6095
+ }
6096
+
6097
+ /**
6098
+ * Write a single LAMMPS dump frame from the JSON shape
6099
+ * [`lammps_dump_frame_to_json_str`] returns.
6100
+ * @param {string} json
6101
+ * @returns {string}
6102
+ */
6103
+ export function write_lammps_dump_frame_json(json) {
6104
+ let deferred3_0;
6105
+ let deferred3_1;
6106
+ try {
6107
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6108
+ const len0 = WASM_VECTOR_LEN;
6109
+ const ret = wasm.write_lammps_dump_frame_json(ptr0, len0);
6110
+ var ptr2 = ret[0];
6111
+ var len2 = ret[1];
6112
+ if (ret[3]) {
6113
+ ptr2 = 0; len2 = 0;
6114
+ throw takeFromExternrefTable0(ret[2]);
6115
+ }
6116
+ deferred3_0 = ptr2;
6117
+ deferred3_1 = len2;
6118
+ return getStringFromWasm0(ptr2, len2);
6119
+ } finally {
6120
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6121
+ }
6122
+ }
6123
+
6124
+ /**
6125
+ * Write a LAMMPS trajectory (N frames concatenated back to back, matching
6126
+ * [`chematic_mol::write_lammps_trajectory`]) from a JSON array of frames
6127
+ * in the shape [`lammps_dump_frame_to_json_str`] returns.
6128
+ * @param {string} json
6129
+ * @returns {string}
6130
+ */
6131
+ export function write_lammps_trajectory_json(json) {
6132
+ let deferred3_0;
6133
+ let deferred3_1;
6134
+ try {
6135
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6136
+ const len0 = WASM_VECTOR_LEN;
6137
+ const ret = wasm.write_lammps_trajectory_json(ptr0, len0);
6138
+ var ptr2 = ret[0];
6139
+ var len2 = ret[1];
6140
+ if (ret[3]) {
6141
+ ptr2 = 0; len2 = 0;
6142
+ throw takeFromExternrefTable0(ret[2]);
6143
+ }
6144
+ deferred3_0 = ptr2;
6145
+ deferred3_1 = len2;
6146
+ return getStringFromWasm0(ptr2, len2);
6147
+ } finally {
6148
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6149
+ }
6150
+ }
6151
+
6152
+ /**
6153
+ * Write an mmCIF file from atom records in the JSON shape
6154
+ * [`mmcif_to_json`]'s `"atoms"` array uses (a full record per atom, not
6155
+ * just element+coordinates -- mmCIF has no equivalent of "build from a
6156
+ * bare `MolHandle`", since occupancy/B-factor/chain/residue fields have no
6157
+ * source in a plain [`MolHandle`]).
6158
+ *
6159
+ * `cell_json`: `"null"` or `{"a":...,"b":...,"c":...,"alpha":...,"beta":...,"gamma":...}`.
6160
+ * `space_group`: pass `""` for none.
6161
+ * @param {string} records_json
6162
+ * @param {string} cell_json
6163
+ * @param {string} space_group
6164
+ * @param {string} data_block_name
6165
+ * @returns {string}
6166
+ */
6167
+ export function write_mmcif_json(records_json, cell_json, space_group, data_block_name) {
6168
+ let deferred6_0;
6169
+ let deferred6_1;
6170
+ try {
6171
+ const ptr0 = passStringToWasm0(records_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6172
+ const len0 = WASM_VECTOR_LEN;
6173
+ const ptr1 = passStringToWasm0(cell_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6174
+ const len1 = WASM_VECTOR_LEN;
6175
+ const ptr2 = passStringToWasm0(space_group, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6176
+ const len2 = WASM_VECTOR_LEN;
6177
+ const ptr3 = passStringToWasm0(data_block_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6178
+ const len3 = WASM_VECTOR_LEN;
6179
+ const ret = wasm.write_mmcif_json(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
6180
+ var ptr5 = ret[0];
6181
+ var len5 = ret[1];
6182
+ if (ret[3]) {
6183
+ ptr5 = 0; len5 = 0;
6184
+ throw takeFromExternrefTable0(ret[2]);
6185
+ }
6186
+ deferred6_0 = ptr5;
6187
+ deferred6_1 = len5;
6188
+ return getStringFromWasm0(ptr5, len5);
6189
+ } finally {
6190
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
6191
+ }
6192
+ }
6193
+
6194
+ /**
6195
+ * Write a grid as an OpenDX file. Fails closed for a
6196
+ * [`chematic_mol::GridUnits::Bohr`]-tagged grid (OpenDX has no unit tag of
6197
+ * its own and is universally read back as Ångström -- see
6198
+ * `chematic_mol::opendx`'s module docs) and for a grid carrying any atoms
6199
+ * (OpenDX has no atom section). Use [`write_opendx_lossy_json`] to opt
6200
+ * into an explicit Bohr->Ångström conversion instead of failing.
6201
+ * @param {string} grid_json
6202
+ * @returns {string}
6203
+ */
6204
+ export function write_opendx_json(grid_json) {
6205
+ let deferred3_0;
6206
+ let deferred3_1;
6207
+ try {
6208
+ const ptr0 = passStringToWasm0(grid_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6209
+ const len0 = WASM_VECTOR_LEN;
6210
+ const ret = wasm.write_opendx_json(ptr0, len0);
6211
+ var ptr2 = ret[0];
6212
+ var len2 = ret[1];
6213
+ if (ret[3]) {
6214
+ ptr2 = 0; len2 = 0;
6215
+ throw takeFromExternrefTable0(ret[2]);
6216
+ }
6217
+ deferred3_0 = ptr2;
6218
+ deferred3_1 = len2;
6219
+ return getStringFromWasm0(ptr2, len2);
6220
+ } finally {
6221
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6222
+ }
6223
+ }
6224
+
6225
+ /**
6226
+ * Like [`write_opendx_json`], but a [`chematic_mol::GridUnits::Bohr`] grid
6227
+ * has its `origin`/`axes` explicitly converted to Ångström rather than
6228
+ * rejected (`values` -- the scalar-field samples themselves -- are never
6229
+ * rescaled; see `write_opendx_lossy`'s doc comment). Still fails for a
6230
+ * grid carrying any atoms.
6231
+ * @param {string} grid_json
6232
+ * @returns {string}
6233
+ */
6234
+ export function write_opendx_lossy_json(grid_json) {
6235
+ let deferred3_0;
6236
+ let deferred3_1;
6237
+ try {
6238
+ const ptr0 = passStringToWasm0(grid_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6239
+ const len0 = WASM_VECTOR_LEN;
6240
+ const ret = wasm.write_opendx_lossy_json(ptr0, len0);
6241
+ var ptr2 = ret[0];
6242
+ var len2 = ret[1];
6243
+ if (ret[3]) {
6244
+ ptr2 = 0; len2 = 0;
6245
+ throw takeFromExternrefTable0(ret[2]);
6246
+ }
6247
+ deferred3_0 = ptr2;
6248
+ deferred3_1 = len2;
6249
+ return getStringFromWasm0(ptr2, len2);
6250
+ } finally {
6251
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6252
+ }
6253
+ }
6254
+
6255
+ /**
6256
+ * Write an ORCA input file from the JSON shape [`orca_input_to_json`]
6257
+ * returns.
6258
+ * @param {string} json
6259
+ * @returns {string}
6260
+ */
6261
+ export function write_orca_input_json(json) {
6262
+ let deferred3_0;
6263
+ let deferred3_1;
6264
+ try {
6265
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6266
+ const len0 = WASM_VECTOR_LEN;
6267
+ const ret = wasm.write_orca_input_json(ptr0, len0);
6268
+ var ptr2 = ret[0];
6269
+ var len2 = ret[1];
6270
+ if (ret[3]) {
6271
+ ptr2 = 0; len2 = 0;
6272
+ throw takeFromExternrefTable0(ret[2]);
6273
+ }
6274
+ deferred3_0 = ptr2;
6275
+ deferred3_1 = len2;
6276
+ return getStringFromWasm0(ptr2, len2);
6277
+ } finally {
6278
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6279
+ }
6280
+ }
6281
+
6282
+ /**
6283
+ * Write a PQR file from atom records in the JSON shape [`pqr_to_json`]'s
6284
+ * `"atoms"` array uses. Each atom's `chain_id` independently controls
6285
+ * whether that line is written with or without the (optional) chain
6286
+ * column.
6287
+ * @param {string} records_json
6288
+ * @returns {string}
6289
+ */
6290
+ export function write_pqr_json(records_json) {
6291
+ let deferred3_0;
6292
+ let deferred3_1;
6293
+ try {
6294
+ const ptr0 = passStringToWasm0(records_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6295
+ const len0 = WASM_VECTOR_LEN;
6296
+ const ret = wasm.write_pqr_json(ptr0, len0);
6297
+ var ptr2 = ret[0];
6298
+ var len2 = ret[1];
6299
+ if (ret[3]) {
6300
+ ptr2 = 0; len2 = 0;
6301
+ throw takeFromExternrefTable0(ret[2]);
6302
+ }
6303
+ deferred3_0 = ptr2;
6304
+ deferred3_1 = len2;
6305
+ return getStringFromWasm0(ptr2, len2);
6306
+ } finally {
6307
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
6308
+ }
6309
+ }
6310
+
5244
6311
  /**
5245
6312
  * Non-canonical SMILES for `mol`.
5246
6313
  *
@@ -5324,6 +6391,14 @@ function __wbg_get_imports() {
5324
6391
  __wbg_error_dd408a7b3cb542dd: function(arg0) {
5325
6392
  console.error(arg0);
5326
6393
  },
6394
+ __wbg_new_from_slice_8aed4f0384605526: function(arg0, arg1) {
6395
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
6396
+ return ret;
6397
+ },
6398
+ __wbg_new_from_slice_f6e95bc2809a2b07: function(arg0, arg1) {
6399
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
6400
+ return ret;
6401
+ },
5327
6402
  __wbg_now_e7c6795a7f81e10f: function(arg0) {
5328
6403
  const ret = arg0.now();
5329
6404
  return ret;
@@ -5399,6 +6474,16 @@ function _assertClass(instance, klass) {
5399
6474
  }
5400
6475
  }
5401
6476
 
6477
+ function getArrayF64FromWasm0(ptr, len) {
6478
+ ptr = ptr >>> 0;
6479
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
6480
+ }
6481
+
6482
+ function getArrayU32FromWasm0(ptr, len) {
6483
+ ptr = ptr >>> 0;
6484
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
6485
+ }
6486
+
5402
6487
  function getArrayU8FromWasm0(ptr, len) {
5403
6488
  ptr = ptr >>> 0;
5404
6489
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -5412,6 +6497,14 @@ function getDataViewMemory0() {
5412
6497
  return cachedDataViewMemory0;
5413
6498
  }
5414
6499
 
6500
+ let cachedFloat64ArrayMemory0 = null;
6501
+ function getFloat64ArrayMemory0() {
6502
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
6503
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
6504
+ }
6505
+ return cachedFloat64ArrayMemory0;
6506
+ }
6507
+
5415
6508
  function getStringFromWasm0(ptr, len) {
5416
6509
  return decodeText(ptr >>> 0, len);
5417
6510
  }
@@ -5521,6 +6614,7 @@ function __wbg_finalize_init(instance, module) {
5521
6614
  wasm = instance.exports;
5522
6615
  wasmModule = module;
5523
6616
  cachedDataViewMemory0 = null;
6617
+ cachedFloat64ArrayMemory0 = null;
5524
6618
  cachedUint32ArrayMemory0 = null;
5525
6619
  cachedUint8ArrayMemory0 = null;
5526
6620
  wasm.__wbindgen_start();