Chemistry Basics¶
Use the chemistry helpers for molecular formulas, exact masses, isotope abundances, and predefined adduct tables.
"""Use emzed chemistry helpers for formulas, masses, and adducts."""
import emzed
def main():
glucose = emzed.mf("C6H12O6")
print(f"glucose monoisotopic mass: {glucose.mass():.6f}")
print(f"water mass: {emzed.mass.of('H2O'):.6f}")
print(f"carbon-12 mass: {emzed.mass.C12:.6f}")
print(f"carbon-13 abundance: {emzed.abundance.C13:.6f}")
positive_adducts = emzed.adducts.positive.extract_columns(
"adduct_name", "z", "sign_z"
)
print(positive_adducts[:5])
if __name__ == "__main__":
main()
uv pip install -U pyopenms==3.3.0:
Using CPython 3.12.11 interpreter at: [36m/.pyenv/versions/3.12.11/bin/python3.12[39m
Creating virtual environment at: [36m.venv/share/pyopenms_venv[39m
✓
uv pip install -U numpy==2.4.4:
✓
glucose monoisotopic mass: 180.063390
water mass: 18.010565
carbon-12 mass: 12.000000
carbon-13 abundance: 0.010700
adduct_name z sign_z
str int int
----------- --- ------
M+ 1 1
M+H 1 1
M+NH4 1 1
M+Na 1 1
M+H-2H2O 1 1