Repository navigation
feat: runtime search diagnostics and tolerance estimation in PeptideSearchEngineFI - #9121
Conversation
…earchEngineFI Log a search summary (PSM count, MS2 ID rate, unique peptides/proteins, missed cleavages distribution) and per-run tolerance estimation (median + MAD of precursor/fragment errors with recommended tolerance) after every search. Addresses items #10 and #11 from #9108. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded a protected helper Changes
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/openms/include/OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.h (1)
435-438: Use a full Doxygen block for the new helper declaration.Please replace the single-line comment with a Doxygen block that includes
@brief(and a short detail paragraph) for this method declaration.As per coding guidelines "Use
@briefplus blank line plus detailed description in Doxygen comments; required@brieftag".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.h` around lines 435 - 438, Replace the single-line comment for the helper method logSearchDiagnostics_ with a full Doxygen comment block containing an `@brief` tag and a short detailed paragraph on the next line; specifically, above the declaration of void logSearchDiagnostics_(const PeakMap& spectra, const std::vector<ProteinIdentification>& protein_ids, const PeptideIdentificationList& peptide_ids) const; add a /** `@brief` ... */ style block that includes `@brief` followed by a blank line and then a concise detailed description of what the method logs (search summary statistics and per-run tolerance estimation) to satisfy the project's Doxygen style requirement.src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp (1)
1290-1342: Prefer\noverstd::endlin the new diagnostics logs.The new block uses
std::endlrepeatedly, which flushes unnecessarily and adds overhead in heavy logging paths.As per coding guidelines "Avoid
std::endlfor performance reasons; prefer\nin C++".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around lines 1290 - 1342, Replace all occurrences of std::endl in the new diagnostics logging block with '\n' to avoid unnecessary flushes; specifically update the OPENMS_LOG_INFO streams in the block that prints the search summary, missed cleavages, tolerance estimation and the final summary (the lines that currently end with << std::endl), keeping existing manipulators (std::fixed, std::setprecision) unchanged so formatting is preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 1278-1285: The diagnostics' tolerance estimation is incorrectly
gated on whether PSM annotation keys PRECURSOR_ERROR_PPM_USERPARAM and
FRAGMENT_ERROR_MEDIAN_PPM_USERPARAM exist, so when annotate:PSM is disabled the
precursor_errors and fragment_errors vectors remain empty; change the logic in
PeptideSearchEngineFIAlgorithm.cpp (around the top.metaValueExists checks and
the code that fills precursor_errors and fragment_errors) to always compute and
push the precursor and fragment error values during post-processing (e.g.,
compute values regardless of top.metaValueExists and use the computed doubles to
populate precursor_errors and fragment_errors), and only conditionally attach
these values to PSM annotations when
PRECURSOR_ERROR_PPM_USERPARAM/FRAGMENT_ERROR_MEDIAN_PPM_USERPARAM are enabled so
diagnostics no longer depend on annotation toggles.
- Around line 1251-1254: The log currently uses peptide_ids.size() (number of
identified spectra) for "PSMs", which underreports when multiple hits per
spectrum are kept; replace that with a count of all PeptideHit entries by
summing getHits().size() across peptide_ids (e.g. accumulate over peptide_ids
calling getHits().size()) so num_identified reflects total PSMs; apply the same
change where the PSM count is computed later (the other occurrence around the
num_identified calculation) and keep the variable name (num_identified) and the
log label "PSMs" intact so report:top_hits > 1 is handled correctly.
---
Nitpick comments:
In `@src/openms/include/OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.h`:
- Around line 435-438: Replace the single-line comment for the helper method
logSearchDiagnostics_ with a full Doxygen comment block containing an `@brief` tag
and a short detailed paragraph on the next line; specifically, above the
declaration of void logSearchDiagnostics_(const PeakMap& spectra, const
std::vector<ProteinIdentification>& protein_ids, const
PeptideIdentificationList& peptide_ids) const; add a /** `@brief` ... */ style
block that includes `@brief` followed by a blank line and then a concise detailed
description of what the method logs (search summary statistics and per-run
tolerance estimation) to satisfy the project's Doxygen style requirement.
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 1290-1342: Replace all occurrences of std::endl in the new
diagnostics logging block with '\n' to avoid unnecessary flushes; specifically
update the OPENMS_LOG_INFO streams in the block that prints the search summary,
missed cleavages, tolerance estimation and the final summary (the lines that
currently end with << std::endl), keeping existing manipulators (std::fixed,
std::setprecision) unchanged so formatting is preserved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 003b231e-ed29-4096-b03e-0000bea0a8bf
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.hsrc/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp
| if (top.metaValueExists(Constants::UserParam::PRECURSOR_ERROR_PPM_USERPARAM)) | ||
| { | ||
| precursor_errors.push_back(fabs(static_cast<double>(top.getMetaValue(Constants::UserParam::PRECURSOR_ERROR_PPM_USERPARAM)))); | ||
| } | ||
| if (top.metaValueExists(Constants::UserParam::FRAGMENT_ERROR_MEDIAN_PPM_USERPARAM)) | ||
| { | ||
| fragment_errors.push_back(static_cast<double>(top.getMetaValue(Constants::UserParam::FRAGMENT_ERROR_MEDIAN_PPM_USERPARAM))); | ||
| } |
There was a problem hiding this comment.
Tolerance estimation is coupled to optional PSM annotation settings.
If users disable PRECURSOR_ERROR_PPM_USERPARAM / FRAGMENT_ERROR_MEDIAN_PPM_USERPARAM in annotate:PSM, the error vectors stay empty and estimation is skipped even with enough identified spectra. The diagnostics feature should not depend on output-annotation toggles.
🔧 Suggested direction
- if (top.metaValueExists(Constants::UserParam::PRECURSOR_ERROR_PPM_USERPARAM))
- {
- precursor_errors.push_back(fabs(static_cast<double>(top.getMetaValue(Constants::UserParam::PRECURSOR_ERROR_PPM_USERPARAM))));
- }
+ if (top.metaValueExists(Constants::UserParam::PRECURSOR_ERROR_PPM_USERPARAM))
+ {
+ precursor_errors.push_back(fabs(static_cast<double>(
+ top.getMetaValue(Constants::UserParam::PRECURSOR_ERROR_PPM_USERPARAM))));
+ }
+ else if (pid.getMZ() > 0.0 && top.getCharge() > 0)
+ {
+ const double theo_mz = top.getSequence().getMZ(top.getCharge());
+ precursor_errors.push_back(fabs(Math::getPPM(pid.getMZ(), theo_mz)));
+ }For fragment error, consider computing/storing it unconditionally in post-processing (even if not requested for final PSM annotation), so diagnostics always has data.
Also applies to: 1320-1338
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around
lines 1278 - 1285, The diagnostics' tolerance estimation is incorrectly gated on
whether PSM annotation keys PRECURSOR_ERROR_PPM_USERPARAM and
FRAGMENT_ERROR_MEDIAN_PPM_USERPARAM exist, so when annotate:PSM is disabled the
precursor_errors and fragment_errors vectors remain empty; change the logic in
PeptideSearchEngineFIAlgorithm.cpp (around the top.metaValueExists checks and
the code that fills precursor_errors and fragment_errors) to always compute and
push the precursor and fragment error values during post-processing (e.g.,
compute values regardless of top.metaValueExists and use the computed doubles to
populate precursor_errors and fragment_errors), and only conditionally attach
these values to PSM annotations when
PRECURSOR_ERROR_PPM_USERPARAM/FRAGMENT_ERROR_MEDIAN_PPM_USERPARAM are enabled so
diagnostics no longer depend on annotation toggles.
peptide_ids.size() counts identified spectra, not total PSM hits. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Compute precursor error inline in logSearchDiagnostics_() instead of reading from annotation metavalues. This ensures tolerance estimation works even if annotate:PSM is customized to exclude precursor error. Fragment error still uses the metavalue (computing it inline would require expensive spectrum alignment). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp (1)
1251-1254:⚠️ Potential issue | 🟠 MajorAdd explicit PSM counting (current summary only counts identified spectra).
Line 1253 (
peptide_ids.size()) is the number of identified spectra, not total PSM hits. This misses the requested PSM metric when multiple hits per spectrum are retained.🔧 Suggested fix
- Size num_identified = peptide_ids.size(); + Size num_identified_spectra = peptide_ids.size(); + Size num_psms = 0; + for (const auto& pid : peptide_ids) + { + num_psms += pid.getHits().size(); + } ... - OPENMS_LOG_INFO << "[PDBS-FI] Matched spectra: " << num_identified << std::endl; + OPENMS_LOG_INFO << "[PDBS-FI] Matched spectra: " << num_identified_spectra << std::endl; + OPENMS_LOG_INFO << "[PDBS-FI] PSMs: " << num_psms << std::endl; ... - << std::fixed << std::setprecision(1) << (100.0 * num_identified / num_ms2) << "%" << std::endl; + << std::fixed << std::setprecision(1) << (100.0 * num_identified_spectra / num_ms2) << "%" << std::endl;Also applies to: 1295-1301
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around lines 1251 - 1254, The code currently uses peptide_ids.size() (number of identified spectra) but needs an explicit PSM count; iterate over peptide_ids and sum id.getHits().size() to compute num_psms (e.g., Size num_psms = std::accumulate(peptide_ids.begin(), peptide_ids.end(), 0u, [](Size acc, const PeptideIdentification& id){ return acc + id.getHits().size(); })), then use num_psms wherever a PSM metric is required (replace uses of peptide_ids.size() at the blocks around the code in PeptideSearchEngineFIAlgorithm.cpp, including the other occurrence around lines ~1295-1301) so both identified spectra and total PSM hits are reported correctly.
🧹 Nitpick comments (1)
src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp (1)
1294-1347: Replacestd::endlin the new diagnostics logger.The new log block uses repeated
std::endl; prefer'\n'to avoid unnecessary stream flushes on frequent logging paths.As per coding guidelines, "Avoid
std::endlfor performance reasons; prefer\nin C++".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around lines 1294 - 1347, The logging block in PeptideSearchEngineFIAlgorithm (the OPENMS_LOG_INFO calls in the search summary / tolerance estimation section) uses multiple std::endl which forces flushes; replace each trailing std::endl with '\n' (e.g., the OPENMS_LOG_INFO lines printing "[PDBS-FI] ============ Search Summary ============", MS2 spectra, MS2 ID rate, Unique peptides/proteins, Missed cleavages line, the tolerance estimation header and the precursor/fragment recommendation lines, and the final divider) so the messages end with '\n' instead of std::endl; keep the same formatting/precision and do not add explicit flushes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 1251-1254: The code currently uses peptide_ids.size() (number of
identified spectra) but needs an explicit PSM count; iterate over peptide_ids
and sum id.getHits().size() to compute num_psms (e.g., Size num_psms =
std::accumulate(peptide_ids.begin(), peptide_ids.end(), 0u, [](Size acc, const
PeptideIdentification& id){ return acc + id.getHits().size(); })), then use
num_psms wherever a PSM metric is required (replace uses of peptide_ids.size()
at the blocks around the code in PeptideSearchEngineFIAlgorithm.cpp, including
the other occurrence around lines ~1295-1301) so both identified spectra and
total PSM hits are reported correctly.
---
Nitpick comments:
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 1294-1347: The logging block in PeptideSearchEngineFIAlgorithm
(the OPENMS_LOG_INFO calls in the search summary / tolerance estimation section)
uses multiple std::endl which forces flushes; replace each trailing std::endl
with '\n' (e.g., the OPENMS_LOG_INFO lines printing "[PDBS-FI] ============
Search Summary ============", MS2 spectra, MS2 ID rate, Unique
peptides/proteins, Missed cleavages line, the tolerance estimation header and
the precursor/fragment recommendation lines, and the final divider) so the
messages end with '\n' instead of std::endl; keep the same formatting/precision
and do not add explicit flushes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cc5569e0-a901-4860-92da-d923a9048c89
📒 Files selected for processing (1)
src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp
PeptideHits with unresolved precursor charge (0) would cause getMZ() to throw. Skip these hits in the precursor error collection. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add missing changelog entries for commits merged after the last sync: - #9127: Fix LinearResampler right_index bounds clamping (intensity spike bug) - #9126: CometAdapter Bruker .d DDA-PASEF input support - #9121: PeptideDataBaseSearchFI runtime search diagnostics and tolerance estimation - #9122: PeptideDataBaseSearchFI automatic mass accuracy calibration (two-pass search) - #9123: PeptideDataBaseSearchFI protein-level FDR (picked-protein) - #9129: OpenSwathWorkflow Bruker DIA MS2 frame aggregation, denoising, and streaming Co-authored-by: Copilot <[email protected]>
Add missing changelog entries for commits merged after the last sync: - #9127: Fix LinearResampler right_index bounds clamping (intensity spike bug) - #9126: CometAdapter Bruker .d DDA-PASEF input support - #9121: PeptideDataBaseSearchFI runtime search diagnostics and tolerance estimation - #9122: PeptideDataBaseSearchFI automatic mass accuracy calibration (two-pass search) - #9123: PeptideDataBaseSearchFI protein-level FDR (picked-protein) - #9129: OpenSwathWorkflow Bruker DIA MS2 frame aggregation, denoising, and streaming Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
ceil(median + 3*MAD)), plus configured tolerance for comparison. Requires ≥10 PSMs (skipped otherwise). Follows theInternalCalibration.cpppattern.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit