@molcrafts/molrs 0.1.3 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/molrs.d.ts CHANGED
@@ -1726,6 +1726,39 @@ export class FrameIndexEntry {
1726
1726
  readonly byteOffset: number;
1727
1727
  }
1728
1728
 
1729
+ /**
1730
+ * GROMACS GRO structure / trajectory reader.
1731
+ *
1732
+ * GRO is a fixed-column text format for GROMACS structures and
1733
+ * single-precision trajectories. Multi-frame files expose each frame via
1734
+ * `read(step)`. Coordinates and box are GROMACS-native nm in the file and
1735
+ * are converted to angstrom on read (x10), matching every other molvis
1736
+ * reader. Each frame produces an `"atoms"` block (`resid`, `resname`,
1737
+ * `atom_name`, `atom_id`, `x`/`y`/`z`, optional `vx`/`vy`/`vz`) and a
1738
+ * `simbox` from the box-vector line.
1739
+ */
1740
+ export class GROReader {
1741
+ free(): void;
1742
+ [Symbol.dispose](): void;
1743
+ /**
1744
+ * Check whether the file contains no frames.
1745
+ */
1746
+ isEmpty(): boolean;
1747
+ /**
1748
+ * Return the number of frames in the GRO file.
1749
+ */
1750
+ len(): number;
1751
+ /**
1752
+ * Create a new GRO reader from a string containing the file content.
1753
+ */
1754
+ constructor(content: string);
1755
+ /**
1756
+ * Read the frame at the given step index (0-based). Coordinates are
1757
+ * converted nm -> angstrom before the frame is returned.
1758
+ */
1759
+ read(step: number): Frame | undefined;
1760
+ }
1761
+
1729
1762
  /**
1730
1763
  * Gyration tensor per cluster.
1731
1764
  *
@@ -1980,6 +2013,37 @@ export class LinkedCell {
1980
2013
  query(ref_frame: Frame, query_frame: Frame): NeighborList;
1981
2014
  }
1982
2015
 
2016
+ /**
2017
+ * Tripos MOL2 reader.
2018
+ *
2019
+ * MOL2 is a section-delimited (`@<TRIPOS>...`) text format. Multi-molecule
2020
+ * files expose each `MOLECULE` record as a frame via `read(step)`.
2021
+ * Coordinates are already in angstrom. Produces an `"atoms"` block (`id`,
2022
+ * `name`, `x`/`y`/`z`, `atom_type`, optional `subst_id`/`subst_name`/
2023
+ * `charge`) and, when present, a `"bonds"` block (`atomi`/`atomj` 0-based,
2024
+ * `bond_type`).
2025
+ */
2026
+ export class MOL2Reader {
2027
+ free(): void;
2028
+ [Symbol.dispose](): void;
2029
+ /**
2030
+ * Check whether the file contains no records.
2031
+ */
2032
+ isEmpty(): boolean;
2033
+ /**
2034
+ * Return the number of molecule records in the MOL2 file.
2035
+ */
2036
+ len(): number;
2037
+ /**
2038
+ * Create a new MOL2 reader from a string containing the file content.
2039
+ */
2040
+ constructor(content: string);
2041
+ /**
2042
+ * Read the molecule record at the given step index (0-based).
2043
+ */
2044
+ read(step: number): Frame | undefined;
2045
+ }
2046
+
1983
2047
  /**
1984
2048
  * Mean squared displacement (MSD) analysis.
1985
2049
  *
@@ -2264,6 +2328,37 @@ export class PDBReader {
2264
2328
  read(step: number): Frame | undefined;
2265
2329
  }
2266
2330
 
2331
+ /**
2332
+ * VASP POSCAR / CONTCAR structure reader.
2333
+ *
2334
+ * POSCAR describes a single crystalline cell. Coordinates are returned as
2335
+ * Cartesian angstrom (`Direct` files are converted on read by molrs).
2336
+ * Produces an `"atoms"` block (`x`/`y`/`z`, optional `symbol`,
2337
+ * selective-dynamics flags, velocities) and a periodic `simbox`.
2338
+ * Single-frame: any `step != 0` returns `undefined`.
2339
+ */
2340
+ export class POSCARReader {
2341
+ free(): void;
2342
+ [Symbol.dispose](): void;
2343
+ /**
2344
+ * Check whether the file contains no valid frame.
2345
+ */
2346
+ isEmpty(): boolean;
2347
+ /**
2348
+ * Return the number of frames (always 0 or 1 for POSCAR files).
2349
+ */
2350
+ len(): number;
2351
+ /**
2352
+ * Create a new POSCAR reader from a string containing the file content.
2353
+ */
2354
+ constructor(content: string);
2355
+ /**
2356
+ * Read the frame at `step`. POSCAR is single-frame, so any `step != 0`
2357
+ * returns `undefined`.
2358
+ */
2359
+ read(step: number): Frame | undefined;
2360
+ }
2361
+
2267
2362
  /**
2268
2363
  * Radial distribution function g(r) analysis.
2269
2364
  *
@@ -2545,6 +2640,37 @@ export class SmilesIR {
2545
2640
  readonly nComponents: number;
2546
2641
  }
2547
2642
 
2643
+ /**
2644
+ * GROMACS TRR binary trajectory reader.
2645
+ *
2646
+ * TRR is the full-precision GROMACS trajectory (XDR, big-endian). Accepts the
2647
+ * file as raw bytes (`Uint8Array`). Each frame produces an `"atoms"` block
2648
+ * (`id`, `x`/`y`/`z`, optional `vx`/`vy`/`vz` and `fx`/`fy`/`fz`);
2649
+ * coordinates and box are converted nm -> angstrom on read. Box is attached
2650
+ * as `simbox` when the frame carries one.
2651
+ */
2652
+ export class TRRReader {
2653
+ free(): void;
2654
+ [Symbol.dispose](): void;
2655
+ /**
2656
+ * Check whether the file contains no frames.
2657
+ */
2658
+ isEmpty(): boolean;
2659
+ /**
2660
+ * Return the number of frames in the TRR file.
2661
+ */
2662
+ len(): number;
2663
+ /**
2664
+ * Create a new TRR reader from the file's raw bytes.
2665
+ */
2666
+ constructor(bytes: Uint8Array);
2667
+ /**
2668
+ * Read a frame at the given step index (0-based). Coordinates are
2669
+ * converted nm -> angstrom before the frame is returned.
2670
+ */
2671
+ read(step: number): Frame | undefined;
2672
+ }
2673
+
2548
2674
  /**
2549
2675
  * Graph-based molecular topology with automated detection of angles,
2550
2676
  * dihedrals, impropers, connected components, and rings (SSSR).
@@ -3696,6 +3822,36 @@ export class WasmXyzStream {
3696
3822
  simboxPbc(): Uint8Array | undefined;
3697
3823
  }
3698
3824
 
3825
+ /**
3826
+ * GROMACS XTC binary trajectory reader.
3827
+ *
3828
+ * XTC is the compressed GROMACS trajectory (XDR, big-endian, lossy
3829
+ * coordinate compression). Accepts the file as raw bytes (`Uint8Array`).
3830
+ * Each frame produces an `"atoms"` block (`id`, `x`/`y`/`z`); coordinates
3831
+ * and box are converted nm -> angstrom on read. Box is attached as `simbox`.
3832
+ */
3833
+ export class XTCReader {
3834
+ free(): void;
3835
+ [Symbol.dispose](): void;
3836
+ /**
3837
+ * Check whether the file contains no frames.
3838
+ */
3839
+ isEmpty(): boolean;
3840
+ /**
3841
+ * Return the number of frames in the XTC file.
3842
+ */
3843
+ len(): number;
3844
+ /**
3845
+ * Create a new XTC reader from the file's raw bytes.
3846
+ */
3847
+ constructor(bytes: Uint8Array);
3848
+ /**
3849
+ * Read a frame at the given step index (0-based). Coordinates are
3850
+ * converted nm -> angstrom before the frame is returned.
3851
+ */
3852
+ read(step: number): Frame | undefined;
3853
+ }
3854
+
3699
3855
  /**
3700
3856
  * XYZ / Extended XYZ file reader.
3701
3857
  *
@@ -3944,3 +4100,18 @@ export function wasmMemory(): WebAssembly.Memory;
3944
4100
  * ```
3945
4101
  */
3946
4102
  export function writeFrame(frame: Frame, format: string): string;
4103
+
4104
+ /**
4105
+ * Serialize a [`Frame`] to bytes in a binary trajectory format.
4106
+ *
4107
+ * Mirrors [`write_frame_export`] for the formats whose output is not valid
4108
+ * UTF-8: `"dcd"`, `"trr"`, `"xtc"` (case-insensitive). Returns a
4109
+ * `Uint8Array` to JavaScript. The GROMACS formats (`trr`/`xtc`) are written
4110
+ * in nm — coordinates and box are scaled Å → nm on a throwaway clone first.
4111
+ *
4112
+ * # Errors
4113
+ *
4114
+ * Throws a `JsValue` string if the format is not a known binary format, the
4115
+ * frame is missing required columns, or the writer encounters an error.
4116
+ */
4117
+ export function writeFrameBytes(frame: Frame, format: string): Uint8Array;
package/molrs.js CHANGED
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./molrs_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- Block, Box, CHGCARReader, CIFReader, CenterOfMass, CenterOfMassResult, Cluster, ClusterCenters, ClusterResult, CubeReader, DCDReader, Frame, FrameIndexEntry, GyrationTensor, InertiaTensor, LAMMPSReader, LAMMPSTrajReader, LinkedCell, MSD, MSDResult, MolRecReader, NeighborList, PDBReader, RDF, RDFResult, RadiusOfGyration, SDFReader, SmilesIR, Topology, TopologyRingInfo, WasmArray, WasmKMeans, WasmLammpsDataStream, WasmLammpsDumpStream, WasmPca2, WasmPcaResult, WasmPdbStream, WasmSdfStream, WasmXyzStream, XYZReader, covalentRadius, generate3D, parseSMILES, start, wasmMemory, writeFrame
8
+ Block, Box, CHGCARReader, CIFReader, CenterOfMass, CenterOfMassResult, Cluster, ClusterCenters, ClusterResult, CubeReader, DCDReader, Frame, FrameIndexEntry, GROReader, GyrationTensor, InertiaTensor, LAMMPSReader, LAMMPSTrajReader, LinkedCell, MOL2Reader, MSD, MSDResult, MolRecReader, NeighborList, PDBReader, POSCARReader, RDF, RDFResult, RadiusOfGyration, SDFReader, SmilesIR, TRRReader, Topology, TopologyRingInfo, WasmArray, WasmKMeans, WasmLammpsDataStream, WasmLammpsDumpStream, WasmPca2, WasmPcaResult, WasmPdbStream, WasmSdfStream, WasmXyzStream, XTCReader, XYZReader, covalentRadius, generate3D, parseSMILES, start, wasmMemory, writeFrame, writeFrameBytes
9
9
  } from "./molrs_bg.js";
package/molrs_bg.js CHANGED
@@ -2587,6 +2587,78 @@ export class FrameIndexEntry {
2587
2587
  }
2588
2588
  if (Symbol.dispose) FrameIndexEntry.prototype[Symbol.dispose] = FrameIndexEntry.prototype.free;
2589
2589
 
2590
+ /**
2591
+ * GROMACS GRO structure / trajectory reader.
2592
+ *
2593
+ * GRO is a fixed-column text format for GROMACS structures and
2594
+ * single-precision trajectories. Multi-frame files expose each frame via
2595
+ * `read(step)`. Coordinates and box are GROMACS-native nm in the file and
2596
+ * are converted to angstrom on read (x10), matching every other molvis
2597
+ * reader. Each frame produces an `"atoms"` block (`resid`, `resname`,
2598
+ * `atom_name`, `atom_id`, `x`/`y`/`z`, optional `vx`/`vy`/`vz`) and a
2599
+ * `simbox` from the box-vector line.
2600
+ */
2601
+ export class GROReader {
2602
+ __destroy_into_raw() {
2603
+ const ptr = this.__wbg_ptr;
2604
+ this.__wbg_ptr = 0;
2605
+ GROReaderFinalization.unregister(this);
2606
+ return ptr;
2607
+ }
2608
+ free() {
2609
+ const ptr = this.__destroy_into_raw();
2610
+ wasm.__wbg_groreader_free(ptr, 0);
2611
+ }
2612
+ /**
2613
+ * Check whether the file contains no frames.
2614
+ * @returns {boolean}
2615
+ */
2616
+ isEmpty() {
2617
+ const ret = wasm.groreader_isEmpty(this.__wbg_ptr);
2618
+ if (ret[2]) {
2619
+ throw takeFromExternrefTable0(ret[1]);
2620
+ }
2621
+ return ret[0] !== 0;
2622
+ }
2623
+ /**
2624
+ * Return the number of frames in the GRO file.
2625
+ * @returns {number}
2626
+ */
2627
+ len() {
2628
+ const ret = wasm.groreader_len(this.__wbg_ptr);
2629
+ if (ret[2]) {
2630
+ throw takeFromExternrefTable0(ret[1]);
2631
+ }
2632
+ return ret[0] >>> 0;
2633
+ }
2634
+ /**
2635
+ * Create a new GRO reader from a string containing the file content.
2636
+ * @param {string} content
2637
+ */
2638
+ constructor(content) {
2639
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
2640
+ const len0 = WASM_VECTOR_LEN;
2641
+ const ret = wasm.groreader_new(ptr0, len0);
2642
+ this.__wbg_ptr = ret;
2643
+ GROReaderFinalization.register(this, this.__wbg_ptr, this);
2644
+ return this;
2645
+ }
2646
+ /**
2647
+ * Read the frame at the given step index (0-based). Coordinates are
2648
+ * converted nm -> angstrom before the frame is returned.
2649
+ * @param {number} step
2650
+ * @returns {Frame | undefined}
2651
+ */
2652
+ read(step) {
2653
+ const ret = wasm.groreader_read(this.__wbg_ptr, step);
2654
+ if (ret[2]) {
2655
+ throw takeFromExternrefTable0(ret[1]);
2656
+ }
2657
+ return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
2658
+ }
2659
+ }
2660
+ if (Symbol.dispose) GROReader.prototype[Symbol.dispose] = GROReader.prototype.free;
2661
+
2590
2662
  /**
2591
2663
  * Gyration tensor per cluster.
2592
2664
  *
@@ -3013,6 +3085,76 @@ export class LinkedCell {
3013
3085
  }
3014
3086
  if (Symbol.dispose) LinkedCell.prototype[Symbol.dispose] = LinkedCell.prototype.free;
3015
3087
 
3088
+ /**
3089
+ * Tripos MOL2 reader.
3090
+ *
3091
+ * MOL2 is a section-delimited (`@<TRIPOS>...`) text format. Multi-molecule
3092
+ * files expose each `MOLECULE` record as a frame via `read(step)`.
3093
+ * Coordinates are already in angstrom. Produces an `"atoms"` block (`id`,
3094
+ * `name`, `x`/`y`/`z`, `atom_type`, optional `subst_id`/`subst_name`/
3095
+ * `charge`) and, when present, a `"bonds"` block (`atomi`/`atomj` 0-based,
3096
+ * `bond_type`).
3097
+ */
3098
+ export class MOL2Reader {
3099
+ __destroy_into_raw() {
3100
+ const ptr = this.__wbg_ptr;
3101
+ this.__wbg_ptr = 0;
3102
+ MOL2ReaderFinalization.unregister(this);
3103
+ return ptr;
3104
+ }
3105
+ free() {
3106
+ const ptr = this.__destroy_into_raw();
3107
+ wasm.__wbg_mol2reader_free(ptr, 0);
3108
+ }
3109
+ /**
3110
+ * Check whether the file contains no records.
3111
+ * @returns {boolean}
3112
+ */
3113
+ isEmpty() {
3114
+ const ret = wasm.mol2reader_isEmpty(this.__wbg_ptr);
3115
+ if (ret[2]) {
3116
+ throw takeFromExternrefTable0(ret[1]);
3117
+ }
3118
+ return ret[0] !== 0;
3119
+ }
3120
+ /**
3121
+ * Return the number of molecule records in the MOL2 file.
3122
+ * @returns {number}
3123
+ */
3124
+ len() {
3125
+ const ret = wasm.mol2reader_len(this.__wbg_ptr);
3126
+ if (ret[2]) {
3127
+ throw takeFromExternrefTable0(ret[1]);
3128
+ }
3129
+ return ret[0] >>> 0;
3130
+ }
3131
+ /**
3132
+ * Create a new MOL2 reader from a string containing the file content.
3133
+ * @param {string} content
3134
+ */
3135
+ constructor(content) {
3136
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
3137
+ const len0 = WASM_VECTOR_LEN;
3138
+ const ret = wasm.mol2reader_new(ptr0, len0);
3139
+ this.__wbg_ptr = ret;
3140
+ MOL2ReaderFinalization.register(this, this.__wbg_ptr, this);
3141
+ return this;
3142
+ }
3143
+ /**
3144
+ * Read the molecule record at the given step index (0-based).
3145
+ * @param {number} step
3146
+ * @returns {Frame | undefined}
3147
+ */
3148
+ read(step) {
3149
+ const ret = wasm.mol2reader_read(this.__wbg_ptr, step);
3150
+ if (ret[2]) {
3151
+ throw takeFromExternrefTable0(ret[1]);
3152
+ }
3153
+ return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
3154
+ }
3155
+ }
3156
+ if (Symbol.dispose) MOL2Reader.prototype[Symbol.dispose] = MOL2Reader.prototype.free;
3157
+
3016
3158
  /**
3017
3159
  * Mean squared displacement (MSD) analysis.
3018
3160
  *
@@ -3489,6 +3631,76 @@ export class PDBReader {
3489
3631
  }
3490
3632
  if (Symbol.dispose) PDBReader.prototype[Symbol.dispose] = PDBReader.prototype.free;
3491
3633
 
3634
+ /**
3635
+ * VASP POSCAR / CONTCAR structure reader.
3636
+ *
3637
+ * POSCAR describes a single crystalline cell. Coordinates are returned as
3638
+ * Cartesian angstrom (`Direct` files are converted on read by molrs).
3639
+ * Produces an `"atoms"` block (`x`/`y`/`z`, optional `symbol`,
3640
+ * selective-dynamics flags, velocities) and a periodic `simbox`.
3641
+ * Single-frame: any `step != 0` returns `undefined`.
3642
+ */
3643
+ export class POSCARReader {
3644
+ __destroy_into_raw() {
3645
+ const ptr = this.__wbg_ptr;
3646
+ this.__wbg_ptr = 0;
3647
+ POSCARReaderFinalization.unregister(this);
3648
+ return ptr;
3649
+ }
3650
+ free() {
3651
+ const ptr = this.__destroy_into_raw();
3652
+ wasm.__wbg_poscarreader_free(ptr, 0);
3653
+ }
3654
+ /**
3655
+ * Check whether the file contains no valid frame.
3656
+ * @returns {boolean}
3657
+ */
3658
+ isEmpty() {
3659
+ const ret = wasm.poscarreader_isEmpty(this.__wbg_ptr);
3660
+ if (ret[2]) {
3661
+ throw takeFromExternrefTable0(ret[1]);
3662
+ }
3663
+ return ret[0] !== 0;
3664
+ }
3665
+ /**
3666
+ * Return the number of frames (always 0 or 1 for POSCAR files).
3667
+ * @returns {number}
3668
+ */
3669
+ len() {
3670
+ const ret = wasm.poscarreader_len(this.__wbg_ptr);
3671
+ if (ret[2]) {
3672
+ throw takeFromExternrefTable0(ret[1]);
3673
+ }
3674
+ return ret[0] >>> 0;
3675
+ }
3676
+ /**
3677
+ * Create a new POSCAR reader from a string containing the file content.
3678
+ * @param {string} content
3679
+ */
3680
+ constructor(content) {
3681
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
3682
+ const len0 = WASM_VECTOR_LEN;
3683
+ const ret = wasm.poscarreader_new(ptr0, len0);
3684
+ this.__wbg_ptr = ret;
3685
+ POSCARReaderFinalization.register(this, this.__wbg_ptr, this);
3686
+ return this;
3687
+ }
3688
+ /**
3689
+ * Read the frame at `step`. POSCAR is single-frame, so any `step != 0`
3690
+ * returns `undefined`.
3691
+ * @param {number} step
3692
+ * @returns {Frame | undefined}
3693
+ */
3694
+ read(step) {
3695
+ const ret = wasm.poscarreader_read(this.__wbg_ptr, step);
3696
+ if (ret[2]) {
3697
+ throw takeFromExternrefTable0(ret[1]);
3698
+ }
3699
+ return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
3700
+ }
3701
+ }
3702
+ if (Symbol.dispose) POSCARReader.prototype[Symbol.dispose] = POSCARReader.prototype.free;
3703
+
3492
3704
  /**
3493
3705
  * Radial distribution function g(r) analysis.
3494
3706
  *
@@ -3949,6 +4161,76 @@ export class SmilesIR {
3949
4161
  }
3950
4162
  if (Symbol.dispose) SmilesIR.prototype[Symbol.dispose] = SmilesIR.prototype.free;
3951
4163
 
4164
+ /**
4165
+ * GROMACS TRR binary trajectory reader.
4166
+ *
4167
+ * TRR is the full-precision GROMACS trajectory (XDR, big-endian). Accepts the
4168
+ * file as raw bytes (`Uint8Array`). Each frame produces an `"atoms"` block
4169
+ * (`id`, `x`/`y`/`z`, optional `vx`/`vy`/`vz` and `fx`/`fy`/`fz`);
4170
+ * coordinates and box are converted nm -> angstrom on read. Box is attached
4171
+ * as `simbox` when the frame carries one.
4172
+ */
4173
+ export class TRRReader {
4174
+ __destroy_into_raw() {
4175
+ const ptr = this.__wbg_ptr;
4176
+ this.__wbg_ptr = 0;
4177
+ TRRReaderFinalization.unregister(this);
4178
+ return ptr;
4179
+ }
4180
+ free() {
4181
+ const ptr = this.__destroy_into_raw();
4182
+ wasm.__wbg_trrreader_free(ptr, 0);
4183
+ }
4184
+ /**
4185
+ * Check whether the file contains no frames.
4186
+ * @returns {boolean}
4187
+ */
4188
+ isEmpty() {
4189
+ const ret = wasm.trrreader_isEmpty(this.__wbg_ptr);
4190
+ if (ret[2]) {
4191
+ throw takeFromExternrefTable0(ret[1]);
4192
+ }
4193
+ return ret[0] !== 0;
4194
+ }
4195
+ /**
4196
+ * Return the number of frames in the TRR file.
4197
+ * @returns {number}
4198
+ */
4199
+ len() {
4200
+ const ret = wasm.trrreader_len(this.__wbg_ptr);
4201
+ if (ret[2]) {
4202
+ throw takeFromExternrefTable0(ret[1]);
4203
+ }
4204
+ return ret[0] >>> 0;
4205
+ }
4206
+ /**
4207
+ * Create a new TRR reader from the file's raw bytes.
4208
+ * @param {Uint8Array} bytes
4209
+ */
4210
+ constructor(bytes) {
4211
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc_command_export);
4212
+ const len0 = WASM_VECTOR_LEN;
4213
+ const ret = wasm.trrreader_new(ptr0, len0);
4214
+ this.__wbg_ptr = ret;
4215
+ TRRReaderFinalization.register(this, this.__wbg_ptr, this);
4216
+ return this;
4217
+ }
4218
+ /**
4219
+ * Read a frame at the given step index (0-based). Coordinates are
4220
+ * converted nm -> angstrom before the frame is returned.
4221
+ * @param {number} step
4222
+ * @returns {Frame | undefined}
4223
+ */
4224
+ read(step) {
4225
+ const ret = wasm.trrreader_read(this.__wbg_ptr, step);
4226
+ if (ret[2]) {
4227
+ throw takeFromExternrefTable0(ret[1]);
4228
+ }
4229
+ return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
4230
+ }
4231
+ }
4232
+ if (Symbol.dispose) TRRReader.prototype[Symbol.dispose] = TRRReader.prototype.free;
4233
+
3952
4234
  /**
3953
4235
  * Graph-based molecular topology with automated detection of angles,
3954
4236
  * dihedrals, impropers, connected components, and rings (SSSR).
@@ -6228,6 +6510,75 @@ export class WasmXyzStream {
6228
6510
  }
6229
6511
  if (Symbol.dispose) WasmXyzStream.prototype[Symbol.dispose] = WasmXyzStream.prototype.free;
6230
6512
 
6513
+ /**
6514
+ * GROMACS XTC binary trajectory reader.
6515
+ *
6516
+ * XTC is the compressed GROMACS trajectory (XDR, big-endian, lossy
6517
+ * coordinate compression). Accepts the file as raw bytes (`Uint8Array`).
6518
+ * Each frame produces an `"atoms"` block (`id`, `x`/`y`/`z`); coordinates
6519
+ * and box are converted nm -> angstrom on read. Box is attached as `simbox`.
6520
+ */
6521
+ export class XTCReader {
6522
+ __destroy_into_raw() {
6523
+ const ptr = this.__wbg_ptr;
6524
+ this.__wbg_ptr = 0;
6525
+ XTCReaderFinalization.unregister(this);
6526
+ return ptr;
6527
+ }
6528
+ free() {
6529
+ const ptr = this.__destroy_into_raw();
6530
+ wasm.__wbg_xtcreader_free(ptr, 0);
6531
+ }
6532
+ /**
6533
+ * Check whether the file contains no frames.
6534
+ * @returns {boolean}
6535
+ */
6536
+ isEmpty() {
6537
+ const ret = wasm.xtcreader_isEmpty(this.__wbg_ptr);
6538
+ if (ret[2]) {
6539
+ throw takeFromExternrefTable0(ret[1]);
6540
+ }
6541
+ return ret[0] !== 0;
6542
+ }
6543
+ /**
6544
+ * Return the number of frames in the XTC file.
6545
+ * @returns {number}
6546
+ */
6547
+ len() {
6548
+ const ret = wasm.xtcreader_len(this.__wbg_ptr);
6549
+ if (ret[2]) {
6550
+ throw takeFromExternrefTable0(ret[1]);
6551
+ }
6552
+ return ret[0] >>> 0;
6553
+ }
6554
+ /**
6555
+ * Create a new XTC reader from the file's raw bytes.
6556
+ * @param {Uint8Array} bytes
6557
+ */
6558
+ constructor(bytes) {
6559
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc_command_export);
6560
+ const len0 = WASM_VECTOR_LEN;
6561
+ const ret = wasm.xtcreader_new(ptr0, len0);
6562
+ this.__wbg_ptr = ret;
6563
+ XTCReaderFinalization.register(this, this.__wbg_ptr, this);
6564
+ return this;
6565
+ }
6566
+ /**
6567
+ * Read a frame at the given step index (0-based). Coordinates are
6568
+ * converted nm -> angstrom before the frame is returned.
6569
+ * @param {number} step
6570
+ * @returns {Frame | undefined}
6571
+ */
6572
+ read(step) {
6573
+ const ret = wasm.xtcreader_read(this.__wbg_ptr, step);
6574
+ if (ret[2]) {
6575
+ throw takeFromExternrefTable0(ret[1]);
6576
+ }
6577
+ return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
6578
+ }
6579
+ }
6580
+ if (Symbol.dispose) XTCReader.prototype[Symbol.dispose] = XTCReader.prototype.free;
6581
+
6231
6582
  /**
6232
6583
  * XYZ / Extended XYZ file reader.
6233
6584
  *
@@ -6574,18 +6925,47 @@ export function writeFrame(frame, format) {
6574
6925
  wasm.__wbindgen_free_command_export(deferred3_0, deferred3_1, 1);
6575
6926
  }
6576
6927
  }
6577
- export function __wbg___wbindgen_debug_string_8a447059637473e2(arg0, arg1) {
6928
+
6929
+ /**
6930
+ * Serialize a [`Frame`] to bytes in a binary trajectory format.
6931
+ *
6932
+ * Mirrors [`write_frame_export`] for the formats whose output is not valid
6933
+ * UTF-8: `"dcd"`, `"trr"`, `"xtc"` (case-insensitive). Returns a
6934
+ * `Uint8Array` to JavaScript. The GROMACS formats (`trr`/`xtc`) are written
6935
+ * in nm — coordinates and box are scaled Å → nm on a throwaway clone first.
6936
+ *
6937
+ * # Errors
6938
+ *
6939
+ * Throws a `JsValue` string if the format is not a known binary format, the
6940
+ * frame is missing required columns, or the writer encounters an error.
6941
+ * @param {Frame} frame
6942
+ * @param {string} format
6943
+ * @returns {Uint8Array}
6944
+ */
6945
+ export function writeFrameBytes(frame, format) {
6946
+ _assertClass(frame, Frame);
6947
+ const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
6948
+ const len0 = WASM_VECTOR_LEN;
6949
+ const ret = wasm.writeFrameBytes(frame.__wbg_ptr, ptr0, len0);
6950
+ if (ret[3]) {
6951
+ throw takeFromExternrefTable0(ret[2]);
6952
+ }
6953
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
6954
+ wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
6955
+ return v2;
6956
+ }
6957
+ export function __wbg___wbindgen_debug_string_c25d447a39f5578f(arg0, arg1) {
6578
6958
  const ret = debugString(arg1);
6579
6959
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
6580
6960
  const len1 = WASM_VECTOR_LEN;
6581
6961
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
6582
6962
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
6583
6963
  }
6584
- export function __wbg___wbindgen_memory_9751d9a3017e7c25() {
6964
+ export function __wbg___wbindgen_memory_de265df8aadd6273() {
6585
6965
  const ret = wasm.memory;
6586
6966
  return ret;
6587
6967
  }
6588
- export function __wbg___wbindgen_string_get_71bb4348194e31f0(arg0, arg1) {
6968
+ export function __wbg___wbindgen_string_get_b0ca35b86a603356(arg0, arg1) {
6589
6969
  const obj = arg1;
6590
6970
  const ret = typeof(obj) === 'string' ? obj : undefined;
6591
6971
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
@@ -6593,10 +6973,10 @@ export function __wbg___wbindgen_string_get_71bb4348194e31f0(arg0, arg1) {
6593
6973
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
6594
6974
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
6595
6975
  }
6596
- export function __wbg___wbindgen_throw_ea4887a5f8f9a9db(arg0, arg1) {
6976
+ export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
6597
6977
  throw new Error(getStringFromWasm0(arg0, arg1));
6598
6978
  }
6599
- export function __wbg_done_b62d4a7d2286852a(arg0) {
6979
+ export function __wbg_done_89b2b13e91a60321(arg0) {
6600
6980
  const ret = arg0.done;
6601
6981
  return ret;
6602
6982
  }
@@ -6615,38 +6995,38 @@ export function __wbg_frameindexentry_new(arg0) {
6615
6995
  const ret = FrameIndexEntry.__wrap(arg0);
6616
6996
  return ret;
6617
6997
  }
6618
- export function __wbg_getRandomValues_76dfc69825c9c552() { return handleError(function (arg0, arg1) {
6998
+ export function __wbg_getRandomValues_cc7f052a444bb2ce() { return handleError(function (arg0, arg1) {
6619
6999
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
6620
7000
  }, arguments); }
6621
- export function __wbg_get_f6f94ffcaf26eed1(arg0, arg1) {
7001
+ export function __wbg_get_53202602c459bfb1(arg0, arg1) {
6622
7002
  const ret = arg0.get(arg1);
6623
7003
  return ret;
6624
7004
  }
6625
- export function __wbg_get_unchecked_54a4374c38e08460(arg0, arg1) {
7005
+ export function __wbg_get_unchecked_6e0ad6d2a41b06f6(arg0, arg1) {
6626
7006
  const ret = arg0[arg1 >>> 0];
6627
7007
  return ret;
6628
7008
  }
6629
- export function __wbg_keys_8c9f7da46ee76e8d(arg0) {
7009
+ export function __wbg_keys_8e08ab7a3c20df35(arg0) {
6630
7010
  const ret = arg0.keys();
6631
7011
  return ret;
6632
7012
  }
6633
- export function __wbg_length_4875795b8939c6b6(arg0) {
7013
+ export function __wbg_length_0133fa10e3234c57(arg0) {
6634
7014
  const ret = arg0.length;
6635
7015
  return ret;
6636
7016
  }
6637
- export function __wbg_length_589238bdcf171f0e(arg0) {
7017
+ export function __wbg_length_1f0964f4a5e2c6d8(arg0) {
6638
7018
  const ret = arg0.length;
6639
7019
  return ret;
6640
7020
  }
6641
- export function __wbg_length_750ab89c52b42479(arg0) {
7021
+ export function __wbg_length_370319915dc99107(arg0) {
6642
7022
  const ret = arg0.length;
6643
7023
  return ret;
6644
7024
  }
6645
- export function __wbg_length_bf9e65fd7019a3f2(arg0) {
7025
+ export function __wbg_length_381d540857ec99e8(arg0) {
6646
7026
  const ret = arg0.length;
6647
7027
  return ret;
6648
7028
  }
6649
- export function __wbg_length_c6054974c0a6cdb9(arg0) {
7029
+ export function __wbg_length_a6f0e2586a65d524(arg0) {
6650
7030
  const ret = arg0.length;
6651
7031
  return ret;
6652
7032
  }
@@ -6658,74 +7038,74 @@ export function __wbg_new_227d7c05414eb861() {
6658
7038
  const ret = new Error();
6659
7039
  return ret;
6660
7040
  }
6661
- export function __wbg_new_36e147a8ced3c6e0() {
7041
+ export function __wbg_new_32b398fb48b6d94a() {
6662
7042
  const ret = new Array();
6663
7043
  return ret;
6664
7044
  }
6665
- export function __wbg_new_81880fb5002cb255(arg0) {
7045
+ export function __wbg_new_cd45aabdf6073e84(arg0) {
6666
7046
  const ret = new Uint8Array(arg0);
6667
7047
  return ret;
6668
7048
  }
6669
- export function __wbg_new_from_slice_3f5658f83d8d0725(arg0, arg1) {
7049
+ export function __wbg_new_from_slice_7568ba55b4a7e81f(arg0, arg1) {
6670
7050
  const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
6671
7051
  return ret;
6672
7052
  }
6673
- export function __wbg_new_from_slice_7b8c5f56d6f4bffc(arg0, arg1) {
6674
- const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
7053
+ export function __wbg_new_from_slice_7e254b47c77fb8cc(arg0, arg1) {
7054
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
6675
7055
  return ret;
6676
7056
  }
6677
- export function __wbg_new_from_slice_98e57cb2fe2e6a5d(arg0, arg1) {
6678
- const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
7057
+ export function __wbg_new_from_slice_adc482e0820cc439(arg0, arg1) {
7058
+ const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
6679
7059
  return ret;
6680
7060
  }
6681
- export function __wbg_new_with_length_3f188e379a8c6a4d(arg0) {
7061
+ export function __wbg_new_with_length_112583d83d0cb73c(arg0) {
6682
7062
  const ret = new Float64Array(arg0 >>> 0);
6683
7063
  return ret;
6684
7064
  }
6685
- export function __wbg_new_with_length_793583df958b3ae2(arg0) {
7065
+ export function __wbg_new_with_length_664ae1da061c56fa(arg0) {
6686
7066
  const ret = new Int32Array(arg0 >>> 0);
6687
7067
  return ret;
6688
7068
  }
6689
- export function __wbg_new_with_length_9b650f44b5c44a4e(arg0) {
7069
+ export function __wbg_new_with_length_e6785c33c8e4cce8(arg0) {
6690
7070
  const ret = new Uint8Array(arg0 >>> 0);
6691
7071
  return ret;
6692
7072
  }
6693
- export function __wbg_new_with_length_ecf42de9ee25651c(arg0) {
7073
+ export function __wbg_new_with_length_f048f86e32f1515e(arg0) {
6694
7074
  const ret = new Uint32Array(arg0 >>> 0);
6695
7075
  return ret;
6696
7076
  }
6697
- export function __wbg_next_0c4066e251d2eff9() { return handleError(function (arg0) {
7077
+ export function __wbg_next_71f2aa1cb3d1e37e() { return handleError(function (arg0) {
6698
7078
  const ret = arg0.next();
6699
7079
  return ret;
6700
7080
  }, arguments); }
6701
- export function __wbg_prototypesetcall_1f31756936f35af0(arg0, arg1, arg2) {
7081
+ export function __wbg_prototypesetcall_18a0f7bcf4a5652d(arg0, arg1, arg2) {
6702
7082
  Int32Array.prototype.set.call(getArrayI32FromWasm0(arg0, arg1), arg2);
6703
7083
  }
6704
- export function __wbg_prototypesetcall_26a86dd8c73de125(arg0, arg1, arg2) {
6705
- Uint32Array.prototype.set.call(getArrayU32FromWasm0(arg0, arg1), arg2);
6706
- }
6707
- export function __wbg_prototypesetcall_83f8c8d8e36faf9f(arg0, arg1, arg2) {
7084
+ export function __wbg_prototypesetcall_21a175a0a8157491(arg0, arg1, arg2) {
6708
7085
  Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
6709
7086
  }
6710
- export function __wbg_prototypesetcall_d721637c7ca66eb8(arg0, arg1, arg2) {
7087
+ export function __wbg_prototypesetcall_4770620bbe4688a0(arg0, arg1, arg2) {
6711
7088
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
6712
7089
  }
6713
- export function __wbg_push_f724b5db8acf89d2(arg0, arg1) {
7090
+ export function __wbg_prototypesetcall_62396032bc038599(arg0, arg1, arg2) {
7091
+ Uint32Array.prototype.set.call(getArrayU32FromWasm0(arg0, arg1), arg2);
7092
+ }
7093
+ export function __wbg_push_d2ae3af0c1217ae6(arg0, arg1) {
6714
7094
  const ret = arg0.push(arg1);
6715
7095
  return ret;
6716
7096
  }
6717
- export function __wbg_set_404b02690d27a687(arg0, arg1, arg2) {
7097
+ export function __wbg_set_29967298e530d279(arg0, arg1, arg2) {
6718
7098
  arg0.set(getArrayF64FromWasm0(arg1, arg2));
6719
7099
  }
6720
- export function __wbg_set_699bda357d38bc49(arg0, arg1, arg2) {
7100
+ export function __wbg_set_d07b6d94c9c97f43(arg0, arg1, arg2) {
6721
7101
  arg0.set(getArrayI32FromWasm0(arg1, arg2));
6722
7102
  }
6723
- export function __wbg_set_index_4cab6f2df9ae8120(arg0, arg1, arg2) {
6724
- arg0[arg1 >>> 0] = arg2 >>> 0;
6725
- }
6726
- export function __wbg_set_index_dd52456a7aef02bf(arg0, arg1, arg2) {
7103
+ export function __wbg_set_index_0a2d916cd3658df4(arg0, arg1, arg2) {
6727
7104
  arg0[arg1 >>> 0] = arg2;
6728
7105
  }
7106
+ export function __wbg_set_index_1edd196294cd6dbf(arg0, arg1, arg2) {
7107
+ arg0[arg1 >>> 0] = arg2 >>> 0;
7108
+ }
6729
7109
  export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
6730
7110
  const ret = arg1.stack;
6731
7111
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
@@ -6733,7 +7113,7 @@ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
6733
7113
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
6734
7114
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
6735
7115
  }
6736
- export function __wbg_value_49f783bb59765962(arg0) {
7116
+ export function __wbg_value_a5d5488a9589444a(arg0) {
6737
7117
  const ret = arg0.value;
6738
7118
  return ret;
6739
7119
  }
@@ -6805,6 +7185,9 @@ const FrameFinalization = (typeof FinalizationRegistry === 'undefined')
6805
7185
  const FrameIndexEntryFinalization = (typeof FinalizationRegistry === 'undefined')
6806
7186
  ? { register: () => {}, unregister: () => {} }
6807
7187
  : new FinalizationRegistry(ptr => wasm.__wbg_frameindexentry_free(ptr, 1));
7188
+ const GROReaderFinalization = (typeof FinalizationRegistry === 'undefined')
7189
+ ? { register: () => {}, unregister: () => {} }
7190
+ : new FinalizationRegistry(ptr => wasm.__wbg_groreader_free(ptr, 1));
6808
7191
  const GyrationTensorFinalization = (typeof FinalizationRegistry === 'undefined')
6809
7192
  ? { register: () => {}, unregister: () => {} }
6810
7193
  : new FinalizationRegistry(ptr => wasm.__wbg_gyrationtensor_free(ptr, 1));
@@ -6820,6 +7203,9 @@ const LAMMPSTrajReaderFinalization = (typeof FinalizationRegistry === 'undefined
6820
7203
  const LinkedCellFinalization = (typeof FinalizationRegistry === 'undefined')
6821
7204
  ? { register: () => {}, unregister: () => {} }
6822
7205
  : new FinalizationRegistry(ptr => wasm.__wbg_linkedcell_free(ptr, 1));
7206
+ const MOL2ReaderFinalization = (typeof FinalizationRegistry === 'undefined')
7207
+ ? { register: () => {}, unregister: () => {} }
7208
+ : new FinalizationRegistry(ptr => wasm.__wbg_mol2reader_free(ptr, 1));
6823
7209
  const MSDFinalization = (typeof FinalizationRegistry === 'undefined')
6824
7210
  ? { register: () => {}, unregister: () => {} }
6825
7211
  : new FinalizationRegistry(ptr => wasm.__wbg_msd_free(ptr, 1));
@@ -6835,6 +7221,9 @@ const NeighborListFinalization = (typeof FinalizationRegistry === 'undefined')
6835
7221
  const PDBReaderFinalization = (typeof FinalizationRegistry === 'undefined')
6836
7222
  ? { register: () => {}, unregister: () => {} }
6837
7223
  : new FinalizationRegistry(ptr => wasm.__wbg_pdbreader_free(ptr, 1));
7224
+ const POSCARReaderFinalization = (typeof FinalizationRegistry === 'undefined')
7225
+ ? { register: () => {}, unregister: () => {} }
7226
+ : new FinalizationRegistry(ptr => wasm.__wbg_poscarreader_free(ptr, 1));
6838
7227
  const RDFFinalization = (typeof FinalizationRegistry === 'undefined')
6839
7228
  ? { register: () => {}, unregister: () => {} }
6840
7229
  : new FinalizationRegistry(ptr => wasm.__wbg_rdf_free(ptr, 1));
@@ -6850,6 +7239,9 @@ const SDFReaderFinalization = (typeof FinalizationRegistry === 'undefined')
6850
7239
  const SmilesIRFinalization = (typeof FinalizationRegistry === 'undefined')
6851
7240
  ? { register: () => {}, unregister: () => {} }
6852
7241
  : new FinalizationRegistry(ptr => wasm.__wbg_smilesir_free(ptr, 1));
7242
+ const TRRReaderFinalization = (typeof FinalizationRegistry === 'undefined')
7243
+ ? { register: () => {}, unregister: () => {} }
7244
+ : new FinalizationRegistry(ptr => wasm.__wbg_trrreader_free(ptr, 1));
6853
7245
  const TopologyFinalization = (typeof FinalizationRegistry === 'undefined')
6854
7246
  ? { register: () => {}, unregister: () => {} }
6855
7247
  : new FinalizationRegistry(ptr => wasm.__wbg_topology_free(ptr, 1));
@@ -6883,6 +7275,9 @@ const WasmSdfStreamFinalization = (typeof FinalizationRegistry === 'undefined')
6883
7275
  const WasmXyzStreamFinalization = (typeof FinalizationRegistry === 'undefined')
6884
7276
  ? { register: () => {}, unregister: () => {} }
6885
7277
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmxyzstream_free(ptr, 1));
7278
+ const XTCReaderFinalization = (typeof FinalizationRegistry === 'undefined')
7279
+ ? { register: () => {}, unregister: () => {} }
7280
+ : new FinalizationRegistry(ptr => wasm.__wbg_xtcreader_free(ptr, 1));
6886
7281
  const XYZReaderFinalization = (typeof FinalizationRegistry === 'undefined')
6887
7282
  ? { register: () => {}, unregister: () => {} }
6888
7283
  : new FinalizationRegistry(ptr => wasm.__wbg_xyzreader_free(ptr, 1));
package/molrs_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "MolCrafts"
6
6
  ],
7
7
  "description": "WASM bindings for molrs",
8
- "version": "0.1.3",
8
+ "version": "0.5.1",
9
9
  "license": "BSD-3-Clause",
10
10
  "repository": {
11
11
  "type": "git",