Skip to main content

parse

Function parse 

Source
pub fn parse<P: Read>(reader: BufReader<P>) -> Result<(Vec<Atom>, Vec<Bond>)>
Expand description

Parses a CIF file and returns a vector of Atom and a vector of Bond objects.

ยงExamples

use chelate::cif;
use std::fs::File;
use nalgebra::Point3;
use approx::relative_eq;
use std::io::BufReader;

let file = File::open("data/147288.cif").unwrap();
let reader = BufReader::new(file);
let (atoms, bonds) = cif::parse(reader).unwrap();

assert_eq!(atoms.len(), 206);
assert_eq!(bonds.len(), 230);
assert_eq!(atoms[0].atomic_number, 31);
assert!(relative_eq!(atoms[0].coord, Point3::new(11.377683611607571, 1.637743396392762, 3.827447754962335), epsilon = 1.0e-5));
assert_eq!(atoms[0].resname, "UNK");
assert_eq!(atoms[0].resid, 0);
assert_eq!(atoms[0].chain, char::default());
assert_eq!(atoms[0].occupancy, 1.0);
assert_eq!(atoms[0].name, "Ga1A");