Skip to content

A fast parser for XYZ molecular geometry files in Rust

License

Notifications You must be signed in to change notification settings

einseler/xyz_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xyz_parser

A fast Rust library for parsing XYZ molecular geometry files.

Features

  • Parse single geometry XYZ files
  • Parse trajectory files with multiple frames
  • Extract specific frames from trajectories
  • Optional parallel parsing with rayon
  • Support for all 118 elements

Usage

use xyz_parser::{parse_xyz, parse_xyz_file, parse_trajectory};

// Parse from string
let content = "3\nWater molecule\nO  0.0  0.0  0.0\nH  0.96 0.0  0.0\nH -0.24 0.93 0.0";
let frame = parse_xyz(content).unwrap();
println!("Atoms: {}", frame.num_atoms());

// Parse from file
let frame = parse_xyz_file("molecule.xyz").unwrap();

// Parse trajectory
let frames = parse_trajectory(content).unwrap();
for frame in frames {
    println!("Frame with {} atoms", frame.num_atoms());
}

XyzFrame struct

pub struct XyzFrame {
    pub atomic_numbers: Vec<u8>,  // Atomic numbers (1=H, 6=C, etc.)
    pub coordinates: Vec<f64>,    // Flat array [x1, y1, z1, x2, y2, z2, ...]
}

Parallel parsing

Enable the parallel feature for multi-threaded trajectory parsing:

[dependencies]
xyz_parser = { version = "0.1", features = ["parallel"] }
use xyz_parser::parse_trajectory_parallel;

let frames = parse_trajectory_parallel(content).unwrap();

License

MIT

About

A fast parser for XYZ molecular geometry files in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages