rustms::ms::spectrum

Struct MzSpectrum

Source
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

Source

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]);
Source

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 new MzSpectrum 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]);
Source

pub fn from_collection(collection: Vec<MzSpectrum>) -> MzSpectrum

Trait Implementations§

Source§

impl Add for MzSpectrum

Source§

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

The resulting type after applying the + operator.
Source§

impl Clone for MzSpectrum

Source§

fn clone(&self) -> MzSpectrum

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MzSpectrum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MzSpectrum

Source§

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

Source§

type Output = MzSpectrum

The resulting type after applying the * operator.
Source§

fn mul(self, scale: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Serialize for MzSpectrum

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Sub for MzSpectrum

Source§

type Output = MzSpectrum

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,