Crate chemical_elements
source ·Expand description
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);
Re-exports
pub use crate::table::PERIODIC_TABLE;
pub use crate::table::PERIODIC_TABLE;
Modules
- Implementations of isotopic pattern generator algorithms.
Structs
- Represents a collection of element-count pairs as found in a flat chemical formula. Built atop
std::collections::HashMap
, and support addition and subtraction with other instances of the same type and multiplication by integers. - Represents a collection of element-count pairs as found in a flat chemical formula. Built atop
std::collections::HashMap
, and support addition and subtraction with other instances of the same type and multiplication by integers. - A helper data structure that encapsulates a
PeriodicTable
, along with some pre-parsedElementSpecification
andChemicalComposition
instances for convenience. - A chemical element with known masses and isotopic frequency.
- A hashable key referencing an element with a specific isotope state.
element
is theElement
represented, andisotope
is the isotope number, though 0 means monoisotopic. - A known isotope of an element with a known number of neutrons, mass, and relative abundance
- A mapping connecting
Element
to its textual symbol.