Crates.io | chemical_elements |
lib.rs | chemical_elements |
version | 0.4.0 |
source | src |
created_at | 2021-08-10 01:47:37.572621 |
updated_at | 2024-09-13 13:59:42.552161 |
description | A library for representing chemical compositions and generating isotopic patterns |
homepage | |
repository | https://github.com/mobiusklein/chemical_elements |
max_upload_size | |
id | 434046 |
size | 1,247,546 |
A library for representing chemical compositions, managing elemental formulae and generating (coarse) isotopic patterns.
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)
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);