#pattern #chemical #composition #generate #elements #elemental #isotopic

bin+lib chemical_elements

A library for representing chemical compositions and generating isotopic patterns

5 releases (breaking)

0.5.0 Dec 15, 2024
0.4.0 Sep 13, 2024
0.3.0 Dec 26, 2023
0.2.0 Sep 5, 2021
0.1.0 Aug 10, 2021

#107 in Science

Download history 20/week @ 2024-09-17 49/week @ 2024-09-24 13/week @ 2024-10-01 15/week @ 2024-10-08 19/week @ 2024-10-15 4/week @ 2024-10-29 9/week @ 2024-11-05 7/week @ 2024-11-19 17/week @ 2024-11-26 1/week @ 2024-12-03 124/week @ 2024-12-10 30/week @ 2024-12-17 21/week @ 2024-12-31

176 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

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
~36K SLoC