BioForge is a pure-Rust toolkit for automated preparation of biological macromolecules. It reads experimental structures (PDB/mmCIF), reconciles them with high-quality residue templates, repairs missing atoms, assigns hydrogens and termini, builds topologies, and optionally solvates the system with water and ions—all without leaving the Rust type system.
Highlights
- Template-driven accuracy – Curated TOML templates for standard amino acids, nucleotides, and water guarantee reproducible coordinates, charges, and bonding.
- High performance – Multithreaded processing (via rayon) handles million-atom systems in milliseconds; single-pass parsing, in-place mutation, and zero-copy serialization minimize overhead.
- Rich structure model – Lightweight
Atom,Residue,Chain, andStructuretypes backed bynalgebramake geometric operations trivial. - Format interoperability – Buffered readers/writers for PDB, mmCIF, and MOL2 plus error types that surface precise parsing diagnostics.
- Preparation pipeline – Cleaning, repairing, protonating, solvation, coordinate transforms, and topology reconstruction share a common
ops::Errorso workflows compose cleanly. - WebAssembly support – Full-featured WASM bindings for modern JavaScript bundlers (Vite, webpack, Rollup); ideal for browser-based molecular viewers and web applications.
- Rust-first ergonomics – No FFI, no global mutable state beyond the lazily-loaded template store, and edition 2024 guarantees modern language features.
Processing Pipeline
Load → Clean → Repair → Hydrogenate → Solvate → Topology → Write
- Load –
io::read_pdb_structureorio::read_mmcif_structureparses coordinates withIoContextalias resolution. - Clean –
ops::clean_structureremoves waters, ions, hetero residues, or arbitrary residue names viaCleanConfig. - Repair –
ops::repair_structurerealigns residues to templates and rebuilds missing heavy atoms (OXT on C-termini, OP3 on 5'-phosphorylated nucleic acids). - Hydrogenate –
ops::add_hydrogensinfers protonation states (configurable pH and histidine strategy) and reconstructs hydrogens from template anchors. - Solvate –
ops::solvate_structurecreates a periodic box, packs water on a configurable lattice, and swaps molecules for ions to satisfy a target charge. - Topology –
ops::TopologyBuilderemits bond connectivity with peptide-link detection, nucleic backbone connectivity, and disulfide heuristics. - Write –
io::write_pdb_structure/io::write_mmcif_structureserialize the processed structure;write_*_topologyhelpers emit CONECT orstruct_connrecords.
Quick Start
For CLI Users
Install the latest BioForge CLI binary from the releases page or via cargo:
Once the bioforge binary is installed, you can repair a structure in a single step:
Explore the complete preparation pipeline in the user manual and browse the examples directory for runnable walkthroughs.
For Library Developers (Rust)
BioForge is also available as a library crate. Add it to your Cargo.toml dependencies:
[]
= "0.3.1"
Example: Preparing a PDB Structure
use ;
use ;
Prefer mmCIF? Swap in
read_mmcif_structure/write_mmcif_structure. Need to process ligands? Parse them viaio::read_mol2_templateand feed the resultingTemplateintoTopologyBuilder::add_hetero_template.
For Library Developers (JavaScript/TypeScript)
Install via npm:
Prepare a structure with the following code:
import { Structure } from "bio-forge-wasm";
const pdb = await fetch("https://files.rcsb.org/view/1UBQ.pdb").then((r) =>
r.text()
);
const structure = Structure.fromPdb(pdb);
structure.clean({ removeWater: true });
structure.repair();
structure.addHydrogens({ hisStrategy: "network" });
const topology = structure.toTopology();
console.log(`Bonds: ${topology.bondCount}`);
Documentation
| Resource | Description |
|---|---|
| CLI Manual | Command-line usage and options |
| JS/TS API | WebAssembly bindings reference |
| Rust API | Library documentation |
| Architecture | Internal design and algorithms |
| Examples | Runnable walkthroughs |
License
This project is licensed under the MIT License - see the LICENSE file for details.