#[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.
Implementations§
Source§impl MassSpectrometryFormat
impl MassSpectrometryFormat
Sourcepub fn as_conversion(&self) -> Option<FormatConversion>
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 }Sourcepub fn as_param(&self) -> Option<Param>
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
impl Clone for MassSpectrometryFormat
impl Copy for MassSpectrometryFormat
Source§impl Debug for MassSpectrometryFormat
impl Debug for MassSpectrometryFormat
Source§impl<'de> Deserialize<'de> for MassSpectrometryFormat
impl<'de> Deserialize<'de> for MassSpectrometryFormat
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 Display for MassSpectrometryFormat
impl Display for MassSpectrometryFormat
impl Eq for MassSpectrometryFormat
Source§impl Hash for MassSpectrometryFormat
impl Hash for MassSpectrometryFormat
Source§impl PartialEq for MassSpectrometryFormat
impl PartialEq for MassSpectrometryFormat
Source§impl Serialize for MassSpectrometryFormat
impl Serialize for MassSpectrometryFormat
impl StructuralPartialEq for MassSpectrometryFormat
Source§impl TryFrom<MassSpectrometryFormat> for Param
impl TryFrom<MassSpectrometryFormat> for Param
Auto Trait Implementations§
impl Freeze for MassSpectrometryFormat
impl RefUnwindSafe for MassSpectrometryFormat
impl Send for MassSpectrometryFormat
impl Sync for MassSpectrometryFormat
impl Unpin for MassSpectrometryFormat
impl UnsafeUnpin for MassSpectrometryFormat
impl UnwindSafe for MassSpectrometryFormat
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
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
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§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 moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.