chemical_elements

Crates.iochemical_elements
lib.rschemical_elements
version0.4.0
sourcesrc
created_at2021-08-10 01:47:37.572621
updated_at2024-09-13 13:59:42.552161
descriptionA library for representing chemical compositions and generating isotopic patterns
homepage
repositoryhttps://github.com/mobiusklein/chemical_elements
max_upload_size
id434046
size1,247,546
Joshua Klein (mobiusklein)

documentation

https://docs.rs/chemical_elements

README

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);
Commit count: 64

cargo fmt