Repository navigation
ProSE: multi-format Parquet output (idXML + QPX + internal) - #9146
timosachsenberg merged 13 commits into
Conversation
…rquet export Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…arch engine output Adds exportToArrow/exportToParquet overloads taking vector<ProteinIdentification> + PeptideIdentificationList instead of ConsensusMap. Quantification columns (intensities, additional_intensities) are null; peptides field is populated from PeptideEvidence counts; run_file_name from getPrimaryMSRunPath(). Uses QPXPgSchema::schema() as target schema and returns empty table (never nullptr) when no groups are present. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…uet with per-file and merged output - Replace single -out file list (auto-detected idXML/parquet) with three dedicated output parameters: -out_idxml (per-file idXML), -out_qpx (QPX exchange format Parquet directory), -out_parquet (OpenMS internal Parquet directory) - -out_idxml requires same count as -in; -out_qpx and -out_parquet require unique input basenames to avoid collisions - Per-file QPX output: <basename>.psm.parquet (QPXPSMSchema) and <basename>.pg.parquet (QPXPgSchema) via QPXFile and ProteinGroupArrowExport - Per-file internal output: <basename>.psm/proteins/pg/search_params.parquet via QPXFile::exportToArrow + ProteinIdentificationArrowIO - Merged output: quantms.psm/pg.parquet (QPX) and openms.psm/proteins/pg/ search_params.parquet (internal) via arrow::ConcatenateTables + ZSTD compression, 128 MB row groups - Add includes for Arrow/Parquet, ProteinGroupArrowExport, ProteinIdentificationArrowIO, ArrowSchemaRegistry, and <set> Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… output test Replace all -out with -out_idxml in TOPP_ProSE_1/2/4 and DDA tests. Rewrite TOPP_ProSE_3_multi to use the new -out_idxml parameter (no more duplicate-basename multi-file list), and add TOPP_ProSE_3_qpx smoke tests that verify .psm.parquet, .pg.parquet and quantms.psm.parquet are written to the output directory. Update ProSE_1.ini, ProSE_2.ini, ProSE_4.ini to rename the 'out' item to 'out_idxml' (required=false, matching the new API). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…roupArrowExport Adds three new test sections to QPXFile_test.cpp: - QPXPgSchema::schema() verifying 20 fields and nullable/non-nullable constraints - ProteinGroupArrowExport::exportToArrow with one protein group (checks run_file_name, anchor_protein, null intensities) - ProteinGroupArrowExport::exportToArrow with empty groups (expects 0-row table) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The registerOutputFileList_ parameter requires <ITEMLIST> in the ini files, not <ITEM>. Without this fix, ProSE rejects the ini with "Parameter 'out_idxml' has changed value type!". Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdded a QPX protein‑group Arrow schema (QPXPgSchema), ID-based Arrow/Parquet protein‑group export overloads, shared Arrow I/O helpers for Parquet, QPX export refactors to use those helpers, ProSE CLI/output changes for separate idXML/QPX/Parquet outputs, and tests for the new schema and exports. All changes are additive. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as "ProSE CLI"
participant Export as "ProteinGroupArrowExport"
participant Schema as "QPXPgSchema"
participant IO as "ArrowIOHelpers"
participant FS as "Filesystem / Parquet writer"
CLI->>Export: exportToParquet(protein_ids, peptide_ids, filename, config)
Export->>Schema: schema()
Export->>Export: build Arrow Table (groups, peptides, counts, nulls)
Export->>Export: attachQPXPgMetadata(table)
Export->>IO: writeTableToParquet(table_with_metadata, filename, config)
IO->>FS: open FileOutputStream(filename)
IO->>FS: parquet::arrow::WriteTable(table, writer_props, ostream)
FS-->>IO: write status
IO-->>Export: return success/failure
Export-->>CLI: return status
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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. Comment |
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/topp/ProSE.cpp (1)
5-6:⚠️ Potential issue | 🟡 MinorMissing
$Maintainer:$and$Authors:$values.The file preamble markers are empty. As per coding guidelines, each source file must contain the
$Maintainer:$marker with a value.Suggested fix
-// $Maintainer: $ -// $Authors: $ +// $Maintainer: Timo Sachsenberg $ +// $Authors: Timo Sachsenberg $🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/ProSE.cpp` around lines 5 - 6, The file header in ProSE.cpp contains empty preamble markers; update the file's top-of-file comment to fill in the $Maintainer:$ field (and optionally $Authors:$) with the appropriate maintainer name/email per project policy so the $Maintainer:$ marker is non-empty; edit the existing "$Maintainer: $" and "$Authors: $" lines in src/topp/ProSE.cpp to include the correct values.
🧹 Nitpick comments (2)
src/topp/ProSE.cpp (1)
450-472: Consider atomic output handling for QPX directory.If the PSM parquet write succeeds (line 455) but the PG parquet write fails (line 465), a partial output is left in the QPX directory. This may cause confusion for downstream tools expecting both files.
Consider either:
- Writing both files to temp locations first, then moving on success
- Cleaning up the PSM file on PG failure
This is a minor reliability concern given the clear error logging.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/ProSE.cpp` around lines 450 - 472, The current QPX output logic can leave a partial PSM parquet if ProteinGroupArrowExport::exportToParquet fails; modify the block around QPXFile::exportToParquet and ProteinGroupArrowExport::exportToParquet so both files are written atomically: write qpx_psm_file and qpx_pg_file to temporary paths first (e.g., qpx_psm_file + ".tmp", qpx_pg_file + ".tmp"), only move/rename them to their final names after both exports succeed, and only push qpx_psm_table/qpx_pg_table into qpx_psm_tables/qpx_pg_tables after the moves succeed; alternatively, if you prefer minimal change, on ProteinGroupArrowExport::exportToParquet failure delete the already-written qpx_psm_file (and avoid pushing its table) before incrementing failed_count to prevent partial output.src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (1)
578-932: Consider extracting shared helpers to reduce complexity and duplication.This method is flagged as complex (~350 lines). While the complexity is inherent to Arrow builder initialization, there are opportunities to improve:
UUID generation (lines 950-968) is duplicated from the ConsensusMap overload (lines 486-503). Extract to a helper function.
Parquet writing configuration (lines 990-1026) mirrors the existing overload (lines 528-558). Extract a shared
writeArrowTableToParquethelper.This would reduce duplication and make both methods easier to maintain.
Suggested helper extraction
// In a shared location or as a private helper: namespace { std::string generateUUID() { std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<uint32_t> dist; uint8_t bytes[16]; for (int i = 0; i < 4; ++i) { uint32_t r = dist(gen); std::memcpy(bytes + i * 4, &r, 4); } bytes[6] = (bytes[6] & 0x0F) | 0x40; bytes[8] = (bytes[8] & 0x3F) | 0x80; char buf[37]; std::snprintf(buf, sizeof(buf), "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]); return std::string(buf); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 578 - 932, The exportToArrow method in ProteinGroupArrowExport is very large and duplicates logic (UUID generation and Parquet write config) present in the ConsensusMap overload; extract shared helpers to reduce duplication and complexity: add a private/static helper like generateUUID() (use the same RNG/format logic currently duplicated) and move Parquet writing code into a shared writeArrowTableToParquet(const arrow::Table&, const std::string& filename, const ParquetOptions&?) helper, then replace the duplicated blocks in ProteinGroupArrowExport::exportToArrow and the ConsensusMap overload with calls to generateUUID() and writeArrowTableToParquet(...) to centralize behavior and simplify the method.
🤖 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/tests/topp/CMakeLists.txt`:
- Around line 2931-2945: Add a parallel smoke test for the merged
quantms.pg.parquet file: create an add_test named
"TOPP_ProSE_3_qpx_merged_pg_exists" that runs ${CMAKE_COMMAND} -E sha256sum on
${TESTS_TEMP_DIR}/ProSE_3_qpx_dir/quantms.pg.parquet and then call
set_tests_properties to make it DEPENDS on the existing "TOPP_ProSE_3_qpx" test
(mirroring the existing "TOPP_ProSE_3_qpx_merged_exists" check for
quantms.psm.parquet); locate this next to the other ProSE QPX existence checks
in the same block.
---
Outside diff comments:
In `@src/topp/ProSE.cpp`:
- Around line 5-6: The file header in ProSE.cpp contains empty preamble markers;
update the file's top-of-file comment to fill in the $Maintainer:$ field (and
optionally $Authors:$) with the appropriate maintainer name/email per project
policy so the $Maintainer:$ marker is non-empty; edit the existing "$Maintainer:
$" and "$Authors: $" lines in src/topp/ProSE.cpp to include the correct values.
---
Nitpick comments:
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 578-932: The exportToArrow method in ProteinGroupArrowExport is
very large and duplicates logic (UUID generation and Parquet write config)
present in the ConsensusMap overload; extract shared helpers to reduce
duplication and complexity: add a private/static helper like generateUUID() (use
the same RNG/format logic currently duplicated) and move Parquet writing code
into a shared writeArrowTableToParquet(const arrow::Table&, const std::string&
filename, const ParquetOptions&?) helper, then replace the duplicated blocks in
ProteinGroupArrowExport::exportToArrow and the ConsensusMap overload with calls
to generateUUID() and writeArrowTableToParquet(...) to centralize behavior and
simplify the method.
In `@src/topp/ProSE.cpp`:
- Around line 450-472: The current QPX output logic can leave a partial PSM
parquet if ProteinGroupArrowExport::exportToParquet fails; modify the block
around QPXFile::exportToParquet and ProteinGroupArrowExport::exportToParquet so
both files are written atomically: write qpx_psm_file and qpx_pg_file to
temporary paths first (e.g., qpx_psm_file + ".tmp", qpx_pg_file + ".tmp"), only
move/rename them to their final names after both exports succeed, and only push
qpx_psm_table/qpx_pg_table into qpx_psm_tables/qpx_pg_tables after the moves
succeed; alternatively, if you prefer minimal change, on
ProteinGroupArrowExport::exportToParquet failure delete the already-written
qpx_psm_file (and avoid pushing its table) before incrementing failed_count to
prevent partial output.
🪄 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: a9f09b97-4dd6-48f4-918e-108fa85bac1e
📒 Files selected for processing (10)
src/openms/include/OpenMS/FORMAT/ArrowSchemaRegistry.hsrc/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport.hsrc/openms/source/FORMAT/ArrowSchemaRegistry.cppsrc/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/tests/class_tests/openms/source/QPXFile_test.cppsrc/tests/topp/CMakeLists.txtsrc/tests/topp/ProSE_1.inisrc/tests/topp/ProSE_2.inisrc/tests/topp/ProSE_4.inisrc/topp/ProSE.cpp
Add ArrowIOHelpers namespace with public writeTableToParquet and concatenateAndWriteToParquet helpers. Arrow and Parquet symbols are now contained inside libOpenMS — TOPP executables on Windows no longer need to link against Arrow/Parquet directly (MSVC dllimport model doesn't re-export dependencies). Also fill in empty $Maintainer:$ and $Authors:$ markers in ProSE.cpp. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/topp/ProSE.cpp (1)
427-436: Optional: Reduce duplicate Arrow table creation.The code calls
exportToParquet(line 429) then separately creates the Arrow table withexportPSMsToQPXArrow(line 434). Consider creating the table first, writing it to Parquet, then accumulating it—avoiding redundant serialization.Example optimization
// PSM const String qpx_psm_file = out_qpx_dir + "/" + basename + ".psm.parquet"; - if (!QPXFile::exportToParquet(result.protein_ids, result.peptide_ids, qpx_psm_file, /*export_all_psms=*/false)) + auto qpx_psm_table = QPXFile::exportPSMsToQPXArrow(result.protein_ids, result.peptide_ids, /*export_all_psms=*/false); + if (!qpx_psm_table || !ArrowIOHelpers::writeTableToParquet(qpx_psm_table, qpx_psm_file)) { OPENMS_LOG_ERROR << "Failed to write QPX PSM parquet for " << in_file << endl; ++failed_count; continue; } - auto qpx_psm_table = QPXFile::exportPSMsToQPXArrow(result.protein_ids, result.peptide_ids, /*export_all_psms=*/false); - if (qpx_psm_table) qpx_psm_tables.push_back(qpx_psm_table); + qpx_psm_tables.push_back(qpx_psm_table);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/ProSE.cpp` around lines 427 - 436, The code currently calls QPXFile::exportToParquet(...) and then separately calls QPXFile::exportPSMsToQPXArrow(...), causing duplicate work; instead, first build the Arrow table with QPXFile::exportPSMsToQPXArrow(result.protein_ids, result.peptide_ids, /*export_all_psms=*/false) into qpx_psm_table, check for null, then write that table to the parquet file (qpx_psm_file) rather than calling exportToParquet with the raw ids; finally push qpx_psm_table into qpx_psm_tables only once. If there is no existing API to write an Arrow table to parquet, add or use a helper that accepts the Arrow table and qpx_psm_file so you avoid rebuilding the table twice.src/openms/source/FORMAT/ArrowIOHelpers.cpp (1)
45-56: Consider replacingstd::endlwith"\n"for performance.Per coding guidelines, prefer
"\n"overstd::endlto avoid unnecessary buffer flushes. This applies to lines 47, 54-55, 84-85, 92-93, and 110-111.Example fix for one instance
if (!table) { - OPENMS_LOG_ERROR << "ArrowIOHelpers: null table passed to writeTableToParquet (" << filename << ")" << std::endl; + OPENMS_LOG_ERROR << "ArrowIOHelpers: null table passed to writeTableToParquet (" << filename << ")\n"; return false; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/ArrowIOHelpers.cpp` around lines 45 - 56, Replace usages of std::endl with "\n" in ArrowIOHelpers.cpp to avoid unnecessary flushes: in the writeTableToParquet function change the OPENMS_LOG_ERROR calls that log the null table (message with filename), the file_result.status() error, and similarly replace std::endl in the subsequent OPENMS_LOG_ERROR lines that report writer_result.status() and close_result.status(); search for OPENMS_LOG_ERROR occurrences in ArrowIOHelpers::writeTableToParquet (and adjacent logging statements using filename, file_result, writer_result, close_result) and swap std::endl for "\n" consistently.
🤖 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/ProSE.cpp`:
- Around line 497-511: The calls to ArrowIOHelpers::concatenateAndWriteToParquet
(used for qpx_psm_tables, qpx_pg_tables, oms_psm_tables, oms_prot_tables,
oms_pg_tables, oms_sp_tables) currently ignore return values; change the block
so each call's boolean result is checked, log a descriptive error via the
existing logger if any call fails, aggregate failures into a single flag (e.g.,
wroteMergedFilesOK or mergeFailure), and ensure the function returns a
non-EXECUTION_OK status (or sets the appropriate non-zero exit/return code) when
any write fails; apply this to both the out_qpx_dir and out_parquet_dir branches
so incomplete merged outputs cause the process to fail.
---
Nitpick comments:
In `@src/openms/source/FORMAT/ArrowIOHelpers.cpp`:
- Around line 45-56: Replace usages of std::endl with "\n" in ArrowIOHelpers.cpp
to avoid unnecessary flushes: in the writeTableToParquet function change the
OPENMS_LOG_ERROR calls that log the null table (message with filename), the
file_result.status() error, and similarly replace std::endl in the subsequent
OPENMS_LOG_ERROR lines that report writer_result.status() and
close_result.status(); search for OPENMS_LOG_ERROR occurrences in
ArrowIOHelpers::writeTableToParquet (and adjacent logging statements using
filename, file_result, writer_result, close_result) and swap std::endl for "\n"
consistently.
In `@src/topp/ProSE.cpp`:
- Around line 427-436: The code currently calls QPXFile::exportToParquet(...)
and then separately calls QPXFile::exportPSMsToQPXArrow(...), causing duplicate
work; instead, first build the Arrow table with
QPXFile::exportPSMsToQPXArrow(result.protein_ids, result.peptide_ids,
/*export_all_psms=*/false) into qpx_psm_table, check for null, then write that
table to the parquet file (qpx_psm_file) rather than calling exportToParquet
with the raw ids; finally push qpx_psm_table into qpx_psm_tables only once. If
there is no existing API to write an Arrow table to parquet, add or use a helper
that accepts the Arrow table and qpx_psm_file so you avoid rebuilding the table
twice.
🪄 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: a5863926-1ae1-43ef-82be-aeb14ef8bf12
📒 Files selected for processing (4)
src/openms/include/OpenMS/FORMAT/ArrowIOHelpers.hsrc/openms/source/FORMAT/ArrowIOHelpers.cppsrc/openms/source/FORMAT/sources.cmakesrc/topp/ProSE.cpp
Behavioral fixes (code-reviewer and CodeRabbit):
* ProteinGroupArrowExport (id-only overload):
- peptide_counts.unique_sequences now uses the union of peptide sequences
across all group members (previously used anchor protein only, silently
undercounting non-anchor contributions)
- gg_accessions / gg_names are now emitted once per group member so they
stay positionally aligned with pg_accessions (previously skipped when
neither gene meta-value existed, breaking cardinality)
* ProSE output loop:
- idXML write wrapped in try/catch; failures now increment failed_count
(previously throws propagated uncaught, no per-file tracking)
- A failure in one output mode no longer skips sibling modes for the
same input (previously "++failed_count; continue;" meant a QPX
failure would cancel -out_parquet output for that input)
- nullptr Arrow tables from exporters now log a warning instead of
being silently skipped
- Stale "-out" references in the -out_merged help text and code
comments replaced with the new parameter names
Refactor:
* Both ProteinGroupArrowExport::exportToParquet overloads (ConsensusMap
and identification-only) now delegate to ArrowIOHelpers::writeTableToParquet
and share a new file-local attachQPXPgMetadata() helper. Removes ~170
lines of byte-identical duplication (UUID generation, Parquet writer
configuration) and drops direct <parquet/*.h> / <random> / <cstring>
includes from the translation unit.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…d pg test * ArrowIOHelpers::generateUuidV4() — shared RFC 4122 v4 UUID generation previously duplicated in QPXFile and ProteinGroupArrowExport. Exposed as public API so QPX Parquet exporters can share one implementation. * QPXFile_test.cpp — extend the ProteinGroupArrowExport identification-only test with content assertions: is_decoy, global_qvalue (carries group.probability), peptides list parallel to pg_accessions, peptide_counts (unique + total_sequences), gg_accessions and gg_names cardinality. Catches the two bugs fixed in the previous commit. * CMakeLists.txt — add TOPP_ProSE_3_qpx_merged_pg_exists smoke test for quantms.pg.parquet, mirroring the existing quantms.psm.parquet check. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
concatenateAndWriteToParquet return values were previously ignored, so a failed merge would leave ProSE reporting EXECUTION_OK despite incomplete output. Thread the return values into a merged_ok flag and escalate to INTERNAL_ERROR on failure. Addresses CodeRabbit review comment on src/topp/ProSE.cpp. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/topp/ProSE.cpp (1)
441-454: Build QPX PSM table once instead of twice.
QPXFile::exportToParquet()internally callsexportPSMsToQPXArrow()to build the table before writing the file. The code then callsexportPSMsToQPXArrow()again immediately after to accumulate the table. This duplicates table construction for identical parameters.Build the table once and reuse it for both file write and accumulation:
Suggested approach
- const String qpx_psm_file = out_qpx_dir + "/" + basename + ".psm.parquet"; - if (QPXFile::exportToParquet(result.protein_ids, result.peptide_ids, qpx_psm_file, /*export_all_psms=*/false)) - { - auto qpx_psm_table = QPXFile::exportPSMsToQPXArrow(result.protein_ids, result.peptide_ids, /*export_all_psms=*/false); - if (qpx_psm_table) { qpx_psm_tables.push_back(qpx_psm_table); } + const String qpx_psm_file = out_qpx_dir + "/" + basename + ".psm.parquet"; + auto qpx_psm_table = QPXFile::exportPSMsToQPXArrow(result.protein_ids, result.peptide_ids, /*export_all_psms=*/false); + if (qpx_psm_table) + { + qpx_psm_tables.push_back(qpx_psm_table); + if (!ArrowIOHelpers::writeTableToParquet(qpx_psm_table, qpx_psm_file)) + { + OPENMS_LOG_ERROR << "Failed to write QPX PSM parquet for " << in_file << " -> " << qpx_psm_file << endl; + input_failed = true; + } + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/ProSE.cpp` around lines 441 - 454, The code currently calls QPXFile::exportToParquet(...) which internally builds the PSM Arrow table and then immediately calls QPXFile::exportPSMsToQPXArrow(...) again, duplicating work; change the flow to call exportPSMsToQPXArrow(result.protein_ids, result.peptide_ids, /*export_all_psms=*/false) once into a local qpx_psm_table, then pass that table (or a path) into exportToParquet so the file write reuses the already-built table; ensure you preserve the existing error handling: if qpx_psm_table is null set input_failed and log the warning/error, otherwise write the parquet to qpx_psm_file and push qpx_psm_table into qpx_psm_tables.src/tests/topp/CMakeLists.txt (1)
2919-2919: Clarify the outdated “Multi-file test” wording.Line 2919 now describes a single-input run, so the comment text is misleading and may confuse future maintenance.
✏️ Suggested wording-only patch
-# Multi-file test: single-file idXML output +# Single-file idXML output regression test🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/topp/CMakeLists.txt` at line 2919, The comment "# Multi-file test: single-file idXML output" is misleading because the test is a single-input run; update that comment text to clearly state it's a single-file/single-input test (for example "Single-file test: single-input idXML output" or "Single-input test: single-file idXML output") so future readers understand the test scope; locate the existing comment string in CMakeLists and replace it accordingly (search for the exact comment "# Multi-file test: single-file idXML output").src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (2)
571-579: Consider adding assertions for type casts.The
dynamic_pointer_castcalls dereference directly without null checks. While the QPXPgSchema types are currently all list types, adding assertions would catch schema definition errors early:auto intensities_type = std::dynamic_pointer_cast<arrow::ListType>(QPXPgSchema::intensitiesType()); assert(intensities_type && "Expected intensitiesType to be ListType"); auto intensities_value_type = intensities_type->value_type();This pattern repeats at lines 582, 601, 627, and 638.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 571 - 579, The code uses std::dynamic_pointer_cast on QPXPgSchema::intensitiesType() (and similar schema accessors) without checking for null; add assertions after each dynamic_pointer_cast to ensure the cast succeeded (e.g., assert(intensities_type && "Expected intensitiesType to be ListType")) before calling ->value_type(), and apply the same pattern for the other casts referenced in the review (the casts at the locations around lines 582, 601, 627, 638) so the builders (e.g., intensities_builder, and other List/Struct builders) never dereference a null pointer.
244-260: Inconsistency with id-only version: gg_accessions/gg_names cardinality.The ConsensusMap version only appends to
gg_accessions/gg_nameswhen gene info exists (if (has_ga || has_gn)), creating lists that may be shorter thanpg_accessions. However, the new id-only version (lines 690-702) always appends an entry per group member to preserve cardinality. This inconsistency could cause issues for consumers expecting parallel lists.Consider applying the same fix here for consistency:
♻️ Proposed fix to match id-only version behavior
// gg_accessions, gg_names (keep lists symmetric so they can be zipped) (void)gg_accessions_builder.Append(); (void)gg_names_builder.Append(); for (const auto& acc : group.accessions) { auto it = hit_lookup.find(acc); - if (it != hit_lookup.end()) - { - bool has_ga = it->second->metaValueExists("gene_accession"); - bool has_gn = it->second->metaValueExists("gene_name"); - if (has_ga || has_gn) - { - (void)gg_acc_vb->Append(has_ga ? it->second->getMetaValue("gene_accession").toString() : ""); - (void)gg_names_vb->Append(has_gn ? it->second->getMetaValue("gene_name").toString() : ""); - } - } + bool has_ga = (it != hit_lookup.end()) && it->second->metaValueExists("gene_accession"); + bool has_gn = (it != hit_lookup.end()) && it->second->metaValueExists("gene_name"); + (void)gg_acc_vb->Append(has_ga ? it->second->getMetaValue("gene_accession").toString() : ""); + (void)gg_names_vb->Append(has_gn ? it->second->getMetaValue("gene_name").toString() : ""); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 244 - 260, The gg_accessions/gg_names lists must preserve one entry per group member like the id-only version; change the loop in ProteinGroupArrowExport so that for each acc in group.accessions you always append to gg_acc_vb and gg_names_vb (use empty string when gene_accession or gene_name is missing) rather than only appending when (has_ga || has_gn); update the logic around gg_accessions_builder/gg_names_builder and the loop that references hit_lookup, has_ga/has_gn, gg_acc_vb and gg_names_vb to append per-member empty or actual values to keep cardinality aligned with pg_accessions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 571-579: The code uses std::dynamic_pointer_cast on
QPXPgSchema::intensitiesType() (and similar schema accessors) without checking
for null; add assertions after each dynamic_pointer_cast to ensure the cast
succeeded (e.g., assert(intensities_type && "Expected intensitiesType to be
ListType")) before calling ->value_type(), and apply the same pattern for the
other casts referenced in the review (the casts at the locations around lines
582, 601, 627, 638) so the builders (e.g., intensities_builder, and other
List/Struct builders) never dereference a null pointer.
- Around line 244-260: The gg_accessions/gg_names lists must preserve one entry
per group member like the id-only version; change the loop in
ProteinGroupArrowExport so that for each acc in group.accessions you always
append to gg_acc_vb and gg_names_vb (use empty string when gene_accession or
gene_name is missing) rather than only appending when (has_ga || has_gn); update
the logic around gg_accessions_builder/gg_names_builder and the loop that
references hit_lookup, has_ga/has_gn, gg_acc_vb and gg_names_vb to append
per-member empty or actual values to keep cardinality aligned with
pg_accessions.
In `@src/tests/topp/CMakeLists.txt`:
- Line 2919: The comment "# Multi-file test: single-file idXML output" is
misleading because the test is a single-input run; update that comment text to
clearly state it's a single-file/single-input test (for example "Single-file
test: single-input idXML output" or "Single-input test: single-file idXML
output") so future readers understand the test scope; locate the existing
comment string in CMakeLists and replace it accordingly (search for the exact
comment "# Multi-file test: single-file idXML output").
In `@src/topp/ProSE.cpp`:
- Around line 441-454: The code currently calls QPXFile::exportToParquet(...)
which internally builds the PSM Arrow table and then immediately calls
QPXFile::exportPSMsToQPXArrow(...) again, duplicating work; change the flow to
call exportPSMsToQPXArrow(result.protein_ids, result.peptide_ids,
/*export_all_psms=*/false) once into a local qpx_psm_table, then pass that table
(or a path) into exportToParquet so the file write reuses the already-built
table; ensure you preserve the existing error handling: if qpx_psm_table is null
set input_failed and log the warning/error, otherwise write the parquet to
qpx_psm_file and push qpx_psm_table into qpx_psm_tables.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 709257a5-67a3-4212-af28-fb87b9632917
📒 Files selected for processing (6)
src/openms/include/OpenMS/FORMAT/ArrowIOHelpers.hsrc/openms/source/FORMAT/ArrowIOHelpers.cppsrc/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/tests/class_tests/openms/source/QPXFile_test.cppsrc/tests/topp/CMakeLists.txtsrc/topp/ProSE.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/source/FORMAT/ArrowIOHelpers.cpp
ProSE previously built each QPX table twice per input — once inside QPXFile::exportToParquet / ProteinGroupArrowExport::exportToParquet and once again via exportPSMsToQPXArrow / exportToArrow to accumulate for the merged output. CodeRabbit flagged this repeatedly. Add a table-taking overload to each exporter that attaches QPX file metadata and delegates to ArrowIOHelpers::writeTableToParquet. ProSE now builds each table once, writes it via the new overload, and reuses the same table for merge concatenation. Also consolidates QPXFile's in-line UUID generation and Parquet writer setup into the same shared helpers already used by ProteinGroupArrowExport, removing ~100 lines of duplication. Addresses CodeRabbit nitpicks on src/topp/ProSE.cpp at lines 427-436 and 441-454. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Previous commit added a second exportToParquet overload that takes a pre-built arrow::Table. nanobind can't resolve the pointer-to-member without an explicit cast, so the binding file must use static_cast to pick the existing (protein_ids, peptide_ids, filename, ...) overload. The new table-taking overload is not wrapped (arrow::Table is not a pyOpenMS type). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/openms/include/OpenMS/FORMAT/QPXFile.h (1)
91-107: Document the failure/exception contract for this new public overload.The Doxygen block explains the expected table type, but it does not tell callers what happens on null input or write-time failures. Please document the return/error behavior and any exception policy alongside the new API.
As per coding guidelines, "Document possible exceptions in C++ function/method documentation".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/FORMAT/QPXFile.h` around lines 91 - 107, The Doxygen for the new static method exportToParquet(const std::shared_ptr<arrow::Table>& table, const String& filename, const ParquetWriteConfig& config) is missing the failure/exception contract; update the comment to state behavior when table is null (e.g., returns false and logs error or throws std::invalid_argument), what happens on write-time failures (returns false on IO/Parquet errors and/or throws specific exceptions), and whether the function may throw (list exception types such as std::invalid_argument, std::runtime_error or Arrow/Parquet exceptions) or guarantees no exceptions and uses return=false on error; explicitly document the return value (true on success, false on recoverable error) and any side-effects (metadata attached, file creation/updating) so callers know how to handle null inputs and write failures when calling exportToParquet.
🤖 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/ProteinGroupArrowExport.cpp`:
- Around line 523-561: The export currently uses protein_identifications[0]
(prot_id) and a single acc_to_peptides map, causing peptides and run-scoping to
be collapsed; change the logic to iterate over each ProteinIdentification (use
getIdentifier() to key per-identification), derive run_file per-identification
via getPrimaryMSRunPath on that ProteinIdentification, and maintain a separate
acc_to_peptides map scoped to that identifier (e.g., a map<string,
unordered_map<string, unordered_set<string>>> or process each
ProteinIdentification in its own loop). When scanning PeptideIdentification
entries, determine the matching ProteinIdentification by its identifier and pick
the best hit explicitly for each PeptideIdentification (do not assume
getHits()[0]; instead call a best-hit helper or sort/compare scores) before
recording peptide sequences into the acc_to_peptides for that particular
ProteinIdentification/identifier. Ensure subsequent code that builds rows uses
the per-identifier run_file and per-identifier acc_to_peptides rather than
prot_id/protein_identifications[0].
- Around line 659-851: The Reserve and Finish failure branches in
ProteinGroupArrowExport.cpp (e.g. calls on anchor_protein_builder,
run_file_name_builder, global_qvalue_builder, is_decoy_builder and the
corresponding Finish calls that now return
arrow::Table::MakeEmpty(target_schema).ValueOrDie()) must not be downgraded to
an empty table; change those error return paths to return nullptr so the caller
can detect a real export failure. Update every Reserve(...) and Finish(...)
error block that currently does "return
arrow::Table::MakeEmpty(target_schema).ValueOrDie();" to instead "return
nullptr;" while keeping the existing empty-table return only for the genuine
no-data case elsewhere.
In `@src/openms/source/FORMAT/QPXFile.cpp`:
- Around line 1357-1368: QPXFile::exportToParquet currently stamps any incoming
arrow::Table as QPX PSM by calling attachQPXPsmMetadata without verifying
schema, so add a strict schema check that the table matches QPXPSMSchema before
attaching metadata; if the schema does not match, log an error and return false.
Implement the guard in exportToParquet (use the same schema-checking logic as
exportToArrow's validations or a helper like isQPXPSMSchema(table->schema())),
then only call attachQPXPsmMetadata and ArrowIOHelpers::writeTableToParquet when
the check succeeds.
---
Nitpick comments:
In `@src/openms/include/OpenMS/FORMAT/QPXFile.h`:
- Around line 91-107: The Doxygen for the new static method
exportToParquet(const std::shared_ptr<arrow::Table>& table, const String&
filename, const ParquetWriteConfig& config) is missing the failure/exception
contract; update the comment to state behavior when table is null (e.g., returns
false and logs error or throws std::invalid_argument), what happens on
write-time failures (returns false on IO/Parquet errors and/or throws specific
exceptions), and whether the function may throw (list exception types such as
std::invalid_argument, std::runtime_error or Arrow/Parquet exceptions) or
guarantees no exceptions and uses return=false on error; explicitly document the
return value (true on success, false on recoverable error) and any side-effects
(metadata attached, file creation/updating) so callers know how to handle null
inputs and write failures when calling exportToParquet.
🪄 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: 253aa437-de00-4a44-9ee2-4675eba76298
📒 Files selected for processing (5)
src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport.hsrc/openms/include/OpenMS/FORMAT/QPXFile.hsrc/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/openms/source/FORMAT/QPXFile.cppsrc/topp/ProSE.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
- src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport.h
- src/topp/ProSE.cpp
* ProteinGroupArrowExport (id-only exportToArrow) now processes all entries in protein_identifications, not just [0]. For each prot_id, scope the run_file_name, hit_lookup, and peptide-to-protein map to that identifier (peptides routed via pep_id.getIdentifier() == prot_id.getIdentifier(), matching the pattern in QPXFile's PSM export). Previously, multi-run idXMLs silently dropped all protein groups after the first ProteinIdentification. * Arrow builder Reserve/Finish failures in the id-only overload now return nullptr instead of an empty table. Callers can now distinguish "no groups found" (still returns MakeEmpty for valid empty input) from real Arrow API failures. The existing ProSE caller already handles nullptr correctly. * QPXFile::exportToParquet(table, filename) and ProteinGroupArrowExport::exportToParquet(table, filename) now validate the input table's schema (strict match against QPXPSMSchema / QPXPgSchema respectively) before stamping it with QPX file_type metadata. Prevents misuse where, e.g., an internal PSMSchema table is passed to the QPX PSM overload and silently written with file_type="psm" despite mismatched columns. Addresses CodeRabbit review comments: - src/openms/source/FORMAT/ProteinGroupArrowExport.cpp L561 (scope) - src/openms/source/FORMAT/ProteinGroupArrowExport.cpp L851 (error sentinel) - src/openms/source/FORMAT/QPXFile.cpp L1368 (schema validation) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Updated ProSE multi-file search entry (#9109) to remove now-inaccurate reference to -out accepting file lists - Added BREAKING entry for ProSE output parameter overhaul (#9146): -out replaced by -out_idxml, -out_qpx, -out_parquet with per-file and merged QPX/internal Parquet output Co-authored-by: Copilot <[email protected]>
- Updated ProSE multi-file search entry (#9109) to remove now-inaccurate reference to -out accepting file lists - Added BREAKING entry for ProSE output parameter overhaul (#9146): -out replaced by -out_idxml, -out_qpx, -out_parquet with per-file and merged QPX/internal Parquet output Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
Extends ProSE to support three independent output formats with per-input and merged Parquet files:
-out_idxml(file list): per-input idXML output — replaces the old-outparameter (breaking change)-out_qpx(directory): QPX exchange format Parquet files (<basename>.psm.parquet,<basename>.pg.parquet, plus mergedquantms.*)-out_parquet(directory): OpenMS internal format Parquet files (PSM + proteins + protein groups + search params, plus mergedopenms.*)At least one output parameter must be specified. Directory outputs require unique input basenames.
Changes
QPXPgSchemaadded toArrowSchemaRegistry— matches quantmspg.yamlspec; quantification columns are nullable so search-engine-only output is valid (same approach as the quantms mzIdentML converter)ProteinGroupArrowExport— new overloadexportToArrow/exportToParquet(vector<ProteinIdentification>, PeptideIdentificationList)that writes QPXpg.parquetfrom search results without aConsensusMap. Derivesrun_file_namefromProteinIdentification::getPrimaryMSRunPath(). Returns empty table (nevernullptr) when no groups exist.ProSE.cpp— parameter rewiring + per-file output dispatch + post-loop merged concatenation viaarrow::ConcatenateTables-out_idxml; newTOPP_ProSE_3_qpxsmoke test for QPX directory output; unit tests forQPXPgSchemaand the newProteinGroupArrowExportoverloadBreaking Change
-outis removed (hard rename to-out_idxml, no deprecation alias). Downstream scripts and.inifiles using-outwill need to be updated.Test Plan
ctest -R TOPP_ProSE— all 14 tests pass (including new QPX directory test)ctest -R QPXFile_test— 7/7 sections pass (including new QPXPgSchema and ProteinGroupArrowExport tests)ctest -R ProteinIdentificationArrowIO_test— passes-out_qpxand-out_parqueton a real dataset, inspect Parquet files with pyarrow🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests
Chores