diff --git a/Cargo.lock b/Cargo.lock index 415629c..1875183 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,6 +249,12 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytecount" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" + [[package]] name = "bytemuck" version = "1.16.1" @@ -323,7 +329,7 @@ version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.72", @@ -350,7 +356,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys", ] @@ -484,6 +490,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "gethostname" version = "0.2.3" @@ -534,6 +546,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -565,25 +583,16 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" dependencies = [ "console", - "instant", "number_prefix", "portable-atomic", "rayon", - "unicode-width", -] - -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", + "unicode-width 0.2.0", + "web-time", ] [[package]] @@ -907,6 +916,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "papergrid" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b0f8def1f117e13c895f3eda65a7b5650688da29d6ad04635f61bc7b92eebd" +dependencies = [ + "bytecount", + "fnv", + "unicode-width 0.2.0", +] + [[package]] name = "parquet" version = "42.0.0" @@ -958,9 +978,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -977,6 +997,28 @@ dependencies = [ "zerocopy 0.6.6", ] +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -1239,6 +1281,29 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tabled" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6709222f3973137427ce50559cd564dc187a95b9cfe01613d2f4e93610e510a" +dependencies = [ + "papergrid", + "tabled_derive", +] + +[[package]] +name = "tabled_derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "931be476627d4c54070a1f3a9739ccbfec9b36b39815106a20cce2243bbcefe1" +dependencies = [ + "heck 0.4.1", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "thiserror" version = "1.0.63" @@ -1324,6 +1389,7 @@ dependencies = [ "rmp-serde", "serde", "serde_json", + "tabled", "timsrust", "tracing", "tracing-bunyan-formatter", @@ -1478,9 +1544,15 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" [[package]] name = "utf8parse" @@ -1566,6 +1638,16 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 4513811..9b8371d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" timsrust = "=0.4.1" rayon = "1.5" nohash-hasher = "=0.2.0" -indicatif = { version = "0.17.8", features = ["rayon"] } +indicatif = { version = "0.17.9", features = ["rayon"] } clap = { version = "4.5.17", features = ["derive"], optional = true } serde = { version = "1.0.204", features = ["derive"] } @@ -27,6 +27,7 @@ tracing-chrome = "0.7.2" # These are only used for benchmarks rand = { version = "0.8.5", optional = true } rand_chacha = { version = "0.3.1", optional = true } +tabled = "0.17.0" [features] @@ -43,6 +44,10 @@ name = "benchmark_indices" path = "benches/benchmark_indices.rs" required-features = ["bench"] +[[bin]] +name = "benchmark_centroiding" +path = "benches/benchmark_centroiding.rs" + [profile.release] opt-level = 3 lto = 'fat' diff --git a/benches/benchmark_centroiding.rs b/benches/benchmark_centroiding.rs new file mode 100644 index 0000000..9a8238f --- /dev/null +++ b/benches/benchmark_centroiding.rs @@ -0,0 +1,64 @@ +use std::env; +use std::time::Instant; +use timsquery::models::frames::expanded_frame::{ + par_expand_and_arrange_frames, + par_expand_and_centroid_frames, + warn_and_skip_badframes, + FrameProcessingConfig, +}; +use timsrust::readers::{ + FrameReader, + MetadataReader, +}; +use timsrust::MSLevel; +use tracing::subscriber::set_global_default; +use tracing_bunyan_formatter::{ + BunyanFormattingLayer, + JsonStorageLayer, +}; +use tracing_subscriber::prelude::*; +use tracing_subscriber::registry::Registry; +use tracing_subscriber::EnvFilter; + +fn main() { + // "TIMS_DATA_FILE" + // Read from env + let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")); + let formatting_layer = BunyanFormattingLayer::new("timsquery".into(), std::io::stdout); + let subscriber = Registry::default() + .with(env_filter) + .with(JsonStorageLayer) + .with(formatting_layer); + + set_global_default(subscriber).expect("Setting default subscriber failed"); + + let tims_data_file = env::var("TIMS_DATA_FILE").expect("TIMS_DATA_FILE not set"); + let sql_path = std::path::Path::new(&tims_data_file).join("analysis.tdf"); + let meta_converters = MetadataReader::new(&sql_path).unwrap(); + let centroiding_config = FrameProcessingConfig::default_centroided(); + let centroiding_config = centroiding_config + .with_converters(meta_converters.im_converter, meta_converters.mz_converter); + + let frame_reader = FrameReader::new(&tims_data_file).unwrap(); + let ms1_iter = frame_reader.parallel_filter(|x| x.ms_level == MSLevel::MS1); + let ms1_iter = warn_and_skip_badframes(ms1_iter); + let start = Instant::now(); + println!("Starting expansion"); + let _expanded_ms1_frames = match centroiding_config { + FrameProcessingConfig::Centroided { + settings, + ims_converter, + mz_converter, + } => par_expand_and_centroid_frames( + ms1_iter, + settings.ims_tol_pct, + settings.mz_tol_ppm, + settings.window_width, + &ims_converter.unwrap(), + &mz_converter.unwrap(), + ), + FrameProcessingConfig::NotCentroided => par_expand_and_arrange_frames(ms1_iter), + }; + let elapsed = start.elapsed(); + println!("Elapsed: {:.2?}", elapsed); +} diff --git a/data/benchmark_results_230510_PRTC_13_S1-B1_1_12817_BatchAccess_full_rt.png b/data/benchmark_results_230510_PRTC_13_S1-B1_1_12817_BatchAccess_full_rt.png index 0e94dcc..37dfb00 100644 Binary files a/data/benchmark_results_230510_PRTC_13_S1-B1_1_12817_BatchAccess_full_rt.png and b/data/benchmark_results_230510_PRTC_13_S1-B1_1_12817_BatchAccess_full_rt.png differ diff --git a/data/benchmark_results_230510_PRTC_13_S1-B1_1_12817_BatchAccess_narrow_rt.png b/data/benchmark_results_230510_PRTC_13_S1-B1_1_12817_BatchAccess_narrow_rt.png index 1b1e7eb..c8d418d 100644 Binary files a/data/benchmark_results_230510_PRTC_13_S1-B1_1_12817_BatchAccess_narrow_rt.png and b/data/benchmark_results_230510_PRTC_13_S1-B1_1_12817_BatchAccess_narrow_rt.png differ diff --git a/data/benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02_BatchAccess_full_rt.png b/data/benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02_BatchAccess_full_rt.png index c0e73a9..a8fdfa2 100644 Binary files a/data/benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02_BatchAccess_full_rt.png and b/data/benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02_BatchAccess_full_rt.png differ diff --git a/data/benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02_BatchAccess_narrow_rt.png b/data/benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02_BatchAccess_narrow_rt.png index bd8a0f8..a4dfdc9 100644 Binary files a/data/benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02_BatchAccess_narrow_rt.png and b/data/benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02_BatchAccess_narrow_rt.png differ diff --git a/data/sageresults/ubb_peptide_plotexpanded-raw-frame-index.png b/data/sageresults/ubb_peptide_plotexpanded-raw-frame-index.png index ad8cb4d..a21a190 100644 Binary files a/data/sageresults/ubb_peptide_plotexpanded-raw-frame-index.png and b/data/sageresults/ubb_peptide_plotexpanded-raw-frame-index.png differ diff --git a/data/sageresults/ubb_peptide_plottransposed-quad-index.png b/data/sageresults/ubb_peptide_plottransposed-quad-index.png index c31aa64..3a2ef21 100644 Binary files a/data/sageresults/ubb_peptide_plottransposed-quad-index.png and b/data/sageresults/ubb_peptide_plottransposed-quad-index.png differ diff --git a/data/slim_benchmark_results_230510_PRTC_13_S1-B1_1_12817.json b/data/slim_benchmark_results_230510_PRTC_13_S1-B1_1_12817.json index c6c3ed2..6d59607 100644 --- a/data/slim_benchmark_results_230510_PRTC_13_S1-B1_1_12817.json +++ b/data/slim_benchmark_results_230510_PRTC_13_S1-B1_1_12817.json @@ -7,87 +7,87 @@ { "name": "RawFileIndex", "context": "BatchAccess_narrow_rt", - "mean_duration_seconds": 32.022435916, - "mean_duration_human_readable": "32.022435916s", - "setup_time_seconds": 0.078233583, - "setup_time_human_readable": "78.233583ms", + "mean_duration_seconds": 30.18029, + "mean_duration_human_readable": "30.18029s", + "setup_time_seconds": 0.080955625, + "setup_time_human_readable": "80.955625ms", "note": "RawFileIndex::query_multi_group aggregated 68182 " }, { "name": "ExpandedRawFileIndex", "context": "BatchAccess_narrow_rt", - "mean_duration_seconds": 0.009044057747747747, - "mean_duration_human_readable": "9.044057ms", - "setup_time_seconds": 5.633474292, - "setup_time_human_readable": "5.633474292s", + "mean_duration_seconds": 0.008114801080645164, + "mean_duration_human_readable": "8.114801ms", + "setup_time_seconds": 6.046508917, + "setup_time_human_readable": "6.046508917s", "note": "ExpandedRawFileIndex::query_multi_group aggregated 571213 " }, { "name": "ExpandedRawFileIndex", "context": "BatchAccess_full_rt", - "mean_duration_seconds": 2.249131542, - "mean_duration_human_readable": "2.249131542s", - "setup_time_seconds": 6.053857416, - "setup_time_human_readable": "6.053857416s", + "mean_duration_seconds": 3.257979625, + "mean_duration_human_readable": "3.257979625s", + "setup_time_seconds": 6.282548833, + "setup_time_human_readable": "6.282548833s", "note": "ExpandedRawFileIndex::query_multi_group aggregated 68222611 " }, { "name": "ExpandedRawFileIndexCentroided", "context": "BatchAccess_narrow_rt", - "mean_duration_seconds": 0.005108526841836739, - "mean_duration_human_readable": "5.108526ms", - "setup_time_seconds": 87.226145542, - "setup_time_human_readable": "87.226145542s", - "note": "ExpandedRawFileIndexCentroided::query_multi_group aggregated 374244 " + "mean_duration_seconds": 0.004419905277533043, + "mean_duration_human_readable": "4.419905ms", + "setup_time_seconds": 55.125986125, + "setup_time_human_readable": "55.125986125s", + "note": "ExpandedRawFileIndexCentroided::query_multi_group aggregated 363057 " }, { "name": "ExpandedRawFileIndexCentroided", "context": "BatchAccess_full_rt", - "mean_duration_seconds": 0.25770495825, - "mean_duration_human_readable": "257.704958ms", - "setup_time_seconds": 87.737051417, - "setup_time_human_readable": "87.737051417s", - "note": "ExpandedRawFileIndexCentroided::query_multi_group aggregated 47164889 " + "mean_duration_seconds": 0.26117429175, + "mean_duration_human_readable": "261.174291ms", + "setup_time_seconds": 54.706755208, + "setup_time_human_readable": "54.706755208s", + "note": "ExpandedRawFileIndexCentroided::query_multi_group aggregated 45634581 " }, { "name": "TransposedQuadIndex", "context": "BatchAccess_narrow_rt", - "mean_duration_seconds": 0.008393515249999999, - "mean_duration_human_readable": "8.393515ms", - "setup_time_seconds": 60.55498175, - "setup_time_human_readable": "60.55498175s", + "mean_duration_seconds": 0.008861190592920353, + "mean_duration_human_readable": "8.86119ms", + "setup_time_seconds": 64.419395125, + "setup_time_human_readable": "64.419395125s", "note": "TransposedQuadIndex::query_multi_group aggregated 558586 " }, { "name": "TransposedQuadIndex", "context": "BatchAccess_full_rt", - "mean_duration_seconds": 0.011671118220930232, - "mean_duration_human_readable": "11.671118ms", - "setup_time_seconds": 59.586185583, - "setup_time_human_readable": "59.586185583s", + "mean_duration_seconds": 0.012704890202531639, + "mean_duration_human_readable": "12.70489ms", + "setup_time_seconds": 64.248769625, + "setup_time_human_readable": "64.248769625s", "note": "TransposedQuadIndex::query_multi_group aggregated 66501531 " }, { "name": "TransposedQuadIndexCentroided", "context": "BatchAccess_narrow_rt", - "mean_duration_seconds": 0.005674485870056497, - "mean_duration_human_readable": "5.674485ms", - "setup_time_seconds": 97.143069834, - "setup_time_human_readable": "97.143069834s", - "note": "TransposedQuadIndex::query_multi_group aggregated 368659 " + "mean_duration_seconds": 0.0037612689210526303, + "mean_duration_human_readable": "3.761268ms", + "setup_time_seconds": 63.369554334, + "setup_time_human_readable": "63.369554334s", + "note": "TransposedQuadIndex::query_multi_group aggregated 353901 " }, { "name": "TransposedQuadIndexCentroided", "context": "BatchAccess_full_rt", - "mean_duration_seconds": 0.0065915490261437915, - "mean_duration_human_readable": "6.591549ms", - "setup_time_seconds": 95.924367458, - "setup_time_human_readable": "95.924367458s", - "note": "TransposedQuadIndex::query_multi_group aggregated 46025604 " + "mean_duration_seconds": 0.004413151973568282, + "mean_duration_human_readable": "4.413151ms", + "setup_time_seconds": 63.189314, + "setup_time_human_readable": "63.189314s", + "note": "TransposedQuadIndex::query_multi_group aggregated 44500583 " } ], "metadata": { "basename": "230510_PRTC_13_S1-B1_1_12817" }, - "full_benchmark_time_seconds": 554.536639958 + "full_benchmark_time_seconds": 434.436133792 } \ No newline at end of file diff --git a/data/slim_benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02.json b/data/slim_benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02.json index 31a2813..29e1743 100644 --- a/data/slim_benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02.json +++ b/data/slim_benchmark_results_LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02.json @@ -7,51 +7,51 @@ { "name": "RawFileIndex", "context": "BatchAccess_narrow_rt", - "mean_duration_seconds": 3.913134625, - "mean_duration_human_readable": "3.913134625s", - "setup_time_seconds": 0.241788791, - "setup_time_human_readable": "241.788791ms", + "mean_duration_seconds": 4.297323083, + "mean_duration_human_readable": "4.297323083s", + "setup_time_seconds": 0.287926542, + "setup_time_human_readable": "287.926542ms", "note": "RawFileIndex::query_multi_group aggregated 8809 " }, { "name": "ExpandedRawFileIndexCentroided", "context": "BatchAccess_narrow_rt", - "mean_duration_seconds": 0.0037595285112781963, - "mean_duration_human_readable": "3.759528ms", - "setup_time_seconds": 456.581050083, - "setup_time_human_readable": "456.581050083s", - "note": "ExpandedRawFileIndexCentroided::query_multi_group aggregated 1570 " + "mean_duration_seconds": 0.002717109048913044, + "mean_duration_human_readable": "2.717109ms", + "setup_time_seconds": 461.478472417, + "setup_time_human_readable": "461.478472417s", + "note": "ExpandedRawFileIndexCentroided::query_multi_group aggregated 2146 " }, { "name": "ExpandedRawFileIndexCentroided", "context": "BatchAccess_full_rt", - "mean_duration_seconds": 11.996143583, - "mean_duration_human_readable": "11.996143583s", - "setup_time_seconds": 478.673331166, - "setup_time_human_readable": "478.673331166s", - "note": "ExpandedRawFileIndexCentroided::query_multi_group aggregated 545060194 " + "mean_duration_seconds": 13.793108458, + "mean_duration_human_readable": "13.793108458s", + "setup_time_seconds": 468.599565709, + "setup_time_human_readable": "468.599565709s", + "note": "ExpandedRawFileIndexCentroided::query_multi_group aggregated 514227831 " }, { "name": "TransposedQuadIndexCentroided", "context": "BatchAccess_narrow_rt", - "mean_duration_seconds": 0.013009783532467532, - "mean_duration_human_readable": "13.009783ms", - "setup_time_seconds": 538.791840375, - "setup_time_human_readable": "538.791840375s", - "note": "TransposedQuadIndex::query_multi_group aggregated 1570 " + "mean_duration_seconds": 0.010208996653061223, + "mean_duration_human_readable": "10.208996ms", + "setup_time_seconds": 536.410410584, + "setup_time_human_readable": "536.410410584s", + "note": "TransposedQuadIndex::query_multi_group aggregated 2146 " }, { "name": "TransposedQuadIndexCentroided", "context": "BatchAccess_full_rt", - "mean_duration_seconds": 0.019372012096153843, - "mean_duration_human_readable": "19.372012ms", - "setup_time_seconds": 535.971821958, - "setup_time_human_readable": "535.971821958s", - "note": "TransposedQuadIndex::query_multi_group aggregated 538196860 " + "mean_duration_seconds": 0.0161994805483871, + "mean_duration_human_readable": "16.19948ms", + "setup_time_seconds": 532.628667875, + "setup_time_human_readable": "532.628667875s", + "note": "TransposedQuadIndex::query_multi_group aggregated 507771161 " } ], "metadata": { "basename": "LFQ_timsTOFPro_diaPASEF_Condition_A_Sample_Alpha_02" }, - "full_benchmark_time_seconds": 2070.526848583 + "full_benchmark_time_seconds": 2074.217246167 } \ No newline at end of file diff --git a/src/errors.rs b/src/errors.rs index 4d9b82b..71b7336 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -47,6 +47,8 @@ pub enum DataProcessingError { ExpectedNonEmptyData, InsufficientData { real: usize, expected: usize }, ExpectedVectorSameLength(usize, usize), + UnexpectedInfiniteError(usize), + UnexpectedInfiniteErrors(Vec<(usize, f64)>), } impl From for TimsqueryError { diff --git a/src/main.rs b/src/main.rs index 83d8322..9246866 100644 --- a/src/main.rs +++ b/src/main.rs @@ -304,7 +304,8 @@ pub fn execute_query( match (index, aggregator) { (PossibleIndex::TransposedQuadIndex, aggregator) => { - let index = QuadSplittedTransposedIndex::from_path(&(raw_file_path.clone())).unwrap(); + let index = QuadSplittedTransposedIndex::from_path_centroided(&(raw_file_path.clone())) + .unwrap(); match aggregator { PossibleAggregator::RawPeakIntensityAggregator => { let aggregator = RawPeakIntensityAggregator::new_with_elution_group; diff --git a/src/models/aggregators/raw_peak_agg/multi_chromatogram_agg/multi_chromatogram_agg.rs b/src/models/aggregators/raw_peak_agg/multi_chromatogram_agg/multi_chromatogram_agg.rs index 2a15c7a..1db14e6 100644 --- a/src/models/aggregators/raw_peak_agg/multi_chromatogram_agg/multi_chromatogram_agg.rs +++ b/src/models/aggregators/raw_peak_agg/multi_chromatogram_agg/multi_chromatogram_agg.rs @@ -13,6 +13,7 @@ use crate::models::elution_group::ElutionGroup; use crate::models::frames::raw_peak::RawPeak; use crate::models::queries::MsLevelContext; use crate::traits::aggregator::Aggregator; +use crate::TimsqueryError; use serde::Serialize; use std::hash::Hash; @@ -130,11 +131,26 @@ impl pub fn finalized_score(&self) -> Result { let main_score = self.cross_ms2.as_slice(); let main_score_rts = self.ms1_stats.retention_time_miliseconds.as_slice(); - let apex_cross_ms2_index = main_score - .iter() - .enumerate() - .max_by(|x, y| x.1.partial_cmp(y.1).unwrap()) - .unwrap(); + let apex_cross_ms2_index = main_score.iter().enumerate().max_by(|x, y| { + let cmp = x.1.partial_cmp(y.1); + if cmp.is_none() { + panic!( + "Main score is not comparable {:?} vs {:?} ... [{:?}]", + x, y, main_score + ); + } + cmp.unwrap() + }); + + let apex_cross_ms2_index = match apex_cross_ms2_index { + Some(x) => x, + None => { + return Err(TimsqueryError::Other(format!( + "Insufficient data for cross score, main_score: {:?}", + main_score + ))); + } + }; let apex_rt = main_score_rts[apex_cross_ms2_index.0]; @@ -218,12 +234,14 @@ impl Aggregat PartitionedCMGArrayStats::from(PartitionedCMGArrays::from(self.ms1_stats)), mz_converter, mobility_converter, - ); + ) + .unwrap(); let ms2_stats = PartitionedCMGScoredStatsArrays::new( PartitionedCMGArrayStats::from(PartitionedCMGArrays::from(self.ms2_stats)), mz_converter, mobility_converter, - ); + ) + .unwrap(); let cross_ms1 = ms2_stats.cross_scores(&ms1_stats).unwrap_or(vec![]); let cross_ms2 = ms1_stats.cross_scores(&ms2_stats).unwrap_or(vec![]); diff --git a/src/models/aggregators/raw_peak_agg/multi_chromatogram_agg/scored_arrays.rs b/src/models/aggregators/raw_peak_agg/multi_chromatogram_agg/scored_arrays.rs index a539dcc..5560b81 100644 --- a/src/models/aggregators/raw_peak_agg/multi_chromatogram_agg/scored_arrays.rs +++ b/src/models/aggregators/raw_peak_agg/multi_chromatogram_agg/scored_arrays.rs @@ -22,6 +22,20 @@ use timsrust::converters::{ }; use tracing::debug; +// fn check_nonnan(x: &[f64]) -> Result<()> { +// if x.iter().any(|y| y.is_infinite() || y.is_nan()) { +// let mut out = Vec::with_capacity(x.len()); +// for (i, val) in x.iter().enumerate() { +// if !(val.is_finite() || val.is_nan()) { +// out.push((i, *val)); +// } +// } +// Err(crate::errors::DataProcessingError::UnexpectedInfiniteErrors(out).into()) +// } else { +// Ok(()) +// } +// } + // This name is starting to get really long ... #[derive(Debug, Clone, Serialize)] pub struct PartitionedCMGScoredStatsArrays { @@ -87,7 +101,7 @@ impl ScoresAtTime { impl ChromatogramScores { pub fn new( arrays: &PartitionedCMGArrayStats, - ) -> Self { + ) -> Result { let lazy_hyperscore = calculate_lazy_hyperscore(&arrays.npeaks, &arrays.summed_intensity); let basline_window_len = 1 + (arrays.retention_time_miliseconds.len() / 20); let lazy_hyperscore_vs_baseline = @@ -141,7 +155,14 @@ impl ChromatogramScores { "Failed sanity check" ); - ChromatogramScores { + // check_nonnan(&lazy_hyperscore)?; + // check_nonnan(&lazyerscore)?; + // check_nonnan(&lazy_hyperscore_vs_baseline)?; + // check_nonnan(&lazyerscore_vs_baseline)?; + // check_nonnan(&norm_hyperscore_vs_baseline)?; + // check_nonnan(&norm_lazyerscore_vs_baseline)?; + + Ok(ChromatogramScores { lazy_hyperscore, lazyerscore, lazy_hyperscore_vs_baseline, @@ -150,7 +171,7 @@ impl ChromatogramScores { norm_lazyerscore_vs_baseline, npeaks: arrays.npeaks.to_owned(), cosine_similarity: arrays.cosine_similarity.to_owned(), - } + }) } fn get_apex_score_index(&self) -> usize { @@ -279,7 +300,7 @@ impl // The aggregator map to the closest cycle, rather than the frame. // 2. Fix the wrapping to not generate -inf values. let score = self_cos * other_cos * other_lzb; - if score.is_infinite() { + if score.is_infinite() || score.is_nan() { out.push(0.0); continue; } @@ -308,8 +329,8 @@ impl PartitionedCMGScoredStatsA other: PartitionedCMGArrayStats, mz_converter: &Tof2MzConverter, mobility_converter: &Scan2ImConverter, - ) -> Self { - let scores = ChromatogramScores::new(&other); + ) -> Result { + let scores = ChromatogramScores::new(&other)?; let apex_primary_score_index = scores.get_apex_score_index(); let average_mobility = other .weighted_scan_index_mean @@ -351,7 +372,7 @@ impl PartitionedCMGScoredStatsA .map(|x| (x.0, mz_converter.convert(x.1 as f64))) .collect(); - PartitionedCMGScoredStatsArrays { + Ok(PartitionedCMGScoredStatsArrays { retention_time_miliseconds: other.retention_time_miliseconds, average_mobility, summed_intensity: other.summed_intensity, @@ -362,6 +383,6 @@ impl PartitionedCMGScoredStatsA scores, expected_mzs, expected_mobility, - } + }) } } diff --git a/src/models/frames/expanded_frame.rs b/src/models/frames/expanded_frame.rs index dbe1aad..1786145 100644 --- a/src/models/frames/expanded_frame.rs +++ b/src/models/frames/expanded_frame.rs @@ -21,6 +21,7 @@ use crate::utils::tolerance_ranges::{ IncludedRange, }; use rayon::prelude::*; +use std::borrow::Cow; use std::collections::HashMap; use std::marker::PhantomData; use std::sync::Arc; @@ -324,11 +325,9 @@ pub fn par_expand_and_arrange_frames( #[derive(Debug, Clone, Copy, PartialEq)] pub struct CentroidingSettings { - ims_tol_pct: f64, - mz_tol_ppm: f64, - window_width: usize, - max_ms1_peaks: usize, - max_ms2_peaks: usize, + pub ims_tol_pct: f64, + pub mz_tol_ppm: f64, + pub window_width: usize, } impl Default for CentroidingSettings { @@ -337,8 +336,6 @@ impl Default for CentroidingSettings { ims_tol_pct: 1.5, mz_tol_ppm: 15.0, window_width: 3, - max_ms1_peaks: 100_000, - max_ms2_peaks: 20_000, } } } @@ -384,7 +381,7 @@ impl FrameProcessingConfig { } } -fn warn_and_skip_badframes( +pub fn warn_and_skip_badframes( frame_iter: impl ParallelIterator>, ) -> impl ParallelIterator { frame_iter.filter_map(|x| { @@ -433,7 +430,6 @@ pub fn par_read_and_expand_frames( settings.ims_tol_pct, settings.mz_tol_ppm, settings.window_width, - settings.max_ms2_peaks, &ims_converter.unwrap(), &mz_converter.unwrap(), ), @@ -448,7 +444,8 @@ pub fn par_read_and_expand_frames( .map(|x| ExpandedQuadSliceInfo::new(x)) .collect(); - println!("Slice info: {:?}", slice_infos); + let tbl = Table::new(slice_infos); + println!("Slice info: \n{}", tbl); info!("Processing MS1 frames"); let ms1_iter = frame_reader.parallel_filter(|x| x.ms_level == MSLevel::MS1); @@ -463,7 +460,6 @@ pub fn par_read_and_expand_frames( settings.ims_tol_pct, settings.mz_tol_ppm, settings.window_width, - settings.max_ms1_peaks, &ims_converter.unwrap(), &mz_converter.unwrap(), ), @@ -475,6 +471,11 @@ pub fn par_read_and_expand_frames( Ok(all_expanded_frames) } +use tabled::{ + Table, + Tabled, +}; + #[derive(Debug, Clone, Copy)] pub struct ExpandedQuadSliceInfo { pub quad_settings: Option, @@ -482,6 +483,57 @@ pub struct ExpandedQuadSliceInfo { pub peak_width_seconds: Option, } +impl Tabled for ExpandedQuadSliceInfo { + const LENGTH: usize = 7; + + // Required methods + fn fields(&self) -> Vec> { + match self.quad_settings { + Some(qs) => { + let qr = qs.ranges; + let qi = qs.index; + + let scan_ranges = format!("{:?}-{:?}", qr.scan_start, qr.scan_end); + let quad_ranges = format!("{:?}-{:?}", qr.isolation_low, qr.isolation_high); + vec![ + Cow::Owned(qi.major_index.to_string()), + Cow::Owned(qi.sub_index.to_string()), + Cow::Owned(quad_ranges), + Cow::Owned(scan_ranges), + Cow::Owned(qr.collision_energy.to_string()), + Cow::Owned(self.cycle_time_seconds.to_string()), + Cow::Owned( + self.peak_width_seconds + .as_ref() + .map(|x| x.to_string()) + .unwrap_or("None".to_string()), + ), + ] + } + None => vec![ + Cow::Borrowed("None"), + Cow::Borrowed("None"), + Cow::Owned("None".to_string()), + Cow::Owned("None".to_string()), + Cow::Owned("None".to_string()), + Cow::Owned("None".to_string()), + ], + } + } + + fn headers() -> Vec> { + vec![ + Cow::Borrowed("Major index"), + Cow::Borrowed("Minor index"), + Cow::Borrowed("Quad ranges"), + Cow::Borrowed("Scan ranges"), + Cow::Borrowed("CE"), + Cow::Borrowed("Cycle time"), + Cow::Borrowed("Peak width"), + ] + } +} + impl ExpandedQuadSliceInfo { #[instrument(skip(frameslices), ret, level = "debug")] pub fn new(frameslices: &[ExpandedFrameSlice]) -> Self { @@ -682,7 +734,6 @@ pub fn par_expand_and_centroid_frames( ims_tol_pct: f64, mz_tol_ppm: f64, window_width: usize, - max_peaks: usize, ims_converter: &Scan2ImConverter, mz_converter: &Tof2MzConverter, ) -> HashMap, Vec>> { @@ -700,7 +751,6 @@ pub fn par_expand_and_centroid_frames( window_width, ims_tol_pct, mz_tol_ppm, - max_peaks, ims_converter, mz_converter, ); @@ -716,11 +766,10 @@ pub fn par_expand_and_centroid_frames( out } -fn centroid_frameslice_window2( +fn centroid_frameslice_window( frameslices: &[ExpandedFrameSlice], ims_tol_pct: f64, mz_tol_ppm: f64, - max_peaks: usize, ims_converter: &Scan2ImConverter, mz_converter: &Tof2MzConverter, ) -> ExpandedFrameSlice { @@ -735,7 +784,6 @@ fn centroid_frameslice_window2( let ((tof_array, intensity_array), ims_array) = lazy_centroid_weighted_frame( &peak_refs, reference_index, - max_peaks, |tof| tof_tol_range(tof, mz_tol_ppm, mz_converter), |scan| scan_tol_range(scan, ims_tol_pct, ims_converter), ); @@ -762,7 +810,6 @@ pub fn par_lazy_centroid_frameslices( window_width: usize, ims_tol_pct: f64, mz_tol_ppm: f64, - max_peaks: usize, ims_converter: &Scan2ImConverter, mz_converter: &Tof2MzConverter, ) -> Vec> { @@ -781,14 +828,7 @@ pub fn par_lazy_centroid_frameslices( assert!(frameslices.len() > window_width); let local_lambda = |fss: &[ExpandedFrameSlice]| { - centroid_frameslice_window2( - fss, - ims_tol_pct, - mz_tol_ppm, - max_peaks, - ims_converter, - mz_converter, - ) + centroid_frameslice_window(fss, ims_tol_pct, mz_tol_ppm, ims_converter, mz_converter) }; frameslices diff --git a/src/traits/tolerance.rs b/src/traits/tolerance.rs index 63e03f3..27b7398 100644 --- a/src/traits/tolerance.rs +++ b/src/traits/tolerance.rs @@ -10,10 +10,11 @@ pub enum MzToleramce { Ppm((f64, f64)), } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub enum RtTolerance { Absolute((f32, f32)), Pct((f32, f32)), + #[default] None, } @@ -33,6 +34,7 @@ pub enum QuadTolerance { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DefaultTolerance { pub ms: MzToleramce, + #[serde(default)] pub rt: RtTolerance, pub mobility: MobilityTolerance, pub quad: QuadTolerance, diff --git a/src/utils/frame_processing.rs b/src/utils/frame_processing.rs index 5657bbb..3cd6c15 100644 --- a/src/utils/frame_processing.rs +++ b/src/utils/frame_processing.rs @@ -1,9 +1,5 @@ use crate::sort_vecs_by_first; -use tracing::{ - error, - info, - warn, -}; +use tracing::error; use super::tolerance_ranges::IncludedRange; @@ -61,11 +57,116 @@ impl<'a> PeakArrayRefs<'a> { } } -// TODO: Refactor this function +struct Peak { + center_tof: u32, + center_ims: usize, + // max_intensity: u32, + agg_intensity: u32, + // point_count: usize, +} +struct OrderItem { + intensity: u32, + weight: u32, + tof: u32, + ims: usize, +} + +fn find_gaussian_peaks( + items: &[OrderItem], + min_points: usize, + min_agg_intensity: u32, + tof_tol_range_fn: impl Fn(u32) -> IncludedRange, + ims_tol_range_fn: impl Fn(usize) -> IncludedRange, +) -> Vec { + let mut taken = vec![false; items.len()]; + let mut taken_queue = Vec::new(); + let mut peaks = Vec::new(); + let mut i = 0; + + while i < items.len() { + let current = &items[i]; + if taken[i] { + i += 1; + continue; + } + + // Fast pre-filtering: check if this point could be a peak center + // I could make a smarter version of this ... like to get the cumulative + // sum of intensities and then get the intensity of each window very quickly. + // if current.weight < min_apex_intensity { + // i += 1; + // continue; + // } + + // Get tolerance ranges for current point + let tof_range = tof_tol_range_fn(current.tof); + let ims_range = ims_tol_range_fn(current.ims); + + // Find all points within tolerance ranges + let st = tof_range.start(); + let ep = tof_range.end(); + let window_start = items[..i].partition_point(|item| item.tof < st); + let window_end = items[i..].partition_point(|item| item.tof < ep) + i; + + // Count points and check intensity distribution + let mut point_count = 0; + let mut is_peak = true; + let max_weight = current.weight; + let mut agg_intensity = 0; + + for j in window_start..window_end { + if taken[j] { + continue; + }; + let point = &items[j]; + + if ims_range.contains(point.ims) { + taken_queue.push(j); + point_count += 1; + agg_intensity += point.intensity; + + // Track maximum intensity + if point.weight > max_weight { + is_peak = false; // Current point isn't the peak if we found higher intensity + break; + } + } + } + + // If this is a valid peak, record it + if is_peak && agg_intensity >= min_agg_intensity && point_count >= min_points { + peaks.push(Peak { + center_tof: current.tof, + center_ims: current.ims, + agg_intensity, + }); + for j in taken_queue.iter() { + taken[*j] = true; + } + taken_queue.clear(); + } else { + // If this wasn't a peak, jump to the maximum intensity point we found + // This optimization helps us avoid checking every point in dense regions + // NOTE: This optimization might make sense but in our data might skip + // peaks that are very close in tof but not in mobility. + // + // i = if max_intensity_idx > i { + // max_intensity_idx + // } else { + // i + 1 + // }; + i += 1; + taken_queue.clear(); + } + } + + peaks +} + +// TODO: Instrument to add/return aggregation metrics/stats pub fn lazy_centroid_weighted_frame<'a>( peak_refs: &'a [PeakArrayRefs<'a>], reference_index: usize, - max_peaks: usize, tof_tol_range_fn: impl Fn(u32) -> IncludedRange, ims_tol_range_fn: impl Fn(usize) -> IncludedRange, ) -> CentroidedVecs { @@ -79,151 +180,38 @@ pub fn lazy_centroid_weighted_frame<'a>( error!("No peaks in reference array when centroiding"); return ((Vec::new(), Vec::new()), Vec::new()); } - let initial_tot_intensity = ref_arrays - .intensity_array - .iter() - .map(|x| *x as u64) - .sum::(); - - let mut touched = vec![false; tot_size]; - let mut global_num_touched = 0; - let mut num_added = 0; - - // We will be iterating in decreasing order of intensity - // Pre-calculate indices and intensities for sorting - struct OrderItem { - global_idx: usize, - major_idx: usize, - minor_idx: usize, - intensity: u32, - } let mut order: Vec = Vec::with_capacity(tot_size); - let mut offset = 0; for (major_idx, peak_ref) in peak_refs.iter().enumerate() { for (minor_idx, &intensity) in peak_ref.intensity_array.iter().enumerate() { + let tof = peak_ref.tof_array[minor_idx]; + let ims = peak_ref.ims_array[minor_idx]; + let weight = if major_idx == reference_index { + peak_ref.intensity_array[minor_idx] + } else { + 0 + }; order.push(OrderItem { - global_idx: offset + minor_idx, - major_idx, - minor_idx, - intensity, + tof, + intensity: weight, + ims, + weight: intensity, }); } - offset += peak_ref.len(); } // Sort by intensity - order.sort_unstable_by(|a, b| b.intensity.cmp(&a.intensity)); - assert!(order[0].intensity > order[tot_size - 1].intensity); - - let capacity = max_peaks.min(arr_len); - let mut agg_tof = Vec::with_capacity(capacity); - let mut agg_intensity = Vec::with_capacity(capacity); - let mut agg_ims = Vec::with_capacity(capacity); - - for item in order { - let major_idx = item.major_idx; - let minor_idx = item.minor_idx; - let this_intensity = item.intensity as u64; - - if touched[item.global_idx] { - continue; - } - - let tof = peak_refs[major_idx].tof_array[minor_idx]; - let ims = peak_refs[major_idx].ims_array[minor_idx]; - let tof_range = tof_tol_range_fn(tof); - let ims_range = ims_tol_range_fn(ims); - - let mut curr_intensity = 0u64; - let mut curr_weight = 0u64; - // let mut curr_agg_tof = 0u64; - // let mut curr_agg_ims = 0u64; - - // This is added to the index within the loop - // To get the touched status of the peaks. - let mut local_offset_touched = 0; - for (ii, local_peak_refs) in peak_refs.iter().enumerate() { - let ss_start = local_peak_refs - .tof_array - .partition_point(|x| *x < tof_range.start()); - let ss_end = local_peak_refs - .tof_array - .partition_point(|x| *x <= tof_range.end()); - for i in ss_start..ss_end { - let ti = local_offset_touched + i; - if !touched[ti] && ims_range.contains(local_peak_refs.ims_array[i]) { - // Peaks are always weighted but not always intense! - let local_intensity = local_peak_refs.intensity_array[i] as u64; - if ii == reference_index { - curr_intensity += local_intensity; - global_num_touched += 1; - } - // curr_agg_tof += local_peak_refs.tof_array[i] as u64 * local_intensity; - // curr_agg_ims += local_peak_refs.ims_array[i] as u64 * local_intensity; - curr_weight += local_intensity; - touched[ti] = true; - } - } - local_offset_touched += local_peak_refs.len(); - } - - // This means that at least 2 peaks need to be aggregated. - if curr_weight > this_intensity && curr_intensity >= this_intensity { - agg_intensity.push(u32::try_from(curr_intensity).expect("Expected to fit in u32")); - // let calc_tof = (curr_agg_tof / curr_weight) as u32; - // let calc_ims = (curr_agg_ims / curr_weight) as usize; - let calc_tof = tof; - let calc_ims = ims; - debug_assert!(tof_range.contains(calc_tof)); - debug_assert!(ims_range.contains(calc_ims)); - agg_tof.push(calc_tof); - agg_ims.push(calc_ims); - num_added += 1; - if num_added == max_peaks { - break; - } - } - - if global_num_touched == arr_len { - break; - } - } - - let out = sort_n_check(agg_intensity, agg_tof, agg_ims); + order.sort_unstable_by(|a, b| a.tof.cmp(&b.tof)); + assert!(order[tot_size - 1].tof > order[0].tof); - // TODO:Make everything below this a separate function and accumulate it. - let tot_final_intensity = out.0.1.iter().map(|x| *x as u64).sum::(); - let inten_ratio = tot_final_intensity as f64 / initial_tot_intensity as f64; - assert!(initial_tot_intensity >= tot_final_intensity); + let outpeaks = find_gaussian_peaks(&order, 1, 100, &tof_tol_range_fn, ims_tol_range_fn); - let output_len = out.0.0.len(); - let compression_ratio = output_len as f64 / arr_len as f64; - assert!(num_added == output_len); + let ((agg_intensity, agg_tof), agg_ims) = outpeaks + .into_iter() + .map(|x| ((x.agg_intensity, x.center_tof), x.center_ims)) + .unzip(); - // 80% of the intensity being preserved sounds like a good cutoff. - if output_len == max_peaks && inten_ratio < 0.80 { - info!( - "Frame trimmed to max peaks ({}), preserved intensity {}/{} intensity ratio: {} compression_ratio: {} if this is not acceptable consider increasing the parameter.", - max_peaks, tot_final_intensity, initial_tot_intensity, inten_ratio, compression_ratio, - ); - } - - if arr_len > 5000 && (output_len == arr_len) { - warn!("Output length is the same as input length, this is probably a bug"); - warn!("Intensity ratio {:?}", inten_ratio); - warn!("initial_tot_intensity: {:?}", initial_tot_intensity); - warn!("tot_final_intensity: {:?}", tot_final_intensity); - warn!( - "First tof {} -> Range {:?}", - out.0.0[0], - tof_tol_range_fn(out.0.0[0]) - ); - panic!(); - // warn!("agg_intensity: {:?}", out.0 .0); - } - - out + sort_n_check(agg_intensity, agg_tof, agg_ims) } #[cfg(test)] @@ -268,8 +256,7 @@ mod tests { let result = lazy_centroid_weighted_frame( &peak_refs, - 0, // reference_index - 10, // max_peaks + 0, // reference_index test_tof_tolerance, test_ims_tolerance, ); @@ -290,33 +277,35 @@ mod tests { // Check that the peaks were properly merged and weighted assert!(tof_array[0] >= 100 && tof_array[0] <= 101); assert_eq!(ims_array[0], 1); - assert!(intensity_array[0] == 3000); // Should be sum of intensities - assert!(intensity_array[1] == 1100); // Should be sum of intensities + assert_eq!(intensity_array[0], 3000); // Should be sum of intensities + assert_eq!(intensity_array[1], 1100); // Should be sum of intensities } - #[test] - fn test_max_peaks_limit() { - // Test that the function respects the max_peaks parameter - let peak_refs = vec![ - create_peak_refs(&[100, 200, 300], &[1, 2, 3], &[1000, 900, 800]), - create_peak_refs(&[101, 201, 301], &[1, 2, 3], &[950, 850, 750]), - ]; + // // NOTE: Current (experimental) implementation doe not have limit + // + // #[test] + // fn test_max_peaks_limit() { + // // Test that the function respects the max_peaks parameter + // let peak_refs = vec![ + // create_peak_refs(&[100, 200, 300], &[1, 2, 3], &[1000, 900, 800]), + // create_peak_refs(&[101, 201, 301], &[1, 2, 3], &[950, 850, 750]), + // ]; - let result = lazy_centroid_weighted_frame( - &peak_refs, - 0, - 2, // max_peaks set to 2 - test_tof_tolerance, - test_ims_tolerance, - ); + // let result = lazy_centroid_weighted_frame( + // &peak_refs, + // 0, + // 2, // max_peaks set to 2 + // test_tof_tolerance, + // test_ims_tolerance, + // ); - let ((tof_array, _), _) = result; - assert_eq!( - tof_array.len(), - 2, - "Should only return max_peaks number of peaks" - ); - } + // let ((tof_array, _), _) = result; + // assert_eq!( + // tof_array.len(), + // 2, + // "Should only return max_peaks number of peaks" + // ); + // } #[test] fn test_empty_input() { @@ -327,7 +316,7 @@ mod tests { ]; let result = - lazy_centroid_weighted_frame(&peak_refs, 0, 10, test_tof_tolerance, test_ims_tolerance); + lazy_centroid_weighted_frame(&peak_refs, 0, test_tof_tolerance, test_ims_tolerance); let ((tof_array, intensity_array), ims_array) = result; assert_eq!(tof_array.len(), 0); @@ -352,7 +341,7 @@ mod tests { ]; let result = - lazy_centroid_weighted_frame(&peak_refs, 0, 10, test_tof_tolerance, test_ims_tolerance); + lazy_centroid_weighted_frame(&peak_refs, 0, test_tof_tolerance, test_ims_tolerance); let ((tof_array, _), ims_array) = result; @@ -373,7 +362,6 @@ mod tests { lazy_centroid_weighted_frame( &peak_refs, 2, // Invalid index - 10, test_tof_tolerance, test_ims_tolerance, );