4 releases (breaking)
0.4.0 | Sep 13, 2024 |
---|---|
0.3.0 | Dec 26, 2023 |
0.2.0 | Sep 5, 2021 |
0.1.0 | Aug 10, 2021 |
#110 in Science
41 downloads per month
Used in 3 crates
(2 directly)
450KB
16K
SLoC
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);
lib.rs
:
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")?;
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")?;
// Use the guessed number of peaks
let peaks = isotopic_variants(composition, 0, 1, PROTON);
for peak in peaks.iter() {
println!("{}", peak);
}
assert_eq!(peaks.len(), 6);
Dependencies
~0.7–1.6MB
~35K SLoC