pub struct SumFormula {
pub formula: String,
pub elements: HashMap<String, i32>,
}Fields§
§formula: String§elements: HashMap<String, i32>Implementations§
Source§impl SumFormula
impl SumFormula
pub fn new(formula: &str) -> Self
Sourcepub fn monoisotopic_weight(&self) -> f64
pub fn monoisotopic_weight(&self) -> f64
Calculate the monoisotopic weight of the chemical formula.
Arguments:
None
Returns:
f64- The monoisotopic weight of the chemical formula.
§Example
use rustms::chemistry::sum_formula::SumFormula;
let formula = "H2O";
let sum_formula = SumFormula::new(formula);
assert_eq!(sum_formula.monoisotopic_weight(), 18.01056468403);Sourcepub fn isotope_distribution(&self, charge: i32) -> MzSpectrum
pub fn isotope_distribution(&self, charge: i32) -> MzSpectrum
Generate the isotope distribution of the chemical formula.
Arguments:
charge- The charge state of the ion.
Returns:
MzSpectrum- The isotope distribution of the chemical formula.
§Example
use rustms::chemistry::sum_formula::SumFormula;
use rustms::ms::spectrum::MzSpectrum;
let formula = "C6H12O6";
let sum_formula = SumFormula::new(formula);
let isotope_distribution = sum_formula.isotope_distribution(1);
let mut first_mz = *isotope_distribution.mz.first().unwrap();
// round to first 5 decimal places
first_mz = (first_mz * 1e5).round() / 1e5;
assert_eq!(first_mz, 181.07066);Auto Trait Implementations§
impl Freeze for SumFormula
impl RefUnwindSafe for SumFormula
impl Send for SumFormula
impl Sync for SumFormula
impl Unpin for SumFormula
impl UnsafeUnpin for SumFormula
impl UnwindSafe for SumFormula
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more