Skip to main content

mzdata_bindata/
utils.rs

1const PROTON: f64 = 1.00727646677;
2
3/// Compute the m/z of an ion given a neutal mass and a charge state.
4///
5/// Assumes the charge carrier is a proton.
6#[inline]
7pub fn mass_charge_ratio(mass: f64, z: i32) -> f64 {
8    (mass + z as f64 * PROTON) / (z.abs() as f64)
9}
10
11
12/// Compute the neutral mass of an ion given an m/z and a charge state.
13///
14/// Assumes the charge carrier is a proton.
15#[inline]
16pub fn neutral_mass(mz: f64, z: i32) -> f64 {
17    (mz * z.abs() as f64) - z as f64 * PROTON
18}