Repository navigation
Conversation
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (7)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (2)
181-199: Remove unsynchronized OpenMP parallel for - race condition on shared map.The
#pragma omp parallel forat line 181 causes multiple threads to write tooriginal_precursor_map(astd::map) without synchronization, leading to undefined behavior. This was flagged in a previous review and confirmed by @KyowonJeong to be removed, but the pragma is still present.-#pragma omp parallel for default(none), shared(map, ms_level, original_precursor_map) for (int i = 0; i < (int) map.size(); i++)
144-147: Fix out-of-bounds access in intensity threshold calculation.When
it.size() == count, the conditionit.size() < countis false, causing access toit[count]which is out-of-bounds (valid indices are 0 tocount-1). This leads to undefined behavior.- Size count = it.getType(false) == SpectrumSettings::CENTROID ? max_peak_count_for_centroid_ : max_peak_count_for_profile_; - it.sortByIntensity(true); - double threshold = it.size() < count ? 0 : it[count].getIntensity(); + Size count = it.getType(false) == SpectrumSettings::CENTROID ? max_peak_count_for_centroid_ : max_peak_count_for_profile_; + it.sortByIntensity(true); + double threshold = 0; + if (it.size() > count && count > 0) + { + threshold = it[count - 1].getIntensity(); + }src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (5)
24-61: Minor docs/UX fixes in parameter descriptions.
- Line 39: Typo in the description string, “all MS levelss” → “all MS levels”.
- Lines 55–57: The example
-min_cos 0.3 0.6contradictssetMinFloat("min_cos", 0.5)— 0.3 would be rejected. Either relax the minimum or update the example to use values ≥ 0.5.These are small but user‑visible; worth fixing while you’re here.
83-109: Guard missing precursors and correctly usetarget_precursor_mz_to avoid crashes and wrong mass.Current logic:
- If the spectrum has no precursors but
target_precursor_mz_ > 0, theif (spec.getPrecursors().empty() && target_precursor_mz_ == 0)guard does not trigger, andspec.getPrecursors()[0]dereferences an empty vector (UB/crash).target_precursor_mz_is never actually used in the mass calculation – you always useprecursor.getMZ(), even when a target m/z override was configured.- If a user sets
precursor_mzwithout settingprecursor_charge,target_precursor_charge_stays 0 and the computed mass collapses to 0, which will generate a degenerate precursor peak group.Consider restructuring as follows:
- Always derive a
Precursorinstance like this:
- If
!spec.getPrecursors().empty(), copyspec.getPrecursors()[0].- Else if
target_precursor_mz_ > 0, synthesize aPrecursorwithsetMZ(target_precursor_mz_).- Else log and return.
- Only proceed if
target_precursor_charge_ != 0; otherwise respect the docs and treatprecursor_mzalone as “ignored”.- Compute the mass from whichever m/z is actually in use and override the precursor’s m/z when an explicit target was given.
For example:
- const auto& spec = deconvolved_spectrum_.getOriginalSpectrum(); - if (spec.getPrecursors().empty() && target_precursor_mz_ == 0) - { - OPENMS_LOG_INFO << "Attempted to set target precursor charge but failed - no precursor is found in MS2 spectra. Specify target precursor m/z " - "with -target_precursor_mz option" - << std::endl; - return; - } - - auto precursor = spec.getPrecursors()[0]; - double target_precursor_mass - = (precursor.getMZ() - FLASHHelperClasses::getChargeMass(target_precursor_charge_ > 0)) * std::abs(target_precursor_charge_); + const auto& spec = deconvolved_spectrum_.getOriginalSpectrum(); + if (target_precursor_charge_ == 0) + { + // `precursor_mz` is documented as only meaningful together with a charge; + // avoid creating a degenerate precursor with charge 0. + return; + } + + Precursor precursor; + if (!spec.getPrecursors().empty()) + { + precursor = spec.getPrecursors()[0]; + } + else if (target_precursor_mz_ > 0) + { + precursor.setMZ(target_precursor_mz_); + } + else + { + OPENMS_LOG_INFO << "Attempted to set target precursor charge but failed - no precursor is found in MS2 spectra and no precursor m/z was " + "specified via precursor_mz." + << std::endl; + return; + } + + const double precursor_mz = + target_precursor_mz_ > 0 ? target_precursor_mz_ : precursor.getMZ(); + const int abs_charge = std::abs(target_precursor_charge_); + const double target_precursor_mass = + (precursor_mz - FLASHHelperClasses::getChargeMass(target_precursor_charge_ > 0)) * abs_charge; + precursor.setMZ(precursor_mz); + precursor.setCharge(target_precursor_charge_); - precursor.setCharge(target_precursor_charge_); - PeakGroup precursorPeakGroup(1, std::abs(target_precursor_charge_), target_precursor_charge_ > 0); + PeakGroup precursorPeakGroup(1, abs_charge, target_precursor_charge_ > 0);Then keep the rest (SNR/Q‑score set to 1.0, assignment into
deconvolved_spectrum_) as is.This prevents the crash, makes
precursor_mzbehave as documented, and avoids constructing zero‑charge precursor groups.
692-744: Loop skips the last peak inlog_mz_peaks_when scanning charge candidates.The inner loop:
while (cpi < log_mz_peak_size - 1) // scan through peaks from cpi { ... cpi++; }never inspects the final element at index
log_mz_peak_size - 1. Any signal that only appears in the last peak can never be selected asmax_peak_index, so it will be silently ignored when buildingPeakGroups for that mass/charge.You can safely iterate through all peaks by relaxing the bound:
- while (cpi < log_mz_peak_size - 1) // scan through peaks from cpi + while (cpi < log_mz_peak_size) // scan through peaks from cpiThe surrounding logic (
max_peak_index < log_mz_peak_size - 1checks, neighbor checks, and the monotonically increasingcpi) still prevents out‑of‑bounds access and infinite loops.
1147-1177: Rebuiltexcluded_masses_for_decoy_runs_is unsorted before reuse withupper_bound.In the late
signal_decoyblock ofscoreAndFilterPeakGroups_you rebuildexcluded_masses_for_decoy_runs_:excluded_masses_for_decoy_runs_.clear(); for (const auto& pg : *target_dspec_for_decoy_calculation_) { for (int j = -allowed_iso_error_; j <= allowed_iso_error_; j++) { excluded_masses_for_decoy_runs_.push_back(pg.getMonoMass() + j * iso_da_distance_); } } ... if (isPeakGroupInExcludedMassForDecoyRuns_(pg, tol)) continue;But unlike the earlier initialization in
performSpectrumDeconvolution, there is nostd::sorthere. SinceisPeakGroupInExcludedMassForDecoyRuns_usesstd::upper_bound, this violates its precondition and can lead to subtle mis‑filtering of decoys.You can fix this by mirroring the earlier sort+unique:
for (int j = -allowed_iso_error_; j <= allowed_iso_error_; j++) { excluded_masses_for_decoy_runs_.push_back(pg.getMonoMass() + j * iso_da_distance_); } } + + std::sort(excluded_masses_for_decoy_runs_.begin(), excluded_masses_for_decoy_runs_.end()); + excluded_masses_for_decoy_runs_.erase( + std::unique(excluded_masses_for_decoy_runs_.begin(), excluded_masses_for_decoy_runs_.end()), + excluded_masses_for_decoy_runs_.end());This keeps
isPeakGroupInExcludedMassForDecoyRuns_well‑defined in this second pass too.
1422-1476:setTargetMasses+removeExcludedMasses_/ targeting: ensure vectors are sorted beforeupper_bound.
setTargetMassesbuildsexcluded_masses_/target_mono_masses_by appending isotope‑offset values:for (const auto& m : masses) { ... for (int j = start; j <= end + 1; j++) { if (excluded) excluded_masses_.push_back(m + iso_da_distance_ * j); else target_mono_masses_.push_back(m + iso_da_distance_ * j); } }Later you rely on both being sorted when calling
std::upper_bound:
- In
removeExcludedMasses_onexcluded_masses.- In
scoreAndFilterPeakGroups_when matching againsttarget_mono_masses_.Without a
sort, the binary searches can silently mis‑match or skip masses.Please sort (and optionally deduplicate) the populated vector at the end of
setTargetMasses:for (const auto& m : masses) { @@ } } + } + + if (excluded) + { + std::sort(excluded_masses_.begin(), excluded_masses_.end()); + excluded_masses_.erase(std::unique(excluded_masses_.begin(), excluded_masses_.end()), + excluded_masses_.end()); + } + else + { + std::sort(target_mono_masses_.begin(), target_mono_masses_.end()); + target_mono_masses_.erase(std::unique(target_mono_masses_.begin(), target_mono_masses_.end()), + target_mono_masses_.end()); }This keeps existing APIs and ensures the
upper_bound‑based lookups are well‑defined.
🧹 Nitpick comments (15)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (1)
55-78: Add Doxygen documentation for new public methods.Several new public methods lack Doxygen documentation:
getTolerances(),getAveragine(),getDecoyAveragine(),getNoiseDecoyWeight(), andgetScanNumber(). As per coding guidelines for headers insrc/openms/include/OpenMS/**/*.h, public methods should have Doxygen comments.Example for
getTolerances():+ /** + * @brief Get the mass tolerances per MS level + * @return vector of tolerance values in ppm for each MS level + */ std::vector<double> getTolerances() const;src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (7)
26-28: Consider moving inline constants into the anonymous namespace or class.These
inline constvariables at namespace scope work in C++17 but could potentially pollute the namespace if this header is included indirectly. Consider moving them into an anonymous namespace or as private static members.+namespace { inline const Size max_peak_count_for_centroid_ = 3e4; inline const Size max_peak_count_for_profile_ = 1e5; +}
286-291: Simplify nested ternary for readability.The nested ternary expression for
scan_numberis difficult to read and maintain.- int scan_number = merge_spec_ == 0? getScanNumber(map, index) : - (rt_scan_map.find(map[index].getRT()) == rt_scan_map.end()? getScanNumber(map, index) : - rt_scan_map[map[index].getRT()]);//getScanNumber(map, index); + int scan_number; + if (merge_spec_ == 0 || rt_scan_map.find(map[index].getRT()) == rt_scan_map.end()) + { + scan_number = getScanNumber(map, index); + } + else + { + scan_number = rt_scan_map[map[index].getRT()]; + }
403-407: Address TODO comment for automatic threshold finding.The TODO at line 405 indicates the Qscore threshold (0.9) should be automatically determined. This could affect tolerance estimation accuracy.
Would you like me to help design an automatic threshold determination approach, or should this be tracked as a separate issue?
433-437: Consider documenting the magic number 2.17.The multiplier
2.17 * 2(≈ 4.34 sigma) covers approximately 97% of the Gaussian distribution. Adding a brief comment or named constant would improve clarity.+ // 2.17 sigma covers ~97% of one-sided Gaussian; doubled for both sides tols_[ms_level - 1] = round(fit.sigma * 2.17 * 2); // 97% area under curve in gaussian
489-492: Consider documenting the reserve multiplier heuristic.The
map.size() * 4reservation is a reasonable heuristic but could benefit from a brief comment explaining the rationale (e.g., multiple MS levels, potential spectrum splitting).setLogType(CMD); + // Reserve space for multiple deconvolved spectra per input spectrum (accounts for multiple MS levels) deconvolved_spectra.reserve(map.size() * 4);
566-568: Clarify the isolation window offset interpretation logic.The condition
loffset > 100.0to distinguish between absolute m/z values and relative offsets is unconventional and could be confusing. Consider adding a comment explaining this convention.+ // If offset > 100, treat as absolute m/z; otherwise as relative offset start_mz = loffset > 100.0 ? loffset : -loffset + precursor.getMZ(); end_mz = uoffset > 100.0 ? uoffset : uoffset + precursor.getMZ();
641-661: Consider using references/pointers to avoid copying DeconvolvedSpectrum objects.The
scan_fullscanmap stores copies ofDeconvolvedSpectrumobjects, and line 660 copies again when retrieving. For large datasets with many peak groups, this could cause significant memory overhead.- std::map<int, DeconvolvedSpectrum> scan_fullscan; + std::map<int, const DeconvolvedSpectrum*> scan_fullscan; for (auto& dspec : deconvolved_spectra) { if ((int)dspec.getOriginalSpectrum().getMSLevel() != ms_level - 1) continue; int scan = dspec.getScanNumber(); - scan_fullscan[scan] = dspec; + scan_fullscan[scan] = &dspec; } for (auto& dspec : deconvolved_spectra) { if ((int)dspec.getOriginalSpectrum().getMSLevel() != ms_level) continue; if (dspec.getPrecursorPeakGroup().empty()) continue; auto precursor_pg = dspec.getPrecursorPeakGroup(); int pscan = precursor_pg.getScanNumber(); if (scan_fullscan.find(pscan) == scan_fullscan.end()) continue; - auto fullscan = scan_fullscan[pscan]; + const auto& fullscan = *scan_fullscan[pscan];src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (7)
339-563: Core mass‑bin candidate search is extremely complex; consider targeted decomposition for maintainability.
updateCandidateMassBins_is doing the bulk of the FLASHDeconv work (right‑to‑left mz bins, charge scanning, harmonic/isotope checks, multiple state vectors). The structure is hard to follow and static analysis already flags it as “Very Complex”.While the algorithmic shape is fine, consider splitting out self‑contained pieces into small
statichelpers for readability and testability, e.g.:
- Harmonic‑artifact suppression per
(mass_bin_index, charge)(lines ~400–472, 500–530).- Low‑charge isotope‑presence check (lines ~417–480).
- High‑charge harmonic check and SNR update (lines ~482–548).
This would not change behavior but would make it much easier to reason about future bugfixes.
850-857: Minor: typo in argument name and clarify ownership/lifetime oftarget_dspec_for_decoy_calcualtion.
The argument
target_dspec_for_decoy_calcualtionis misspelled; consider fixing totarget_dspec_for_decoy_calculationfor readability.You store a raw pointer to the passed reference:
target_dspec_for_decoy_calculation_ = &target_dspec_for_decoy_calcualtion;which assumes the referenced
DeconvolvedSpectrumoutlives thisSpectralDeconvolutioninstance and all decoy processing. That’s probably true in the current callers, but it’s subtle.If you expect long‑lived reuse or asynchronous usage, consider either documenting the required lifetime clearly in the header or switching to a
const DeconvolvedSpectrum*parameter everywhere (and passing addresses explicitly) to make ownership and lifetime assumptions more obvious.
975-1079: OpenMP region: per‑group work looks thread‑safe, but shared state assumptions should be explicit.The first
#pragma omp parallel for:
- Mutates each
PeakGroupviaauto& peak_group = deconvolved_spectrum_[i];with distinctiin each iteration — no intra‑loop data race as long asdeconvolved_spectrum_isn’t used concurrently from outside.- Reads shared, effectively read‑only members (
avg_,min_isotope_cosine_,target_mono_masses_,excluded_masses_for_decoy_runs_, etc.).- Uses a shared
selectedbitset for output with anomp criticalaroundselected[i] = true;, which is safe though a bit heavy.Assuming
SpectralDeconvolution::scoreAndFilterPeakGroups_is not called concurrently on the same object from multiple threads, this is fine. If concurrent use might happen, you’ll need a higher‑level guard around the whole call to avoid data races on members likedeconvolved_spectrum_,excluded_masses_for_decoy_runs_, andtarget_mono_masses_.
1198-1269:getIsotopeCosineAndIsoOffset: edge case when no valid offsets are added tooffset_cos.If
offset_cosstays empty (e.g., all candidates excluded bywindow_width/excluded_masses), you return:if (offset_cos.empty()) return max_cos; ... max_cos = std::max(max_cos, .0f); offset -= iso_int_shift; return max_cos;Since
max_cosis initialized to-1000andoffsetto0, this yields:
- cosine = 0
- offset =
-iso_int_shifteven though you never evaluated any candidate. Downstream this likely behaves like “no good match”, but the offset value is arguably misleading and may affect any debug/QA that inspects it.
At minimum, consider leaving
offsetat 0 in this case:- if (offset_cos.empty()) return max_cos; + if (offset_cos.empty()) + { + offset = 0; + return .0f; + }to make the “no usable offset” case explicit.
1298-1364:removeChargeErrorPeakGroups_: overlapping logic seems sound; consider documenting the heuristic.The overlap detection logic:
- Maps each raw peak m/z to the set of peak‑groups using it.
- For shared peaks, marks a group as overlap if there exists another group with a different representative charge and higher charge‑specific SNR on that peak.
- Later removes non‑targeted groups whose summed
overlap_intensityexceeds half their total intensity (mul_factor = 0.5).This is a reasonable heuristic, but it’s subtle. Given how critical this is for charge‑error suppression, a brief high‑level comment in the header (what “charge error” means and how this filter behaves) would help future maintainers reason about possible regressions without re‑deriving the logic from scratch.
No functional issues spotted in the current implementation.
1366-1420:removeOverlappingPeakGroups_: complex but appears correct; static analysis warnings can be addressed with light refactors.This function:
- Walks sorted
dspecin mass order.- Maintains a moving window of peak groups within
mass * tol.- Within each window, keeps the highest‑SNR non‑targeted group plus all targeted groups of the requested
target_decoy_type.The control flow is quite branchy but logically sound. To quiet CodeFactor and ease review, you could:
- Extract the window‑finalization block (
if (mass - start_mass > mass * tol) { ... }) into a small helper.- Inline the “push targeted” logic into a helper that takes
dspec[i]andtarget_decoy_type.Behavior should remain unchanged; this is purely a readability refactor.
339-671: Multiple “complex method” warnings: consider small, localized extractions rather than large rewrites.Static analysis flags the following methods as complex:
updateCandidateMassBins_(very complex)filterMassBins_getCandidatePeakGroups_generatePeakGroupsFromSpectrum_scoreAndFilterPeakGroups_removeOverlappingPeakGroups_Given that these encode the core FLASHDeconv math, large rewrites are risky. However, there are some safe wins:
- Extract inner blocks with clear responsibilities (e.g., harmonic suppression, low‑charge isotope checks, FDR/decoy filtering) into private helper functions in this
.cpp.- Keep loop structure and data layout intact to avoid performance regressions, but move condition‑heavy chunks into helpers for readability and unit‑testing in isolation.
- Add short comments at the top of each function describing its role in the overall pipeline (several already have brief comments; extending them slightly would help).
This should address CodeFactor’s complaints and make future changes safer without altering performance‑critical logic.
Also applies to: 879-969, 994-1216, 1363-1430
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h(3 hunks)src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp(1 hunks)src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cppsrc/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cppsrc/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h
🧠 Learnings (9)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cppsrc/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cppsrc/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-09-16T10:59:20.544Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8208
File: src/openms/source/FORMAT/MzParquetFile.cpp:127-146
Timestamp: 2025-09-16T10:59:20.544Z
Learning: Throwing exceptions from within OpenMP critical sections (#pragma omp critical) can cause undefined behavior and deadlocks because the critical section may not be properly released during exception unwinding. Always avoid throwing exceptions from within OpenMP synchronization constructs.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/**/*.h : Add Doxygen comments for new public methods and classes in pyOpenMS bindings
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-29T19:09:45.997Z
Learnt from: jcharkow
Repo: OpenMS/OpenMS PR: 8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h
🧬 Code graph analysis (2)
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (3)
src/openms/source/ANALYSIS/TOPDOWN/DeconvolvedSpectrum.cpp (12)
precursor(136-136)i(254-257)i(254-254)i(259-262)i(259-259)sort(331-334)sort(331-331)DeconvolvedSpectrum(13-15)a(17-20)a(17-17)a(22-25)a(22-22)src/openms/source/ANALYSIS/TOPDOWN/FLASHHelperClasses.cpp (9)
getChargeMass(236-239)getChargeMass(236-236)LogMzPeak(194-197)a(212-219)a(212-212)a(221-228)a(221-221)a(230-233)a(230-230)src/openms/source/ANALYSIS/TOPDOWN/PeakGroup.cpp (10)
i(1125-1128)i(1125-1125)sort(1165-1168)sort(1165-1165)a(22-26)a(22-22)a(28-32)a(28-28)a(34-37)a(34-34)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (1)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h (1)
FLASHHelperClasses(35-245)
🪛 GitHub Check: CodeFactor
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
[notice] 258-353: src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp#L258-L353
Complex Method
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
[warning] 357-586: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L357-L586
Very Complex Method
[notice] 122-228: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L122-L228
Complex Method
[notice] 587-680: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L587-L680
Complex Method
[notice] 879-969: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L879-L969
Complex Method
[notice] 1217-1332: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L1217-L1332
Complex Method
[notice] 692-863: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L692-L863
Complex Method
[notice] 994-1216: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L994-L1216
Complex Method
[notice] 1363-1430: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L1363-L1430
Complex Method
🔇 Additional comments (3)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (1)
34-53: LGTM!The inheritance from
DefaultParamHandlerandProgressLoggerfollows established OpenMS patterns. The move constructor withnoexceptand destructor override are correctly declared.src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (2)
508-531: LGTM!The scan number bounds finding logic correctly handles the precursor window search for both MS2 and higher MS levels.
323-342: LGTM!The OpenMP parallel sections for decoy deconvolution are correctly structured. Each section operates on separate
SpectralDeconvolutioninstances (sd_noise_decoy_andsd_signal_decoy_), anddeconvolved_spectrumis only read (not written) within the parallel sections. Results are merged after the implicit barrier.
Extract two helper methods to reduce cyclomatic complexity from 21: - findPrecursorScanNumber_: find precursor scan number when peak group not found - appendDecoyPeakGroups_: handle decoy processing and appending with OpenMP Simplified conditionals and improved code organization without changing algorithm behavior or performance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (1)
11-21: Ensure header is self‑contained: add missing includes forProgressLoggerandstd::map.
FLASHDeconvAlgorithmnow publicly inherits fromProgressLogger, but this header neither includes nor forward‑declares it. The class also usesstd::mapin member declarations without including<map>. This can break compilation when the header is used in isolation and unnecessarily relies on transitive includes.Consider adding:
#include <OpenMS/ANALYSIS/TOPDOWN/DeconvolvedSpectrum.h> #include <OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h> #include <OpenMS/ANALYSIS/TOPDOWN/PeakGroup.h> #include <OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h> #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h> #include <OpenMS/DATASTRUCTURES/Matrix.h> +#include <OpenMS/CONCEPT/ProgressLogger.h> #include <OpenMS/KERNEL/MSExperiment.h> #include <OpenMS/KERNEL/MSSpectrum.h> +#include <map>
♻️ Duplicate comments (4)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (3)
144-147: Critical: Out-of-bounds access persists.The previous review identified this issue, but the fix was not applied. When
it.size() == count, accessingit[count]reads past the end of the vector (0-based indexing), causing undefined behavior.Apply this diff to fix the out-of-bounds access:
- Size count = it.getType(false) == SpectrumSettings::CENTROID ? max_peak_count_for_centroid_ : max_peak_count_for_profile_; - it.sortByIntensity(true); - double threshold = it.size() < count ? 0 : it[count].getIntensity(); + Size count = it.getType(false) == SpectrumSettings::CENTROID ? max_peak_count_for_centroid_ : max_peak_count_for_profile_; + it.sortByIntensity(true); + double threshold = 0; + if (it.size() >= count && count > 0) + { + threshold = it[count - 1].getIntensity(); + }
181-199: Critical: Race condition on sharedstd::mappersists.The previous review identified this issue, and @KyowonJeong confirmed the fix: "Let's remove the line:
#pragma omp parallel for...". However, the pragma is still present. Multiple threads concurrently writing tooriginal_precursor_mapcauses undefined behavior.Apply this diff to remove the unsafe parallelization:
-#pragma omp parallel for default(none), shared(map, ms_level, original_precursor_map) for (int i = 0; i < (int) map.size(); i++)
688-688: Remove unused variabledecoy_mass_tracer.This variable was flagged in a previous review and is still present. It is declared but never used; the code correctly uses
mass_tracerfor both target and decoy feature finding.Apply this diff:
auto mass_tracer = MassFeatureTrace(); - auto decoy_mass_tracer = MassFeatureTrace();src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (1)
57-63: Fix typos and clarify parameter naming inrunDoxygen.The comment still contains typos (“wll”, “strored”) and the parameter name
deconvolved_featureis singular although the type is a vector. This is confusing in the public API docs.Suggested edit:
- /** - * @brief Run FLASHDeconv algorithm for @p map and store @p deconvolved_spectra and @p deconvolved_feature - * @param map the dataset - * @param deconvolved_spectra the deconvolved spectra will be stored in here - * @param deconvolved_feature the deconvolved features wll be strored in here - */ - void run(MSExperiment& map, std::vector<DeconvolvedSpectrum>& deconvolved_spectra, std::vector<FLASHHelperClasses::MassFeature>& deconvolved_feature); + /** + * @brief Run FLASHDeconv algorithm for @p map and store results in @p deconvolved_spectra and @p deconvolved_features. + * @param map The input dataset (may be modified, e.g. by spectrum merging). + * @param deconvolved_spectra Deconvolved spectra will be stored here. + * @param deconvolved_features Deconvolved mass features will be stored here. + */ + void run(MSExperiment& map, + std::vector<DeconvolvedSpectrum>& deconvolved_spectra, + std::vector<FLASHHelperClasses::MassFeature>& deconvolved_features);(Adjust the implementation/callers accordingly if you rename the parameter.)
🧹 Nitpick comments (7)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (4)
410-411: Address or track the TODO comment.The hardcoded Q-score threshold of 0.9 with a TODO note suggests this should be dynamically determined. Consider either implementing automatic threshold detection or creating a tracking issue for this enhancement.
Would you like me to open an issue to track this TODO for automatic Q-score threshold determination?
571-572: Consider clarifying the offset interpretation logic.The condition
loffset > 100.0triggering direct use vs. relative offset calculation is non-obvious. If this handles a legacy format or vendor-specific quirk, a brief inline comment would help future maintainers understand this special-case handling.+ // If offset > 100, treat as absolute m/z value; otherwise, treat as relative offset from precursor m/z start_mz = loffset > 100.0 ? loffset : -loffset + precursor.getMZ(); end_mz = uoffset > 100.0 ? uoffset : uoffset + precursor.getMZ();
665-665: Avoid unnecessary copy ofDeconvolvedSpectrum.
fullscanis only read from, so use aconstreference to avoid copying the potentially largeDeconvolvedSpectrumobject (which contains vectors ofPeakGroup).- auto fullscan = scan_fullscan[pscan]; + const auto& fullscan = scan_fullscan[pscan];
203-203: Address or track the hardcoded RT tolerance TODO.The 30-second RT tolerance for precursor-based merging is hardcoded with a TODO suggesting it should be user-configurable. Consider adding this as a parameter in the constructor defaults.
Would you like me to suggest the parameter addition, or should this be tracked as a separate issue?
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (3)
65-77: Consider marking accessor methods asconstfor a clearer API.
getAveragine(),getDecoyAveragine()andgetScanNumber(...)are logically read‑only, andgetNoiseDecoyWeight()already is aconstmethod. For a cleaner and more predictable interface, it would be good to make all these accessorsconstmembers /noexceptwhere applicable, if their implementations don’t mutate state.For example:
- const FLASHHelperClasses::PrecalculatedAveragine& getAveragine(); + const FLASHHelperClasses::PrecalculatedAveragine& getAveragine() const; - const FLASHHelperClasses::PrecalculatedAveragine& getDecoyAveragine(); + const FLASHHelperClasses::PrecalculatedAveragine& getDecoyAveragine() const;Update the corresponding .cpp definitions accordingly.
83-125: Prefer OpenMS integer types (UInt/Size) over bareuintand ensure comments are typo‑free.In the private section you consistently use
UIntfor members (max_ms_level_, etc.), but some helper signatures still useuint:
mergeSpectra_(MSExperiment& map, uint ms_level);findPrecursorScanNumber_(..., uint ms_level) const;findPrecursorPeakGroupsForMSnSpectra_(..., uint ms_level);findScanNumberBounds_(..., uint ms_level) const;collectSurveyScans_(..., uint ms_level) const;findBestPrecursorPeakGroup_(..., uint ms_level) const;
uintis not a standard C++ type and may hurt portability. UsingUIntorSize(as elsewhere in this class) would align with OpenMS conventions.Additionally, there are a couple of small typos in comments/names that are cheap to fix:
- Line 119: “qvalue calcualtion” → “q‑value calculation”.
- Line 148: method name
findPrecursorPeakGroupsFormIdaLog_should likely befindPrecursorPeakGroupsFromIdaLog_(rename in header, implementation, and call sites).Example for the type change:
- void mergeSpectra_(MSExperiment& map, uint ms_level); + void mergeSpectra_(MSExperiment& map, UInt ms_level);(and similarly for the other helpers).
165-172: Validate edge‑case handling in helper utilities (determineTolerance_,getHistogram_,filterLowPeaks_).The signatures for
determineTolerance_,getHistogram_, andfilterLowPeaks_look reasonable, but please ensure in the implementation that edge cases are handled gracefully (empty data, zero/negativebin_size, invalidmin_range/max_range, etc.), as these utilities may be reused by other parts of the TOPDOWN pipeline.No header change required; just a reminder to double‑check the corresponding .cpp logic and tests.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h(3 hunks)src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.hsrc/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h
🧠 Learnings (7)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.hsrc/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-09-16T10:59:20.544Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8208
File: src/openms/source/FORMAT/MzParquetFile.cpp:127-146
Timestamp: 2025-09-16T10:59:20.544Z
Learning: Throwing exceptions from within OpenMP critical sections (#pragma omp critical) can cause undefined behavior and deadlocks because the critical section may not be properly released during exception unwinding. Always avoid throwing exceptions from within OpenMP synchronization constructs.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
🧬 Code graph analysis (1)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (3)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h (1)
FLASHHelperClasses(35-245)src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (9)
FLASHDeconvAlgorithm(29-94)run(458-511)run(458-460)getAveragine(356-359)getAveragine(356-356)getDecoyAveragine(361-365)getDecoyAveragine(361-361)getScanNumber(234-250)getScanNumber(234-234)src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (2)
getAveragine(249-252)getAveragine(249-249)
🪛 GitHub Check: CodeFactor
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
[notice] 258-353: src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp#L258-L353
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (macos-15-intel, xcode, 16.0.0)
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-macos
- GitHub Check: build-macos-arm
- GitHub Check: build-lnx
- GitHub Check: build-lnx-arm
- GitHub Check: cppcheck-test
🔇 Additional comments (6)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (5)
26-27: LGTM!The global inline constants for peak count thresholds are appropriately defined and provide sensible defaults for centroid and profile spectra filtering.
29-94: LGTM!The constructor properly initializes the parameter handler with well-documented defaults. The parameter organization with subsections (
SD:,ft:,iq:) provides clean separation of concerns.
266-294: LGTM!The parallel sections correctly operate on independent
SpectralDeconvolutioninstances (sd_noise_decoy_andsd_signal_decoy_). The implicit barrier ensures results are fully populated before being accessed. This is a proper use of OpenMP sections.
296-353: LGTM!The method orchestrates spectral deconvolution across MS levels in a logical flow: precursor finding → optional merging → deconvolution → decoy appending. The complexity is inherent to the workflow rather than indicating poor design.
513-536: LGTM!The asymmetric search bounds (backward search uses
precursor_MS1_window_for all MSn, forward search only for MS2) appears intentional for the precursor identification workflow. The implementation is correct.src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (1)
34-53: Multiple inheritance fromProgressLoggerlooks fine, but ensure virtual destructor semantics are intentional.The switch to
class FLASHDeconvAlgorithm : public DefaultParamHandler, public ProgressLoggerwith~FLASHDeconvAlgorithm() override = default;is consistent and safe, assuming both bases already have virtual destructors (which is typical in OpenMS). No change requested here; just confirming this design choice is deliberate.
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (4)
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py (4)
157-169: Use precise assertion methods for better failure messages.Several assertions use generic
assertTrue/assertFalseinstead of specific comparison methods:
- Line 158:
assertTrue(peak2 > peak1)→assertGreater(peak2, peak1)- Line 169:
assertTrue(peak1 == peak2)→assertEqual(peak1, peak2)self.assertLess(peak1, peak2) - self.assertTrue(peak2 > peak1) + self.assertGreater(peak2, peak1) def test_equality_operator(self): """Test equality operator.""" p = pyopenms.Peak1D() p.setMZ(1000.0) p.setIntensity(100.0) peak1 = pyopenms.LogMzPeak(p, True) peak2 = pyopenms.LogMzPeak(peak1) - self.assertTrue(peak1 == peak2) + self.assertEqual(peak1, peak2)
381-397: Use precise assertion methods for comparison and equality tests.Multiple imprecise assertions flagged by static analysis:
- Line 381:
assertTrue(mf1 < mf2)→assertLess(mf1, mf2)- Line 382:
assertFalse(mf2 < mf1)→assertGreaterEqual(mf2, mf1)- Line 383:
assertTrue(mf2 > mf1)→assertGreater(mf2, mf1)- Line 384:
assertFalse(mf1 > mf2)→assertLessEqual(mf1, mf2)- Line 394:
assertTrue(mf1 == mf2)→assertEqual(mf1, mf2)- Line 397:
assertFalse(mf1 == mf2)→assertNotEqual(mf1, mf2)- self.assertTrue(mf1 < mf2) - self.assertFalse(mf2 < mf1) - self.assertTrue(mf2 > mf1) - self.assertFalse(mf1 > mf2) + self.assertLess(mf1, mf2) + self.assertGreaterEqual(mf2, mf1) + self.assertGreater(mf2, mf1) + self.assertLessEqual(mf1, mf2)- self.assertTrue(mf1 == mf2) + self.assertEqual(mf1, mf2) mf2.avg_mass = 2000.0 - self.assertFalse(mf1 == mf2) + self.assertNotEqual(mf1, mf2)
679-687: Use precise assertion methods for comparison and equality tests.- self.assertTrue(pg1 < pg2) - self.assertTrue(pg2 > pg1) + self.assertLess(pg1, pg2) + self.assertGreater(pg2, pg1)- self.assertTrue(pg1 == pg2) + self.assertEqual(pg1, pg2)
1194-1220: Remove hardcoded absolute path.Line 1204 contains a developer-specific absolute path that will fail on other machines and in CI environments. The relative paths and
OPENMS_DATA_PATHenvironment variable fallback are the correct approach.possible_paths = [ # When running from build directory os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "src", "tests", "class_tests", "openms", "data", "FLASHDeconv_1_input.mzML"), # When running from source directory os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "..", "tests", "class_tests", "openms", "data", "FLASHDeconv_1_input.mzML"), - # Absolute path in source tree - "/home/tom-mueller/kohlbacherlab/openms/OpenMS/src/tests/class_tests/openms/data/FLASHDeconv_1_input.mzML", ]
🧹 Nitpick comments (3)
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py (3)
16-16: Remove unused import.
tempfileis imported but never used in this test file.import unittest import os -import tempfile import pyopenms
941-949: Use precise assertion methods for comparison and equality tests.# Comparison is based on scan number - self.assertTrue(ds1 < ds2) - self.assertTrue(ds2 > ds1) + self.assertLess(ds1, ds2) + self.assertGreater(ds2, ds1)- self.assertTrue(ds1 == ds2) + self.assertEqual(ds1, ds2)
1129-1157: Consider adding tests for file write operations.These test classes only cover constructors. Based on the AI summary,
FLASHDeconvSpectrumFileandFLASHDeconvFeatureFilehave ostream-based write interfaces. Consider adding tests that exercise the write methods (e.g.,writeHeader,writeDeconvolvedMassesHeader, etc.) once the bindings are complete.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/pyOpenMS/tests/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write pyOpenMS tests for new Python bindings
Files:
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py
🧠 Learnings (5)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/tests/**/*.py : Write pyOpenMS tests for new Python bindings
Applied to files:
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/**/*.h : Add Doxygen comments for new public methods and classes in pyOpenMS bindings
Applied to files:
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py
📚 Learning: 2025-09-25T20:31:10.016Z
Learnt from: alhigaylan
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/class_tests/openms/source/PeakPickerIM_test_2.cpp:41-58
Timestamp: 2025-09-25T20:31:10.016Z
Learning: When encountering dummy or placeholder test files that were created during early development but are now obsolete due to proper test coverage, they should be removed rather than fixed, especially when they contain mismatched test data and assertions.
Applied to files:
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Applied to files:
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py
🧬 Code graph analysis (1)
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py (3)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h (2)
FLASHHelperClasses(35-245)IsobaricQuantities(172-183)src/openms/include/OpenMS/KERNEL/Peak1D.h (1)
Peak1D(46-52)src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (1)
SpectralDeconvolution(24-74)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: build-lnx-arm
- GitHub Check: build-lnx
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: cppcheck-test
🔇 Additional comments (6)
src/pyOpenMS/tests/unittests/test_FLASHDeconv.py (6)
191-313: LGTM!The
TestPrecalculatedAveraginetests provide good coverage of thePrecalAveragineAPI including constructors, isotope distribution retrieval, index accessors, and both peptide/RNA modes.
400-443: LGTM!Good coverage of
IsobaricQuantitiesstruct including theempty()method behavior and all member variable access.
952-1070: LGTM!Good coverage of
SpectralDeconvolutionincluding parameter handling, averagine calculation for both peptide and RNA modes, and static utility methods.
1072-1127: LGTM!Good coverage of
FLASHDeconvAlgorithmincluding theDefaultParamHandlerandProgressLoggerinterfaces, tolerance handling, and static utility methods.
1159-1181: LGTM!Good coverage of the
TargetDecoyTypeenum including value verification and round-trip assignment throughPeakGroup.
1221-1401: Integration tests are well-structured.The integration tests properly:
- Skip gracefully when test data is unavailable
- Validate meaningful properties (positive masses, valid score ranges, charge constraints)
- Test the full deconvolution workflow including FDR reporting
- Use
setUpClassefficiently for shared data loading
Extract three helper methods to reduce cyclomatic complexity from 21: - prepareSignalDecoyExclusions_: setup signal decoy mass exclusions - prepareNoiseDecoySpectrum_: filter signal peaks for noise decoy - registerPrecursorForMSn_: register precursor info for MSn spectra The main method now cleanly orchestrates these operations, improving readability without changing algorithm behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (4)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h (1)
119-124: Typo persists in parameter documentation:target_dspec_for_decoy_calcualtion.The parameter name still contains the typo "calcualtion" instead of "calculation". This was flagged in a previous review and confirmed by the author as needing a fix.
/** * set target dummy type for the SpectralDeconvolution run. All masses from the target SpectralDeconvolution run will have the target_decoy_type_. * @param target_decoy_type This target_decoy_type_ specifies if a PeakGroup is a target (0), charge dummy (1), noise dummy (2), or isotope dummy (3) - * @param target_dspec_for_decoy_calcualtion target masses from normal deconvolution + * @param target_dspec_for_decoy_calculation target masses from normal deconvolution */ - void setTargetDecoyType(PeakGroup::TargetDecoyType target_decoy_type, const DeconvolvedSpectrum& target_dspec_for_decoy_calcualtion); + void setTargetDecoyType(PeakGroup::TargetDecoyType target_decoy_type, const DeconvolvedSpectrum& target_dspec_for_decoy_calculation);src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (3)
37-40: Typo in parameter description: "all MS levelss".This was flagged in a previous review. The word "levels" is misspelled as "levelss".
defaults_.setValue( "max_charge", 100, - "Maximum charge state for spectra (can be negative for negative mode). Apart from min_charge, this option applies to all MS levelss."); + "Maximum charge state for spectra (can be negative for negative mode). Apart from min_charge, this option applies to all MS levels.");
83-109: Potential crash when accessing precursors on spectra without precursors.At line 94,
spec.getPrecursors()[0]is accessed after only checkingspec.getPrecursors().empty() && target_precursor_mz_ == 0. If precursors are empty buttarget_precursor_mz_ > 0, the early return is skipped and the code attempts to accessgetPrecursors()[0]on an empty container.void SpectralDeconvolution::setTargetPrecursorCharge_() { const auto& spec = deconvolved_spectrum_.getOriginalSpectrum(); - if (spec.getPrecursors().empty() && target_precursor_mz_ == 0) + if (spec.getPrecursors().empty() && target_precursor_mz_ <= 0) { OPENMS_LOG_INFO << "Attempted to set target precursor charge but failed - no precursor is found in MS2 spectra. Specify target precursor m/z " "with -target_precursor_mz option" << std::endl; return; } - auto precursor = spec.getPrecursors()[0]; - double target_precursor_mass - = (precursor.getMZ() - FLASHHelperClasses::getChargeMass(target_precursor_charge_ > 0)) * std::abs(target_precursor_charge_); + Precursor precursor; + double precursor_mz; + if (!spec.getPrecursors().empty()) + { + precursor = spec.getPrecursors()[0]; + precursor_mz = target_precursor_mz_ > 0 ? target_precursor_mz_ : precursor.getMZ(); + } + else + { + precursor_mz = target_precursor_mz_; + } + double target_precursor_mass + = (precursor_mz - FLASHHelperClasses::getChargeMass(target_precursor_charge_ > 0)) * std::abs(target_precursor_charge_); precursor.setCharge(target_precursor_charge_);
165-168: Guard condition allowssetTargetPrecursorCharge_()to be called with only m/z set.The condition
target_precursor_charge_ != 0 || target_precursor_mz_ > 0allows callingsetTargetPrecursorCharge_()when onlytarget_precursor_mz_is set but charge is 0. This contradicts the parameter documentation stating "precursor_mz must be used in combination with precursor_charge". A previous review flagged this.- if (target_precursor_charge_ != 0 || target_precursor_mz_ > 0) { setTargetPrecursorCharge_(); } + if (target_precursor_charge_ != 0) { setTargetPrecursorCharge_(); }
🧹 Nitpick comments (8)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h (2)
65-72: Missingconstqualifier ongetDeconvolvedSpectrum()accessor.The
getDeconvolvedSpectrum()method returns a non-const reference, which is appropriate for modification. However, consider also providing a const overload for read-only access, which is a common pattern in OpenMS./// return deconvolved spectrum DeconvolvedSpectrum& getDeconvolvedSpectrum(); + /// return deconvolved spectrum (const version) + const DeconvolvedSpectrum& getDeconvolvedSpectrum() const;
85-89: Inline method mutates state without documenting side effects.
setToleranceEstimation()modifiesmax_mass_dalton_tolerance_inline but lacks documentation about when this should be called and its impact on deconvolution behavior.- /// when estimating tolerance, max_mass_dalton_tolerance_ should be large + /** @brief Set tolerance estimation mode. + * When estimating tolerance, max_mass_dalton_tolerance_ is set to a large value (100 Da) + * to capture more high signal-to-noise ratio peaks during candidate peakgroup finding. + * Call this before performSpectrumDeconvolution() when tolerance estimation is needed. + */ void setToleranceEstimation() { max_mass_dalton_tolerance_ = 100; }src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (6)
111-128: Loop with fixed boundsfor (int i = 0; i <= 0; i++)is effectively a single iteration.The loop at line 115 iterates from 0 to 0 inclusive, meaning it only executes once. If this is intentional, consider removing the loop for clarity. If multiple offsets were intended, adjust the bounds.
for (const auto& pg : *target_dspec_for_decoy_calculation_) { - for (int i = 0; i <= 0; i++) - { - excluded_masses_for_decoy_runs_.push_back(pg.getMonoMass() + i * iso_da_distance_); - excluded_peak_masses_for_decoy_runs_.push_back(pg.getMonoMass() + avg_.getAverageMassDelta(pg.getMonoMass()) + i * iso_da_distance_); - } + excluded_masses_for_decoy_runs_.push_back(pg.getMonoMass()); + excluded_peak_masses_for_decoy_runs_.push_back(pg.getMonoMass() + avg_.getAverageMassDelta(pg.getMonoMass())); }
18-22: Namespace-scope inline globals may cause ODR issues with older compilers.The
inlineglobals (harmonic_charges_,low_charge_,tol_div_factor) are C++17 compliant but may cause issues with toolchains not fully supporting inline variables. If OpenMS targets C++14, consider usingconstexprfor scalar types and moving the vector to a static member or anonymous namespace.-inline const std::vector<int> harmonic_charges_ {2, 3, 5, 7, 11}; -inline const int low_charge_ = 10; -inline const double tol_div_factor = 2.5; +namespace { + const std::vector<int> harmonic_charges_ {2, 3, 5, 7, 11}; + constexpr int low_charge_ = 10; + constexpr double tol_div_factor = 2.5; +}
345-568: Very complex methodupdateCandidateMassBins_would benefit from decomposition.Static analysis flagged this as "Very Complex Method" (lines 357-586). The method contains deeply nested loops with multiple conditional branches for harmonic detection and charge analysis. Consider extracting logical sub-operations into helper methods to improve readability and testability.
Potential extraction points:
- Harmonic peak detection (lines 452-484): Extract to
bool isHarmonicPeak_(...)- Charge continuity check (lines 489-553): Extract to
void updateMassIntensityForCharge_(...)- Low-charge isotope presence check (lines 423-485): Extract to
bool hasValidIsotopePeakForLowCharge_(...)This would reduce cognitive load and make the algorithm's flow clearer.
1277-1301:getCosinehas unused/misleading variableb_norm = 1.0f.The variable
b_normis initialized to 1.0f and never updated, yet the final cosine calculation divides bysqrt(a_norm * b_norm). This suggestsb_normwas intended to be the squared norm ofbbut was optimized out (assumingbis already normalized). Ifbis pre-normalized, consider removingb_normfrom the calculation for clarity, or add a comment explaining the assumption.float SpectralDeconvolution::getCosine(const std::vector<float>& a, int a_start, int a_end, const IsotopeDistribution& b, int offset, int min_iso_len) { - float n = .0, a_norm = .0, b_norm = 1.0f; + float n = .0, a_norm = .0; + // Note: b (IsotopeDistribution) is assumed to be pre-normalized to unit L2 norm a_start = std::max(0, a_start); a_end = std::min((int)a.size(), a_end); ... - return n / sqrt(a_norm * b_norm); + return n / sqrt(a_norm); // b_norm = 1.0 since b is pre-normalized }
1424-1424: Explicitswapwith empty vector for deallocation is idiomatic but considershrink_to_fit.The pattern
std::vector<PeakGroup>().swap(filtered_pg_vec)at lines 1424 and 1454 forcibly deallocates memory. In C++11+,filtered_pg_vec.clear(); filtered_pg_vec.shrink_to_fit();is more readable. Since the vectors go out of scope immediately after, this explicit deallocation may be unnecessary.Also applies to: 1454-1454
259-271:calculateAveragineuses hardcoded values that could be configurable.The method uses hardcoded values like
300forCoarseIsotopePatternGenerator,200for max isotope,50for min mass, and25for delta. Consider documenting why these values were chosen or making them configurable for advanced users.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h(1 hunks)src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.hsrc/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h
🧠 Learnings (9)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.hsrc/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/**/*.h : Add Doxygen comments for new public methods and classes in pyOpenMS bindings
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h
📚 Learning: 2025-10-15T07:49:09.293Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h:11-14
Timestamp: 2025-10-15T07:49:09.293Z
Learning: In OpenMS, DefaultParamHandler.h is located under OpenMS/DATASTRUCTURES/, not OpenMS/CONCEPT/. The correct include is: `#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>`
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.hsrc/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-29T19:09:45.997Z
Learnt from: jcharkow
Repo: OpenMS/OpenMS PR: 8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
🧬 Code graph analysis (2)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h (3)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/PeakGroup.h (1)
OpenMS(14-422)src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h (2)
OpenMS(18-245)FLASHHelperClasses(35-245)src/openms/include/OpenMS/ANALYSIS/TOPDOWN/DeconvolvedSpectrum.h (1)
OpenMS(16-169)
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (4)
src/openms/source/ANALYSIS/TOPDOWN/DeconvolvedSpectrum.cpp (15)
i(254-257)i(254-254)i(259-262)i(259-259)sort(331-334)sort(331-331)DeconvolvedSpectrum(13-15)a(17-20)a(17-17)a(22-25)a(22-22)end(239-242)end(239-239)end(249-252)end(249-249)src/openms/source/ANALYSIS/TOPDOWN/FLASHHelperClasses.cpp (10)
getChargeMass(236-239)getChargeMass(236-236)LogMzPeak(194-197)PrecalculatedAveragine(15-134)a(212-219)a(212-212)a(221-228)a(221-221)a(230-233)a(230-230)src/openms/source/ANALYSIS/TOPDOWN/PeakGroup.cpp (14)
i(1125-1128)i(1125-1125)sort(1165-1168)sort(1165-1165)a(22-26)a(22-22)a(28-32)a(28-28)a(34-37)a(34-34)end(1110-1113)end(1110-1110)end(1120-1123)end(1120-1120)src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (2)
getAveragine(356-359)getAveragine(356-356)
🪛 GitHub Check: CodeFactor
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
[warning] 357-586: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L357-L586
Very Complex Method
[notice] 587-680: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L587-L680
Complex Method
[notice] 879-969: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L879-L969
Complex Method
[notice] 1217-1332: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L1217-L1332
Complex Method
[notice] 692-863: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L692-L863
Complex Method
[notice] 994-1216: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L994-L1216
Complex Method
[notice] 1363-1430: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L1363-L1430
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (macos-26, xcode, 26.0)
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-lnx-arm
- GitHub Check: build-lnx
- GitHub Check: cppcheck-test
🔇 Additional comments (4)
src/openms/include/OpenMS/ANALYSIS/TOPDOWN/SpectralDeconvolution.h (2)
23-31: Class documentation is well-structured and follows Doxygen conventions.The class-level documentation clearly explains the three-step deconvolution algorithm. The
@ingrouptag properly categorizes this under Topdown.
136-169: Private member initialization and documentation are well-organized.The private section documents member purposes clearly. Default values are appropriately initialized inline. The use of
DoubleListfor per-MS-level parameters aligns with OpenMS conventions.src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (2)
980-1056: OpenMP parallel loop with shared mutable state requires careful synchronization.The
#pragma omp parallel forat line 986 sharesselected(aboost::dynamic_bitset<>) across threads. The critical section at line 1054-1055 protects the bitset write, which is correct. However, thedeconvolved_spectrum_is read/written within the loop body (e.g., line 990 mutates viasetTargetDecoyType). Ensure no data races occur ondeconvolved_spectrum_[i].The
peak_groupat line 990 is obtained by reference fromdeconvolved_spectrum_[i]. Since each thread operates on a distinct indexi, this should be safe as long as no thread accesses another thread's index. Please confirm this assumption holds for all operations within the loop.
724-737: Fix the loop condition to include the final peak in the scan.The loop condition
while (cpi < log_mz_peak_size - 1)continues to skip the last peak. Change it towhile (cpi < log_mz_peak_size)to ensure all peaks are considered when selecting the most intense peak for the current mass and charge state.
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (6)
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (6)
723-736: Include the last peak when scanning charge candidates.The condition
while (cpi < log_mz_peak_size - 1)never inspects the final peak at indexlog_mz_peak_size - 1, causing any signal at the highest m/z to be silently ignored during mass reconstruction. This issue was previously flagged and confirmed but the fix does not appear in the current code.Apply this diff:
- while (cpi < log_mz_peak_size - 1) // scan through peaks from cpi + while (cpi < log_mz_peak_size) // scan through peaks from cpi
167-167: Align call condition with parameter documentation.The condition calls
setTargetPrecursorCharge_()when eithertarget_precursor_charge_ != 0ORtarget_precursor_mz_ > 0, but the parameter documentation (lines 46-50) states thatprecursor_mzmust be used in combination withprecursor_charge. To prevent creating degenerate precursor peak groups, only call the function when a valid charge is present.Apply this diff:
- if (target_precursor_charge_ != 0 || target_precursor_mz_ > 0) { setTargetPrecursorCharge_(); } + if (target_precursor_charge_ != 0) { setTargetPrecursorCharge_(); }
854-861: Fix parameter name typo: "calcualtion" → "calculation".The parameter name contains a typo in both the function signature (line 855) and the assignment (line 860). This should be corrected to "calculation" for consistency with the member variable name.
Apply this diff:
void SpectralDeconvolution::setTargetDecoyType(PeakGroup::TargetDecoyType target_decoy_type, - const DeconvolvedSpectrum& target_dspec_for_decoy_calcualtion) + const DeconvolvedSpectrum& target_dspec_for_decoy_calculation) { target_decoy_type_ = target_decoy_type; if (target_decoy_type == PeakGroup::signal_decoy) allowed_iso_error_ = param_.getValue("allowed_isotope_error"); - target_dspec_for_decoy_calculation_ = &target_dspec_for_decoy_calcualtion; + target_dspec_for_decoy_calculation_ = &target_dspec_for_decoy_calculation; }
1456-1480: Sort vectors after population to enable binary search.The vectors
excluded_masses_andtarget_mono_masses_are populated without subsequent sorting (lines 1468-1479), but both are used withstd::upper_boundfor binary search (line 1437 forexcluded_masses_inremoveExcludedMasses_, line 1039 fortarget_mono_masses_inscoreAndFilterPeakGroups_). Binary search requires sorted data; without sorting, lookups will produce incorrect results.Apply this diff:
{ if (excluded) excluded_masses_.push_back(m + iso_da_distance_ * j); else target_mono_masses_.push_back(m + iso_da_distance_ * j); } } + + if (excluded) + { + std::sort(excluded_masses_.begin(), excluded_masses_.end()); + excluded_masses_.erase( + std::unique(excluded_masses_.begin(), excluded_masses_.end()), + excluded_masses_.end()); + } + else + { + std::sort(target_mono_masses_.begin(), target_mono_masses_.end()); + target_mono_masses_.erase( + std::unique(target_mono_masses_.begin(), target_mono_masses_.end()), + target_mono_masses_.end()); + } }
1152-1166: Sortexcluded_masses_for_decoy_runs_after repopulation.At lines 1154-1161,
excluded_masses_for_decoy_runs_is repopulated but not sorted before being used at line 1166. The functionisPeakGroupInExcludedMassForDecoyRuns_(line 962) usesstd::upper_bound, which requires a sorted range. Without sorting, the binary search produces incorrect results. This issue was previously flagged as addressed but the fix is not present in the current code.Apply this diff:
for (const auto& pg : *target_dspec_for_decoy_calculation_) // pg are the target peak groups from normal spectrum deconvolution { for (int j = -allowed_iso_error_; j <= allowed_iso_error_; j++) { excluded_masses_for_decoy_runs_.push_back(pg.getMonoMass() + j * iso_da_distance_); } } + + std::sort(excluded_masses_for_decoy_runs_.begin(), excluded_masses_for_decoy_runs_.end()); + excluded_masses_for_decoy_runs_.erase( + std::unique(excluded_masses_for_decoy_runs_.begin(), excluded_masses_for_decoy_runs_.end()), + excluded_masses_for_decoy_runs_.end()); for (Size k = 0; k < deconvolved_spectrum_.size(); k++)
82-108: Critical: Handle missing precursors when target_precursor_mz_ is provided.At line 93,
spec.getPrecursors()[0]is accessed without verifying the precursor list is non-empty. Whentarget_precursor_mz_ > 0but the spectrum has no precursors, this causes undefined behavior or a crash. The early-return at line 90 only guards the case where BOTH the precursor list is empty ANDtarget_precursor_mz_ == 0.Apply this diff:
void SpectralDeconvolution::setTargetPrecursorCharge_() { const auto& spec = deconvolved_spectrum_.getOriginalSpectrum(); - if (spec.getPrecursors().empty() && target_precursor_mz_ == 0) + if (spec.getPrecursors().empty()) { - OPENMS_LOG_INFO << "Attempted to set target precursor charge but failed - no precursor is found in MS2 spectra. Specify target precursor m/z " - "with -target_precursor_mz option" - << std::endl; - return; + if (target_precursor_mz_ == 0) + { + OPENMS_LOG_INFO << "Attempted to set target precursor charge but failed - no precursor is found in MS2 spectra. Specify target precursor m/z " + "with -target_precursor_mz option" + << std::endl; + return; + } } - auto precursor = spec.getPrecursors()[0]; + Precursor precursor; + if (!spec.getPrecursors().empty()) + { + precursor = spec.getPrecursors()[0]; + } + const double precursor_mz = target_precursor_mz_ > 0 ? target_precursor_mz_ + : precursor.getMZ(); double target_precursor_mass - = (precursor.getMZ() - FLASHHelperClasses::getChargeMass(target_precursor_charge_ > 0)) * std::abs(target_precursor_charge_); + = (precursor_mz - FLASHHelperClasses::getChargeMass(target_precursor_charge_ > 0)) * std::abs(target_precursor_charge_); + precursor.setMZ(precursor_mz); precursor.setCharge(target_precursor_charge_);
🧹 Nitpick comments (1)
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (1)
344-567: Consider extracting helper methods to reduce complexity.The
updateCandidateMassBins_method is flagged as very complex (230 lines). While the logic appears correct for this sophisticated deconvolution algorithm, consider extracting sub-operations (e.g., isotope validation, harmonic checking, intensity ratio filtering) into helper methods to improve readability and testability. This is an optional refactoring that can be deferred.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
🧠 Learnings (6)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-29T19:09:45.997Z
Learnt from: jcharkow
Repo: OpenMS/OpenMS PR: 8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
🧬 Code graph analysis (1)
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (3)
src/openms/source/ANALYSIS/TOPDOWN/DeconvolvedSpectrum.cpp (16)
precursor(136-136)i(254-257)i(254-254)i(259-262)i(259-259)sort(331-334)sort(331-331)DeconvolvedSpectrum(13-15)a(17-20)a(17-17)a(22-25)a(22-22)end(239-242)end(239-239)end(249-252)end(249-249)src/openms/source/ANALYSIS/TOPDOWN/FLASHHelperClasses.cpp (10)
getChargeMass(236-239)getChargeMass(236-236)LogMzPeak(194-197)PrecalculatedAveragine(15-134)a(212-219)a(212-212)a(221-228)a(221-221)a(230-233)a(230-230)src/openms/source/ANALYSIS/TOPDOWN/PeakGroup.cpp (14)
i(1125-1128)i(1125-1125)sort(1165-1168)sort(1165-1165)a(22-26)a(22-22)a(28-32)a(28-28)a(34-37)a(34-34)end(1110-1113)end(1110-1110)end(1120-1123)end(1120-1120)
🪛 GitHub Check: CodeFactor
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp
[warning] 357-586: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L357-L586
Very Complex Method
[notice] 587-680: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L587-L680
Complex Method
[notice] 879-969: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L879-L969
Complex Method
[notice] 1217-1332: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L1217-L1332
Complex Method
[notice] 692-863: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L692-L863
Complex Method
[notice] 994-1216: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L994-L1216
Complex Method
[notice] 1363-1430: src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp#L1363-L1430
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-lnx
- GitHub Check: build-lnx-arm
- GitHub Check: build-win
- GitHub Check: cppcheck-test
🔇 Additional comments (3)
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (3)
24-73: Constructor and parameter setup look good.The default parameter configuration is well-structured with appropriate constraints and documentation for each option.
979-1200: Scoring and filtering logic is comprehensive.The multi-pass refinement with isotope cosine optimization, SNR thresholding, charge range validation, and decoy filtering is well-implemented. The OpenMP parallelization with critical sections for shared state updates is correctly structured.
1202-1300: Isotope cosine computation and similarity scoring look correct.The
getIsotopeCosineAndIsoOffsetandgetCosinehelper methods properly handle isotope pattern matching with offset exploration and normalization. The logic for finding the best isotope alignment is sound.
Use operator[] instead of back() to access last element since PeakGroup::back() is non-const and the method is const. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (3)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (3)
130-157: Out-of-bounds access in intensity-threshold selectionWhen
it.size() == count,it[count]is one past the end of the spectrum (0-based index), leading to undefined behaviour. This was already flagged earlier and is still present.Suggested fix:
- Size count = it.getType(false) == SpectrumSettings::CENTROID ? max_peak_count_for_centroid_ : max_peak_count_for_profile_; - it.sortByIntensity(true); - double threshold = it.size() < count ? 0 : it[count].getIntensity(); - threshold = std::max(threshold, (double)it.begin()->getIntensity() / 1000); + Size count = it.getType(false) == SpectrumSettings::CENTROID ? max_peak_count_for_centroid_ : max_peak_count_for_profile_; + it.sortByIntensity(true); + + double threshold = 0.0; + if (count > 0 && it.size() >= count) + { + threshold = it[count - 1].getIntensity(); + } + threshold = std::max(threshold, (double)it.begin()->getIntensity() / 1000);This keeps the intended “top-N” behaviour and avoids OOB.
159-232: Data race onoriginal_precursor_mapin OpenMP loop
original_precursor_mapis a sharedstd::mapthat all threads write to inside the#pragma omp parallel forloop without any synchronization. This is undefined behaviour and was already called out in earlier reviews; the race is still there.Simplest safe fix (as discussed in past comments) is to drop the parallelization here:
- std::map<String, std::vector<Precursor>> original_precursor_map; -#pragma omp parallel for default(none), shared(map, ms_level, original_precursor_map) - for (int i = 0; i < (int) map.size(); i++) + std::map<String, std::vector<Precursor>> original_precursor_map; + for (int i = 0; i < (int) map.size(); i++) { auto spec = map[i]; if (spec.getMSLevel() != ms_level) continue; const auto& native_id = spec.getNativeID(); original_precursor_map[native_id] = spec.getPrecursors(); ...The loop is relatively light (just precursor bookkeeping), so the benefit from OpenMP here is small compared to the risk.
682-749: Unuseddecoy_mass_tracerand general feature-finding flowThe overall feature-finding logic (MS1 features first, then MSn features per feature index and optional decoys) is coherent and uses
MassFeatureTraceappropriately. However,decoy_mass_traceris declared but never used; previous review already pointed this out and it’s still present.You can safely remove it:
- auto mass_tracer = MassFeatureTrace(); - auto decoy_mass_tracer = MassFeatureTrace(); + auto mass_tracer = MassFeatureTrace();The rest of the code only uses
mass_tracerfor both target and decoy paths.
🧹 Nitpick comments (4)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (4)
111-128: MS level detection logic is fine; optionally guard forced_ms_level_The
updateMSLevels_pass correctly updatescurrent_min_ms_level_/current_max_ms_level_and respectsforced_ms_level_. You may want to ensure (via parameter validation elsewhere) thatforced_ms_level_never exceedsmax_ms_level_, but the loop itself is sound.
296-353: Core deconvolution loop is correct but quite complexThe multi-pass
runSpectralDeconvolution_over MS levels, optional precursor mapping for MSn, optional merging, and RT→scan remapping is logically consistent. However, the nested control flow makes the method hard to read/maintain (in line with the “Complex Method” hint).Consider extracting small helpers for:
- Building
rt_scan_map.- The inner “process one spectrum at ms_level” body.
This would keep the algorithmic structure but improve readability and testability.
382-456: Tolerance estimation logic is reasonable; watch for param consistencyThe tolerance-estimation pipeline (temporary
SpectralDeconvolution, sampling spectra, collecting mass errors, fitting a Gaussian, and falling back to 10 ppm) looks sound and matches the intended use. The try/catch handling and logging are also acceptable.If you touch this again, small robustness tweaks could be:
- Early-return if
bin_size <= 0ormin_range >= max_rangebefore callinggetHistogram_(even if current callers are safe).- Log
e.what()at debug level in the catch blocks for easier diagnosis.
As per coding guidelines, be mindful of the cost of repeated deconvolutions when datasets are very large.
458-511: Top-levelrunpipeline is coherent; double filtering worth revisitingThe high-level flow—update MS levels, peak filtering, set up SD/decoy SD, auto-determine tolerances when negative, deconvolve, feature trace, update Q-values, then isobaric quantification—is well structured and uses the existing components idiomatically.
One thing to double-check:
filterLowPeaks_(map)is called once at the top ofrun, and again at the end ofmergeSpectra_. Formerge_spec_ > 0, this means spectra are filtered twice. If that’s intentional (e.g. once on raw, once on merged spectra), a short comment would help; otherwise, consider filtering only once per logical stage to save work on large datasets.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
🧠 Learnings (5)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-09-16T10:59:20.544Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8208
File: src/openms/source/FORMAT/MzParquetFile.cpp:127-146
Timestamp: 2025-09-16T10:59:20.544Z
Learning: Throwing exceptions from within OpenMP critical sections (#pragma omp critical) can cause undefined behavior and deadlocks because the critical section may not be properly released during exception unwinding. Always avoid throwing exceptions from within OpenMP synchronization constructs.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
🧬 Code graph analysis (1)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (6)
src/openms/source/ANALYSIS/TOPDOWN/SpectralDeconvolution.cpp (6)
SpectralDeconvolution(24-73)updateMembers_(218-251)updateMembers_(218-218)pg(1101-1101)getAveragine(253-256)getAveragine(253-253)src/openms/source/ANALYSIS/TOPDOWN/MassFeatureTrace.cpp (3)
MassFeatureTrace(14-36)updateMembers_(230-232)updateMembers_(230-230)src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.h (1)
isolation_window_size_(117-173)src/openms/source/ANALYSIS/TOPDOWN/PeakGroup.cpp (6)
i(1125-1128)i(1125-1125)getScanNumber(919-922)getScanNumber(919-919)sort(1165-1168)sort(1165-1165)src/openms/source/ANALYSIS/TOPDOWN/DeconvolvedSpectrum.cpp (10)
i(254-257)i(254-254)i(259-262)i(259-259)precursor(136-136)getScanNumber(194-197)getScanNumber(194-194)sort(331-334)sort(331-331)DeconvolvedSpectrum(13-15)src/openms/source/ANALYSIS/TOPDOWN/Qvalue.cpp (2)
updatePeakGroupQvalues(29-197)updatePeakGroupQvalues(29-29)
🪛 GitHub Check: CodeFactor
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
[notice] 258-353: src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp#L258-L353
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: build-lnx-arm
- GitHub Check: build-lnx
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: cppcheck-test
🔇 Additional comments (7)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (7)
29-109: Ctor and member update wiring looks consistent with sub-componentsThe constructor wiring of defaults (SD:/ft:/iq:) and
updateMembers_mapping fromparam_into internal fields is coherent and matches the patterns in the related TOPDOWN components. I don’t see functional issues here.
234-265: Scan-number helpers are reasonable
getScanNumber’s use ofSpectrumLookup::extractScanNumberwith a sensible fallback toindex + 1andfindPrecursorScanNumber_’s backward scan for the previous MS level both look correct and robust for typical mzMLs.
266-294: Parallel decoy deconvolution usage looks safeThe
appendDecoyPeakGroups_function runssd_noise_decoy_andsd_signal_decoy_inomp parallel sectionson separateSpectralDeconvolutioninstances and only touches the shareddeconvolved_spectrumafter the parallel region. Given that no shared mutable state is written inside the sections, this pattern is fine.
356-365: Averagine accessors are straightforward
getAveragine()andgetDecoyAveragine()correctly delegate to the underlyingSpectralDeconvolutioninstances and respectreport_decoy_. No issues here.
367-380: Histogram helper is fine; assumes positive bin_size/min<max
getHistogram_does what it advertises and is used with well-defined arguments in this file (±100, bin size 1). No functional issues from what’s visible here.
621-641: Precursor PG mapping for MSn is consistent
findPrecursorPeakGroupsForMSnSpectra_’s combination of scan-number bounds, survey-scan collection, isolation window, and best-PG search is consistent with the helpers around it. With the guard suggested infindBestPrecursorPeakGroup_, it should behave well even when isolation-window metadata are absent.
643-680: Precursor Q-score propagation is reasonable
updatePrecursorQScores_sensibly maps precursor full scans by scan number, then propagates feature indices and Q-scores from the full scans back into MSn precursor peak groups usinglower_bound. This looks correct assuming theDeconvolvedSpectrumordering and comparison operators are defined as in the rest of the TOPDOWN module.
Change @PARAM fs to @PARAM os to match actual parameter names in: - FLASHDeconvFeatureFile::writeTopFDFeatures - FLASHDeconvSpectrumFile::writeDeconvolvedMassesHeader - FLASHDeconvSpectrumFile::writeIsobaricQuantification - FLASHDeconvSpectrumFile::writeTopFD 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
src/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h (1)
67-80: Incomplete Doxygen documentation forwriteMzML.The
@paramtags still lack descriptions. This was previously flagged and confirmed as addressed, but the fix may not have been pushed yet.src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.h (1)
33-34: UseUIntinstead ofuintfor consistency.This was previously flagged and confirmed as addressed, but the fix may not have been pushed yet.
🧹 Nitpick comments (4)
src/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h (3)
32-35: UseUIntinstead ofuintfor cross-platform consistency.OpenMS convention is to use
UInt(fromOpenMS/CONCEPT/Types.h) rather than the non-portableuinttype.- static void writeDeconvolvedMassesHeader(std::ostream& os, - uint ms_level, - bool detail, - bool report_decoy); + static void writeDeconvolvedMassesHeader(std::ostream& os, + UInt ms_level, + bool detail, + bool report_decoy);You'll also need to ensure
#include <OpenMS/CONCEPT/Types.h>is present (likely already included transitively).
89-90: Add complete Doxygen documentation forwriteTopFDHeader.Per coding guidelines, new public methods should have complete Doxygen comments including
@paramdescriptions.- /// write topFD header - static void writeTopFDHeader(std::ostream& os, const Param& param); + /** + * @brief Write header for TopFD output format + * @param os Output stream to write to + * @param param Parameters containing FLASHDeconv configuration + */ + static void writeTopFDHeader(std::ostream& os, const Param& param);
102-106: UseUIntinstead ofuintformin_ms_levelparameter.Consistent with OpenMS type conventions.
static void writeTopFD(const DeconvolvedSpectrum& dspec, std::ostream& os, const String& filename, double qval_threshold = 1.0, - uint min_ms_level = 1, + UInt min_ms_level = 1, bool randomize_precursor_mass = false, bool randomize_fragment_mass = false);src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.h (1)
49-50: UseUIntinstead ofuintforms_levelparameter.For consistency with OpenMS type conventions.
static void writeTopFDFeatures(std::vector<DeconvolvedSpectrum>& deconvolved_spectra, const std::vector<FLASHHelperClasses::MassFeature>& mass_features, - const std::map<int, double>& scan_rt_map, const String& file_name, std::ostream& os, uint ms_level); + const std::map<int, double>& scan_rt_map, const String& file_name, std::ostream& os, UInt ms_level);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.h(2 hunks)src/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.hsrc/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.hsrc/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
🧠 Learnings (9)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.hsrc/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.hsrc/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.hsrc/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.hsrc/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.hsrc/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/**/*.h : Add Doxygen comments for new public methods and classes in pyOpenMS bindings
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Update relevant documentation when modifying existing functionality
Applied to files:
src/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h
🧬 Code graph analysis (1)
src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.h (2)
src/openms/source/FORMAT/FLASHDeconvFeatureFile.cpp (8)
writeHeader(18-27)writeHeader(18-18)writeTopFDFeatureHeader(29-44)writeTopFDFeatureHeader(29-29)writeFeatures(46-102)writeFeatures(46-46)writeTopFDFeatures(104-203)writeTopFDFeatures(104-105)src/openms/include/OpenMS/ANALYSIS/TOPDOWN/FLASHHelperClasses.h (1)
FLASHHelperClasses(35-245)
🔇 Additional comments (6)
src/openms/include/OpenMS/FORMAT/FLASHDeconvSpectrumFile.h (3)
10-12: LGTM!Include updates correctly add
FLASHHelperClasses.hto support the new type dependencies (PrecalculatedAveragine, etc.).
58-65: LGTM!The updated signature properly integrates the new
FLASHHelperClasses::PrecalculatedAveraginetypes and decoy parameters. Documentation is complete.
82-87: LGTM!The new
writeIsobaricQuantificationmethod has adequate Doxygen documentation and follows the stream-based I/O pattern.src/openms/include/OpenMS/FORMAT/FLASHDeconvFeatureFile.h (3)
12-13: LGTM!Include updates correctly add
DeconvolvedSpectrum.handFLASHHelperClasses.hto support the updated API.
30-31: LGTM!The stream-based signature with optional
report_decoyflag aligns well with the refactored I/O model.
36-37: LGTM!The updated signature correctly uses
FLASHHelperClasses::MassFeatureand the stream-based output pattern.
Document major FLASHDeconv update including: - Improved scoring and FDR estimation - Isobaric quantification support - Automatic mass tolerance estimation - Per-MS-level outputs - TopFD 1.7 compatible exports - Better precursor mass assignment
Document parameter changes including: - Per-MS-level output files (out_spec1-4, out_msalign1-2, out_feature1-2) - New isobaric quantification output and parameters (iq:) - Reorganized parameters into FD: and SD: subsections - Removed deprecated parameters (in_log, out_promex, out_topFD, etc.)
|
Once CI passes we are ready to go. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
CHANGELOG_PARAMS (1)
117-118: Inconsistent boolean parameter representation.Parameters
FD:report_FDR,FD:use_RNA_averagine,iq:isotope_correction, andiq:only_fully_quantifiedusestringtype with"true","false"restrictions, whilekeep_empty_out(line 100) andwrite_detail(line 106) use the nativebooltype.Consider using
boolconsistently for all boolean parameters to simplify parsing and improve API consistency.Also applies to: 127-127, 129-129
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
CHANGELOG_PARAMS(1 hunks)
🔇 Additional comments (2)
CHANGELOG_PARAMS (2)
84-85: LGTM!The enzyme restriction list reordering is a non-breaking change that doesn't affect functionality.
86-99: Breaking API changes require CHANGELOG documentation.The output parameter restructuring introduces several breaking changes:
out_spec(list) → individualout_spec1-out_spec4filesout_topFD(list) →out_msalign1/out_msalign2out_topFD_feature(list) →out_feature1/out_feature2- Removed:
in_log,out_promexExisting user scripts and workflows referencing the old parameter names will break. Per PR objectives, the CHANGELOG update is pending—ensure these breaking changes are explicitly documented before merging.
- Take upstream's PR OpenMS#8257 FLASHDeconv updates (Qvalue/PeakGroup/PeakGroupScoring/ DeconvolvedSpectrum/SpectralDeconvolution/MassFeatureTrace/ TopDownIsobaricQuantification/FLASHDeconvAlgorithm/FLASHHelperClasses/ FLASHDeconv*File and TOPP FLASHDeconv). - Retain fork-only FLASHIda module (FLASHIda*, FLASHTaggerAlgorithm, FLASHTnTAlgorithm, FLASHGappedTaggerAlgorithm, FLASHExtenderAlgorithm, FLASHIdaBridgeFunctions, FLASHIda/ subdir, OptimizationMetadata) and add the corresponding entries to TOPDOWN sources.cmake. - Restore Qscore.h and Qscore.cpp (the only files removed by the last merge from FDdevelop, PR OpenMS#8257 / commit 7d471e3); kept in the source tree but intentionally not added to sources.cmake. - Drop FLASH-specific Python bindings and the now-incompatible DeconvolvedSpectrum.pxd / PeakGroup.pxd; the rest of the pyOpenMS tree is taken from upstream/develop per PR OpenMS#8257. - Drop ProForma.h/.cpp and Tutorial_ProForma.cpp (absent on both sides). - Take upstream's contrib submodule SHA.
Description
This PR merges the latest FLASHDeconv Version back into OpenMS. It is intended for the 3.5 release. The timeline that was agreed on was end of October (Next OpenMS Hackathon).
TODO:
SpectraMergerChecklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit
New Features
Improvements
UI
Tests
✏️ Tip: You can customize this high-level summary in your review settings.