5 releases

0.2.0 Feb 21, 2024
0.1.3 Feb 20, 2024
0.1.2 Feb 19, 2024
0.1.1 Feb 18, 2024
0.1.0 Feb 17, 2024

#1242 in Parser implementations

Download history 223/week @ 2024-02-12 417/week @ 2024-02-19 25/week @ 2024-02-26 20/week @ 2024-03-04 21/week @ 2024-03-11 24/week @ 2024-03-18 23/week @ 2024-03-25 36/week @ 2024-04-01 9/week @ 2024-04-08 8/week @ 2024-04-15 16/week @ 2024-04-22 10/week @ 2024-04-29 9/week @ 2024-05-06 15/week @ 2024-05-13

51 downloads per month
Used in 12 crates (via gchemol-readwrite)

MIT/Apache

35KB
681 lines

A fast parser for chemical file in the extended xyz (extxyz) format.

The extended XYZ format is an enhanced version of the simple XYZ format, allowing extra columns to be present in the file for extra atom properties (forces, charges, labels, etc.) as well as molecule's properties (energy, dipole moment, etc.)specified in the comment line.

Usage

Example usage:

use extxyz::{read_xyz_frames, RawAtoms, Info};

fn main() -> anyhow::Result<()> {
    // a large xyz/extxyz trajectory file
    let f = "nmd.xyz";
    // skip the first 100 frames, and read frames with a step size `10`
    let selection = (100..).step_by(10);
    let frames = read_xyz_frames(f, selection)?;
    for frame in frames {
        let atoms = RawAtoms::parse_from(&frame)?;
        // it will returen error if the comment is not in normal extxyz format
        let info: Info = atoms.comment.parse()?;
        // get molecule's properties
        let energy = info.get("energy").unwrap();
        // get atom's properties
        for atom in atoms.atoms {
            // parse extra data for each atom
            let atom_properties = info.parse_extra_columns(&atom.extra)?;
            // get `forces` component for each atom
            let forces = &atom_properties["forces"];
        }
    }

    Ok(())
}

Dependencies

~9–18MB
~303K SLoC