#molecule #chemistry #format

chelate

Parser for a bunch of molecular file formats

2 unstable releases

Uses new Rust 2024

new 0.2.0 Apr 15, 2025
0.1.0 Apr 14, 2025

#81 in Science

Download history 135/week @ 2025-04-09

135 downloads per month

MIT/Apache

5MB
856 lines

Chelate

Crates.io Version Crates.io Total Downloads 🦀 Continuous Integration Docs.rs License

Chelate is a simple parser for a bunch of molecular file formats.

Format MIME Import Export
IUCr CIF chemical/x-cif
PDBx/mmCIF chemical/x-mmcif
PDB chemical/x-pdb 🏗️
MOL chemical/x-mdl-molfile 🏗️
MOL2 (TRIPOS) chemical/x-mol2 🏗️
XYZ chemical/x-xyz 🏗️

✅ = implemented 🏗️ = planned ❌ = not available

Example

Simple Example returning (Vec<Atom>, Vec<Bond>)

use chelate;

let (atoms, bonds) = chelate::from_file("data/147288.cif").unwrap();

assert_eq!(atoms.len(), 206);
assert_eq!(bonds.len(), 230);

Example using petgraph returning Graph<Atom, Edge, Undirected>

Formats that do not have bond information like xyz are able to generate Bond objects when petgraph feature is active (default).

use chelate;
//its a Molecule (type alias for Graph<Atom, Edge, Undirected>)
let mol = chelate::molecule_from_file("data/oriluy.pdb").unwrap(); 

assert_eq!(mol.node_count(), 130);
assert_eq!(mol.edge_count(), 151);

Installation

Run the following Cargo command in your project directory:

cargo add chelate

Or add the following line to your Cargo.toml:

chelate = "0.2.0"

Dependencies

~7MB
~124K SLoC