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);

Modules§

isotopic_pattern
Implementations of isotopic pattern generator algorithms.

Structs§

ChemicalCompositionMap
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.
ChemicalCompositionVec
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.
ChemicalElements
A helper data structure that encapsulates a PeriodicTable, along with some pre-parsed ElementSpecification and ChemicalComposition instances for convenience.
Element
A chemical element with known masses and isotopic frequency.
ElementSpecification
A hashable key referencing an element with a specific isotope state. element is the Element represented, and isotope is the isotope number, though 0 means monoisotopic.
Isotope
A known isotope of an element with a known number of neutrons, mass, and relative abundance
PeriodicTable
A mapping connecting Element to its textual symbol.

Enums§

ChemicalComposition
ChemicalCompositionRef
ElementSpecificationParsingError
FormulaParserError

Constants§

PROTON

Statics§

PERIODIC_TABLE

Traits§

ChemicalCompositionLike

Functions§

mass_charge_ratio
neutral_mass
parse_formula
parse_formula_with_table