@@ -14,7 +14,10 @@ use timsrust::{
1414 FramePeaks ,
1515 Metadata ,
1616} ;
17- use tracing:: instrument;
17+ use tracing:: {
18+ instrument,
19+ warn,
20+ } ;
1821
1922use crate :: rt_mapping:: {
2023 CycleToRTMapping ,
@@ -669,14 +672,29 @@ impl<T: RTIndex> IndexedPeakGroup<T> {
669672 ) -> Vec < ( usize , u32 , u32 ) > {
670673 let mut out = Vec :: new ( ) ;
671674 let mut cycle_index = 0 ;
675+ let mut last_pushed_cycle = None ;
672676
673677 for ( i, meta) in frame_reader. frame_metas . iter ( ) . enumerate ( ) {
674678 if matches ! ( meta. ms_level, timsrust:: MSLevel :: MS1 ) {
675679 cycle_index += 1 ;
676680 }
677681 if filter ( meta) {
682+ if let Some ( last_cycle) = last_pushed_cycle
683+ && last_cycle == cycle_index
684+ {
685+ warn ! (
686+ "Found multiple frames in the same cycle,
687+ skipping the non-first ones (cycle: {}, rt: {})
688+ this might point to an error when collecting the data
689+ (missing ms1 frame)
690+ " ,
691+ last_cycle, meta. rt_in_seconds,
692+ ) ;
693+ continue ;
694+ }
678695 let rt_ms = ( meta. rt_in_seconds * 1000.0 ) . round ( ) as u32 ;
679696 out. push ( ( i, cycle_index, rt_ms) ) ;
697+ last_pushed_cycle = Some ( cycle_index) ;
680698 }
681699 }
682700 // TODO: check that cycle indices are continuous AND without replicates
@@ -685,11 +703,21 @@ impl<T: RTIndex> IndexedPeakGroup<T> {
685703 // Note: These are assertions instead of errors because
686704 // they are invariants I am checking, not recoverable errors, none of the logic
687705 // after this point would make sense if this is not true.
706+ //
707+ // This checks that whatever filter is used returns only a single frame within each
708+ // cycle ...
688709 assert ! (
689710 w[ 0 ] . 1 < w[ 1 ] . 1 ,
690- "Cycle indices should be strictly increasing"
711+ "Cycle indices should be strictly increasing, {:?} vs {:?}" ,
712+ w[ 0 ] ,
713+ w[ 1 ] ,
714+ ) ;
715+ assert ! (
716+ w[ 0 ] . 2 <= w[ 1 ] . 2 ,
717+ "Retention times should be non-decreasing, {:?} vs {:?}" ,
718+ w[ 0 ] ,
719+ w[ 1 ] ,
691720 ) ;
692- assert ! ( w[ 0 ] . 2 <= w[ 1 ] . 2 , "Retention times should be non-decreasing" ) ;
693721 assert ! (
694722 w[ 1 ] . 1 - w[ 0 ] . 1 == 1 ,
695723 "Cycle indices should be continuous without gaps, found gap between {} and {}" ,
0 commit comments