pub struct IndexedMzSpectrum {
pub index: Vec<i32>,
pub mz_spectrum: MzSpectrum,
}Expand description
Represents a mass spectrum with associated m/z indices, m/z values, and intensities
Fields§
§index: Vec<i32>§mz_spectrum: MzSpectrumImplementations§
Source§impl IndexedMzSpectrum
impl IndexedMzSpectrum
Sourcepub fn new(index: Vec<i32>, mz: Vec<f64>, intensity: Vec<f64>) -> Self
pub fn new(index: Vec<i32>, mz: Vec<f64>, intensity: Vec<f64>) -> Self
Creates a new TOFMzSpectrum instance.
§Arguments
index- A vector containing the mz index, e.g., time-of-flight values.mz- A vector containing the m/z values.intensity- A vector containing the intensity values.
§Examples
use mscore::data::spectrum::IndexedMzSpectrum;
use mscore::data::spectrum::MzSpectrum;
let spectrum = IndexedMzSpectrum::new(vec![1000, 2000], vec![100.5, 200.5], vec![50.0, 60.0]);Sourcepub fn to_resolution(&self, resolution: i32) -> IndexedMzSpectrum
pub fn to_resolution(&self, resolution: i32) -> IndexedMzSpectrum
Bins the spectrum based on a given m/z resolution, summing intensities and averaging index values for m/z values that fall into the same bin.
§Arguments
resolution- The desired m/z resolution for binning.
§Examples
use mscore::data::spectrum::IndexedMzSpectrum;
let spectrum = IndexedMzSpectrum::new(vec![1000, 2000], vec![100.42, 100.43], vec![50.0, 60.0]);
let binned_spectrum = spectrum.to_resolution(1);
assert_eq!(binned_spectrum.mz_spectrum.mz, vec![100.4]);
assert_eq!(binned_spectrum.mz_spectrum.intensity, vec![110.0]);
assert_eq!(binned_spectrum.index, vec![1500]);Sourcepub fn vectorized(&self, resolution: i32) -> IndexedMzSpectrumVectorized
pub fn vectorized(&self, resolution: i32) -> IndexedMzSpectrumVectorized
Convert the IndexedMzSpectrum to a IndexedMzVector using the given resolution for binning.
After binning to the desired resolution, the binned m/z values are translated into integer indices.
§Arguments
resolution- The desired m/z resolution for binning.
§Examples
use mscore::data::spectrum::IndexedMzSpectrum;
let spectrum = IndexedMzSpectrum::new(vec![1000, 2000], vec![100.42, 100.43], vec![50.0, 60.0]);
let binned_spectrum = spectrum.to_resolution(1);
assert_eq!(binned_spectrum.mz_spectrum.mz, vec![100.4]);
assert_eq!(binned_spectrum.mz_spectrum.intensity, vec![110.0]);
assert_eq!(binned_spectrum.index, vec![1500]);pub fn filter_ranged( &self, mz_min: f64, mz_max: f64, intensity_min: f64, intensity_max: f64, ) -> Self
Trait Implementations§
Source§impl Clone for IndexedMzSpectrum
impl Clone for IndexedMzSpectrum
Source§fn clone(&self) -> IndexedMzSpectrum
fn clone(&self) -> IndexedMzSpectrum
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IndexedMzSpectrum
impl Debug for IndexedMzSpectrum
Source§impl Default for IndexedMzSpectrum
impl Default for IndexedMzSpectrum
Auto Trait Implementations§
impl Freeze for IndexedMzSpectrum
impl RefUnwindSafe for IndexedMzSpectrum
impl Send for IndexedMzSpectrum
impl Sync for IndexedMzSpectrum
impl Unpin for IndexedMzSpectrum
impl UnwindSafe for IndexedMzSpectrum
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.