Repository navigation
fix: post-#9232 idparquet follow-ups (IDMerger order, Percolator post-filter, schema validation, …) - #9240
Conversation
…Runs mergeIds_ was using std::map<String, ProteinIdentification> for both proteins_by_id and selected_proteins, which silently re-sorts runs in alphabetical-by-identifier order on output (and in the add_to branch, reverse-alphabetical via rbegin()/rend()). Whether or not a fixture happened to be in input order was an accident of how identifiers sort lexically. This breaks any downstream tool that expects "first run in equals first run out" — most concretely IDRipper, where the per-run output index is load-bearing for users splitting a merged file back into per-source .idparquet directories. Replace the map with an insertion-ordered structure (std::vector<String> of keys for order + std::unordered_map<String, ProteinIdentification> for O(1) lookup); emit runs in first-seen order in both the no-add_to and add_to paths. Update IDRipper_3_output.idXML reference to reflect the corrected order (no content change, just run order; downstream out1/out2 diffs against the original inputs still pass, confirming the rip is faithful). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…on in-process path The in-process Percolator backend (vendored library + TRON solver, OpenMS#9218) returned EXECUTION_OK immediately after writing output, bypassing the post-filter logic that the subprocess path runs. Result: same input, same -score:fdr / -best_per_spectrum_only flags, different output depending on which backend the user happened to be using. Extract the post-filter into a small helper (applyPostFilters_) and invoke it from both paths so the two backends produce equivalent output. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
importFromArrow used to bail with success on (!table || num_rows == 0) before any schema check. That silently accepted a nullptr table as "success" and let a structurally-incompatible 0-row file pass through without rejection. Split the early return: nullptr -> log + return false; otherwise combine chunks and run ArrowSchemaValidation regardless of row count, then if num_rows == 0 return true after a successful validation. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The .idparquet round-trip section asserted only container sizes, which silently passed even if identifier, score_type, hit sequence, charge or score got corrupted on reload. Add explicit equality checks for the key fields after load so a future regression in any of them fails the test instead of slipping through. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SageAdapter, CometAdapter and MSGFPlusAdapter now all accept .idparquet in addition to .idXML, but their -out help text still claimed "Single output file" / "Output file", which is misleading because .idparquet is a directory of four .parquet files. Reword to mention both shapes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
C++ integer division truncates toward zero, so a small negative timestamp like raw = -500 ms previously divided to 0 in the SEC scaling step and then passed the epoch_secs >= 0 guard, silently rendering as 1970-01-01. Use floor-style division so -500 ms becomes -1 s and the existing negative-epoch guard rejects it. Realistic proteomics timestamps are post-1970 so this is unobservable in production data, but the code is now correct for any future synthetic or pre-1970 input. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
-score:fdr is an FDR threshold and only makes sense when the main score is
a q-value or FDR; with -score_type q-value (the default) PercolatorAdapter
sets it that way after parsing, so the assumption holds on the well-formed
code path. But IDFilter::filterHitsByScore would silently mis-threshold
if a future code path landed here with an svm/PEP main score.
Add an explicit precondition check using OpenMS::Scores::isScoreType
against IDType::QVAL / IDType::FDR; throw Exception::Precondition with a
fix-it message ("Re-run with -score_type q-value or omit -score:fdr.") if
the score type is something else.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughFixed Arrow/Parquet I/O timestamp normalization and null-table/schema handling, strengthened parquet round-trip test assertions and fixture data, stabilized IDMerger output ordering to first-seen identifiers, centralized PercolatorAdapter post-filtering for both execution paths, and clarified several adapter Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PercolatorAdapter
participant Subprocess
participant IDFilter
participant FileHandler
User->>PercolatorAdapter: run (in-process)
PercolatorAdapter->>IDFilter: applyPostFilters_()
IDFilter-->>PercolatorAdapter: filtered identifications
PercolatorAdapter->>FileHandler: storeIdentifications(...)
User->>PercolatorAdapter: run (subprocess)
PercolatorAdapter->>Subprocess: spawn external Percolator
Subprocess-->>PercolatorAdapter: produce identifications file
PercolatorAdapter->>IDFilter: applyPostFilters_()
IDFilter-->>PercolatorAdapter: filtered identifications
PercolatorAdapter->>FileHandler: storeIdentifications(...)
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/topp/IDMerger.cpp (1)
347-347: Add an explicit<unordered_map>include
std::unordered_mapis used at lines 347 and 399, but the file does not explicitly include<unordered_map>. While the dependency is satisfied through transitive includes (likely from ProteinIdentification.h), relying on indirect includes is fragile and may break if those headers change.Proposed patch
`#include` <algorithm> +#include <unordered_map>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/IDMerger.cpp` at line 347, Add a direct include for the unordered_map header to avoid relying on transitive includes: update the file that declares std::unordered_map (where proteins_by_id and other uses appear, e.g., around proteins_by_id and the later use at line ~399) to `#include` <unordered_map> so the symbol std::unordered_map is guaranteed to be available regardless of changes to ProteinIdentification.h or other headers.src/topp/PercolatorAdapter.cpp (1)
361-366: Use'\n'instead ofstd::endlin new log linesThe new logging on Lines 361-366 uses
std::endl; please switch to'\n'to avoid unnecessary flushes.As per coding guidelines
**/*.{cpp,cxx,cc}: Avoidstd::endlfor performance; prefer\n.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/PercolatorAdapter.cpp` around lines 361 - 366, Replace the use of std::endl with '\n' in the logging statements that print score_fdr and all_peptide_ids (the OPENMS_LOG_INFO and OPENMS_LOG_WARN lines referencing score_fdr and all_peptide_ids in PercolatorAdapter) so the logs no longer force an unnecessary flush; keep the same message text but terminate with '\n' instead of std::endl.
🤖 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/FORMAT/ProteinIdentificationArrowIO.cpp`:
- Around line 1357-1359: The floor_div lambda that negates r causes UB for
INT64_MIN; replace its implementation in ProteinIdentificationArrowIO.cpp (the
floor_div lambda used with arrow::TimestampArray::Value(row) and its calls) with
a quotient/remainder-based floor division: compute q = r / d and rem = r % d,
adjust q by -1 when remainder and divisor signs differ to ensure floor behavior,
and return q; update all uses (the calls noted around the three downstream uses)
to rely on this safe implementation so no negation of INT64_MIN occurs.
In `@src/openms/source/FORMAT/QPXFile.cpp`:
- Line 1425: The log statement in QPXFile::importFromArrow uses std::endl which
forces a flush; replace the use of std::endl in the OPENMS_LOG_ERROR <<
"QPXFile::importFromArrow: null table" << std::endl; line with a plain newline
character (i.e., "\n") to avoid unnecessary stream flushes and follow the
project's logging guideline.
In `@src/topp/PercolatorAdapter.cpp`:
- Around line 353-360: The current filter uses
IDFilter::filterHitsByScore(all_peptide_ids, score_fdr) which uses the main hit
score and is wrong when Percolator's -score_type is pep or svm; change the call
to the overload that specifies the score name so it always filters on the
q-value (e.g. IDFilter::filterHitsByScore(all_peptide_ids, score_fdr, "q-value")
or the equivalent API) after retrieving getDoubleOption_("score:fdr"), and keep
calling IDFilter::removeEmptyIdentifications(all_peptide_ids) as before; also
replace any uses of std::endl in the messages emitted around this filtering
block with '\n' to avoid the performance penalty.
---
Nitpick comments:
In `@src/topp/IDMerger.cpp`:
- Line 347: Add a direct include for the unordered_map header to avoid relying
on transitive includes: update the file that declares std::unordered_map (where
proteins_by_id and other uses appear, e.g., around proteins_by_id and the later
use at line ~399) to `#include` <unordered_map> so the symbol std::unordered_map
is guaranteed to be available regardless of changes to ProteinIdentification.h
or other headers.
In `@src/topp/PercolatorAdapter.cpp`:
- Around line 361-366: Replace the use of std::endl with '\n' in the logging
statements that print score_fdr and all_peptide_ids (the OPENMS_LOG_INFO and
OPENMS_LOG_WARN lines referencing score_fdr and all_peptide_ids in
PercolatorAdapter) so the logs no longer force an unnecessary flush; keep the
same message text but terminate with '\n' instead of std::endl.
🪄 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: fa43932f-b476-47f1-bbb8-e5cceaa52b52
📒 Files selected for processing (9)
src/openms/source/FORMAT/ProteinIdentificationArrowIO.cppsrc/openms/source/FORMAT/QPXFile.cppsrc/tests/class_tests/openms/source/FileHandler_test.cppsrc/tests/topp/IDRipper_3_output.idXMLsrc/topp/CometAdapter.cppsrc/topp/IDMerger.cppsrc/topp/MSGFPlusAdapter.cppsrc/topp/PercolatorAdapter.cppsrc/topp/SageAdapter.cpp
Two small follow-ups to PR OpenMS#9240: 1. IDMerger: replace the count(id)==0 then [id]=prot two-lookup pattern with try_emplace + iterator update, mirroring the same change in the selected_proteins path. No behavior change; one hash lookup per insert instead of two. 2. ProteinIdentificationArrowIO: rewrite the floor_div lambda in the timestamp-scaling switch using quotient/remainder so the function is well-defined at INT64_MIN (the previous "-((-r + d - 1) / d)" form negated r and would have hit signed-overflow UB at INT64_MIN). Practically unobservable in real proteomics timestamps but cheap to make watertight. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/topp/IDMerger.cpp`:
- Line 347: This file uses std::unordered_map (see the proteins_by_id variable
and its type std::unordered_map<String, ProteinIdentification>) but does not
include the header directly; add an explicit `#include` <unordered_map> at the top
of the translation unit so the use of std::unordered_map is self-contained and
not reliant on transitive includes from ProteinIdentification.h or other
headers.
🪄 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: cd607a89-3b21-4c93-9ea7-1dfc01508e31
📒 Files selected for processing (2)
src/openms/source/FORMAT/ProteinIdentificationArrowIO.cppsrc/topp/IDMerger.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/source/FORMAT/ProteinIdentificationArrowIO.cpp
…core_type Switch to IDFilter::filterHitsByScore(...,ScoreType::QVAL) so the cutoff is always applied to the q-value, even when the user selects -score_type svm or pep as the main hit score. The q-value is found via the MS:1001491 meta value that both backends stamp on every rescored hit. Supersedes 15be39b, which rejected svm/pep score types outright; that was too strict — users want svm/PEP as the displayed main score while still applying a q-value FDR cutoff. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/topp/PercolatorAdapter.cpp (1)
366-371:⚠️ Potential issue | 🟡 MinorUse
\ninstead ofstd::endlin post-filter logs.Line 367 and Line 371 still use
std::endl, which forces a flush and violates repo logging guidance.Suggested patch
- OPENMS_LOG_INFO << "Applied score:fdr cutoff " << score_fdr - << "; remaining peptide identifications: " << all_peptide_ids.size() << std::endl; + OPENMS_LOG_INFO << "Applied score:fdr cutoff " << score_fdr + << "; remaining peptide identifications: " << all_peptide_ids.size() << "\n"; ... - OPENMS_LOG_WARN << "score:fdr cutoff " << score_fdr << " dropped all PSMs. " - << "Output will contain no peptide identifications." << std::endl; + OPENMS_LOG_WARN << "score:fdr cutoff " << score_fdr << " dropped all PSMs. " + << "Output will contain no peptide identifications.\n";As per coding guidelines, "Avoid
std::endlfor performance reasons; prefer\nfor logging and output".#!/bin/bash # Verify std::endl usage in the post-filter block and file-wide. sed -n '348,380p' src/topp/PercolatorAdapter.cpp | nl -ba rg -n '\bstd::endl\b' src/topp/PercolatorAdapter.cpp🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/PercolatorAdapter.cpp` around lines 366 - 371, The two logging statements using OPENMS_LOG_INFO and OPENMS_LOG_WARN around the post-filter messages (which reference score_fdr and all_peptide_ids) use std::endl and should be changed to use '\n' instead; update the two occurrences in the block that logs "Applied score:fdr cutoff ..." and "score:fdr cutoff ... dropped all PSMs." so they end with '\n' (not std::endl) to avoid forced flushes and follow repo logging guidance.
🤖 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/topp/PercolatorAdapter.cpp`:
- Around line 366-371: The two logging statements using OPENMS_LOG_INFO and
OPENMS_LOG_WARN around the post-filter messages (which reference score_fdr and
all_peptide_ids) use std::endl and should be changed to use '\n' instead; update
the two occurrences in the block that logs "Applied score:fdr cutoff ..." and
"score:fdr cutoff ... dropped all PSMs." so they end with '\n' (not std::endl)
to avoid forced flushes and follow repo logging guidance.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e8376ea5-e9f6-4c3b-a004-781e0c26d2d5
📒 Files selected for processing (1)
src/topp/PercolatorAdapter.cpp
Added entries for: - Perf: BrukerTimsFile FrameAggregator boost::unordered_flat_map (#9243) - Native .featureparquet and .consensusparquet formats (#9242) - IsobaricWorkflow: .idparquet and .mzId input support (#9241) - IDMerger: fix preserved input file order (#9240) - PercolatorAdapter: fix in-process post-filter (#9240) - IDRipper: .idparquet input/output support (#9237) - ProteomicsLFQ: .idparquet and .mzId input support (#9236) - FileTypes::FEATUREPARQUET, FileTypes::CONSENSUSPARQUET in Library section (#9242) Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Added entries for: - IDRipper .idparquet input/output support (#9237) - FEATUREPARQUET and CONSENSUSPARQUET file types (#9242) - BrukerTimsFile FrameAggregator perf improvement with boost::unordered_flat_map (#9243) - PercolatorAdapter: fix post-filters on in-process backend (#9240) - IDMerger: fix input file order preservation (#9240) - ProteomicsLFQ: .idparquet/.mzId input support (#9236) - IsobaricWorkflow: .idparquet/.mzId input support (#9241) - wnetalign/wnet/pylmcf FetchContent dependencies (#8992) - OpenMS Library: FileTypes::FEATUREPARQUET/CONSENSUSPARQUET (#9242) - OpenMS Library: FeatureGroupingAlgorithmWNet and WNetMatcher (#8992) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: timosachsenberg <[email protected]>
Six follow-ups landing on develop after the squash-merge of #9232:
IDMerger insertion-order preservation (
fix(IDMerger): preserve input file order …).Replaces
std::map<String, ProteinIdentification>(alphabetical, with rbegin/rend in the add_to branch) with astd::vector<String>+unordered_mapso merged runs come out in first-seen order. Load-bearing for IDRipper (feat(IDRipper): split merged .idparquet into per-run .idparquet outputs #9237) and any downstream tool that expects "first run in equals first run out".Percolator in-process post-filter (
fix(PercolatorAdapter): apply -score:fdr and -best_per_spectrum_only on in-process path).The vendored in-process backend (feat(Percolator): in-process backend (vendored library + TRON solver) #9218) returned EXECUTION_OK before reaching the post-filter logic the subprocess path runs, so the two backends silently produced different output. Extracted into
applyPostFilters_, now called by both paths.QPXFile::importFromArrowvalidation (fix(QPXFile): validate schema even for null/empty tables).Used to bail with success on
(!table || num_rows == 0)before any schema check; nownullptr → false, schema is validated regardless of row count, andnum_rows == 0returns success only after a successful validation.FileHandler_testtighter idparquet asserts (test(FileHandler): tighten idparquet round-trip assertions).Was checking only container sizes; now also verifies identifier, score_type, hit sequence/charge/score round-trip.
Adapter -out doc clarity (
docs(adapters): clarify -out is a directory bundle for .idparquet).Sage/Comet/MSGFPlus -out help text used to say "Single output file" / "Output file"; now mentions both file and directory shapes.
Floor-div for negative sub-second timestamps in
ProteinIdentificationArrowIO(fix(idparquet): floor-div sub-second negative timestamps).Truncating integer division turned raw = -500 ms into 0 s and silently rendered as 1970-01-01. Floor division now rejects it. Realistic proteomics timestamps are post-1970 so this is unobservable in production data, but the code is correct now.
Out of scope (deferred)
TOPP_PercolatorAdapter_score_fdr. Investigated; the IDFilter-idempotency approach has fragile structural noise, and on a clean-Percolator binary mismatch the output has 0 hits so there's nothing to validate against. Worth revisiting once a deterministic Percolator-output fixture exists in the repo.Test plan
ctest -R "TOPP_IDMerger|TOPP_IDRipper|QPXFile|PSMArrowIO|ConsensusMapArrow|FeatureMapArrow|TOPP_PercolatorAdapter|FileHandler_test"— all pass.IDRipper_3_output.idXMLreference regenerated to reflect the corrected (insertion-order) IDMerger output; downstream_out1/_out2diffs against the original inputs still pass.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation
Refactor
Tests