Repository navigation
[FIX] QPX 1.1: re-key the pg view onto grouped_runs, bump qpx_version (#9817) - #9843
Conversation
|
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:
📝 WalkthroughWalkthroughQPX exports now follow version 1.1. Protein-group rows use grouped runs and nullable scalar quantities. Quantification preserves fraction-group and label data. Collection preflight validates inputs before file creation. IsobaricWorkflow handles missing MS1 spectra safely. ChangesQPX 1.1 export flow
Sequence Diagram(s)sequenceDiagram
participant Workflow
participant QPXCollectionExport
participant ProteinGroupArrowExport
participant QPXParquetFiles
Workflow->>QPXCollectionExport: Validate the complete collection
QPXCollectionExport->>ProteinGroupArrowExport: Validate design and protein-group data
QPXCollectionExport-->>Workflow: Return exportability
Workflow->>QPXParquetFiles: Write feature, PSM, and protein-group files
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 (4)
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (1)
554-570: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low valueConsider applying the same null-versus-empty rule to
additional_intensities.The new comment states the rule clearly: null means "no quantification", and an empty list means "quantified across zero channels".
intensitiesnow follows that rule in both overloads.additional_intensitiesdoes not. The quantified overload appends an empty list on Line 574, while the identification-only overload appends null on Line 1309. Both are valid against the nullable schema field, so a consumer reading two QPXpg_fileoutputs sees two encodings for the same absence.Align the two producers on one encoding.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 554 - 570, Apply the same null-versus-empty encoding rule used for intensities to additional_intensities: update the quantified overload to append null when its channel map is empty, while preserving the nested list output for non-empty values and matching the identification-only overload.src/tests/class_tests/openms/source/QPXCollectionExport_test.cpp (1)
99-120: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
omit_rowis never used.Every call site passes only
paths, and the ragged-design section at Line 174 builds its ownMSFileSectioninline instead of using this helper. Remove the parameter, or use it in the ragged section to reduce the duplicated design construction.♻️ Proposed simplification
- /// A one-sample design over `@p` paths, optionally omitting one (path, label) row. - ExperimentalDesign makeDesign(const std::vector<std::string>& paths, int omit_row = -1) + /// A one-sample design over `@p` paths. + ExperimentalDesign makeDesign(const std::vector<std::string>& paths) { ExperimentalDesign::MSFileSection section; for (Size m = 0; m < paths.size(); ++m) { - if (static_cast<int>(m) == omit_row) { continue; } ExperimentalDesign::MSFileSectionEntry e;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/QPXCollectionExport_test.cpp` around lines 99 - 120, Remove the unused omit_row parameter from makeDesign and its conditional skip logic, since all callers provide only paths and the ragged-design construction is separate. Keep the existing design-building behavior unchanged for the remaining call sites.src/openms/source/FORMAT/QPXCollectionExport.cpp (1)
43-54: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAvoid copying all PSMs for
requireResolvableMergeIndicesin this preflight.
IsobaricWorkflowpassesQPXFile::exportToParquetStreamingits existingstd::vector<const PeptideIdentification*>, but this block copies every assigned and unassignedPeptideIdentificationintoPeptideIdentificationListbefore passing it toQPXFile::requireResolvableMergeIndices. Add/use a public pointer-based merge-index validation overload that delegates to the existing pointer overload, so the preflight can reject unexportable inputs without duplicating millions of PSMs.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/QPXCollectionExport.cpp` around lines 43 - 54, Update the preflight block in QPXCollectionExport to avoid constructing and populating the copied PeptideIdentificationList; expose or reuse a public pointer-based requireResolvableMergeIndices overload matching IsobaricWorkflow’s std::vector<const PeptideIdentification*> input, delegate it to the existing pointer validation, and pass collected peptide-identification pointers through the preflight while preserving validation of assigned and unassigned entries.src/tests/topp/CMakeLists.txt (1)
1012-1017: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding an output check for
TOPP_IsobaricWorkflow_1.
TOPP_IsobaricWorkflow_1runs the tool and writesIsobaricWorkflow_1_output.tmp.consensusXML, but no test compares that output. The test therefore only asserts a zero exit code. AFuzzyDiffcheck against a committed reference would catch quantification regressions in the iTRAQ4plex path.
TOPP_IsobaricWorkflow_2_no_preceding_ms1is a crash regression guard, so a bare run is sufficient there.♻️ Sketch of the added check
-out ${TESTS_TEMP_DIR}/IsobaricWorkflow_1_output.tmp.consensusXML -out_mzTab ${TESTS_TEMP_DIR}/IsobaricWorkflow_1_output.tmp.mzTab) +add_test("TOPP_IsobaricWorkflow_1_out1" ${DIFF} -whitelist "id=" "<map" "?xml-stylesheet" + -in1 ${TESTS_TEMP_DIR}/IsobaricWorkflow_1_output.tmp.consensusXML + -in2 ${DATA_DIR_TOPP}/IsobaricWorkflow_1_output.consensusXML) +set_tests_properties("TOPP_IsobaricWorkflow_1_out1" PROPERTIES DEPENDS "TOPP_IsobaricWorkflow_1")As per coding guidelines "TOPP tests must be registered in
src/tests/topp/CMakeLists.txt; use small test data andFuzzyDifffor numeric comparisons."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/topp/CMakeLists.txt` around lines 1012 - 1017, Extend the TOPP_IsobaricWorkflow_1 registration in CMakeLists.txt with a FuzzyDiff output comparison for IsobaricWorkflow_1_output.tmp.consensusXML against a committed reference file, while leaving TOPP_IsobaricWorkflow_2_no_preceding_ms1 as a run-only crash regression test.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/FORMAT/ConsensusMapArrowExport.cpp`:
- Around line 1326-1333: Reject duplicate ProteinIdentification::getIdentifier()
values before constructing any run mapper. In
ConsensusMapArrowExport::requireResolvableIdRuns, perform the uniqueness
validation before mapper.create(); apply the same preflight validation in
QPXFile.cpp before buildRunMapper() processes PSM merge indices. Update both
src/openms/source/FORMAT/ConsensusMapArrowExport.cpp:1326-1333 and
src/openms/source/FORMAT/QPXFile.cpp:145-150; preserve existing validation
behavior for unique identifiers.
---
Nitpick comments:
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 554-570: Apply the same null-versus-empty encoding rule used for
intensities to additional_intensities: update the quantified overload to append
null when its channel map is empty, while preserving the nested list output for
non-empty values and matching the identification-only overload.
In `@src/openms/source/FORMAT/QPXCollectionExport.cpp`:
- Around line 43-54: Update the preflight block in QPXCollectionExport to avoid
constructing and populating the copied PeptideIdentificationList; expose or
reuse a public pointer-based requireResolvableMergeIndices overload matching
IsobaricWorkflow’s std::vector<const PeptideIdentification*> input, delegate it
to the existing pointer validation, and pass collected peptide-identification
pointers through the preflight while preserving validation of assigned and
unassigned entries.
In `@src/tests/class_tests/openms/source/QPXCollectionExport_test.cpp`:
- Around line 99-120: Remove the unused omit_row parameter from makeDesign and
its conditional skip logic, since all callers provide only paths and the
ragged-design construction is separate. Keep the existing design-building
behavior unchanged for the remaining call sites.
In `@src/tests/topp/CMakeLists.txt`:
- Around line 1012-1017: Extend the TOPP_IsobaricWorkflow_1 registration in
CMakeLists.txt with a FuzzyDiff output comparison for
IsobaricWorkflow_1_output.tmp.consensusXML against a committed reference file,
while leaving TOPP_IsobaricWorkflow_2_no_preceding_ms1 as a run-only crash
regression test.
🪄 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 Plus
Run ID: 27e58d88-276b-49c8-b29e-92be84364469
📒 Files selected for processing (29)
CHANGELOGsrc/openms/include/OpenMS/FORMAT/ArrowSchemaRegistry.hsrc/openms/include/OpenMS/FORMAT/ConsensusMapArrowExport.hsrc/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport.hsrc/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.hsrc/openms/include/OpenMS/FORMAT/QPXCollectionExport.hsrc/openms/include/OpenMS/FORMAT/QPXFile.hsrc/openms/include/OpenMS/FORMAT/sources.cmakesrc/openms/source/FORMAT/ArrowIOHelpers.cppsrc/openms/source/FORMAT/ArrowSchemaRegistry.cppsrc/openms/source/FORMAT/ConsensusMapArrowExport.cppsrc/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/openms/source/FORMAT/QPXCollectionExport.cppsrc/openms/source/FORMAT/QPXFile.cppsrc/openms/source/FORMAT/sources.cmakesrc/pyOpenMS/pyopenms/addons/consensusmap.pysrc/pyOpenMS/pyopenms/addons/peptideidentificationlist.pysrc/pyOpenMS/tests/unittests/test_feature_dataframe.pysrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ArrowIOHelpers_test.cppsrc/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cppsrc/tests/class_tests/openms/source/QPXCollectionExport_test.cppsrc/tests/class_tests/openms/source/QPXFile_test.cppsrc/tests/topp/CMakeLists.txtsrc/tests/topp/IsobaricWorkflow_1_input.idXMLsrc/tests/topp/IsobaricWorkflow_2_input.idXMLsrc/topp/IsobaricWorkflow.cppsrc/topp/ProteinQuantifier.cppsrc/topp/ProteomicsLFQ.cpp
|
Confirmed findings (deduped)
|
Consolidated independent reviewVerdict: request changes; do not merge yet. I reviewed the current head ( Target contract: OpenMS is targeting the active, unreleased QPX 1.1 development line on bigbio/qpx's Blockers
Major correctness and contract issues
Test and documentation gaps
Confirmed good changes
I did not count the Validation performed without a local build, per the repository instructions: |
…#9817) bigbio/qpx#220 (merged) defines QPX format 1.1. The protein-group view drops the scalar required column run_file_name and gains grouped_runs (list<string>); the primary key becomes [anchor_protein, grouped_runs], and every QPX view declares qpx_version 1.1. The psm and feature views are otherwise unchanged by 1.1 and keep their scalar run_file_name. This is a change of GRAIN, not a rename. A pg row used to carry a per-file cell from the group's file_channel_level_abundance array; it now carries the SAMPLE-level value from the array PeptideAndProteinQuant names "abundances". The two are not interchangeable: the quantifier accumulates total_abundances[sample] += abundance over every fraction, file, charge and channel of a sample, while the per-file cells aggregate within a file, so summing them does not reproduce the sample value. Measured on the shipped BSA fixture, summing BSA1's two per-file cells gives 304,924,936 against a true 214,289,808; the export now emits 214,289,808. A quantification unit is a CONNECTED COMPONENT of the (run, sample) incidence: two runs join as soon as they share one sample, transitively. That is the weakest grouping under which no sample straddles two units, which is what makes the spec's "(any file in grouped_runs, label) -> run.samples[]" well defined. It is deliberately neither of the two obvious alternatives: * the design's fraction_group -- share/OpenMS/examples/FRACTIONS/BSA_design_onetable_nonconsec.tsv puts BSA1_F1 in fraction group 1 and BSA1_F2 in fraction group 4 while both are sample BSA1, so that key emits one sample's quantity twice under two keys; * equality of a run's whole (label -> sample) map -- OpenMS accepts designs with missing rows on purpose (ExperimentalDesign_test.cpp: "missing fractions and wrong orders should work now"), and in the shipped 4-plex ExperimentalDesign_input_2_wrong.tsv one fraction has no label-1 row. Requiring equal maps splits that plex into units that then share samples, refusing a design the loader accepts. ProteinGroupArrowExport gained overloads taking the ExperimentalDesign that drove quantification: it supplies both the grouping and the sample index space the abundances are stored under. ProteomicsLFQ, ProteinQuantifier and IsobaricWorkflow pass theirs; the convenience overload reconstructs one with fromConsensusMap() and is documented as best-effort. Identification-only output (ProSE, protein inference) has no design and writes single-element lists, the form the 1.1 schema documents for unfractionated input. Four shapes are refused rather than guessed at, because the row cannot represent them: a design whose sample count does not match the abundance array (it is not the design that produced it); a label that means two different samples within one unit (a common reference channel shared across plexes joins the plexes, and the remaining channels then disagree about what each label means); a sample filling two labels of one unit, whose single aggregated quantity would be published twice; and a label mapped to a sample the sample section does not describe. Design files the ConsensusMap has no column header for contributed nothing and are left out of grouped_runs, which also keeps the pg run names a subset of what psm and feature can join to. Two adjacent corrections. feature_counts.total_features now counts (feature, run) pairs: the feature view melts one ConsensusFeature into one row per run, so a feature spanning two fractions of a unit is two feature rows, and counting bare feature indices made pg disagree with feature.parquet; unique_features stays keyed on peptidoform+charge and does not grow. And a group melted onto a run it was only identified in wrote an empty intensities list where the identification-only overload writes null -- one column meaning two things depending on which overload produced the file, contradicting the code's own comment. The ConsensusMap overload now builds its table on QPXPgSchema::schema() instead of restating the 20 fields inline, which is what let the two definitions drift apart. Tests: eight new sections pin the grain, the sample-vs-fraction-group unit, the missing-design-row unit, the foreign-design refusal, the ambiguous-label refusal, the header intersection, the feature-row count and the null-intensity convention. Each was verified to fail against the previous behaviour before being kept. Zero reference-file churn: the -out_qpx TOPP tests only sha256sum for existence and no reference file contains a pg column name. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
Preserve protein quantities at fraction-group and label grain and emit the scalar protein-group schema used by active QPX development. Complete collection preflight and add regression coverage for schema, grouping, label resolution, and malformed annotations.
Reject duplicate identification-run identifiers in both merge-index preflight overloads and cover the value and pointer paths. Preserve develop's safe normalization fallback for fraction-group quantities after integrating #9844.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (5)
src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h (1)
87-192: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueThe second
run_in_several_groups_check cannot trigger.
run_infostores exactly onefraction_groupper run, soruns_by_fraction_groupplaces each run in exactly one bucket. Theunit_of_run_duplicate branch at lines 184-188 is therefore unreachable; the real detection is theinfo.fraction_group != entry.fraction_groupbranch at lines 122-127. Keep the branch only if you intend it as a defensive invariant, and say so in a comment; otherwise remove it to avoid suggesting two independent detections exist.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h` around lines 87 - 192, Remove the unreachable duplicate check around unit_of_run_.emplace in the fraction-group construction, since each run is already assigned to one bucket by run_info and runs_by_fraction_group. Retain the existing detection in the info.fraction_group != entry.fraction_group branch as the sole fraction-group inconsistency check.src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (2)
493-499: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winMake the label/intensity pairing explicit in
emitRow.The signature accepts
labelandintensityas independent optionals, but the append logic branches onlabelalone and dereferences*intensityin theelsebranch. A future caller that passes a label without an intensity dereferences an empty optional, which is undefined behavior. Both current call sites pass the two together (lines 833 and 860), so this is a latent hazard rather than a live defect. Pass onestd::optional<std::pair<std::string, float>>, or assert the invariant.🛡️ Minimal defensive change
else { + OPENMS_PRECONDITION(intensity.has_value(), + "a labelled pg row must carry an intensity"); (void)label_builder.Append(*label); (void)intensity_builder.Append(*intensity); }Also applies to: 559-573
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 493 - 499, Update the emitRow lambda to make label and intensity a single paired optional, or explicitly validate that both independent optionals are present together before dereferencing. Adjust the append logic and both current call sites to preserve the existing labeled-quantity behavior while preventing an empty intensity from being accessed when a label is provided.
741-745: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
\noverstd::endlin the new log statements.The new and modified diagnostics in this file end with
std::endl, which forces a stream flush on every message. The surrounding code uses the same style, so this is a consistency question rather than a defect; apply it to the changed lines if you touch them.As per coding guidelines, "Prefer
\noverstd::endl".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 741 - 745, Update the new diagnostic in the channel-label handling logic near the visible ProteinGroupArrowExport error log to terminate the message with "\n" instead of std::endl, avoiding a forced flush while preserving the existing message and return behavior.Source: Coding guidelines
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h (1)
448-471: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDocument the thrown exceptions with
@throws.
buildSampleIDLookup_()throwsException::MissingInformationfor invalid samples, conflicting cells, conflicting run fraction groups, and ambiguous fraction-group labels (seePeptideAndProteinQuant.cpplines 192-229).getSampleIDFromFilenameAndChannel_()propagates the throw ofgetDesignCellFromFilenameAndChannel_(). Both descriptions state the rejection in prose only. Add explicit tags so the documented exceptions match the required Doxygen form.As per coding guidelines, "documented exceptions should use
@throwsor@exception".📝 Proposed documentation change
Maps each (basename without extension, channel/label) of the MS file section to its sample and fraction group. Conflicting duplicate cells and fraction-group labels that resolve to different samples are rejected. Called whenever the experimental design is (re)set. + + `@throws` Exception::MissingInformation if a design cell refers to a sample outside the + sample section, or if duplicate cells, run fraction groups, or fraction-group + labels conflict */ void buildSampleIDLookup_(); @@ - /// Map (filename, channel) to sample using the precomputed design-cell lookup. + /** + `@brief` Map (filename, channel) to sample using the precomputed design-cell lookup. + + `@param`[in] filename The base filename (without path/extension) + `@param`[in] channel_or_label The channel/label identifier + `@return` The sample of the design cell + `@throws` Exception::MissingInformation if the (filename, channel) pair is not in the + experimental design + */ Size getSampleIDFromFilenameAndChannel_(const std::string& filename, UInt channel_or_label) const;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h` around lines 448 - 471, Update the Doxygen comments for buildSampleIDLookup_() and getSampleIDFromFilenameAndChannel_() to add explicit `@throws` Exception::MissingInformation entries. Describe that buildSampleIDLookup_() throws for invalid or conflicting design cells, fraction groups, or ambiguous labels, and that getSampleIDFromFilenameAndChannel_() propagates the exception from getDesignCellFromFilenameAndChannel_().Source: Coding guidelines
src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp (1)
510-510: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd negative coverage for the new design validations.
buildSampleIDLookup_()now rejects four distinct malformed designs: a sample index outside the sample section, conflicting(run, label)cells, one run in two fraction groups, and one fraction-group label resolving to two samples (PeptideAndProteinQuant.cpplines 192-229). No section exercises those throws. The existing file already usesTEST_EXCEPTION(Exception::MissingInformation, ...)at line 179, so each case is a short addition.As per coding guidelines, "Write unit tests for new functionality".
Also applies to: 535-535, 545-547
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp` at line 510, Extend the existing PeptideAndProteinQuant design-validation tests around buildSampleIDLookup_() with four negative cases: an out-of-range sample index, conflicting (run, label) cells, a run assigned to multiple fraction groups, and a fraction-group label resolving to multiple samples. Use the established TEST_EXCEPTION(Exception::MissingInformation, ...) pattern and minimal malformed design fixtures, asserting each case throws the expected validation exception.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h`:
- Around line 286-350: Update fractionGroupAbundances to reject fraction-group
keys less than or equal to zero, matching the existing 1-based validation for
labels. Keep the current key conversion and duplicate detection unchanged, and
revise the validation error text to state that both fraction-group and label
keys must be 1-based.
In `@src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp`:
- Around line 930-935: Update
PeptideAndProteinQuant::annotateQuantificationsToProteins() so QPX quantity
arrays are populated only for (fraction_group, label) pairs retained by
QuantificationUnits, excluding design runs without ConsensusMap column headers.
Ensure emitted annotation keys match
ProteinGroupArrowExport::expected_quantity_keys rather than relying on all
ExperimentalDesign::MSFileSection entries.
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 748-836: Extract the duplicated exportability checks from the
protein-group loop and QPXCollectionExport::requireExportable into a shared
helper in ProteinGroupArrowExport_impl.h that returns a diagnostic string. The
helper must validate quantities.valid, sample-abundance count, sample-only
annotations, empty units, expected key count, and every required
fraction-group/label lookup in that order. Update both call sites to invoke the
helper and format its returned diagnostic consistently, preserving their
existing success behavior and aborting when a diagnostic is present.
---
Nitpick comments:
In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`:
- Around line 448-471: Update the Doxygen comments for buildSampleIDLookup_()
and getSampleIDFromFilenameAndChannel_() to add explicit `@throws`
Exception::MissingInformation entries. Describe that buildSampleIDLookup_()
throws for invalid or conflicting design cells, fraction groups, or ambiguous
labels, and that getSampleIDFromFilenameAndChannel_() propagates the exception
from getDesignCellFromFilenameAndChannel_().
In `@src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h`:
- Around line 87-192: Remove the unreachable duplicate check around
unit_of_run_.emplace in the fraction-group construction, since each run is
already assigned to one bucket by run_info and runs_by_fraction_group. Retain
the existing detection in the info.fraction_group != entry.fraction_group branch
as the sole fraction-group inconsistency check.
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 493-499: Update the emitRow lambda to make label and intensity a
single paired optional, or explicitly validate that both independent optionals
are present together before dereferencing. Adjust the append logic and both
current call sites to preserve the existing labeled-quantity behavior while
preventing an empty intensity from being accessed when a label is provided.
- Around line 741-745: Update the new diagnostic in the channel-label handling
logic near the visible ProteinGroupArrowExport error log to terminate the
message with "\n" instead of std::endl, avoiding a forced flush while preserving
the existing message and return behavior.
In `@src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp`:
- Line 510: Extend the existing PeptideAndProteinQuant design-validation tests
around buildSampleIDLookup_() with four negative cases: an out-of-range sample
index, conflicting (run, label) cells, a run assigned to multiple fraction
groups, and a fraction-group label resolving to multiple samples. Use the
established TEST_EXCEPTION(Exception::MissingInformation, ...) pattern and
minimal malformed design fixtures, asserting each case throws the expected
validation exception.
🪄 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 Plus
Run ID: b0518b28-754e-4d80-aaf8-460f0035f6f3
📒 Files selected for processing (21)
CHANGELOGsrc/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.hsrc/openms/include/OpenMS/FORMAT/ArrowSchemaRegistry.hsrc/openms/include/OpenMS/FORMAT/ConsensusMapArrowExport.hsrc/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport.hsrc/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.hsrc/openms/include/OpenMS/FORMAT/QPXCollectionExport.hsrc/openms/include/OpenMS/FORMAT/QPXFile.hsrc/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cppsrc/openms/source/FORMAT/ArrowSchemaRegistry.cppsrc/openms/source/FORMAT/ConsensusMapArrowExport.cppsrc/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/openms/source/FORMAT/QPXCollectionExport.cppsrc/openms/source/FORMAT/QPXFile.cppsrc/pyOpenMS/bindings/bind_analysis.cppsrc/pyOpenMS/tests/unittests/test_PeptideAndProteinQuant.pysrc/tests/class_tests/openms/source/ArrowSchemaRegistry_test.cppsrc/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cppsrc/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cppsrc/tests/class_tests/openms/source/QPXCollectionExport_test.cppsrc/tests/class_tests/openms/source/QPXFile_test.cpp
🚧 Files skipped from review as they are similar to previous changes (7)
- src/openms/include/OpenMS/FORMAT/QPXCollectionExport.h
- src/openms/include/OpenMS/FORMAT/ConsensusMapArrowExport.h
- src/openms/source/FORMAT/QPXFile.cpp
- src/openms/include/OpenMS/FORMAT/ArrowSchemaRegistry.h
- src/openms/source/FORMAT/QPXCollectionExport.cpp
- CHANGELOG
- src/openms/source/FORMAT/ConsensusMapArrowExport.cpp
aea3ca5 to
022878a
Compare
Use the design-cell lookup introduced by the QPX fraction-group work when naming samples without positive abundance.
There was a problem hiding this comment.
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/QUANTITATION/PeptideAndProteinQuant.h (1)
455-477: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winDocument the full exception contract for the lookup methods.
buildSampleIDLookup_()can throwException::MissingInformationfor invalid sample indices, conflicting duplicate cells, conflicting run/fraction-group assignments, and conflicting(fraction_group, label)sample mappings. The current documentation lists only some conflicts and has no@throwstag.
getSampleIDFromFilenameAndChannel_()delegates togetDesignCellFromFilenameAndChannel_(), so it can also throwException::MissingInformation. Document that exception at the declaration.As per coding guidelines, possible exceptions must be documented with
@throwsor@exception.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h` around lines 455 - 477, Add complete `@throws Exception::MissingInformation` documentation to buildSampleIDLookup_() that covers all exception cases: invalid sample indices, conflicting duplicate cells, conflicting run/fraction-group assignments, and conflicting (fraction_group, label) sample mappings. Additionally, add `@throws Exception::MissingInformation` documentation to getSampleIDFromFilenameAndChannel_() to document that it can throw the exception because it delegates to getDesignCellFromFilenameAndChannel_(), which already documents this exception.Source: Coding guidelines
🧹 Nitpick comments (1)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h (1)
43-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the required Doxygen block form for the new declarations.
The added
///comments do not contain the required@brieftags. ThegetSampleIDFromFilenameAndChannel_comment also lacks@param[in]tags. Convert these new comments to/** ... */blocks.Example
- /// Mapping: experimental-design fraction group -> label/channel -> abundance + /** `@brief` Mapping from experimental-design fraction groups to label/channel abundances. */As per coding guidelines, Doxygen comments must use
/** */with@tags, and@briefis required.Also applies to: 58-60, 83-85, 97-99, 229-235, 265-268, 475-477
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h` around lines 43 - 45, Convert all newly added Doxygen comments in the declarations, including FractionGroupAbundances and getSampleIDFromFilenameAndChannel_, from /// form to /** ... */ blocks. Add an `@brief` tag to each block, and add `@param`[in] tags for every input parameter of getSampleIDFromFilenameAndChannel_; apply the same required format to the other referenced declarations.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`:
- Around line 455-477: Add complete `@throws Exception::MissingInformation`
documentation to buildSampleIDLookup_() that covers all exception cases: invalid
sample indices, conflicting duplicate cells, conflicting run/fraction-group
assignments, and conflicting (fraction_group, label) sample mappings.
Additionally, add `@throws Exception::MissingInformation` documentation to
getSampleIDFromFilenameAndChannel_() to document that it can throw the exception
because it delegates to getDesignCellFromFilenameAndChannel_(), which already
documents this exception.
---
Nitpick comments:
In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`:
- Around line 43-45: Convert all newly added Doxygen comments in the
declarations, including FractionGroupAbundances and
getSampleIDFromFilenameAndChannel_, from /// form to /** ... */ blocks. Add an
`@brief` tag to each block, and add `@param`[in] tags for every input parameter of
getSampleIDFromFilenameAndChannel_; apply the same required format to the other
referenced declarations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 39c03d5e-86d4-4d58-8d3c-011b2c6682b9
📒 Files selected for processing (3)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.hsrc/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cppsrc/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
- src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp
- src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp
Centralize the protein-group annotation contract so preflight and export cannot drift. Document design lookup exceptions and cover each malformed-design rejection.
|
first part of qpx 1.1 (WIP) support. This needs a bit of back and forth because we need to adapt between sdrf, qpx, OpenMS and other qpx enabled workflows |
…e a partial collection (#9849) * [FIX,TEST] QPX: separate unmapped features, never leave a partial collection Three defects in the QPX export contract added by #9846/#9843, found reviewing #9847. Tightening the contract is fine where the producers can satisfy it; these are cases where they cannot, or where the enforcement is not clean. 1. Feature primary key refused maps OpenMS itself produces. The key is (peptidoform, charge, run_file_name, rt). QPX permits unmapped features and ConsensusMapArrowExport writes them with an empty peptidoform, so for those rows the key collapses to (charge, run_file_name, rt) - and 'rt' is narrowed to float32 on write, one ULP being 244 us at 3000 s. Two co-eluting unmapped features of the same charge in one run then share a key although they are plainly different features, and the whole table is refused. Not a corner case for the tools that write QPX: ProteomicsLFQ with seeds leaves 79 % of the ProteomicsLFQ_3 fixture's consensus features unidentified, and a real run carries tens of thousands, where the birthday bound over the ~2.2e7 representable float32 retention times makes a collision expected. The only ProteomicsLFQ QPX test uses the unseeded configuration, whose features are all identified, so nothing exercised it. 'observed_mz' - written one column over, previously excluded - joins the key. Genuine duplicates (same run, charge, rt AND m/z) are still refused. 2. A refused collection left its earlier files behind. requireExportable() catches everything decidable from the input, but a view can still refuse a row it only sees while building its table, and a write can fail on I/O; by then quantms.feature.parquet is on disk, and a directory holding it without a PSM file is indistinguishable from a complete export of a smaller dataset. New QPXCollectionExport::Transaction scope guard: constructed before the first write, committed after the last, and on any other exit - a view returning false, a writer throwing, an early return - it removes every collection file present. Used by ProteinQuantifier, ProteomicsLFQ and IsobaricWorkflow. Guarding the scope rather than enumerating the failure sites covers the next refusal mode without anyone having to remember it. 3. QPXFile::exportToParquetStreaming() left a truncated PSM file. One validator spans all batches so it can fail on a late one, and the writer and sink are closed regardless, so the footer is written and the file reads as a valid, merely smaller, PSM table. It is now removed, matching what ConsensusMapArrowExport's streaming writer already did for the same situation. Each fix ships with a test that was confirmed to fail without it: the feature-key section fails at the validate() of two co-eluting unmapped features, and the streaming section at TEST_FALSE(File::exists(duplicate_file)). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ * [DOC,TEST] QPX: record the input contract once, and test the validator directly Documentation and tests only; no behaviour change. The QPX input contract was not written down anywhere a user could find it: the tools that offer -out_qpx just fail with UnableToCreateFile, and the four requirements a foreign consensus map can miss (a scan per identification, a resolvable origin file, uniqueness per (peptidoform, charge, run, scan), and a channel label from the QPX vocabulary) were only discoverable by reading QPXValueValidation. It is now stated on that class - the code that enforces it, so it cannot drift - and nowhere else. ProteinQuantifier's -out_qpx parameter and its documentation page point there rather than restating it, naming ProteomicsLFQ and IsobaricWorkflow as the producers that satisfy the contract by construction. QPXValueValidation had no test file of its own although every sibling QPX class has one, and it is a 600-line OPENMS_DLLAPI class that decides whether an export happens at all. QPXValueValidation_test covers all three views: the psm view's empty-scan, empty/blank run_file_name and duplicate-key refusals, the feature view's separation of unmapped rows by observed_mz and its non-finite coordinate refusals, the documented statefulness (a validator spans batches so a key repeated after a batch boundary is caught; a rejected batch does not advance the key state; reset() starts a new file), the schema-mismatch path, multi-chunk columns, null and 0-row tables, and Result::toString(). The invalid inputs are built through the exporters rather than by patching columns, so each section exercises a shape a producer really emits - an identification without a spectrum reference, or the one-MS2-on-two-features duplication IDMapper creates. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ * [FIX,TEST] Transaction must not delete a collection that predates it Addresses the CodeRabbit review on #9849. The scope guard removed every collection file in the output directory on a failed export, including files that were already there. Re-running a pipeline into the same -out_qpx directory is the normal case, so a failed re-run destroyed the previous, complete result. The test encoded that behaviour by creating its stub files before constructing the guard. The guard now records which of the three files exist at construction and removes only the ones this export created. A run that fails after overwriting a pre-existing file still leaves the directory mixing two exports - that cannot be undone without staging - so the destructor names the surviving files in a warning instead of letting the directory look coherent. The test creates its files inside the guard's lifetime, as an export does, and gains coverage that a failed export preserves a complete previous collection; that assertion fails without the fix. Also from the same review: - QPXFile and ConsensusMapArrowExport left a zero-byte .parquet behind when parquet::arrow::FileWriter::Open failed: arrow::io::FileOutputStream::Open had already created and truncated the file, and this early return happens before the close-and-remove block that covers every later failure. Both now close and remove it. (ConsensusMapArrowExport is not otherwise part of this PR's changes, but the two writers are deliberately symmetric here.) - Doxygen: the Transaction constructor, destructor and commit() use /** */ with @brief, and the constructor documents @PARAM[in] directory. - Style: braces on their own aligned lines, and '\n' instead of std::endl in the new logging. Verified end to end: a failed export into a fresh directory still leaves it empty, and a failed export into a directory holding a previous collection leaves all three of its files in place with the warning. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ * [FIX] Link QPXValueValidation_test against Arrow Fixes the windows-2025/cl.exe build failure on this branch: 37 LNK2019s, all unresolved __declspec(dllimport) arrow:: symbols, on QPXValueValidation_test.exe. The test was added to executables.cmake without the matching target_link_libraries(... ${OPENMS_ARROW_TARGET} ${OPENMS_PARQUET_TARGET}) that every other Arrow-using class test carries. It builds its invalid inputs with arrow::FloatBuilder and ArrayData::Make rather than through the exporters - deliberately, so each section exercises a shape a producer really emits - so it needs Arrow itself, not just what OpenMS re-exports. On Linux/macOS libOpenMS statically links Arrow and re-exports its symbols, so the link happens to succeed; on Windows they are dllimport and nothing satisfies them. QPXCollectionExport_test, added alongside it, uses no Arrow type and correctly stays unlinked. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ * [FIX,TEST] Remove the partial file when a one-shot Parquet write fails This PR taught both streaming writers to clean up after themselves, but the one-shot writers next to them still leak. arrow::io::FileOutputStream::Open creates and truncates the file before the table is written, so a write that fails afterwards leaves a fragment carrying little more than the Parquet magic bytes - no footer, so a reader reports it as corrupt rather than as the smaller table it looks like. Two sites, both now closing the stream and removing the file on any failure after the open: - ConsensusMapArrowExport::exportToParquet, directly above the streaming function this PR already fixed. - ArrowIOHelpers::writeTableToParquet, the shared path behind the psm, pg, OpenSwath and MSExperiment exports. ConsensusMapArrowExport::exportToParquet additionally closes explicitly instead of leaving it to the stream's destructor, which discards the error: the final flush is where a full disk surfaces, and that used to be reported as success with a truncated file on disk. Inside the three tools this was contained by QPXCollectionExport::Transaction, which is why it did not show up as a bug; it was not contained for pyOpenMS and library callers, or for ProSE, whose -out_qpx layout the guard cannot cover. Each fix ships with a test confirmed to fail without it - both at the TEST_FALSE(File::exists(...)) line, with the write failing for the intended reason. A row group size of 0 is refused by Parquet for a non-empty table, which reaches a post-open write failure deterministically on every platform. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ * [TEST] Cover -out_qpx from the seeded ProteomicsLFQ configuration The feature-key defect this PR fixes reached develop because the only ProteomicsLFQ QPX test runs -targeted_only true, whose consensus features are all identified: 0 of its 60 feature rows are unmapped, so nothing ever exported the shape the key could not distinguish. The class test added here reproduces that shape synthetically, but nothing asserts that the tool still produces it. New TOPP_ProteomicsLFQ_qpx_seeds runs TOPP_ProteomicsLFQ_3's seeded configuration with -out_qpx: 210 of 298 feature rows are unmapped, and all three collection files must exist afterwards. Kept as a separate run rather than folded into TOPP_ProteomicsLFQ_3 so no reference file is touched. What it guards is that the shape reaches the exporter and clears it end to end. It is not a reproducer for the float32-rt collision itself - measured on the produced table, the pre-fix key happens not to collide at this fixture's size - and the comment says so rather than implying more; ConsensusMapArrowExport_test covers that directly. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Aligns OpenMS QPX export with the active, unreleased QPX 1.1 contract on bigbio/qpx's
devbranch, as merged in bigbio/qpx#224 and pinned here at381986f5.Part of #9817.
QPX 1.1 contract implemented
qpx_version=1.1.labelandintensity.(anchor_protein, grouped_runs, label).grouped_runscomes from the exact OpenMSExperimentalDesign::fraction_group; it is not inferred from sample connectivity.grouped_runsand nulllabel/intensity.Quantification grain
PeptideAndProteinQuantnow preserves quantities at both existing sample grain and QPX's required(fraction_group, label)grain. Normalization, top-N aggregation, iBAQ, protein transfer, named data arrays, and pyOpenMS bindings carry the fraction-group quantities through to export.This is necessary because sample-level totals cannot be split back into independent fraction-group quantities after aggregation.
Complete collection preflight
QPXCollectionExport::requireExportable()validates all three views before the first Parquet file is opened. It now covers:The PSM preflight has a pointer overload so
IsobaricWorkflowdoes not deep-copy millions of identifications.Additional fixes
feature_counts.total_featuresfollows the feature view's one-row-per-(feature, run) grain.Integration with current
developThe branch is rebased over OpenMS #9844, which persists protein-group data arrays in consensusXML. The new fraction-group abundance/label arrays use that generic persistence path, and #9844's safe zero-aware normalization and IsobaricWorkflow consensusXML regression test are retained.
Verification
Focused coverage includes:
PeptideAndProteinQuant_testProteinGroupArrowExport_testQPXCollectionExport_testQPXFile_testArrowSchemaRegistry_testThe focused C++ suite passed 5/5 before the rebase. On head
d08816dc6a, GitHub's five-platform Build and Test matrix, cppcheck, and CodeRabbit pass; the pyOpenMS wheel matrix is still running.Summary by CodeRabbit
New Features
Bug Fixes