Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions rust/timscentroid/src/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use timsrust::{
FramePeaks,
Metadata,
};
use tracing::instrument;
use tracing::{
instrument,
warn,
};

use crate::rt_mapping::{
CycleToRTMapping,
Expand Down Expand Up @@ -669,14 +672,29 @@ impl<T: RTIndex> IndexedPeakGroup<T> {
) -> 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
Expand All @@ -685,11 +703,21 @@ impl<T: RTIndex> IndexedPeakGroup<T> {
// 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 {}",
Expand Down
1 change: 0 additions & 1 deletion rust/timsquery/src/models/aggregators/spectrum_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,3 @@ impl Add for MzMobilityStatsCollector {
}
}
}

4 changes: 3 additions & 1 deletion rust/timsquery/src/models/indexed_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@ impl<FH: KeyLike> QueriableData<ChromatogramCollector<FH, f32>> for IndexedPeaks
}
}

impl<FH: KeyLike> QueriableData<SpectralCollector<FH, MzMobilityStatsCollector>> for IndexedPeaksHandle {
impl<FH: KeyLike> QueriableData<SpectralCollector<FH, MzMobilityStatsCollector>>
for IndexedPeaksHandle
{
fn add_query(
&self,
aggregator: &mut SpectralCollector<FH, MzMobilityStatsCollector>,
Expand Down
19 changes: 10 additions & 9 deletions rust/timsquery_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<u8> = image
Expand Down Expand Up @@ -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 => {}
Expand Down
9 changes: 5 additions & 4 deletions rust/timsquery_viewer/src/computed_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
};
Expand All @@ -567,9 +570,7 @@ impl ComputedState {

let to_range = |r: OptionallyRestricted<TupleRange<f32>>| -> (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),
}
};
Expand Down
15 changes: 6 additions & 9 deletions rust/timsquery_viewer/src/ui/panels/config_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -24,12 +26,6 @@ pub enum ScreenshotState {
Saving(Arc<egui::ColorImage>),
}

impl Default for ScreenshotState {
fn default() -> Self {
Self::Idle
}
}

/// Actions the export UI can request
pub enum ScreenshotAction {
None,
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion rust/timsquery_viewer/src/ui/panels/mobility_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct MobilityPanel;

impl MobilityPanel {
pub fn new() -> Self {
Self::default()
Self
}

pub fn title(&self) -> &str {
Expand Down
Loading