Skip to main content

MassSpectrometryFormat

Enum MassSpectrometryFormat 

Source
#[non_exhaustive]
pub enum MassSpectrometryFormat { MGF, MzML, MzMLb, ThermoRaw, BrukerTDF, IMzML, Unknown, }
Expand description

Mass spectrometry file formats that mzdata supports

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

MGF

§

MzML

§

MzMLb

§

ThermoRaw

§

BrukerTDF

§

IMzML

§

Unknown

Implementations§

Source§

impl MassSpectrometryFormat

Source

pub fn as_conversion(&self) -> Option<FormatConversion>

Examples found in repository?
examples/mzconvert.rs (line 312)
238    fn transform_writer<
239        R: RandomAccessSpectrumIterator<CentroidPeak, DeconvolutedPeak>
240            + MSDataFileMetadata
241            + SpectrumSource<CentroidPeak, DeconvolutedPeak>
242            + Send
243            + Any
244            + 'static,
245        W: SpectrumWriter<CentroidPeak, DeconvolutedPeak> + MSDataFileMetadata + Send + Any + 'static,
246    >(
247        &self,
248        reader: R,
249        reader_format: MassSpectrometryFormat,
250        mut writer: W,
251        writer_format: MassSpectrometryFormat,
252    ) -> Result<(R, W), Self::ErrorType> {
253        self.configure_writer(&mut writer);
254        if self.inpath != "-" {
255            let pb: PathBuf = self.inpath.clone().into();
256            let checksum = if pb.is_dir() {
257                Default::default()
258            } else {
259                info!("Computing checksum for {}", pb.display());
260
261                checksum_file(&pb)?
262            };
263            let has_already = reader
264                .file_description()
265                .source_files
266                .iter()
267                .flat_map(|f| {
268                    f.get_param_by_name("SHA-1")
269                        .map(|c| c.value.as_str() == checksum)
270                })
271                .all(|a| a);
272
273            if !has_already {
274                let mut sf = SourceFile {
275                    location: pb
276                        .parent()
277                        .map(|p| format!("file:///{}", p.to_string_lossy()))
278                        .unwrap_or("file:///".to_string()),
279                    name: pb
280                        .file_name()
281                        .map(|p| p.to_string_lossy().to_string())
282                        .unwrap_or("".to_string()),
283                    ..Default::default()
284                };
285                let par = ControlledVocabulary::MS.param_val(1000569, "SHA-1", checksum);
286                sf.add_param(par);
287                sf.file_format = reader_format.as_param();
288
289                if let Some(ref_sf) = reader.file_description().source_files.last() {
290                    sf.id_format = ref_sf.id_format.clone()
291                }
292                writer.file_description_mut().source_files.push(sf);
293            }
294        };
295
296        let mut sw = Software {
297            version: format!(
298                "v{}",
299                option_env!("CARGO_PKG_VERSION").unwrap_or_else(|| "?")
300            ),
301            id: Software::find_unique_id("mzconvert", writer.softwares()),
302            ..Default::default()
303        };
304        sw.add_param(custom_software_name("mzconvert"));
305
306        let mut method = ProcessingMethod {
307            software_reference: sw.id.clone(),
308            ..Default::default()
309        };
310        writer.softwares_mut().push(sw);
311
312        if let Some(conv) = writer_format.as_conversion() {
313            method.add_param(conv.into())
314        }
315
316        if writer.data_processings().is_empty() {
317            let mut dp = DataProcessing::default();
318            method.order = 0;
319            dp.push(method.clone());
320            dp.id = "DP1".to_string();
321            writer.data_processings_mut().push(dp)
322        } else {
323            for dp in writer.data_processings_mut() {
324                let mut next_step = method.clone();
325                next_step.order = dp.highest_order() + 1;
326                dp.push(next_step);
327            }
328        }
329        Ok((reader, writer))
330    }
Source

pub fn as_param(&self) -> Option<Param>

Examples found in repository?
examples/mzconvert.rs (line 287)
238    fn transform_writer<
239        R: RandomAccessSpectrumIterator<CentroidPeak, DeconvolutedPeak>
240            + MSDataFileMetadata
241            + SpectrumSource<CentroidPeak, DeconvolutedPeak>
242            + Send
243            + Any
244            + 'static,
245        W: SpectrumWriter<CentroidPeak, DeconvolutedPeak> + MSDataFileMetadata + Send + Any + 'static,
246    >(
247        &self,
248        reader: R,
249        reader_format: MassSpectrometryFormat,
250        mut writer: W,
251        writer_format: MassSpectrometryFormat,
252    ) -> Result<(R, W), Self::ErrorType> {
253        self.configure_writer(&mut writer);
254        if self.inpath != "-" {
255            let pb: PathBuf = self.inpath.clone().into();
256            let checksum = if pb.is_dir() {
257                Default::default()
258            } else {
259                info!("Computing checksum for {}", pb.display());
260
261                checksum_file(&pb)?
262            };
263            let has_already = reader
264                .file_description()
265                .source_files
266                .iter()
267                .flat_map(|f| {
268                    f.get_param_by_name("SHA-1")
269                        .map(|c| c.value.as_str() == checksum)
270                })
271                .all(|a| a);
272
273            if !has_already {
274                let mut sf = SourceFile {
275                    location: pb
276                        .parent()
277                        .map(|p| format!("file:///{}", p.to_string_lossy()))
278                        .unwrap_or("file:///".to_string()),
279                    name: pb
280                        .file_name()
281                        .map(|p| p.to_string_lossy().to_string())
282                        .unwrap_or("".to_string()),
283                    ..Default::default()
284                };
285                let par = ControlledVocabulary::MS.param_val(1000569, "SHA-1", checksum);
286                sf.add_param(par);
287                sf.file_format = reader_format.as_param();
288
289                if let Some(ref_sf) = reader.file_description().source_files.last() {
290                    sf.id_format = ref_sf.id_format.clone()
291                }
292                writer.file_description_mut().source_files.push(sf);
293            }
294        };
295
296        let mut sw = Software {
297            version: format!(
298                "v{}",
299                option_env!("CARGO_PKG_VERSION").unwrap_or_else(|| "?")
300            ),
301            id: Software::find_unique_id("mzconvert", writer.softwares()),
302            ..Default::default()
303        };
304        sw.add_param(custom_software_name("mzconvert"));
305
306        let mut method = ProcessingMethod {
307            software_reference: sw.id.clone(),
308            ..Default::default()
309        };
310        writer.softwares_mut().push(sw);
311
312        if let Some(conv) = writer_format.as_conversion() {
313            method.add_param(conv.into())
314        }
315
316        if writer.data_processings().is_empty() {
317            let mut dp = DataProcessing::default();
318            method.order = 0;
319            dp.push(method.clone());
320            dp.id = "DP1".to_string();
321            writer.data_processings_mut().push(dp)
322        } else {
323            for dp in writer.data_processings_mut() {
324                let mut next_step = method.clone();
325                next_step.order = dp.highest_order() + 1;
326                dp.push(next_step);
327            }
328        }
329        Ok((reader, writer))
330    }

Trait Implementations§

Source§

impl Clone for MassSpectrometryFormat

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for MassSpectrometryFormat

Source§

impl Debug for MassSpectrometryFormat

Source§

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

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

impl<'de> Deserialize<'de> for MassSpectrometryFormat

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 Display for MassSpectrometryFormat

Source§

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

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

impl Eq for MassSpectrometryFormat

Source§

impl Hash for MassSpectrometryFormat

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MassSpectrometryFormat

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for MassSpectrometryFormat

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 StructuralPartialEq for MassSpectrometryFormat

Source§

impl TryFrom<MassSpectrometryFormat> for Param

Source§

type Error = &'static str

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

fn try_from(value: MassSpectrometryFormat) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<MassSpectrometryFormat> for FormatConversion

Source§

type Error = &'static str

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

fn try_from(value: MassSpectrometryFormat) -> Result<Self, Self::Error>

Performs the conversion.

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> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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

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

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more