Skip to content

Commit

Permalink
FEAT: implemented option to only read ms1 or ms2 frames for readablef…
Browse files Browse the repository at this point in the history
…rames trait
  • Loading branch information
sander-willems-bruker committed Oct 19, 2023
1 parent ffa603b commit 771e18f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/file_readers/frame_readers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ pub trait ReadableFrames {
fn read_single_frame(&self, index: usize) -> Frame;

fn read_all_frames(&self) -> Vec<Frame>;

fn read_ms1_frames(&self) -> Vec<Frame>;

fn read_ms2_frames(&self) -> Vec<Frame>;
}

impl FileFormat {
Expand All @@ -35,4 +39,12 @@ impl ReadableFrames for FileFormat {
fn read_all_frames(&self) -> Vec<Frame> {
self.unwrap_frame_reader().read_all_frames()
}

fn read_ms1_frames(&self) -> Vec<Frame> {
self.unwrap_frame_reader().read_ms1_frames()
}

fn read_ms2_frames(&self) -> Vec<Frame> {
self.unwrap_frame_reader().read_ms2_frames()
}
}
20 changes: 20 additions & 0 deletions src/file_readers/frame_readers/tdf_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,24 @@ impl ReadableFrames for TDFReader {
.map(|index| self.read_single_frame(index))
.collect()
}

fn read_ms1_frames(&self) -> Vec<Frame> {
(0..self.tdf_bin_reader.size())
.into_par_iter()
.map(|index| match self.frame_types[index] {
FrameType::MS1 => self.read_single_frame(index),
_ => Frame::default(),
})
.collect()
}

fn read_ms2_frames(&self) -> Vec<Frame> {
(0..self.tdf_bin_reader.size())
.into_par_iter()
.map(|index| match self.frame_types[index] {
FrameType::MS2(_) => self.read_single_frame(index),
_ => Frame::default(),
})
.collect()
}
}

0 comments on commit 771e18f

Please sign in to comment.