diff --git a/rust/timscentroid/src/indexing.rs b/rust/timscentroid/src/indexing.rs index 28d30c2..c4ffe5e 100644 --- a/rust/timscentroid/src/indexing.rs +++ b/rust/timscentroid/src/indexing.rs @@ -14,7 +14,10 @@ use timsrust::{ FramePeaks, Metadata, }; -use tracing::instrument; +use tracing::{ + instrument, + warn, +}; use crate::rt_mapping::{ CycleToRTMapping, @@ -669,14 +672,29 @@ impl IndexedPeakGroup { ) -> Vec<(usize, u32, u32)> { let mut out = Vec::new(); let mut cycle_index = 0; + let mut last_pushed_cycle = None; for (i, meta) in frame_reader.frame_metas.iter().enumerate() { if matches!(meta.ms_level, timsrust::MSLevel::MS1) { cycle_index += 1; } if filter(meta) { + if let Some(last_cycle) = last_pushed_cycle + && last_cycle == cycle_index + { + warn!( + "Found multiple frames in the same cycle, + skipping the non-first ones (cycle: {}, rt: {}) + this might point to an error when collecting the data + (missing ms1 frame) + ", + last_cycle, meta.rt_in_seconds, + ); + continue; + } let rt_ms = (meta.rt_in_seconds * 1000.0).round() as u32; out.push((i, cycle_index, rt_ms)); + last_pushed_cycle = Some(cycle_index); } } // TODO: check that cycle indices are continuous AND without replicates @@ -685,11 +703,21 @@ impl IndexedPeakGroup { // Note: These are assertions instead of errors because // they are invariants I am checking, not recoverable errors, none of the logic // after this point would make sense if this is not true. + // + // This checks that whatever filter is used returns only a single frame within each + // cycle ... assert!( w[0].1 < w[1].1, - "Cycle indices should be strictly increasing" + "Cycle indices should be strictly increasing, {:?} vs {:?}", + w[0], + w[1], + ); + assert!( + w[0].2 <= w[1].2, + "Retention times should be non-decreasing, {:?} vs {:?}", + w[0], + w[1], ); - assert!(w[0].2 <= w[1].2, "Retention times should be non-decreasing"); assert!( w[1].1 - w[0].1 == 1, "Cycle indices should be continuous without gaps, found gap between {} and {}", diff --git a/rust/timsquery/src/models/aggregators/spectrum_agg.rs b/rust/timsquery/src/models/aggregators/spectrum_agg.rs index bb55288..39d94fa 100644 --- a/rust/timsquery/src/models/aggregators/spectrum_agg.rs +++ b/rust/timsquery/src/models/aggregators/spectrum_agg.rs @@ -167,4 +167,3 @@ impl Add for MzMobilityStatsCollector { } } } - diff --git a/rust/timsquery/src/models/indexed_data.rs b/rust/timsquery/src/models/indexed_data.rs index d9bf429..a78e16a 100644 --- a/rust/timsquery/src/models/indexed_data.rs +++ b/rust/timsquery/src/models/indexed_data.rs @@ -455,7 +455,9 @@ impl QueriableData> for IndexedPeaks } } -impl QueriableData> for IndexedPeaksHandle { +impl QueriableData> + for IndexedPeaksHandle +{ fn add_query( &self, aggregator: &mut SpectralCollector, diff --git a/rust/timsquery_viewer/src/app.rs b/rust/timsquery_viewer/src/app.rs index 0658ad0..d7b1026 100644 --- a/rust/timsquery_viewer/src/app.rs +++ b/rust/timsquery_viewer/src/app.rs @@ -310,9 +310,7 @@ impl ViewerApp { for &pane in ALL_PANES { if dock_state.find_tab(&pane).is_none() { tracing::info!("Adding missing pane {:?} to saved layout", pane); - dock_state - .main_surface_mut() - .push_to_first_leaf(pane); + dock_state.main_surface_mut().push_to_first_leaf(pane); } } @@ -603,7 +601,13 @@ impl ViewerApp { return Err("Computation cancelled".to_string()); } - Ok((output, collector, expected_intensities, selected_idx as u64, elution_group)) + Ok(( + output, + collector, + expected_intensities, + selected_idx as u64, + elution_group, + )) } /// Check if background chromatogram computation completed @@ -1296,10 +1300,7 @@ impl ViewerApp { } /// Encode an egui ColorImage as PNG and write to disk -fn save_color_image_as_png( - image: &egui::ColorImage, - path: &std::path::Path, -) -> Result<(), String> { +fn save_color_image_as_png(image: &egui::ColorImage, path: &std::path::Path) -> Result<(), String> { let width = image.width() as u32; let height = image.height() as u32; let pixels: Vec = image @@ -1442,7 +1443,7 @@ impl<'a> AppTabViewer<'a> { let action = ConfigPanel::render_export_section( ui, self.screenshot_delay_secs, - &self.screenshot_state, + self.screenshot_state, ); match action { ScreenshotAction::None => {} diff --git a/rust/timsquery_viewer/src/computed_state.rs b/rust/timsquery_viewer/src/computed_state.rs index c7003cf..eb653ff 100644 --- a/rust/timsquery_viewer/src/computed_state.rs +++ b/rust/timsquery_viewer/src/computed_state.rs @@ -544,7 +544,10 @@ impl ComputedState { return false; }; ( - result.elution_group.clone().with_rt_seconds(rt_seconds as f32), + result + .elution_group + .clone() + .with_rt_seconds(rt_seconds as f32), result.output.mobility_ook0 as f64, ) }; @@ -567,9 +570,7 @@ impl ComputedState { let to_range = |r: OptionallyRestricted>| -> (f64, f64) { match r { - OptionallyRestricted::Restricted(tr) => { - (tr.start() as f64, tr.end() as f64) - } + OptionallyRestricted::Restricted(tr) => (tr.start() as f64, tr.end() as f64), OptionallyRestricted::Unrestricted => (0.0, 2.0), } }; diff --git a/rust/timsquery_viewer/src/ui/panels/config_panel.rs b/rust/timsquery_viewer/src/ui/panels/config_panel.rs index 0039193..05d0a4e 100644 --- a/rust/timsquery_viewer/src/ui/panels/config_panel.rs +++ b/rust/timsquery_viewer/src/ui/panels/config_panel.rs @@ -13,8 +13,10 @@ const SECTION_SPACING: f32 = 12.0; const INTERNAL_SPACING: f32 = 8.0; /// Screenshot capture lifecycle +#[derive(Default)] pub enum ScreenshotState { /// Nothing happening + #[default] Idle, /// Timer running, show remaining seconds overlay Countdown { deadline: Instant }, @@ -24,12 +26,6 @@ pub enum ScreenshotState { Saving(Arc), } -impl Default for ScreenshotState { - fn default() -> Self { - Self::Idle - } -} - /// Actions the export UI can request pub enum ScreenshotAction { None, @@ -243,9 +239,10 @@ impl ConfigPanel { .as_secs_f32() .ceil() as u32; ui.horizontal(|ui| { - ui.add_enabled(false, egui::Button::new( - format!("Capturing in {}s...", remaining), - )); + ui.add_enabled( + false, + egui::Button::new(format!("Capturing in {}s...", remaining)), + ); if ui.button("Cancel").clicked() { action = ScreenshotAction::Cancel; } diff --git a/rust/timsquery_viewer/src/ui/panels/mobility_panel.rs b/rust/timsquery_viewer/src/ui/panels/mobility_panel.rs index 17842e4..e5ae62c 100644 --- a/rust/timsquery_viewer/src/ui/panels/mobility_panel.rs +++ b/rust/timsquery_viewer/src/ui/panels/mobility_panel.rs @@ -20,7 +20,7 @@ pub struct MobilityPanel; impl MobilityPanel { pub fn new() -> Self { - Self::default() + Self } pub fn title(&self) -> &str {