Skip to content

Commit

Permalink
FEAT: add serialization to spectrum reader config
Browse files Browse the repository at this point in the history
  • Loading branch information
sander-willems-bruker committed Sep 3, 2024
1 parent e8d2416 commit d58e46b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/domain_converters/scan_to_im.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};

/// A converter from Scan -> (inversed) ion mobility.
#[derive(Debug, Default, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct Scan2ImConverter {
scan_intercept: f64,
scan_slope: f64,
Expand Down
3 changes: 3 additions & 0 deletions src/domain_converters/tof_to_mz.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use linreg::linear_regression;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};

/// A converter from TOF -> m/z.
#[derive(Debug, Default, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct Tof2MzConverter {
tof_intercept: f64,
tof_slope: f64,
Expand Down
4 changes: 4 additions & 0 deletions src/io/readers/quad_settings_reader.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::path::Path;

use crate::{
Expand Down Expand Up @@ -151,6 +153,7 @@ type ScanSpanStep = (usize, usize);
/// 100 and step 80 between their in the scan number.
///
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub enum QuadWindowExpansionStrategy {
None,
Even(usize),
Expand All @@ -171,6 +174,7 @@ pub enum FrameWindowSplittingStrategy {
}

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub enum FrameWindowSplittingConfiguration {
Quadrupole(QuadWindowExpansionStrategy),
Window(QuadWindowExpansionStrategy),
Expand Down
8 changes: 6 additions & 2 deletions src/io/readers/spectrum_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use core::fmt;
#[cfg(feature = "minitdf")]
use minitdf::{MiniTDFSpectrumReader, MiniTDFSpectrumReaderError};
use rayon::iter::{IntoParallelIterator, ParallelIterator};
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
#[cfg(feature = "tdf")]
use tdf::{TDFSpectrumReader, TDFSpectrumReaderError};
Expand Down Expand Up @@ -135,7 +137,8 @@ pub enum SpectrumReaderError {
SpectrumReaderFileError(PathBuf),
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct SpectrumProcessingParams {
pub smoothing_window: u32,
pub centroiding_window: u32,
Expand All @@ -154,7 +157,8 @@ impl Default for SpectrumProcessingParams {
}
}

#[derive(Debug, Default, Clone)]
#[derive(Debug, Default, Clone, Copy)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct SpectrumReaderConfig {
pub spectrum_processing_params: SpectrumProcessingParams,
#[cfg(feature = "tdf")]
Expand Down

0 comments on commit d58e46b

Please sign in to comment.