Skip to content

Commit

Permalink
FEAT: added derive options to converters
Browse files Browse the repository at this point in the history
  • Loading branch information
sander-willems-bruker committed Jul 12, 2024
1 parent 66b1e6f commit 150d623
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/domain_converters/frame_to_rt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// A converter from Frame -> retention time.
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone, PartialEq)]
pub struct Frame2RtConverter {
rt_values: Vec<f64>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/domain_converters/scan_to_im.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// A converter from Scan -> (inversed) ion mobility.
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct Scan2ImConverter {
scan_intercept: f64,
scan_slope: f64,
Expand Down
4 changes: 2 additions & 2 deletions src/domain_converters/tof_to_mz.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use linreg::linear_regression;

/// A converter from TOF -> m/z.
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct Tof2MzConverter {
tof_intercept: f64,
tof_slope: f64,
Expand All @@ -22,7 +22,7 @@ impl Tof2MzConverter {
}
}

pub fn from_pairs(data: &Vec<(f64, u32)>) -> Self {
pub fn regress_from_pairs(data: &Vec<(f64, u32)>) -> Self {
let x: Vec<u32> = data.iter().map(|(_, x_val)| *x_val).collect();
let y: Vec<f64> =
data.iter().map(|(y_val, _)| (*y_val).sqrt()).collect();
Expand Down
2 changes: 1 addition & 1 deletion src/io/readers/spectrum_reader/tdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl SpectrumReaderTrait for TDFSpectrumReader {
acc
});
if hits.len() >= 2 {
self.mz_reader = Tof2MzConverter::from_pairs(&hits);
self.mz_reader = Tof2MzConverter::regress_from_pairs(&hits);
}
}
}

0 comments on commit 150d623

Please sign in to comment.