mobiusklein / chemical_elements

Rust Chemical Composition Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A library for representing chemical compositions, managing elemental formulae and generating (coarse) isotopic patterns.

Chemical Compositions

use chemical_elements::{ChemicalComposition, ElementSpecification};

let mut composition = ChemicalComposition::parse("H2O").unwrap();
composition["C"] = 6;
composition["O"] = 6;
composition["H"] = 12;
assert!((composition.mass() - 180.06339).abs() < 1e-6)

Isotopic Distributions

use chemical_elements::{ChemicalComposition, PROTON};
use chemical_elements::isotopic_pattern::isotopic_variants;
let composition = ChemicalComposition::parse("C34H53O15N7").unwrap();
// Use the guessed number of peaks
let peaks = isotopic_variants(&composition, 0, 1, PROTON);
for peak in peaks.iter() {
    println!("{}", peak);
}
assert!(peaks.len() == 10);

About

Rust Chemical Composition Library

License:Apache License 2.0


Languages

Language:Rust 99.3%Language:Python 0.6%Language:Just 0.0%