| Crates.io | chemical_elements |
| lib.rs | chemical_elements |
| version | 0.7.0 |
| created_at | 2021-08-10 01:47:37.572621+00 |
| updated_at | 2025-03-19 01:47:01.239507+00 |
| 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,232,629 |
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);