@molcrafts/molrs 0.0.6 → 0.0.7
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/README.md +4 -1
- package/molrs.d.ts +303 -0
- package/molrs.js +1 -1
- package/molrs_bg.js +716 -0
- package/molrs_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,10 +75,13 @@ Frames without a simulation box are supported — a non-periodic bounding box is
|
|
|
75
75
|
| `bonds` | `i`, `j` | `u32` | Atom indices |
|
|
76
76
|
| `bonds` | `order` | `f32` | Bond order (1.0, 1.5, 2.0, 3.0) |
|
|
77
77
|
|
|
78
|
-
## Build from source
|
|
78
|
+
## Build from source and use it for development
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
81
|
wasm-pack build --target bundler --scope molcrafts --out-name molrs
|
|
82
|
+
npm link
|
|
83
|
+
cd ../my-app
|
|
84
|
+
npm link @molcrafts/molrs
|
|
82
85
|
```
|
|
83
86
|
|
|
84
87
|
## License
|
package/molrs.d.ts
CHANGED
|
@@ -803,6 +803,53 @@ export class Box {
|
|
|
803
803
|
wrapToBlock(coords: WasmArray, out_block: Block, out_key: string): void;
|
|
804
804
|
}
|
|
805
805
|
|
|
806
|
+
/**
|
|
807
|
+
* Mass-weighted cluster center calculator.
|
|
808
|
+
*/
|
|
809
|
+
export class CenterOfMass {
|
|
810
|
+
free(): void;
|
|
811
|
+
[Symbol.dispose](): void;
|
|
812
|
+
/**
|
|
813
|
+
* Compute centers of mass.
|
|
814
|
+
*/
|
|
815
|
+
compute(frame: Frame, cluster_result: ClusterResult): CenterOfMassResult;
|
|
816
|
+
/**
|
|
817
|
+
* Create a center-of-mass calculator.
|
|
818
|
+
*
|
|
819
|
+
* Pass `null` for uniform masses, or a `Float32Array` of per-particle masses.
|
|
820
|
+
*/
|
|
821
|
+
constructor(masses?: Float32Array | null);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Result of center-of-mass computation.
|
|
826
|
+
*
|
|
827
|
+
* # Example (JavaScript)
|
|
828
|
+
*
|
|
829
|
+
* ```js
|
|
830
|
+
* const com = new CenterOfMass().compute(frame, clusterResult);
|
|
831
|
+
* com.centersOfMass(); // Float32Array [x0,y0,z0, ...]
|
|
832
|
+
* com.clusterMasses(); // Float32Array
|
|
833
|
+
* ```
|
|
834
|
+
*/
|
|
835
|
+
export class CenterOfMassResult {
|
|
836
|
+
private constructor();
|
|
837
|
+
free(): void;
|
|
838
|
+
[Symbol.dispose](): void;
|
|
839
|
+
/**
|
|
840
|
+
* Mass-weighted centers, flat `[x0,y0,z0, x1,y1,z1, ...]`.
|
|
841
|
+
*/
|
|
842
|
+
centersOfMass(): Float32Array;
|
|
843
|
+
/**
|
|
844
|
+
* Total mass per cluster.
|
|
845
|
+
*/
|
|
846
|
+
clusterMasses(): Float32Array;
|
|
847
|
+
/**
|
|
848
|
+
* Number of clusters.
|
|
849
|
+
*/
|
|
850
|
+
readonly numClusters: number;
|
|
851
|
+
}
|
|
852
|
+
|
|
806
853
|
/**
|
|
807
854
|
* Distance-based cluster analysis using BFS on the neighbor graph.
|
|
808
855
|
*
|
|
@@ -869,6 +916,26 @@ export class Cluster {
|
|
|
869
916
|
constructor(min_cluster_size: number);
|
|
870
917
|
}
|
|
871
918
|
|
|
919
|
+
/**
|
|
920
|
+
* Geometric cluster centers with minimum image convention.
|
|
921
|
+
*
|
|
922
|
+
* # Example (JavaScript)
|
|
923
|
+
*
|
|
924
|
+
* ```js
|
|
925
|
+
* const centers = new ClusterCenters().compute(frame, clusterResult);
|
|
926
|
+
* // Float32Array [x0,y0,z0, x1,y1,z1, ...]
|
|
927
|
+
* ```
|
|
928
|
+
*/
|
|
929
|
+
export class ClusterCenters {
|
|
930
|
+
free(): void;
|
|
931
|
+
[Symbol.dispose](): void;
|
|
932
|
+
/**
|
|
933
|
+
* Compute geometric centers. Returns flat `Float32Array` `[x0,y0,z0, ...]`.
|
|
934
|
+
*/
|
|
935
|
+
compute(frame: Frame, cluster_result: ClusterResult): Float32Array;
|
|
936
|
+
constructor();
|
|
937
|
+
}
|
|
938
|
+
|
|
872
939
|
/**
|
|
873
940
|
* Result of a distance-based cluster analysis.
|
|
874
941
|
*
|
|
@@ -1169,6 +1236,72 @@ export class Frame {
|
|
|
1169
1236
|
set simbox(value: Box | null | undefined);
|
|
1170
1237
|
}
|
|
1171
1238
|
|
|
1239
|
+
/**
|
|
1240
|
+
* Gyration tensor per cluster.
|
|
1241
|
+
*
|
|
1242
|
+
* Returns flat array: `[g00,g01,g02, g10,g11,g12, g20,g21,g22, ...]` per cluster.
|
|
1243
|
+
*/
|
|
1244
|
+
export class GyrationTensor {
|
|
1245
|
+
free(): void;
|
|
1246
|
+
[Symbol.dispose](): void;
|
|
1247
|
+
/**
|
|
1248
|
+
* Compute gyration tensors. Returns flat `Float32Array` (9 values per cluster).
|
|
1249
|
+
*/
|
|
1250
|
+
compute(frame: Frame, cluster_result: ClusterResult): Float32Array;
|
|
1251
|
+
constructor();
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* Moment of inertia tensor per cluster.
|
|
1256
|
+
*/
|
|
1257
|
+
export class InertiaTensor {
|
|
1258
|
+
free(): void;
|
|
1259
|
+
[Symbol.dispose](): void;
|
|
1260
|
+
/**
|
|
1261
|
+
* Compute inertia tensors. Returns flat `Float32Array` (9 values per cluster).
|
|
1262
|
+
*/
|
|
1263
|
+
compute(frame: Frame, cluster_result: ClusterResult): Float32Array;
|
|
1264
|
+
constructor(masses?: Float32Array | null);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* LAMMPS dump trajectory file reader.
|
|
1269
|
+
*
|
|
1270
|
+
* Reads multi-frame LAMMPS dump files (the format produced by the
|
|
1271
|
+
* `dump` command). Each frame produces a [`Frame`] containing an
|
|
1272
|
+
* `"atoms"` block with columns matching the dump header (e.g.
|
|
1273
|
+
* `id`, `type`, `x`, `y`, `z`, `vx`, `vy`, `vz`).
|
|
1274
|
+
*
|
|
1275
|
+
* # Example (JavaScript)
|
|
1276
|
+
*
|
|
1277
|
+
* ```js
|
|
1278
|
+
* const reader = new LAMMPSDumpReader(dumpContent);
|
|
1279
|
+
* console.log(reader.len()); // number of timesteps
|
|
1280
|
+
* const frame = reader.read(0);
|
|
1281
|
+
* const atoms = frame.getBlock("atoms");
|
|
1282
|
+
* ```
|
|
1283
|
+
*/
|
|
1284
|
+
export class LAMMPSDumpReader {
|
|
1285
|
+
free(): void;
|
|
1286
|
+
[Symbol.dispose](): void;
|
|
1287
|
+
/**
|
|
1288
|
+
* Check whether the file contains no frames.
|
|
1289
|
+
*/
|
|
1290
|
+
isEmpty(): boolean;
|
|
1291
|
+
/**
|
|
1292
|
+
* Return the number of frames in the dump file.
|
|
1293
|
+
*/
|
|
1294
|
+
len(): number;
|
|
1295
|
+
/**
|
|
1296
|
+
* Create a new LAMMPS dump reader from string content.
|
|
1297
|
+
*/
|
|
1298
|
+
constructor(content: string);
|
|
1299
|
+
/**
|
|
1300
|
+
* Read a frame at the given step index.
|
|
1301
|
+
*/
|
|
1302
|
+
read(step: number): Frame | undefined;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1172
1305
|
/**
|
|
1173
1306
|
* LAMMPS data file reader.
|
|
1174
1307
|
*
|
|
@@ -1755,6 +1888,19 @@ export class RDFResult {
|
|
|
1755
1888
|
readonly volume: number;
|
|
1756
1889
|
}
|
|
1757
1890
|
|
|
1891
|
+
/**
|
|
1892
|
+
* Radius of gyration per cluster.
|
|
1893
|
+
*/
|
|
1894
|
+
export class RadiusOfGyration {
|
|
1895
|
+
free(): void;
|
|
1896
|
+
[Symbol.dispose](): void;
|
|
1897
|
+
/**
|
|
1898
|
+
* Compute radii of gyration. Returns `Float32Array` of length `numClusters`.
|
|
1899
|
+
*/
|
|
1900
|
+
compute(frame: Frame, cluster_result: ClusterResult): Float32Array;
|
|
1901
|
+
constructor(masses?: Float32Array | null);
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1758
1904
|
/**
|
|
1759
1905
|
* Reader for Zarr V3 simulation archives.
|
|
1760
1906
|
*
|
|
@@ -1935,6 +2081,163 @@ export class SmilesIR {
|
|
|
1935
2081
|
readonly nComponents: number;
|
|
1936
2082
|
}
|
|
1937
2083
|
|
|
2084
|
+
/**
|
|
2085
|
+
* Graph-based molecular topology with automated detection of angles,
|
|
2086
|
+
* dihedrals, impropers, connected components, and rings (SSSR).
|
|
2087
|
+
*
|
|
2088
|
+
* API mirrors igraph / molpy conventions.
|
|
2089
|
+
*
|
|
2090
|
+
* # Example (JavaScript)
|
|
2091
|
+
*
|
|
2092
|
+
* ```js
|
|
2093
|
+
* const topo = Topology.fromFrame(frame);
|
|
2094
|
+
* console.log(topo.nAtoms, topo.nBonds);
|
|
2095
|
+
*
|
|
2096
|
+
* const angles = topo.angles(); // Uint32Array [i,j,k, ...]
|
|
2097
|
+
* const dihedrals = topo.dihedrals(); // Uint32Array [i,j,k,l, ...]
|
|
2098
|
+
* const cc = topo.connectedComponents(); // Int32Array per-atom labels
|
|
2099
|
+
*
|
|
2100
|
+
* const rings = topo.findRings();
|
|
2101
|
+
* console.log(rings.numRings);
|
|
2102
|
+
* ```
|
|
2103
|
+
*/
|
|
2104
|
+
export class Topology {
|
|
2105
|
+
free(): void;
|
|
2106
|
+
[Symbol.dispose](): void;
|
|
2107
|
+
/**
|
|
2108
|
+
* Add a single atom.
|
|
2109
|
+
*/
|
|
2110
|
+
addAtom(): void;
|
|
2111
|
+
/**
|
|
2112
|
+
* Add a bond between atoms `i` and `j`.
|
|
2113
|
+
*/
|
|
2114
|
+
addBond(i: number, j: number): void;
|
|
2115
|
+
/**
|
|
2116
|
+
* All angle triplets as flat `Uint32Array` `[i,j,k, ...]`.
|
|
2117
|
+
*/
|
|
2118
|
+
angles(): Uint32Array;
|
|
2119
|
+
/**
|
|
2120
|
+
* Whether atoms `i` and `j` are directly bonded.
|
|
2121
|
+
*/
|
|
2122
|
+
areBonded(i: number, j: number): boolean;
|
|
2123
|
+
/**
|
|
2124
|
+
* All bond pairs as flat `Uint32Array` `[i0,j0, i1,j1, ...]`.
|
|
2125
|
+
*/
|
|
2126
|
+
bonds(): Uint32Array;
|
|
2127
|
+
/**
|
|
2128
|
+
* Per-atom connected component labels as `Int32Array`.
|
|
2129
|
+
*
|
|
2130
|
+
* Labels are 0-based and contiguous. Each atom gets a component ID.
|
|
2131
|
+
* Atoms in the same connected subgraph share the same label.
|
|
2132
|
+
*/
|
|
2133
|
+
connectedComponents(): Int32Array;
|
|
2134
|
+
/**
|
|
2135
|
+
* Degree (number of bonds) of atom `idx`.
|
|
2136
|
+
*/
|
|
2137
|
+
degree(idx: number): number;
|
|
2138
|
+
/**
|
|
2139
|
+
* Delete an atom by index.
|
|
2140
|
+
*/
|
|
2141
|
+
deleteAtom(idx: number): void;
|
|
2142
|
+
/**
|
|
2143
|
+
* Delete a bond by edge index.
|
|
2144
|
+
*/
|
|
2145
|
+
deleteBond(idx: number): void;
|
|
2146
|
+
/**
|
|
2147
|
+
* All proper dihedral quartets as flat `Uint32Array` `[i,j,k,l, ...]`.
|
|
2148
|
+
*/
|
|
2149
|
+
dihedrals(): Uint32Array;
|
|
2150
|
+
/**
|
|
2151
|
+
* Compute the Smallest Set of Smallest Rings (SSSR).
|
|
2152
|
+
*/
|
|
2153
|
+
findRings(): TopologyRingInfo;
|
|
2154
|
+
/**
|
|
2155
|
+
* Build a topology from a Frame's `bonds` block.
|
|
2156
|
+
*
|
|
2157
|
+
* Reads the `atoms` block for atom count and `bonds` block for
|
|
2158
|
+
* `i`, `j` columns (Uint32).
|
|
2159
|
+
*/
|
|
2160
|
+
static fromFrame(frame: Frame): Topology;
|
|
2161
|
+
/**
|
|
2162
|
+
* All improper dihedral quartets as flat `Uint32Array` `[center,i,j,k, ...]`.
|
|
2163
|
+
*/
|
|
2164
|
+
impropers(): Uint32Array;
|
|
2165
|
+
/**
|
|
2166
|
+
* Neighbor atom indices of atom `idx` as `Uint32Array`.
|
|
2167
|
+
*/
|
|
2168
|
+
neighbors(idx: number): Uint32Array;
|
|
2169
|
+
/**
|
|
2170
|
+
* Create a topology with `n` atoms and no bonds.
|
|
2171
|
+
*/
|
|
2172
|
+
constructor(n_atoms: number);
|
|
2173
|
+
/**
|
|
2174
|
+
* Number of unique angles.
|
|
2175
|
+
*/
|
|
2176
|
+
readonly nAngles: number;
|
|
2177
|
+
/**
|
|
2178
|
+
* Number of atoms (vertices).
|
|
2179
|
+
*/
|
|
2180
|
+
readonly nAtoms: number;
|
|
2181
|
+
/**
|
|
2182
|
+
* Number of bonds (edges).
|
|
2183
|
+
*/
|
|
2184
|
+
readonly nBonds: number;
|
|
2185
|
+
/**
|
|
2186
|
+
* Number of connected components.
|
|
2187
|
+
*/
|
|
2188
|
+
readonly nComponents: number;
|
|
2189
|
+
/**
|
|
2190
|
+
* Number of unique proper dihedrals.
|
|
2191
|
+
*/
|
|
2192
|
+
readonly nDihedrals: number;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* Result of ring detection (SSSR) on a topology graph.
|
|
2197
|
+
*
|
|
2198
|
+
* # Example (JavaScript)
|
|
2199
|
+
*
|
|
2200
|
+
* ```js
|
|
2201
|
+
* const rings = topo.findRings();
|
|
2202
|
+
* console.log(rings.numRings);
|
|
2203
|
+
* console.log(rings.ringSizes()); // Uint32Array
|
|
2204
|
+
* console.log(rings.isAtomInRing(0));
|
|
2205
|
+
*
|
|
2206
|
+
* // Get all rings as flat array [size0, idx0_0, idx0_1, ..., size1, ...]
|
|
2207
|
+
* const data = rings.rings();
|
|
2208
|
+
* ```
|
|
2209
|
+
*/
|
|
2210
|
+
export class TopologyRingInfo {
|
|
2211
|
+
private constructor();
|
|
2212
|
+
free(): void;
|
|
2213
|
+
[Symbol.dispose](): void;
|
|
2214
|
+
/**
|
|
2215
|
+
* Per-atom boolean mask as `Uint8Array` (0 or 1). 1 if atom is in any ring.
|
|
2216
|
+
*/
|
|
2217
|
+
atomRingMask(n_atoms: number): Uint8Array;
|
|
2218
|
+
/**
|
|
2219
|
+
* Whether atom `idx` belongs to any ring.
|
|
2220
|
+
*/
|
|
2221
|
+
isAtomInRing(idx: number): boolean;
|
|
2222
|
+
/**
|
|
2223
|
+
* Number of rings containing atom `idx`.
|
|
2224
|
+
*/
|
|
2225
|
+
numAtomRings(idx: number): number;
|
|
2226
|
+
/**
|
|
2227
|
+
* Size of each ring as `Uint32Array`.
|
|
2228
|
+
*/
|
|
2229
|
+
ringSizes(): Uint32Array;
|
|
2230
|
+
/**
|
|
2231
|
+
* All rings as flat `Uint32Array` with length-prefixed encoding:
|
|
2232
|
+
* `[size0, atom0, atom1, ..., size1, atom0, atom1, ...]`.
|
|
2233
|
+
*/
|
|
2234
|
+
rings(): Uint32Array;
|
|
2235
|
+
/**
|
|
2236
|
+
* Total number of rings detected.
|
|
2237
|
+
*/
|
|
2238
|
+
readonly numRings: number;
|
|
2239
|
+
}
|
|
2240
|
+
|
|
1938
2241
|
/**
|
|
1939
2242
|
* Owned f32 array with ndarray-compatible shape metadata.
|
|
1940
2243
|
*
|
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, Cluster, ClusterResult, Frame, LAMMPSReader, LinkedCell, MSD, MSDResult, NeighborList, PDBReader, RDF, RDFResult, SimulationReader, SmilesIR, WasmArray, XYZReader, generate3D, parseSMILES, start, wasmMemory, writeFrame
|
|
8
|
+
Block, Box, CenterOfMass, CenterOfMassResult, Cluster, ClusterCenters, ClusterResult, Frame, GyrationTensor, InertiaTensor, LAMMPSDumpReader, LAMMPSReader, LinkedCell, MSD, MSDResult, NeighborList, PDBReader, RDF, RDFResult, RadiusOfGyration, SimulationReader, SmilesIR, Topology, TopologyRingInfo, WasmArray, XYZReader, generate3D, parseSMILES, start, wasmMemory, writeFrame
|
|
9
9
|
} from "./molrs_bg.js";
|
package/molrs_bg.js
CHANGED
|
@@ -1149,6 +1149,112 @@ export class Box {
|
|
|
1149
1149
|
}
|
|
1150
1150
|
if (Symbol.dispose) Box.prototype[Symbol.dispose] = Box.prototype.free;
|
|
1151
1151
|
|
|
1152
|
+
/**
|
|
1153
|
+
* Mass-weighted cluster center calculator.
|
|
1154
|
+
*/
|
|
1155
|
+
export class CenterOfMass {
|
|
1156
|
+
__destroy_into_raw() {
|
|
1157
|
+
const ptr = this.__wbg_ptr;
|
|
1158
|
+
this.__wbg_ptr = 0;
|
|
1159
|
+
CenterOfMassFinalization.unregister(this);
|
|
1160
|
+
return ptr;
|
|
1161
|
+
}
|
|
1162
|
+
free() {
|
|
1163
|
+
const ptr = this.__destroy_into_raw();
|
|
1164
|
+
wasm.__wbg_centerofmass_free(ptr, 0);
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Compute centers of mass.
|
|
1168
|
+
* @param {Frame} frame
|
|
1169
|
+
* @param {ClusterResult} cluster_result
|
|
1170
|
+
* @returns {CenterOfMassResult}
|
|
1171
|
+
*/
|
|
1172
|
+
compute(frame, cluster_result) {
|
|
1173
|
+
_assertClass(frame, Frame);
|
|
1174
|
+
_assertClass(cluster_result, ClusterResult);
|
|
1175
|
+
const ret = wasm.centerofmass_compute(this.__wbg_ptr, frame.__wbg_ptr, cluster_result.__wbg_ptr);
|
|
1176
|
+
if (ret[2]) {
|
|
1177
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1178
|
+
}
|
|
1179
|
+
return CenterOfMassResult.__wrap(ret[0]);
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Create a center-of-mass calculator.
|
|
1183
|
+
*
|
|
1184
|
+
* Pass `null` for uniform masses, or a `Float32Array` of per-particle masses.
|
|
1185
|
+
* @param {Float32Array | null} [masses]
|
|
1186
|
+
*/
|
|
1187
|
+
constructor(masses) {
|
|
1188
|
+
var ptr0 = isLikeNone(masses) ? 0 : passArrayF32ToWasm0(masses, wasm.__wbindgen_malloc_command_export);
|
|
1189
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1190
|
+
const ret = wasm.centerofmass_new(ptr0, len0);
|
|
1191
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1192
|
+
CenterOfMassFinalization.register(this, this.__wbg_ptr, this);
|
|
1193
|
+
return this;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
if (Symbol.dispose) CenterOfMass.prototype[Symbol.dispose] = CenterOfMass.prototype.free;
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* Result of center-of-mass computation.
|
|
1200
|
+
*
|
|
1201
|
+
* # Example (JavaScript)
|
|
1202
|
+
*
|
|
1203
|
+
* ```js
|
|
1204
|
+
* const com = new CenterOfMass().compute(frame, clusterResult);
|
|
1205
|
+
* com.centersOfMass(); // Float32Array [x0,y0,z0, ...]
|
|
1206
|
+
* com.clusterMasses(); // Float32Array
|
|
1207
|
+
* ```
|
|
1208
|
+
*/
|
|
1209
|
+
export class CenterOfMassResult {
|
|
1210
|
+
static __wrap(ptr) {
|
|
1211
|
+
ptr = ptr >>> 0;
|
|
1212
|
+
const obj = Object.create(CenterOfMassResult.prototype);
|
|
1213
|
+
obj.__wbg_ptr = ptr;
|
|
1214
|
+
CenterOfMassResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1215
|
+
return obj;
|
|
1216
|
+
}
|
|
1217
|
+
__destroy_into_raw() {
|
|
1218
|
+
const ptr = this.__wbg_ptr;
|
|
1219
|
+
this.__wbg_ptr = 0;
|
|
1220
|
+
CenterOfMassResultFinalization.unregister(this);
|
|
1221
|
+
return ptr;
|
|
1222
|
+
}
|
|
1223
|
+
free() {
|
|
1224
|
+
const ptr = this.__destroy_into_raw();
|
|
1225
|
+
wasm.__wbg_centerofmassresult_free(ptr, 0);
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Mass-weighted centers, flat `[x0,y0,z0, x1,y1,z1, ...]`.
|
|
1229
|
+
* @returns {Float32Array}
|
|
1230
|
+
*/
|
|
1231
|
+
centersOfMass() {
|
|
1232
|
+
const ret = wasm.centerofmassresult_centersOfMass(this.__wbg_ptr);
|
|
1233
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
1234
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
1235
|
+
return v1;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Total mass per cluster.
|
|
1239
|
+
* @returns {Float32Array}
|
|
1240
|
+
*/
|
|
1241
|
+
clusterMasses() {
|
|
1242
|
+
const ret = wasm.centerofmassresult_clusterMasses(this.__wbg_ptr);
|
|
1243
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
1244
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
1245
|
+
return v1;
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Number of clusters.
|
|
1249
|
+
* @returns {number}
|
|
1250
|
+
*/
|
|
1251
|
+
get numClusters() {
|
|
1252
|
+
const ret = wasm.centerofmassresult_numClusters(this.__wbg_ptr);
|
|
1253
|
+
return ret >>> 0;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
if (Symbol.dispose) CenterOfMassResult.prototype[Symbol.dispose] = CenterOfMassResult.prototype.free;
|
|
1257
|
+
|
|
1152
1258
|
/**
|
|
1153
1259
|
* Distance-based cluster analysis using BFS on the neighbor graph.
|
|
1154
1260
|
*
|
|
@@ -1241,6 +1347,53 @@ export class Cluster {
|
|
|
1241
1347
|
}
|
|
1242
1348
|
if (Symbol.dispose) Cluster.prototype[Symbol.dispose] = Cluster.prototype.free;
|
|
1243
1349
|
|
|
1350
|
+
/**
|
|
1351
|
+
* Geometric cluster centers with minimum image convention.
|
|
1352
|
+
*
|
|
1353
|
+
* # Example (JavaScript)
|
|
1354
|
+
*
|
|
1355
|
+
* ```js
|
|
1356
|
+
* const centers = new ClusterCenters().compute(frame, clusterResult);
|
|
1357
|
+
* // Float32Array [x0,y0,z0, x1,y1,z1, ...]
|
|
1358
|
+
* ```
|
|
1359
|
+
*/
|
|
1360
|
+
export class ClusterCenters {
|
|
1361
|
+
__destroy_into_raw() {
|
|
1362
|
+
const ptr = this.__wbg_ptr;
|
|
1363
|
+
this.__wbg_ptr = 0;
|
|
1364
|
+
ClusterCentersFinalization.unregister(this);
|
|
1365
|
+
return ptr;
|
|
1366
|
+
}
|
|
1367
|
+
free() {
|
|
1368
|
+
const ptr = this.__destroy_into_raw();
|
|
1369
|
+
wasm.__wbg_clustercenters_free(ptr, 0);
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Compute geometric centers. Returns flat `Float32Array` `[x0,y0,z0, ...]`.
|
|
1373
|
+
* @param {Frame} frame
|
|
1374
|
+
* @param {ClusterResult} cluster_result
|
|
1375
|
+
* @returns {Float32Array}
|
|
1376
|
+
*/
|
|
1377
|
+
compute(frame, cluster_result) {
|
|
1378
|
+
_assertClass(frame, Frame);
|
|
1379
|
+
_assertClass(cluster_result, ClusterResult);
|
|
1380
|
+
const ret = wasm.clustercenters_compute(this.__wbg_ptr, frame.__wbg_ptr, cluster_result.__wbg_ptr);
|
|
1381
|
+
if (ret[3]) {
|
|
1382
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1383
|
+
}
|
|
1384
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
1385
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
1386
|
+
return v1;
|
|
1387
|
+
}
|
|
1388
|
+
constructor() {
|
|
1389
|
+
const ret = wasm.clustercenters_new();
|
|
1390
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1391
|
+
ClusterCentersFinalization.register(this, this.__wbg_ptr, this);
|
|
1392
|
+
return this;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
if (Symbol.dispose) ClusterCenters.prototype[Symbol.dispose] = ClusterCenters.prototype.free;
|
|
1396
|
+
|
|
1244
1397
|
/**
|
|
1245
1398
|
* Result of a distance-based cluster analysis.
|
|
1246
1399
|
*
|
|
@@ -1683,6 +1836,170 @@ export class Frame {
|
|
|
1683
1836
|
}
|
|
1684
1837
|
if (Symbol.dispose) Frame.prototype[Symbol.dispose] = Frame.prototype.free;
|
|
1685
1838
|
|
|
1839
|
+
/**
|
|
1840
|
+
* Gyration tensor per cluster.
|
|
1841
|
+
*
|
|
1842
|
+
* Returns flat array: `[g00,g01,g02, g10,g11,g12, g20,g21,g22, ...]` per cluster.
|
|
1843
|
+
*/
|
|
1844
|
+
export class GyrationTensor {
|
|
1845
|
+
__destroy_into_raw() {
|
|
1846
|
+
const ptr = this.__wbg_ptr;
|
|
1847
|
+
this.__wbg_ptr = 0;
|
|
1848
|
+
GyrationTensorFinalization.unregister(this);
|
|
1849
|
+
return ptr;
|
|
1850
|
+
}
|
|
1851
|
+
free() {
|
|
1852
|
+
const ptr = this.__destroy_into_raw();
|
|
1853
|
+
wasm.__wbg_gyrationtensor_free(ptr, 0);
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Compute gyration tensors. Returns flat `Float32Array` (9 values per cluster).
|
|
1857
|
+
* @param {Frame} frame
|
|
1858
|
+
* @param {ClusterResult} cluster_result
|
|
1859
|
+
* @returns {Float32Array}
|
|
1860
|
+
*/
|
|
1861
|
+
compute(frame, cluster_result) {
|
|
1862
|
+
_assertClass(frame, Frame);
|
|
1863
|
+
_assertClass(cluster_result, ClusterResult);
|
|
1864
|
+
const ret = wasm.gyrationtensor_compute(this.__wbg_ptr, frame.__wbg_ptr, cluster_result.__wbg_ptr);
|
|
1865
|
+
if (ret[3]) {
|
|
1866
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1867
|
+
}
|
|
1868
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
1869
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
1870
|
+
return v1;
|
|
1871
|
+
}
|
|
1872
|
+
constructor() {
|
|
1873
|
+
const ret = wasm.gyrationtensor_new();
|
|
1874
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1875
|
+
GyrationTensorFinalization.register(this, this.__wbg_ptr, this);
|
|
1876
|
+
return this;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
if (Symbol.dispose) GyrationTensor.prototype[Symbol.dispose] = GyrationTensor.prototype.free;
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Moment of inertia tensor per cluster.
|
|
1883
|
+
*/
|
|
1884
|
+
export class InertiaTensor {
|
|
1885
|
+
__destroy_into_raw() {
|
|
1886
|
+
const ptr = this.__wbg_ptr;
|
|
1887
|
+
this.__wbg_ptr = 0;
|
|
1888
|
+
InertiaTensorFinalization.unregister(this);
|
|
1889
|
+
return ptr;
|
|
1890
|
+
}
|
|
1891
|
+
free() {
|
|
1892
|
+
const ptr = this.__destroy_into_raw();
|
|
1893
|
+
wasm.__wbg_inertiatensor_free(ptr, 0);
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Compute inertia tensors. Returns flat `Float32Array` (9 values per cluster).
|
|
1897
|
+
* @param {Frame} frame
|
|
1898
|
+
* @param {ClusterResult} cluster_result
|
|
1899
|
+
* @returns {Float32Array}
|
|
1900
|
+
*/
|
|
1901
|
+
compute(frame, cluster_result) {
|
|
1902
|
+
_assertClass(frame, Frame);
|
|
1903
|
+
_assertClass(cluster_result, ClusterResult);
|
|
1904
|
+
const ret = wasm.inertiatensor_compute(this.__wbg_ptr, frame.__wbg_ptr, cluster_result.__wbg_ptr);
|
|
1905
|
+
if (ret[3]) {
|
|
1906
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1907
|
+
}
|
|
1908
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
1909
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
1910
|
+
return v1;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* @param {Float32Array | null} [masses]
|
|
1914
|
+
*/
|
|
1915
|
+
constructor(masses) {
|
|
1916
|
+
var ptr0 = isLikeNone(masses) ? 0 : passArrayF32ToWasm0(masses, wasm.__wbindgen_malloc_command_export);
|
|
1917
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1918
|
+
const ret = wasm.inertiatensor_new(ptr0, len0);
|
|
1919
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1920
|
+
InertiaTensorFinalization.register(this, this.__wbg_ptr, this);
|
|
1921
|
+
return this;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
if (Symbol.dispose) InertiaTensor.prototype[Symbol.dispose] = InertiaTensor.prototype.free;
|
|
1925
|
+
|
|
1926
|
+
/**
|
|
1927
|
+
* LAMMPS dump trajectory file reader.
|
|
1928
|
+
*
|
|
1929
|
+
* Reads multi-frame LAMMPS dump files (the format produced by the
|
|
1930
|
+
* `dump` command). Each frame produces a [`Frame`] containing an
|
|
1931
|
+
* `"atoms"` block with columns matching the dump header (e.g.
|
|
1932
|
+
* `id`, `type`, `x`, `y`, `z`, `vx`, `vy`, `vz`).
|
|
1933
|
+
*
|
|
1934
|
+
* # Example (JavaScript)
|
|
1935
|
+
*
|
|
1936
|
+
* ```js
|
|
1937
|
+
* const reader = new LAMMPSDumpReader(dumpContent);
|
|
1938
|
+
* console.log(reader.len()); // number of timesteps
|
|
1939
|
+
* const frame = reader.read(0);
|
|
1940
|
+
* const atoms = frame.getBlock("atoms");
|
|
1941
|
+
* ```
|
|
1942
|
+
*/
|
|
1943
|
+
export class LAMMPSDumpReader {
|
|
1944
|
+
__destroy_into_raw() {
|
|
1945
|
+
const ptr = this.__wbg_ptr;
|
|
1946
|
+
this.__wbg_ptr = 0;
|
|
1947
|
+
LAMMPSDumpReaderFinalization.unregister(this);
|
|
1948
|
+
return ptr;
|
|
1949
|
+
}
|
|
1950
|
+
free() {
|
|
1951
|
+
const ptr = this.__destroy_into_raw();
|
|
1952
|
+
wasm.__wbg_lammpsdumpreader_free(ptr, 0);
|
|
1953
|
+
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Check whether the file contains no frames.
|
|
1956
|
+
* @returns {boolean}
|
|
1957
|
+
*/
|
|
1958
|
+
isEmpty() {
|
|
1959
|
+
const ret = wasm.lammpsdumpreader_isEmpty(this.__wbg_ptr);
|
|
1960
|
+
if (ret[2]) {
|
|
1961
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1962
|
+
}
|
|
1963
|
+
return ret[0] !== 0;
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Return the number of frames in the dump file.
|
|
1967
|
+
* @returns {number}
|
|
1968
|
+
*/
|
|
1969
|
+
len() {
|
|
1970
|
+
const ret = wasm.lammpsdumpreader_len(this.__wbg_ptr);
|
|
1971
|
+
if (ret[2]) {
|
|
1972
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1973
|
+
}
|
|
1974
|
+
return ret[0] >>> 0;
|
|
1975
|
+
}
|
|
1976
|
+
/**
|
|
1977
|
+
* Create a new LAMMPS dump reader from string content.
|
|
1978
|
+
* @param {string} content
|
|
1979
|
+
*/
|
|
1980
|
+
constructor(content) {
|
|
1981
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
1982
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1983
|
+
const ret = wasm.lammpsdumpreader_new(ptr0, len0);
|
|
1984
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1985
|
+
LAMMPSDumpReaderFinalization.register(this, this.__wbg_ptr, this);
|
|
1986
|
+
return this;
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Read a frame at the given step index.
|
|
1990
|
+
* @param {number} step
|
|
1991
|
+
* @returns {Frame | undefined}
|
|
1992
|
+
*/
|
|
1993
|
+
read(step) {
|
|
1994
|
+
const ret = wasm.lammpsdumpreader_read(this.__wbg_ptr, step);
|
|
1995
|
+
if (ret[2]) {
|
|
1996
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1997
|
+
}
|
|
1998
|
+
return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
if (Symbol.dispose) LAMMPSDumpReader.prototype[Symbol.dispose] = LAMMPSDumpReader.prototype.free;
|
|
2002
|
+
|
|
1686
2003
|
/**
|
|
1687
2004
|
* LAMMPS data file reader.
|
|
1688
2005
|
*
|
|
@@ -2569,6 +2886,51 @@ export class RDFResult {
|
|
|
2569
2886
|
}
|
|
2570
2887
|
if (Symbol.dispose) RDFResult.prototype[Symbol.dispose] = RDFResult.prototype.free;
|
|
2571
2888
|
|
|
2889
|
+
/**
|
|
2890
|
+
* Radius of gyration per cluster.
|
|
2891
|
+
*/
|
|
2892
|
+
export class RadiusOfGyration {
|
|
2893
|
+
__destroy_into_raw() {
|
|
2894
|
+
const ptr = this.__wbg_ptr;
|
|
2895
|
+
this.__wbg_ptr = 0;
|
|
2896
|
+
RadiusOfGyrationFinalization.unregister(this);
|
|
2897
|
+
return ptr;
|
|
2898
|
+
}
|
|
2899
|
+
free() {
|
|
2900
|
+
const ptr = this.__destroy_into_raw();
|
|
2901
|
+
wasm.__wbg_radiusofgyration_free(ptr, 0);
|
|
2902
|
+
}
|
|
2903
|
+
/**
|
|
2904
|
+
* Compute radii of gyration. Returns `Float32Array` of length `numClusters`.
|
|
2905
|
+
* @param {Frame} frame
|
|
2906
|
+
* @param {ClusterResult} cluster_result
|
|
2907
|
+
* @returns {Float32Array}
|
|
2908
|
+
*/
|
|
2909
|
+
compute(frame, cluster_result) {
|
|
2910
|
+
_assertClass(frame, Frame);
|
|
2911
|
+
_assertClass(cluster_result, ClusterResult);
|
|
2912
|
+
const ret = wasm.radiusofgyration_compute(this.__wbg_ptr, frame.__wbg_ptr, cluster_result.__wbg_ptr);
|
|
2913
|
+
if (ret[3]) {
|
|
2914
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2915
|
+
}
|
|
2916
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
2917
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2918
|
+
return v1;
|
|
2919
|
+
}
|
|
2920
|
+
/**
|
|
2921
|
+
* @param {Float32Array | null} [masses]
|
|
2922
|
+
*/
|
|
2923
|
+
constructor(masses) {
|
|
2924
|
+
var ptr0 = isLikeNone(masses) ? 0 : passArrayF32ToWasm0(masses, wasm.__wbindgen_malloc_command_export);
|
|
2925
|
+
var len0 = WASM_VECTOR_LEN;
|
|
2926
|
+
const ret = wasm.radiusofgyration_new(ptr0, len0);
|
|
2927
|
+
this.__wbg_ptr = ret >>> 0;
|
|
2928
|
+
RadiusOfGyrationFinalization.register(this, this.__wbg_ptr, this);
|
|
2929
|
+
return this;
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
if (Symbol.dispose) RadiusOfGyration.prototype[Symbol.dispose] = RadiusOfGyration.prototype.free;
|
|
2933
|
+
|
|
2572
2934
|
/**
|
|
2573
2935
|
* Reader for Zarr V3 simulation archives.
|
|
2574
2936
|
*
|
|
@@ -2812,6 +3174,326 @@ export class SmilesIR {
|
|
|
2812
3174
|
}
|
|
2813
3175
|
if (Symbol.dispose) SmilesIR.prototype[Symbol.dispose] = SmilesIR.prototype.free;
|
|
2814
3176
|
|
|
3177
|
+
/**
|
|
3178
|
+
* Graph-based molecular topology with automated detection of angles,
|
|
3179
|
+
* dihedrals, impropers, connected components, and rings (SSSR).
|
|
3180
|
+
*
|
|
3181
|
+
* API mirrors igraph / molpy conventions.
|
|
3182
|
+
*
|
|
3183
|
+
* # Example (JavaScript)
|
|
3184
|
+
*
|
|
3185
|
+
* ```js
|
|
3186
|
+
* const topo = Topology.fromFrame(frame);
|
|
3187
|
+
* console.log(topo.nAtoms, topo.nBonds);
|
|
3188
|
+
*
|
|
3189
|
+
* const angles = topo.angles(); // Uint32Array [i,j,k, ...]
|
|
3190
|
+
* const dihedrals = topo.dihedrals(); // Uint32Array [i,j,k,l, ...]
|
|
3191
|
+
* const cc = topo.connectedComponents(); // Int32Array per-atom labels
|
|
3192
|
+
*
|
|
3193
|
+
* const rings = topo.findRings();
|
|
3194
|
+
* console.log(rings.numRings);
|
|
3195
|
+
* ```
|
|
3196
|
+
*/
|
|
3197
|
+
export class Topology {
|
|
3198
|
+
static __wrap(ptr) {
|
|
3199
|
+
ptr = ptr >>> 0;
|
|
3200
|
+
const obj = Object.create(Topology.prototype);
|
|
3201
|
+
obj.__wbg_ptr = ptr;
|
|
3202
|
+
TopologyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3203
|
+
return obj;
|
|
3204
|
+
}
|
|
3205
|
+
__destroy_into_raw() {
|
|
3206
|
+
const ptr = this.__wbg_ptr;
|
|
3207
|
+
this.__wbg_ptr = 0;
|
|
3208
|
+
TopologyFinalization.unregister(this);
|
|
3209
|
+
return ptr;
|
|
3210
|
+
}
|
|
3211
|
+
free() {
|
|
3212
|
+
const ptr = this.__destroy_into_raw();
|
|
3213
|
+
wasm.__wbg_topology_free(ptr, 0);
|
|
3214
|
+
}
|
|
3215
|
+
/**
|
|
3216
|
+
* Add a single atom.
|
|
3217
|
+
*/
|
|
3218
|
+
addAtom() {
|
|
3219
|
+
wasm.topology_addAtom(this.__wbg_ptr);
|
|
3220
|
+
}
|
|
3221
|
+
/**
|
|
3222
|
+
* Add a bond between atoms `i` and `j`.
|
|
3223
|
+
* @param {number} i
|
|
3224
|
+
* @param {number} j
|
|
3225
|
+
*/
|
|
3226
|
+
addBond(i, j) {
|
|
3227
|
+
wasm.topology_addBond(this.__wbg_ptr, i, j);
|
|
3228
|
+
}
|
|
3229
|
+
/**
|
|
3230
|
+
* All angle triplets as flat `Uint32Array` `[i,j,k, ...]`.
|
|
3231
|
+
* @returns {Uint32Array}
|
|
3232
|
+
*/
|
|
3233
|
+
angles() {
|
|
3234
|
+
const ret = wasm.topology_angles(this.__wbg_ptr);
|
|
3235
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3236
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
3237
|
+
return v1;
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* Whether atoms `i` and `j` are directly bonded.
|
|
3241
|
+
* @param {number} i
|
|
3242
|
+
* @param {number} j
|
|
3243
|
+
* @returns {boolean}
|
|
3244
|
+
*/
|
|
3245
|
+
areBonded(i, j) {
|
|
3246
|
+
const ret = wasm.topology_areBonded(this.__wbg_ptr, i, j);
|
|
3247
|
+
return ret !== 0;
|
|
3248
|
+
}
|
|
3249
|
+
/**
|
|
3250
|
+
* All bond pairs as flat `Uint32Array` `[i0,j0, i1,j1, ...]`.
|
|
3251
|
+
* @returns {Uint32Array}
|
|
3252
|
+
*/
|
|
3253
|
+
bonds() {
|
|
3254
|
+
const ret = wasm.topology_bonds(this.__wbg_ptr);
|
|
3255
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3256
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
3257
|
+
return v1;
|
|
3258
|
+
}
|
|
3259
|
+
/**
|
|
3260
|
+
* Per-atom connected component labels as `Int32Array`.
|
|
3261
|
+
*
|
|
3262
|
+
* Labels are 0-based and contiguous. Each atom gets a component ID.
|
|
3263
|
+
* Atoms in the same connected subgraph share the same label.
|
|
3264
|
+
* @returns {Int32Array}
|
|
3265
|
+
*/
|
|
3266
|
+
connectedComponents() {
|
|
3267
|
+
const ret = wasm.topology_connectedComponents(this.__wbg_ptr);
|
|
3268
|
+
var v1 = getArrayI32FromWasm0(ret[0], ret[1]).slice();
|
|
3269
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
3270
|
+
return v1;
|
|
3271
|
+
}
|
|
3272
|
+
/**
|
|
3273
|
+
* Degree (number of bonds) of atom `idx`.
|
|
3274
|
+
* @param {number} idx
|
|
3275
|
+
* @returns {number}
|
|
3276
|
+
*/
|
|
3277
|
+
degree(idx) {
|
|
3278
|
+
const ret = wasm.topology_degree(this.__wbg_ptr, idx);
|
|
3279
|
+
return ret >>> 0;
|
|
3280
|
+
}
|
|
3281
|
+
/**
|
|
3282
|
+
* Delete an atom by index.
|
|
3283
|
+
* @param {number} idx
|
|
3284
|
+
*/
|
|
3285
|
+
deleteAtom(idx) {
|
|
3286
|
+
wasm.topology_deleteAtom(this.__wbg_ptr, idx);
|
|
3287
|
+
}
|
|
3288
|
+
/**
|
|
3289
|
+
* Delete a bond by edge index.
|
|
3290
|
+
* @param {number} idx
|
|
3291
|
+
*/
|
|
3292
|
+
deleteBond(idx) {
|
|
3293
|
+
wasm.topology_deleteBond(this.__wbg_ptr, idx);
|
|
3294
|
+
}
|
|
3295
|
+
/**
|
|
3296
|
+
* All proper dihedral quartets as flat `Uint32Array` `[i,j,k,l, ...]`.
|
|
3297
|
+
* @returns {Uint32Array}
|
|
3298
|
+
*/
|
|
3299
|
+
dihedrals() {
|
|
3300
|
+
const ret = wasm.topology_dihedrals(this.__wbg_ptr);
|
|
3301
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3302
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
3303
|
+
return v1;
|
|
3304
|
+
}
|
|
3305
|
+
/**
|
|
3306
|
+
* Compute the Smallest Set of Smallest Rings (SSSR).
|
|
3307
|
+
* @returns {TopologyRingInfo}
|
|
3308
|
+
*/
|
|
3309
|
+
findRings() {
|
|
3310
|
+
const ret = wasm.topology_findRings(this.__wbg_ptr);
|
|
3311
|
+
return TopologyRingInfo.__wrap(ret);
|
|
3312
|
+
}
|
|
3313
|
+
/**
|
|
3314
|
+
* Build a topology from a Frame's `bonds` block.
|
|
3315
|
+
*
|
|
3316
|
+
* Reads the `atoms` block for atom count and `bonds` block for
|
|
3317
|
+
* `i`, `j` columns (Uint32).
|
|
3318
|
+
* @param {Frame} frame
|
|
3319
|
+
* @returns {Topology}
|
|
3320
|
+
*/
|
|
3321
|
+
static fromFrame(frame) {
|
|
3322
|
+
_assertClass(frame, Frame);
|
|
3323
|
+
const ret = wasm.topology_fromFrame(frame.__wbg_ptr);
|
|
3324
|
+
if (ret[2]) {
|
|
3325
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3326
|
+
}
|
|
3327
|
+
return Topology.__wrap(ret[0]);
|
|
3328
|
+
}
|
|
3329
|
+
/**
|
|
3330
|
+
* All improper dihedral quartets as flat `Uint32Array` `[center,i,j,k, ...]`.
|
|
3331
|
+
* @returns {Uint32Array}
|
|
3332
|
+
*/
|
|
3333
|
+
impropers() {
|
|
3334
|
+
const ret = wasm.topology_impropers(this.__wbg_ptr);
|
|
3335
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3336
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
3337
|
+
return v1;
|
|
3338
|
+
}
|
|
3339
|
+
/**
|
|
3340
|
+
* Number of unique angles.
|
|
3341
|
+
* @returns {number}
|
|
3342
|
+
*/
|
|
3343
|
+
get nAngles() {
|
|
3344
|
+
const ret = wasm.topology_nAngles(this.__wbg_ptr);
|
|
3345
|
+
return ret >>> 0;
|
|
3346
|
+
}
|
|
3347
|
+
/**
|
|
3348
|
+
* Number of atoms (vertices).
|
|
3349
|
+
* @returns {number}
|
|
3350
|
+
*/
|
|
3351
|
+
get nAtoms() {
|
|
3352
|
+
const ret = wasm.topology_nAtoms(this.__wbg_ptr);
|
|
3353
|
+
return ret >>> 0;
|
|
3354
|
+
}
|
|
3355
|
+
/**
|
|
3356
|
+
* Number of bonds (edges).
|
|
3357
|
+
* @returns {number}
|
|
3358
|
+
*/
|
|
3359
|
+
get nBonds() {
|
|
3360
|
+
const ret = wasm.topology_nBonds(this.__wbg_ptr);
|
|
3361
|
+
return ret >>> 0;
|
|
3362
|
+
}
|
|
3363
|
+
/**
|
|
3364
|
+
* Number of connected components.
|
|
3365
|
+
* @returns {number}
|
|
3366
|
+
*/
|
|
3367
|
+
get nComponents() {
|
|
3368
|
+
const ret = wasm.topology_nComponents(this.__wbg_ptr);
|
|
3369
|
+
return ret >>> 0;
|
|
3370
|
+
}
|
|
3371
|
+
/**
|
|
3372
|
+
* Number of unique proper dihedrals.
|
|
3373
|
+
* @returns {number}
|
|
3374
|
+
*/
|
|
3375
|
+
get nDihedrals() {
|
|
3376
|
+
const ret = wasm.topology_nDihedrals(this.__wbg_ptr);
|
|
3377
|
+
return ret >>> 0;
|
|
3378
|
+
}
|
|
3379
|
+
/**
|
|
3380
|
+
* Neighbor atom indices of atom `idx` as `Uint32Array`.
|
|
3381
|
+
* @param {number} idx
|
|
3382
|
+
* @returns {Uint32Array}
|
|
3383
|
+
*/
|
|
3384
|
+
neighbors(idx) {
|
|
3385
|
+
const ret = wasm.topology_neighbors(this.__wbg_ptr, idx);
|
|
3386
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3387
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
3388
|
+
return v1;
|
|
3389
|
+
}
|
|
3390
|
+
/**
|
|
3391
|
+
* Create a topology with `n` atoms and no bonds.
|
|
3392
|
+
* @param {number} n_atoms
|
|
3393
|
+
*/
|
|
3394
|
+
constructor(n_atoms) {
|
|
3395
|
+
const ret = wasm.topology_new(n_atoms);
|
|
3396
|
+
this.__wbg_ptr = ret >>> 0;
|
|
3397
|
+
TopologyFinalization.register(this, this.__wbg_ptr, this);
|
|
3398
|
+
return this;
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
if (Symbol.dispose) Topology.prototype[Symbol.dispose] = Topology.prototype.free;
|
|
3402
|
+
|
|
3403
|
+
/**
|
|
3404
|
+
* Result of ring detection (SSSR) on a topology graph.
|
|
3405
|
+
*
|
|
3406
|
+
* # Example (JavaScript)
|
|
3407
|
+
*
|
|
3408
|
+
* ```js
|
|
3409
|
+
* const rings = topo.findRings();
|
|
3410
|
+
* console.log(rings.numRings);
|
|
3411
|
+
* console.log(rings.ringSizes()); // Uint32Array
|
|
3412
|
+
* console.log(rings.isAtomInRing(0));
|
|
3413
|
+
*
|
|
3414
|
+
* // Get all rings as flat array [size0, idx0_0, idx0_1, ..., size1, ...]
|
|
3415
|
+
* const data = rings.rings();
|
|
3416
|
+
* ```
|
|
3417
|
+
*/
|
|
3418
|
+
export class TopologyRingInfo {
|
|
3419
|
+
static __wrap(ptr) {
|
|
3420
|
+
ptr = ptr >>> 0;
|
|
3421
|
+
const obj = Object.create(TopologyRingInfo.prototype);
|
|
3422
|
+
obj.__wbg_ptr = ptr;
|
|
3423
|
+
TopologyRingInfoFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3424
|
+
return obj;
|
|
3425
|
+
}
|
|
3426
|
+
__destroy_into_raw() {
|
|
3427
|
+
const ptr = this.__wbg_ptr;
|
|
3428
|
+
this.__wbg_ptr = 0;
|
|
3429
|
+
TopologyRingInfoFinalization.unregister(this);
|
|
3430
|
+
return ptr;
|
|
3431
|
+
}
|
|
3432
|
+
free() {
|
|
3433
|
+
const ptr = this.__destroy_into_raw();
|
|
3434
|
+
wasm.__wbg_topologyringinfo_free(ptr, 0);
|
|
3435
|
+
}
|
|
3436
|
+
/**
|
|
3437
|
+
* Per-atom boolean mask as `Uint8Array` (0 or 1). 1 if atom is in any ring.
|
|
3438
|
+
* @param {number} n_atoms
|
|
3439
|
+
* @returns {Uint8Array}
|
|
3440
|
+
*/
|
|
3441
|
+
atomRingMask(n_atoms) {
|
|
3442
|
+
const ret = wasm.topologyringinfo_atomRingMask(this.__wbg_ptr, n_atoms);
|
|
3443
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
3444
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
|
|
3445
|
+
return v1;
|
|
3446
|
+
}
|
|
3447
|
+
/**
|
|
3448
|
+
* Whether atom `idx` belongs to any ring.
|
|
3449
|
+
* @param {number} idx
|
|
3450
|
+
* @returns {boolean}
|
|
3451
|
+
*/
|
|
3452
|
+
isAtomInRing(idx) {
|
|
3453
|
+
const ret = wasm.topologyringinfo_isAtomInRing(this.__wbg_ptr, idx);
|
|
3454
|
+
return ret !== 0;
|
|
3455
|
+
}
|
|
3456
|
+
/**
|
|
3457
|
+
* Number of rings containing atom `idx`.
|
|
3458
|
+
* @param {number} idx
|
|
3459
|
+
* @returns {number}
|
|
3460
|
+
*/
|
|
3461
|
+
numAtomRings(idx) {
|
|
3462
|
+
const ret = wasm.topologyringinfo_numAtomRings(this.__wbg_ptr, idx);
|
|
3463
|
+
return ret >>> 0;
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* Total number of rings detected.
|
|
3467
|
+
* @returns {number}
|
|
3468
|
+
*/
|
|
3469
|
+
get numRings() {
|
|
3470
|
+
const ret = wasm.topologyringinfo_numRings(this.__wbg_ptr);
|
|
3471
|
+
return ret >>> 0;
|
|
3472
|
+
}
|
|
3473
|
+
/**
|
|
3474
|
+
* Size of each ring as `Uint32Array`.
|
|
3475
|
+
* @returns {Uint32Array}
|
|
3476
|
+
*/
|
|
3477
|
+
ringSizes() {
|
|
3478
|
+
const ret = wasm.topologyringinfo_ringSizes(this.__wbg_ptr);
|
|
3479
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3480
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
3481
|
+
return v1;
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* All rings as flat `Uint32Array` with length-prefixed encoding:
|
|
3485
|
+
* `[size0, atom0, atom1, ..., size1, atom0, atom1, ...]`.
|
|
3486
|
+
* @returns {Uint32Array}
|
|
3487
|
+
*/
|
|
3488
|
+
rings() {
|
|
3489
|
+
const ret = wasm.topologyringinfo_rings(this.__wbg_ptr);
|
|
3490
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3491
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
3492
|
+
return v1;
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
if (Symbol.dispose) TopologyRingInfo.prototype[Symbol.dispose] = TopologyRingInfo.prototype.free;
|
|
3496
|
+
|
|
2815
3497
|
/**
|
|
2816
3498
|
* Owned f32 array with ndarray-compatible shape metadata.
|
|
2817
3499
|
*
|
|
@@ -3562,15 +4244,33 @@ const BlockFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
3562
4244
|
const BoxFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3563
4245
|
? { register: () => {}, unregister: () => {} }
|
|
3564
4246
|
: new FinalizationRegistry(ptr => wasm.__wbg_box_free(ptr >>> 0, 1));
|
|
4247
|
+
const CenterOfMassFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4248
|
+
? { register: () => {}, unregister: () => {} }
|
|
4249
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_centerofmass_free(ptr >>> 0, 1));
|
|
4250
|
+
const CenterOfMassResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4251
|
+
? { register: () => {}, unregister: () => {} }
|
|
4252
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_centerofmassresult_free(ptr >>> 0, 1));
|
|
3565
4253
|
const ClusterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3566
4254
|
? { register: () => {}, unregister: () => {} }
|
|
3567
4255
|
: new FinalizationRegistry(ptr => wasm.__wbg_cluster_free(ptr >>> 0, 1));
|
|
4256
|
+
const ClusterCentersFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4257
|
+
? { register: () => {}, unregister: () => {} }
|
|
4258
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_clustercenters_free(ptr >>> 0, 1));
|
|
3568
4259
|
const ClusterResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3569
4260
|
? { register: () => {}, unregister: () => {} }
|
|
3570
4261
|
: new FinalizationRegistry(ptr => wasm.__wbg_clusterresult_free(ptr >>> 0, 1));
|
|
3571
4262
|
const FrameFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3572
4263
|
? { register: () => {}, unregister: () => {} }
|
|
3573
4264
|
: new FinalizationRegistry(ptr => wasm.__wbg_frame_free(ptr >>> 0, 1));
|
|
4265
|
+
const GyrationTensorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4266
|
+
? { register: () => {}, unregister: () => {} }
|
|
4267
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_gyrationtensor_free(ptr >>> 0, 1));
|
|
4268
|
+
const InertiaTensorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4269
|
+
? { register: () => {}, unregister: () => {} }
|
|
4270
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_inertiatensor_free(ptr >>> 0, 1));
|
|
4271
|
+
const LAMMPSDumpReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4272
|
+
? { register: () => {}, unregister: () => {} }
|
|
4273
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_lammpsdumpreader_free(ptr >>> 0, 1));
|
|
3574
4274
|
const LAMMPSReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3575
4275
|
? { register: () => {}, unregister: () => {} }
|
|
3576
4276
|
: new FinalizationRegistry(ptr => wasm.__wbg_lammpsreader_free(ptr >>> 0, 1));
|
|
@@ -3595,15 +4295,24 @@ const RDFFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
3595
4295
|
const RDFResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3596
4296
|
? { register: () => {}, unregister: () => {} }
|
|
3597
4297
|
: new FinalizationRegistry(ptr => wasm.__wbg_rdfresult_free(ptr >>> 0, 1));
|
|
4298
|
+
const RadiusOfGyrationFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4299
|
+
? { register: () => {}, unregister: () => {} }
|
|
4300
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_radiusofgyration_free(ptr >>> 0, 1));
|
|
3598
4301
|
const SimulationReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3599
4302
|
? { register: () => {}, unregister: () => {} }
|
|
3600
4303
|
: new FinalizationRegistry(ptr => wasm.__wbg_simulationreader_free(ptr >>> 0, 1));
|
|
4304
|
+
const TopologyRingInfoFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4305
|
+
? { register: () => {}, unregister: () => {} }
|
|
4306
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_topologyringinfo_free(ptr >>> 0, 1));
|
|
3601
4307
|
const WasmArrayFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3602
4308
|
? { register: () => {}, unregister: () => {} }
|
|
3603
4309
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmarray_free(ptr >>> 0, 1));
|
|
3604
4310
|
const SmilesIRFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3605
4311
|
? { register: () => {}, unregister: () => {} }
|
|
3606
4312
|
: new FinalizationRegistry(ptr => wasm.__wbg_smilesir_free(ptr >>> 0, 1));
|
|
4313
|
+
const TopologyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4314
|
+
? { register: () => {}, unregister: () => {} }
|
|
4315
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_topology_free(ptr >>> 0, 1));
|
|
3607
4316
|
const XYZReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3608
4317
|
? { register: () => {}, unregister: () => {} }
|
|
3609
4318
|
: new FinalizationRegistry(ptr => wasm.__wbg_xyzreader_free(ptr >>> 0, 1));
|
|
@@ -3781,6 +4490,13 @@ function passArray32ToWasm0(arg, malloc) {
|
|
|
3781
4490
|
return ptr;
|
|
3782
4491
|
}
|
|
3783
4492
|
|
|
4493
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
4494
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
4495
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
4496
|
+
WASM_VECTOR_LEN = arg.length;
|
|
4497
|
+
return ptr;
|
|
4498
|
+
}
|
|
4499
|
+
|
|
3784
4500
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
3785
4501
|
if (realloc === undefined) {
|
|
3786
4502
|
const buf = cachedTextEncoder.encode(arg);
|
package/molrs_bg.wasm
CHANGED
|
Binary file
|