Skip to content

Commit

Permalink
FEAT: imporved speed performance of ddareader by only reading ms2 frames
Browse files Browse the repository at this point in the history
  • Loading branch information
sander-willems-bruker committed Oct 19, 2023
1 parent 771e18f commit 1ed2d54
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/file_readers/spectrum_readers/dda_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ pub struct DDASpectrumReader {
pub path_name: String,
precursor_reader: PrecursorReader,
mz_reader: Tof2MzConverter,
frames: Vec<Frame>,
ms2_frames: Vec<Frame>,
}

impl DDASpectrumReader {
pub fn new(path_name: String) -> Self {
let tdf_reader: TDFReader = TDFReader::new(&path_name.to_string());
let mz_reader: Tof2MzConverter = tdf_reader.mz_converter;
let frames: Vec<Frame> = tdf_reader.read_all_frames();
let ms2_frames: Vec<Frame> = tdf_reader.read_ms2_frames();
let precursor_reader: PrecursorReader =
PrecursorReader::new(&tdf_reader);
Self {
path_name,
precursor_reader,
mz_reader,
frames,
ms2_frames,
}
}

Expand All @@ -53,21 +53,21 @@ impl DDASpectrumReader {
for &index in selection.iter() {
let frame: usize =
self.precursor_reader.pasef_frames.frame[index] - 1;
if self.frames[frame].intensities.len() == 0 {
if self.ms2_frames[frame].intensities.len() == 0 {
continue;
}
let scan_start: usize =
self.precursor_reader.pasef_frames.scan_start[index];
let scan_end: usize =
self.precursor_reader.pasef_frames.scan_end[index];
let offset_start: usize =
self.frames[frame].scan_offsets[scan_start] as usize;
self.ms2_frames[frame].scan_offsets[scan_start] as usize;
let offset_end: usize =
self.frames[frame].scan_offsets[scan_end] as usize;
self.ms2_frames[frame].scan_offsets[scan_end] as usize;
let tof_selection: &[u32] =
&self.frames[frame].tof_indices[offset_start..offset_end];
&self.ms2_frames[frame].tof_indices[offset_start..offset_end];
let intensity_selection: &[u32] =
&self.frames[frame].intensities[offset_start..offset_end];
&self.ms2_frames[frame].intensities[offset_start..offset_end];
tof_indices.extend(tof_selection);
intensities.extend(intensity_selection);
}
Expand Down

0 comments on commit 1ed2d54

Please sign in to comment.