pub struct MzSpectrum {
pub mz: Vec<f64>,
pub intensity: Vec<f64>,
}
Expand description
Represents a mass spectrum with associated m/z values and intensities.
Fields§
§mz: Vec<f64>
§intensity: Vec<f64>
Implementations§
Source§impl MzSpectrum
impl MzSpectrum
Sourcepub fn new(mz: Vec<f64>, intensity: Vec<f64>) -> Self
pub fn new(mz: Vec<f64>, intensity: Vec<f64>) -> Self
Constructs a new MzSpectrum
.
§Arguments
mz
- A vector of m/z values.intensity
- A vector of intensity values corresponding to the m/z values.
§Panics
Panics if the lengths of mz
and intensity
are not the same. (actually, it doesn’t at the moment, planning on adding this later)
§Example
let spectrum = MzSpectrum::new(vec![200.0, 100.0], vec![20.0, 10.0]);
assert_eq!(spectrum.mz, vec![100.0, 200.0]);
assert_eq!(spectrum.intensity, vec![10.0, 20.0]);
Sourcepub fn filter_ranged(
&self,
mz_min: f64,
mz_max: f64,
intensity_min: f64,
intensity_max: f64,
) -> Self
pub fn filter_ranged( &self, mz_min: f64, mz_max: f64, intensity_min: f64, intensity_max: f64, ) -> Self
Filters the m/z values and intensities based on a range of m/z values and intensities.
§Arguments
mz_min
- The minimum m/z value.mz_max
- The maximum m/z value.intensity_min
- The minimum intensity value.intensity_max
- The maximum intensity value.
§Returns
MzSpectrum
- A newMzSpectrum
with m/z values and intensities within the specified ranges.
§Example
let spectrum = MzSpectrum::new(vec![100.0, 200.0, 300.0], vec![10.0, 20.0, 30.0]);
let filtered_spectrum = spectrum.filter_ranged(150.0, 250.0, 15.0, 25.0);
assert_eq!(filtered_spectrum.mz, vec![200.0]);
assert_eq!(filtered_spectrum.intensity, vec![20.0]);
pub fn from_collection(collection: Vec<MzSpectrum>) -> MzSpectrum
Trait Implementations§
Source§impl Add for MzSpectrum
impl Add for MzSpectrum
Source§fn add(self, other: Self) -> MzSpectrum
fn add(self, other: Self) -> MzSpectrum
Combines two MzSpectrum
instances by summing up the intensities of matching m/z values.
§Description
Each m/z value is quantized to retain at least 6 decimals. If two spectra have m/z values that quantize to the same integer value, their intensities are summed.
§Example
let spectrum1 = MzSpectrum { mz: vec![100.523, 101.923], intensity: vec![10.0, 20.0] };
let spectrum2 = MzSpectrum { mz: vec![101.235, 105.112], intensity: vec![15.0, 30.0] };
let combined = spectrum1 + spectrum2;
assert_eq!(combined.mz, vec![100.523, 101.235, 101.923, 105.112]);
assert_eq!(combined.intensity, vec![10.0, 15.0, 20.0, 30.0]);
Source§type Output = MzSpectrum
type Output = MzSpectrum
The resulting type after applying the
+
operator.Source§impl Clone for MzSpectrum
impl Clone for MzSpectrum
Source§fn clone(&self) -> MzSpectrum
fn clone(&self) -> MzSpectrum
Returns a copy 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 MzSpectrum
impl Debug for MzSpectrum
Source§impl<'de> Deserialize<'de> for MzSpectrum
impl<'de> Deserialize<'de> for MzSpectrum
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Mul<f64> for MzSpectrum
impl Mul<f64> for MzSpectrum
Source§impl Serialize for MzSpectrum
impl Serialize for MzSpectrum
Auto Trait Implementations§
impl Freeze for MzSpectrum
impl RefUnwindSafe for MzSpectrum
impl Send for MzSpectrum
impl Sync for MzSpectrum
impl Unpin for MzSpectrum
impl UnwindSafe for MzSpectrum
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