bio-forge-wasm 0.3.1 → 0.4.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/README.md CHANGED
@@ -21,7 +21,7 @@ Load → Clean → Repair → Hydrogenate → Solvate → Topology → Write
21
21
  1. **Load** – `io::read_pdb_structure` or `io::read_mmcif_structure` parses coordinates with `IoContext` alias resolution.
22
22
  2. **Clean** – `ops::clean_structure` removes waters, ions, hetero residues, or arbitrary residue names via `CleanConfig`.
23
23
  3. **Repair** – `ops::repair_structure` realigns residues to templates and rebuilds missing heavy atoms (OXT on C-termini, OP3 on 5'-phosphorylated nucleic acids).
24
- 4. **Hydrogenate** – `ops::add_hydrogens` infers protonation states (configurable pH and histidine strategy) and reconstructs hydrogens from template anchors.
24
+ 4. **Hydrogenate** – `ops::add_hydrogens` infers protonation states (configurable pH, histidine strategy, and salt bridge detection) and reconstructs hydrogens from template anchors.
25
25
  5. **Solvate** – `ops::solvate_structure` creates a periodic box, packs water on a configurable lattice, and swaps molecules for ions to satisfy a target charge.
26
26
  6. **Topology** – `ops::TopologyBuilder` emits bond connectivity with peptide-link detection, nucleic backbone connectivity, and disulfide heuristics.
27
27
  7. **Write** – `io::write_pdb_structure` / `io::write_mmcif_structure` serialize the processed structure; `write_*_topology` helpers emit CONECT or `struct_conn` records.
@@ -50,7 +50,7 @@ BioForge is also available as a library crate. Add it to your `Cargo.toml` depen
50
50
 
51
51
  ```toml
52
52
  [dependencies]
53
- bio-forge = "0.3.1"
53
+ bio-forge = "0.4.1"
54
54
  ```
55
55
 
56
56
  #### Example: Preparing a PDB Structure
@@ -1,5 +1,95 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Comprehensive structure information.
5
+ */
6
+ export interface StructureInfo {
7
+ /**
8
+ * Number of chains.
9
+ */
10
+ chainCount: number;
11
+ /**
12
+ * Total number of residues.
13
+ */
14
+ residueCount: number;
15
+ /**
16
+ * Total number of atoms.
17
+ */
18
+ atomCount: number;
19
+ /**
20
+ * Box dimensions `[a, b, c]` in Å, if present.
21
+ */
22
+ boxLengths: [number, number, number] | undefined;
23
+ /**
24
+ * Box angles `[α, β, γ]` in degrees, if present.
25
+ */
26
+ boxAngles: [number, number, number] | undefined;
27
+ /**
28
+ * Per-chain information.
29
+ */
30
+ chains: ChainInfo[];
31
+ }
32
+
33
+ /**
34
+ * Configuration for hydrogen addition.
35
+ */
36
+ export interface HydroConfig {
37
+ /**
38
+ * Target pH for protonation state decisions. Default: `undefined` (neutral)
39
+ */
40
+ targetPh?: number | undefined;
41
+ /**
42
+ * Remove existing hydrogens before adding new ones. Default: `true`
43
+ */
44
+ removeExistingH?: boolean;
45
+ /**
46
+ * Histidine tautomer strategy: `\"hid\"`, `\"hie\"`, `\"random\"`, `\"network\"`. Default: `\"network\"`
47
+ */
48
+ hisStrategy?: "hid" | "hie" | "random" | "network";
49
+ /**
50
+ * Detect salt bridges for HIS → HIP conversion near carboxylate groups. Default: `true`
51
+ */
52
+ hisSaltBridgeProtonation?: boolean;
53
+ }
54
+
55
+ /**
56
+ * Configuration for solvation.
57
+ */
58
+ export interface SolvateConfig {
59
+ /**
60
+ * Margin around solute (Å). Default: `10.0`
61
+ */
62
+ margin?: number;
63
+ /**
64
+ * Water grid spacing (Å). Default: `3.1`
65
+ */
66
+ waterSpacing?: number;
67
+ /**
68
+ * Minimum solvent-solute distance (Å). Default: `2.4`
69
+ */
70
+ vdwCutoff?: number;
71
+ /**
72
+ * Remove existing solvent before solvating. Default: `true`
73
+ */
74
+ removeExisting?: boolean;
75
+ /**
76
+ * Cation species: `\"Na\"`, `\"K\"`, `\"Mg\"`, `\"Ca\"`, `\"Li\"`, `\"Zn\"`. Default: `[\"Na\"]`
77
+ */
78
+ cations?: Array<"Na" | "K" | "Mg" | "Ca" | "Li" | "Zn">;
79
+ /**
80
+ * Anion species: `\"Cl\"`, `\"Br\"`, `\"I\"`, `\"F\"`. Default: `[\"Cl\"]`
81
+ */
82
+ anions?: Array<"Cl" | "Br" | "I" | "F">;
83
+ /**
84
+ * Target net charge after solvation. Default: `0`
85
+ */
86
+ targetCharge?: number;
87
+ /**
88
+ * Random seed for reproducible placement.
89
+ */
90
+ rngSeed?: number | undefined;
91
+ }
92
+
3
93
  /**
4
94
  * Configuration for structure cleaning operations.
5
95
  */
@@ -40,24 +130,6 @@ export interface TopologyConfig {
40
130
  disulfideCutoff?: number;
41
131
  }
42
132
 
43
- /**
44
- * Configuration for hydrogen addition.
45
- */
46
- export interface HydroConfig {
47
- /**
48
- * Target pH for protonation state decisions. Default: `undefined` (neutral)
49
- */
50
- targetPh?: number | undefined;
51
- /**
52
- * Remove existing hydrogens before adding new ones. Default: `true`
53
- */
54
- removeExistingH?: boolean;
55
- /**
56
- * Histidine tautomer strategy: `\"hid\"`, `\"hie\"`, `\"random\"`, `\"network\"`. Default: `\"network\"`
57
- */
58
- hisStrategy?: "hid" | "hie" | "random" | "network";
59
- }
60
-
61
133
  /**
62
134
  * Per-chain information.
63
135
  */
@@ -82,231 +154,172 @@ export interface ChainInfo {
82
154
  polymerTypes: Array<"protein" | "nucleic" | "solvent" | "hetero">;
83
155
  }
84
156
 
157
+
85
158
  /**
86
- * Configuration for solvation.
159
+ * A molecular structure for manipulation and export.
87
160
  */
88
- export interface SolvateConfig {
161
+ export class Structure {
162
+ private constructor();
163
+ free(): void;
164
+ [Symbol.dispose](): void;
89
165
  /**
90
- * Margin around solute (Å). Default: `10.0`
166
+ * Adds hydrogen atoms.
91
167
  */
92
- margin?: number;
168
+ addHydrogens(config?: HydroConfig | null): void;
93
169
  /**
94
- * Water grid spacing (Å). Default: `3.1`
170
+ * Centers the geometric centroid at the origin.
95
171
  */
96
- waterSpacing?: number;
172
+ centerGeometry(): void;
97
173
  /**
98
- * Minimum solvent-solute distance (Å). Default: `2.4`
174
+ * Centers the center of mass at the origin.
99
175
  */
100
- vdwCutoff?: number;
176
+ centerMass(): void;
101
177
  /**
102
- * Remove existing solvent before solvating. Default: `true`
178
+ * Removes unwanted components (water, ions, hydrogens, hetero residues).
103
179
  */
104
- removeExisting?: boolean;
180
+ clean(config?: CleanConfig | null): void;
105
181
  /**
106
- * Cation species: `\"Na\"`, `\"K\"`, `\"Mg\"`, `\"Ca\"`, `\"Li\"`, `\"Zn\"`. Default: `[\"Na\"]`
182
+ * Creates a deep copy of the structure.
107
183
  */
108
- cations?: Array<"Na" | "K" | "Mg" | "Ca" | "Li" | "Zn">;
184
+ clone(): Structure;
109
185
  /**
110
- * Anion species: `\"Cl\"`, `\"Br\"`, `\"I\"`, `\"F\"`. Default: `[\"Cl\"]`
186
+ * Parses an mmCIF string into a Structure.
111
187
  */
112
- anions?: Array<"Cl" | "Br" | "I" | "F">;
188
+ static fromMmcif(content: string): Structure;
113
189
  /**
114
- * Target net charge after solvation. Default: `0`
190
+ * Parses an mmCIF byte array into a Structure.
115
191
  */
116
- targetCharge?: number;
192
+ static fromMmcifBytes(content: Uint8Array): Structure;
117
193
  /**
118
- * Random seed for reproducible placement.
194
+ * Parses a PDB string into a Structure.
119
195
  */
120
- rngSeed?: number | undefined;
121
- }
122
-
123
- /**
124
- * Comprehensive structure information.
125
- */
126
- export interface StructureInfo {
196
+ static fromPdb(content: string): Structure;
127
197
  /**
128
- * Number of chains.
198
+ * Parses a PDB byte array into a Structure.
129
199
  */
130
- chainCount: number;
200
+ static fromPdbBytes(content: Uint8Array): Structure;
131
201
  /**
132
- * Total number of residues.
202
+ * Returns comprehensive structure statistics.
133
203
  */
134
- residueCount: number;
204
+ info(): StructureInfo;
135
205
  /**
136
- * Total number of atoms.
206
+ * Reconstructs missing atoms from templates.
137
207
  */
138
- atomCount: number;
208
+ repair(): void;
139
209
  /**
140
- * Box dimensions `[a, b, c]` in Å, if present.
210
+ * Rotates using Euler angles (XYZ convention, all in radians).
141
211
  */
142
- boxLengths: [number, number, number] | undefined;
212
+ rotateEuler(x: number, y: number, z: number): void;
143
213
  /**
144
- * Box angles `[α, β, γ]` in degrees, if present.
214
+ * Rotates around the X axis (angle in radians).
145
215
  */
146
- boxAngles: [number, number, number] | undefined;
216
+ rotateX(radians: number): void;
147
217
  /**
148
- * Per-chain information.
218
+ * Rotates around the Y axis (angle in radians).
149
219
  */
150
- chains: ChainInfo[];
151
- }
152
-
153
-
154
- export class Structure {
155
- private constructor();
156
- free(): void;
157
- [Symbol.dispose](): void;
158
- /**
159
- * Parses an mmCIF string into a Structure.
160
- */
161
- static fromMmcif(content: string): Structure;
162
- /**
163
- * Centers the center of mass at the origin.
164
- */
165
- centerMass(): void;
166
- /**
167
- * Builds a Topology from this structure.
168
- */
169
- toTopology(config?: TopologyConfig | null, templates?: Template[] | null): Topology;
170
- /**
171
- * Rotates using Euler angles (XYZ convention, all in radians).
172
- */
173
- rotateEuler(x: number, y: number, z: number): void;
174
- /**
175
- * Serializes to PDB format as bytes.
176
- */
177
- toPdbBytes(): Uint8Array;
178
- /**
179
- * Adds hydrogen atoms.
180
- */
181
- addHydrogens(config?: HydroConfig | null): void;
182
- /**
183
- * Parses a PDB byte array into a Structure.
184
- */
185
- static fromPdbBytes(content: Uint8Array): Structure;
186
- /**
187
- * Serializes to mmCIF format as bytes.
188
- */
189
- toMmcifBytes(): Uint8Array;
190
- /**
191
- * Centers the geometric centroid at the origin.
192
- */
193
- centerGeometry(): void;
194
- /**
195
- * Creates a deep copy of the structure.
196
- */
197
- clone(): Structure;
198
- /**
199
- * Parses an mmCIF byte array into a Structure.
200
- */
201
- static fromMmcifBytes(content: Uint8Array): Structure;
202
- /**
203
- * Returns comprehensive structure statistics.
204
- */
205
- info(): StructureInfo;
206
- /**
207
- * Removes unwanted components (water, ions, hydrogens, hetero residues).
208
- */
209
- clean(config?: CleanConfig | null): void;
210
- /**
211
- * Reconstructs missing atoms from templates.
212
- */
213
- repair(): void;
214
- /**
215
- * Serializes to PDB format.
216
- */
217
- toPdb(): string;
218
- /**
219
- * Solvates the structure with water and ions.
220
- */
221
- solvate(config?: SolvateConfig | null): void;
222
- /**
223
- * Parses a PDB string into a Structure.
224
- */
225
- static fromPdb(content: string): Structure;
226
- /**
227
- * Rotates around the X axis (angle in radians).
228
- */
229
- rotateX(radians: number): void;
230
- /**
231
- * Rotates around the Y axis (angle in radians).
232
- */
233
- rotateY(radians: number): void;
234
- /**
235
- * Rotates around the Z axis (angle in radians).
236
- */
237
- rotateZ(radians: number): void;
238
- /**
239
- * Serializes to mmCIF format.
240
- */
241
- toMmcif(): string;
242
- /**
243
- * Translates all atoms by the given vector (x, y, z in Å).
244
- */
245
- translate(x: number, y: number, z: number): void;
246
- /**
247
- * Returns the number of atoms.
248
- */
249
- readonly atomCount: number;
250
- /**
251
- * Returns the number of chains.
252
- */
253
- readonly chainCount: number;
254
- /**
255
- * Returns the number of residues.
256
- */
257
- readonly residueCount: number;
220
+ rotateY(radians: number): void;
221
+ /**
222
+ * Rotates around the Z axis (angle in radians).
223
+ */
224
+ rotateZ(radians: number): void;
225
+ /**
226
+ * Solvates the structure with water and ions.
227
+ */
228
+ solvate(config?: SolvateConfig | null): void;
229
+ /**
230
+ * Serializes to mmCIF format.
231
+ */
232
+ toMmcif(): string;
233
+ /**
234
+ * Serializes to mmCIF format as bytes.
235
+ */
236
+ toMmcifBytes(): Uint8Array;
237
+ /**
238
+ * Serializes to PDB format.
239
+ */
240
+ toPdb(): string;
241
+ /**
242
+ * Serializes to PDB format as bytes.
243
+ */
244
+ toPdbBytes(): Uint8Array;
245
+ /**
246
+ * Builds a Topology from this structure.
247
+ */
248
+ toTopology(config?: TopologyConfig | null, templates?: Template[] | null): Topology;
249
+ /**
250
+ * Translates all atoms by the given vector (x, y, z in Å).
251
+ */
252
+ translate(x: number, y: number, z: number): void;
253
+ /**
254
+ * Returns the number of atoms.
255
+ */
256
+ readonly atomCount: number;
257
+ /**
258
+ * Returns the number of chains.
259
+ */
260
+ readonly chainCount: number;
261
+ /**
262
+ * Returns the number of residues.
263
+ */
264
+ readonly residueCount: number;
258
265
  }
259
266
 
267
+ /**
268
+ * A residue or ligand template for topology building.
269
+ */
260
270
  export class Template {
261
- private constructor();
262
- free(): void;
263
- [Symbol.dispose](): void;
264
- /**
265
- * Parses a MOL2 byte array into a Template.
266
- */
267
- static fromMol2Bytes(content: Uint8Array): Template;
268
- /**
269
- * Parses a MOL2 string into a Template.
270
- */
271
- static fromMol2(content: string): Template;
272
- /**
273
- * Returns the template name (residue code).
274
- */
275
- readonly name: string;
271
+ private constructor();
272
+ free(): void;
273
+ [Symbol.dispose](): void;
274
+ /**
275
+ * Parses a MOL2 string into a Template.
276
+ */
277
+ static fromMol2(content: string): Template;
278
+ /**
279
+ * Parses a MOL2 byte array into a Template.
280
+ */
281
+ static fromMol2Bytes(content: Uint8Array): Template;
282
+ /**
283
+ * Returns the template name (residue code).
284
+ */
285
+ readonly name: string;
276
286
  }
277
287
 
288
+ /**
289
+ * A structure with bond connectivity information.
290
+ */
278
291
  export class Topology {
279
- private constructor();
280
- free(): void;
281
- [Symbol.dispose](): void;
282
- /**
283
- * Serializes to PDB format as bytes.
284
- */
285
- toPdbBytes(): Uint8Array;
286
- /**
287
- * Creates a Topology from a Structure.
288
- */
289
- static fromStructure(structure: Structure, config?: TopologyConfig | null, templates?: Template[] | null): Topology;
290
- /**
291
- * Serializes to mmCIF format as bytes.
292
- */
293
- toMmcifBytes(): Uint8Array;
294
- /**
295
- * Serializes to PDB format with CONECT records.
296
- */
297
- toPdb(): string;
298
- /**
299
- * Serializes to mmCIF format with struct_conn records.
300
- */
301
- toMmcif(): string;
302
- /**
303
- * Returns the number of bonds.
304
- */
305
- readonly bondCount: number;
306
- /**
307
- * Returns a copy of the underlying structure.
308
- */
309
- readonly structure: Structure;
292
+ private constructor();
293
+ free(): void;
294
+ [Symbol.dispose](): void;
295
+ /**
296
+ * Creates a Topology from a Structure.
297
+ */
298
+ static fromStructure(structure: Structure, config?: TopologyConfig | null, templates?: Template[] | null): Topology;
299
+ /**
300
+ * Serializes to mmCIF format with struct_conn records.
301
+ */
302
+ toMmcif(): string;
303
+ /**
304
+ * Serializes to mmCIF format as bytes.
305
+ */
306
+ toMmcifBytes(): Uint8Array;
307
+ /**
308
+ * Serializes to PDB format with CONECT records.
309
+ */
310
+ toPdb(): string;
311
+ /**
312
+ * Serializes to PDB format as bytes.
313
+ */
314
+ toPdbBytes(): Uint8Array;
315
+ /**
316
+ * Returns the number of bonds.
317
+ */
318
+ readonly bondCount: number;
319
+ /**
320
+ * Returns a copy of the underlying structure.
321
+ */
322
+ readonly structure: Structure;
310
323
  }
311
324
 
312
325
  /**
package/bio_forge_wasm.js CHANGED
@@ -1,5 +1,9 @@
1
+ /* @ts-self-types="./bio_forge_wasm.d.ts" */
2
+
1
3
  import * as wasm from "./bio_forge_wasm_bg.wasm";
2
- export * from "./bio_forge_wasm_bg.js";
3
4
  import { __wbg_set_wasm } from "./bio_forge_wasm_bg.js";
4
5
  __wbg_set_wasm(wasm);
5
6
  wasm.__wbindgen_start();
7
+ export {
8
+ Structure, Template, Topology, init
9
+ } from "./bio_forge_wasm_bg.js";