Repository navigation
[FIX] QPX export: melt the identification-only pg view onto its evidence runs (#9817) - #9832
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (8)
📝 WalkthroughWalkthroughThe change centralizes merged-run index validation, derives Arrow protein-group rows from evidence-associated runs, validates generated tables, expands merged-run tests, and prevents one QPX output failure from aborting processing of other inputs. ChangesMerged-run attribution and Arrow export
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: 1
🧹 Nitpick comments (3)
src/openms/include/OpenMS/METADATA/IdentifierMSRunMapper.h (1)
82-82: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider
Sizeinstead of rawsize_tfor the index parameter.Header guidelines call for OpenMS primitive types from
OpenMS/CONCEPT/Types.h; the surrounding API (e.g.Size size() const) already follows that.As per coding guidelines: "Use OpenMS primitive types from
OpenMS/CONCEPT/Types.h".🤖 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/METADATA/IdentifierMSRunMapper.h` at line 82, Update the validateMergeIndex method declaration to use OpenMS’s Size type instead of raw size_t for psm_index, following the surrounding API and the project’s primitive-type convention; ensure the corresponding definition and callers remain type-consistent.Source: Coding guidelines
src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp (1)
122-139: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider asserting the per-run peptide scoping here.
This is the one fixture with two runs each holding distinct evidence, so it is the natural place to pin the headline behavior from the header doc — that
peptides[].peptide_count/peptide_countsreflect only the emitted run (rowrunAseesPROT_A's peptide, rowrunBseesPROT_B's). Currently onlyrun_file_nameand the row count are checked, so a regression in the scoping would pass. Using distinct sequences viamakeMergedPeptide(acc, idx, "SEQUENCE")makes the assertion sharper.🤖 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/ProteinGroupArrowExport_test.cpp` around lines 122 - 139, Strengthen the test section around ProteinGroupArrowExport::exportToArrow by creating the merged peptides with distinct sequences using makeMergedPeptide and asserting each emitted run’s peptide_count/peptide_counts includes only its corresponding peptide: runA with PROT_A and runB with PROT_B. Preserve the existing row-count and run_file_name assertions.src/openms/source/METADATA/IdentifierMSRunMapper.cpp (1)
102-105: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winBuild the diagnostic strings lazily.
keyandwhereare constructed for every PSM of every merged run, including the overwhelmingly common success path;validateMergeIndicescalls this once per PSM, so this is a few string allocations per PSM for output that is almost never used. Move the construction into the failure branches (or a small lambda).♻️ Suggested change
- const std::string key = std::string(Constants::UserParam::ID_MERGE_INDEX); - const std::string where = "PSM #" + StringUtils::toStr(psm_index) + " of identification run '" - + pep_id.getIdentifier() + "' (" + StringUtils::toStr(paths.size()) - + " files in the run)"; + const auto where = [&]() { + return "PSM #" + StringUtils::toStr(psm_index) + " of identification run '" + + pep_id.getIdentifier() + "' (" + StringUtils::toStr(paths.size()) + + " files in the run)"; + }; + const std::string key = std::string(Constants::UserParam::ID_MERGE_INDEX);(and use
where()in each throw;keycan also move into the branches.)🤖 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/METADATA/IdentifierMSRunMapper.cpp` around lines 102 - 105, Update validateMergeIndices to construct the diagnostic strings key and where only inside the failure branches that use them, or through a lazy lambda for where; preserve the existing diagnostic contents and use the lazy value in each throw while avoiding allocations on successful PSM validation.
🤖 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/ProteinGroupArrowExport.cpp`:
- Around line 1009-1011: Update the ProteinIdentifications export paths around
best_hit.getSequence() and the corresponding logic around lines 1139–1145 to use
unmodified peptide sequences for peptide_count and unique_sequences, matching
the ConsensusMap overload; retain peptidoform-plus-charge counting only for
feature_counts. Revise the related “Peptidoforms of” comment to describe
unmodified sequences consistently.
---
Nitpick comments:
In `@src/openms/include/OpenMS/METADATA/IdentifierMSRunMapper.h`:
- Line 82: Update the validateMergeIndex method declaration to use OpenMS’s Size
type instead of raw size_t for psm_index, following the surrounding API and the
project’s primitive-type convention; ensure the corresponding definition and
callers remain type-consistent.
In `@src/openms/source/METADATA/IdentifierMSRunMapper.cpp`:
- Around line 102-105: Update validateMergeIndices to construct the diagnostic
strings key and where only inside the failure branches that use them, or through
a lazy lambda for where; preserve the existing diagnostic contents and use the
lazy value in each throw while avoiding allocations on successful PSM
validation.
In `@src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp`:
- Around line 122-139: Strengthen the test section around
ProteinGroupArrowExport::exportToArrow by creating the merged peptides with
distinct sequences using makeMergedPeptide and asserting each emitted run’s
peptide_count/peptide_counts includes only its corresponding peptide: runA with
PROT_A and runB with PROT_B. Preserve the existing row-count and run_file_name
assertions.
🪄 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: 03c3544f-e749-4e40-bb55-39f269151c6f
📒 Files selected for processing (7)
src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport.hsrc/openms/include/OpenMS/METADATA/IdentifierMSRunMapper.hsrc/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/openms/source/FORMAT/QPXFile.cppsrc/openms/source/METADATA/IdentifierMSRunMapper.cppsrc/tests/class_tests/openms/source/IdentifierMSRunMapper_test.cppsrc/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (1)
992-1027: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winSkip empty-hit PSMs before validating
id_merge_index.
validateMergeIndexhas no special case for empty-hitPeptideIdentifications and still throws whenid_merge_indexis missing, so this loop can abort export of a valid ProteinIdentification when an unused empty-hit PSM would not have contributed to any output row.🐛 Skip empty-hit PSMs in the validation loop too
for (const auto& [psm_index, pep_ptr] : bucket->second) { - mapper.validateMergeIndex(*pep_ptr, psm_index); + if (pep_ptr->getHits().empty()) { continue; } // no evidence, no say in the output + mapper.validateMergeIndex(*pep_ptr, psm_index); }🤖 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 992 - 1027, Update the validation loop in the protein-group export flow around acc_run_peptides to skip PeptideIdentification entries whose getHits() is empty before calling mapper.validateMergeIndex. Keep validation for PSMs with hits unchanged, and preserve the existing processing loop behavior.
🧹 Nitpick comments (2)
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (1)
38-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGood extraction, minor duplication with
QPXFile's equivalent helper.
buildRunMappermirrors the salvage-on-ambiguous-mapping idiom the comment says is "Same idiom as QPXFile's buildRunMapper()". Since both files now implement the identical try/catch-and-salvage logic, consider hoisting it into a shared helper (e.g.,ArrowIOHelpers) so a future change to the salvage rationale only needs to happen once.🤖 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 38 - 97, Extract the duplicated salvage-on-ambiguous-mapping logic from buildRunMapper and QPXFile’s equivalent helper into a shared ArrowIOHelpers utility. Update both callers to use that helper, preserving the existing warning context, forward-map salvage behavior, and returned IdentifierMSRunMapper semantics.src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp (1)
220-246: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding coverage for the intra-bucket empty-hit case.
This section (and the one above) validate identifier/bucket-level scoping of the merge-index refusal, but not the narrower case where a group-bearing, merged-run identifier's own bucket also contains an empty-hit PSM lacking
id_merge_index— see the related concern raised inProteinGroupArrowExport.cpp(lines 992-1027). A test withusable's own bucket containing an extra hit-lessPeptideIdentificationwithoutID_MERGE_INDEXwould pin down whether that's rejected or tolerated.As per path instructions,
src/tests/class_tests/**/*_test.cpp: "Write unit tests for new functionality and ensure existing tests pass before suggesting changes."🤖 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/ProteinGroupArrowExport_test.cpp` around lines 220 - 246, Add a unit-test case alongside the existing exportToArrow merge-index tests where the group-bearing merged-run identifier’s own peptide bucket also contains an empty-hit PeptideIdentification without ID_MERGE_INDEX. Assert the expected export behavior, preserving the existing usable-run assertions, and use the existing ProteinGroupArrowExport::exportToArrow test helpers and symbols.Source: Path instructions
🤖 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/topp/ProSE.cpp`:
- Around line 625-629: Extend the exception handling surrounding the QPX export
block in ProSE to also catch std::exception after the existing OpenMS exception
handler. Log or mark the QPX write as failed using the same per-file handling
path, so exceptions from QPXFile::exportToParquet, including
parquet::arrow::WriteTable or outfile->Close failures, do not abort sibling
output writes.
---
Outside diff comments:
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 992-1027: Update the validation loop in the protein-group export
flow around acc_run_peptides to skip PeptideIdentification entries whose
getHits() is empty before calling mapper.validateMergeIndex. Keep validation for
PSMs with hits unchanged, and preserve the existing processing loop behavior.
---
Nitpick comments:
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 38-97: Extract the duplicated salvage-on-ambiguous-mapping logic
from buildRunMapper and QPXFile’s equivalent helper into a shared ArrowIOHelpers
utility. Update both callers to use that helper, preserving the existing warning
context, forward-map salvage behavior, and returned IdentifierMSRunMapper
semantics.
In `@src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp`:
- Around line 220-246: Add a unit-test case alongside the existing exportToArrow
merge-index tests where the group-bearing merged-run identifier’s own peptide
bucket also contains an empty-hit PeptideIdentification without ID_MERGE_INDEX.
Assert the expected export behavior, preserving the existing usable-run
assertions, and use the existing ProteinGroupArrowExport::exportToArrow test
helpers and symbols.
🪄 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: 22282817-f8fb-4135-94f5-c63218e5b51f
📒 Files selected for processing (3)
src/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cppsrc/topp/ProSE.cpp
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 (2)
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (2)
1001-1008: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDo not reject PSMs that cannot contribute to this protein group export.
This validates every PSM sharing
prot_id.getIdentifier()before checking hits or whether its evidence matches any accession ingroups. An unrelated or empty-hit merged PSM lackingid_merge_indexaborts an otherwise exportable protein identification. Filter to best hits with evidence for this identification’s group accessions before callingvalidateMergeIndex().🤖 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 1001 - 1008, Update the validation loop around mapper.validateMergeIndex to consider only PSMs that can contribute to the current protein group: first require a best hit with usable evidence matching one of the group’s accessions, then validate that PSM’s merge index. Leave unrelated PSMs and PSMs with empty or non-matching evidence out of validation while preserving validation for eligible evidence.
74-78: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winValidate merged-run evidence before resolving its origin.
getPrimaryMSRunPath(pid)is called withoutvalidateMergeIndex(). A contributing unassigned PSM in a merged run withoutid_merge_indexcan therefore be attributed to the first input path and emit a row under the wrongrun_file_name. Carry the PSM index/relevant group-accession context into this helper and validate before deriving the run.🤖 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 74 - 78, Update the protein-group export flow around getPrimaryMSRunPath and its caller to pass the PSM index and relevant group-accession context into the run-resolution helper, invoke validateMergeIndex() before deriving the primary MS run path, and skip or reject unvalidated merged-run evidence rather than attributing it to the first input path.
🧹 Nitpick comments (1)
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (1)
55-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winApply the required C++ block and logging style.
The newly added helpers use one-line braced conditionals and
std::endl. Expand blocks with braces on their own lines and use'\n'for new OpenMS log messages. As per coding guidelines, C++ blocks must always use braces on their own aligned lines and logging should prefer\noverstd::endl.Also applies to: 74-83, 90-96, 112-129
🤖 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 55 - 60, Update the affected helper conditionals and OpenMS logging statements, including the catch block around Exception::BaseException, to use multiline braces on their own aligned lines and replace newly added std::endl terminators with '\n'. Apply the same style consistently to the referenced blocks while preserving their behavior and log content.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/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 1001-1008: Update the validation loop around
mapper.validateMergeIndex to consider only PSMs that can contribute to the
current protein group: first require a best hit with usable evidence matching
one of the group’s accessions, then validate that PSM’s merge index. Leave
unrelated PSMs and PSMs with empty or non-matching evidence out of validation
while preserving validation for eligible evidence.
- Around line 74-78: Update the protein-group export flow around
getPrimaryMSRunPath and its caller to pass the PSM index and relevant
group-accession context into the run-resolution helper, invoke
validateMergeIndex() before deriving the primary MS run path, and skip or reject
unvalidated merged-run evidence rather than attributing it to the first input
path.
---
Nitpick comments:
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 55-60: Update the affected helper conditionals and OpenMS logging
statements, including the catch block around Exception::BaseException, to use
multiline braces on their own aligned lines and replace newly added std::endl
terminators with '\n'. Apply the same style consistently to the referenced
blocks while preserving their behavior and log content.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 71f2f387-c604-4e9b-bbf7-27366403e7ee
📒 Files selected for processing (3)
src/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cppsrc/topp/ProSE.cpp
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/METADATA/IdentifierMSRunMapper.cpp`:
- Line 108: Update the if statement in the affected mapping logic to place the
opening and closing braces on their own aligned lines, preserving the existing
early return behavior when paths.size() is less than 2.
- Around line 100-108: Update getPrimaryMSRunPath() in
src/openms/source/METADATA/IdentifierMSRunMapper.cpp: for a single-path run with
a stale id_merge_index, inspect the PSM’s reference_file_name and return the
sole path when it resolves, preserving empty results when no fallback exists.
Add a regression at
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp:1045-1052 covering a
single-path PSM with stale metadata and verifying peptide_counts is populated.
🪄 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: 510ef3a5-b70e-4c71-a704-b45f6328041e
📒 Files selected for processing (2)
src/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/openms/source/METADATA/IdentifierMSRunMapper.cpp
| // Only a merged run can be mis-resolved: with 0 or 1 paths there is no wrong file to pick. | ||
| // | ||
| // Deliberately NOT extended to a stale index on a single-path run. That shape is produced by | ||
| // QPXFile::importFromArrow, whose shell run carries one path while the PSMs it restores keep | ||
| // their original indices -- and there it is harmless, because each hit also carries a | ||
| // 'reference_file_name' metavalue that resolution prefers. Refusing it would reject a round | ||
| // trip that produces correct output. Where no such fallback exists the index simply does not | ||
| // resolve, which callers see as evidence they could not attribute rather than as a wrong key. | ||
| if (paths.size() < 2) { return; } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline src/openms/source/FORMAT/QPXFile.cpp \
--items all --type function --match 'importFromArrow|importPSMsFromArrow'
rg -n -C 4 \
'reference_file_name|base_name|ID_MERGE_INDEX|setMetaValue' \
src/openms/source/FORMAT/QPXFile.cpp \
src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cppRepository: OpenMS/OpenMS
Length of output: 10759
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Files:"
fd -a 'IdentifierMSRunMapper\.(h|cpp)|ProteinGroupArrowExport\.cpp|ProteinGroupArrowExport_test\.cpp|QPXFile\.cpp' . | sed 's#^\./##'
echo
echo "IdentifierMSRunMapper.cpp relevant section:"
sed -n '1,180p' src/openms/source/METADATA/IdentifierMSRunMapper.cpp | cat -n
echo
echo "IdentifierMSRunMapper.h:"
sed -n '1,180p' src/openms/source/METADATA/IdentifierMSRunMapper.h | cat -n
echo
echo "ProteinGroupArrowExport.cpp relevant section:"
sed -n '1000,1075p' src/openms/source/FORMAT/ProteinGroupArrowExport.cpp | cat -n
echo
echo "QPXFile importFromArrow reference_file_name handling:"
sed -n '1700,2020p' src/openms/source/FORMAT/QPXFile.cpp | cat -n
echo
echo "QPXFile write reference_file_name handling:"
sed -n '490,575p' src/openms/source/FORMAT/QPXFile.cpp | cat -n
echo
echo "Imports/using in relevant files:"
sed -n '1,40p' src/openms/source/METADATA/IdentifierMSRunMapper.cpp | cat -n
sed -n '1,40p' src/openms/source/FORMAT/ProteinGroupArrowExport.cpp | cat -nRepository: OpenMS/OpenMS
Length of output: 9407
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "IdentifierMSRunMapper.h:"
sed -n '1,220p' include/OpenMS/METADATA/IdentifierMSRunMapper.h | cat -n
echo
echo "ProteinGroupArrowExport.cpp relevant section:"
sed -n '990,1070p' src/openms/source/FORMAT/ProteinGroupArrowExport.cpp | cat -n
echo
echo "QPXFile importFromArrow reference_file_name handling:"
sed -n '1700,2020p' src/openms/source/FORMAT/QPXFile.cpp | cat -n
echo
echo "QPXFile write reference_file_name handling:"
sed -n '490,575p' src/openms/source/FORMAT/QPXFile.cpp | cat -n
echo
echo "Relevant tests:"
sed -n '1,160p' src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp | cat -n
echo
rg -n -C 5 'single|stale|merge.*index|reference_file_name|peptide_count|proteins' src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cppRepository: OpenMS/OpenMS
Length of output: 267
🏁 Script executed:
#!/bin/bash
set -euo pipefail
for f in include/OpenMS/METADATA/IdentifierMSRunMapper.h \
src/openms/include/OpenMS/METADATA/IdentifierMSRunMapper.h \
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp \
src/openms/source/FORMAT/QPXFile.cpp \
src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp; do
if [ -f "$f" ]; then
echo "FOUND $f"
else
echo "MISSING $f"
fi
done
echo
echo "IdentifierMSRunMapper.h:"
sed -n '1,220p' include/OpenMS/METADATA/IdentifierMSRunMapper.h | cat -n || true
echo
echo "ProteinGroupArrowExport.cpp relevant section:"
sed -n '990,1070p' src/openms/source/FORMAT/ProteinGroupArrowExport.cpp | cat -n
echo
echo "QPXFile importFromArrow reference_file_name handling:"
sed -n '1700,2020p' src/openms/source/FORMAT/QPXFile.cpp | cat -n
echo
echo "QPXFile write reference_file_name handling:"
sed -n '490,575p' src/openms/source/FORMAT/QPXFile.cpp | cat -n
echo
echo "Relevant tests:"
sed -n '1,180p' src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp | cat -n
echo
rg -n -C 5 'single|stale|merge.*index|reference_file_name|peptide_count|proteins' src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp || trueRepository: OpenMS/OpenMS
Length of output: 38893
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "IdentifierMSRunMapper.h:"
sed -n '1,220p' src/openms/include/OpenMS/METADATA/IdentifierMSRunMapper.h | cat -n
echo
echo "ArrowIOHelpers qpxRunFileName/reference_file_name usage:"
rg -n -C 8 'qpxRunFileName|reference_file_name' src/openms source/src include 2>/dev/null | head -200
echo
echo "ProteinGroupArrowExport.cpp later summary section:"
sed -n '1070,1135p' src/openms/source/FORMAT/ProteinGroupArrowExport.cpp | cat -nRepository: OpenMS/OpenMS
Length of output: 25569
Resolve accepted stale single-path id_merge_index values.
validateMergeIndex() accepts stale per-hit indices when the run has exactly one MS path, but getPrimaryMSRunPath() only falls back to the resolved path via BASE_NAME; it does not inspect the hit’s reference_file_name. For single-path imports, this returns empty and the PSM evidence is skipped before peptide_counts is populated, so an otherwise valid round-trip can publish zero counts. Return the sole path from the resolver when present, and add a regression covering a single-path PSM with stale metadata.
📍 Affects 2 files
src/openms/source/METADATA/IdentifierMSRunMapper.cpp#L100-L108(this comment)src/openms/source/FORMAT/ProteinGroupArrowExport.cpp#L1045-L1052
🤖 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/METADATA/IdentifierMSRunMapper.cpp` around lines 100 - 108,
Update getPrimaryMSRunPath() in
src/openms/source/METADATA/IdentifierMSRunMapper.cpp: for a single-path run with
a stale id_merge_index, inspect the PSM’s reference_file_name and return the
sole path when it resolves, preserving empty results when no fallback exists.
Add a regression at
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp:1045-1052 covering a
single-path PSM with stale metadata and verifying peptide_counts is populated.
Source: Coding guidelines
| // 'reference_file_name' metavalue that resolution prefers. Refusing it would reject a round | ||
| // trip that produces correct output. Where no such fallback exists the index simply does not | ||
| // resolve, which callers see as evidence they could not attribute rather than as a wrong key. | ||
| if (paths.size() < 2) { return; } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use the required brace layout.
Move the block braces onto their own lines.
As per coding guidelines, “braces on their own aligned lines.”
🤖 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/METADATA/IdentifierMSRunMapper.cpp` at line 108, Update the
if statement in the affected mapping logic to place the opening and closing
braces on their own aligned lines, preserving the existing early return behavior
when paths.size() is less than 2.
Source: Coding guidelines
…x guard QPXFile's PSM export refuses a PSM that belongs to a merged run but carries no usable 'id_merge_index': without it getPrimaryMSRunPath() falls back to the run's FIRST file, silently labelling every PSM of the run with it. Since QPX run_file_name is a primary-key component, a wrong key is worse than a refused export. The check lived in QPXFile.cpp's anonymous namespace, so it had internal linkage and no other exporter could apply it. Move it verbatim onto the mapper that owns the resolution it guards, and let QPXFile's two loop wrappers delegate. The protein-group exporter needs the same refusal for the same reason. Kept deliberately: the value is read as long long, not Size. Casting a DataValue to an unsigned type raises its own ConversionError on a negative value, which would escape as an undiagnosed exception instead of the located message here. Behaviour is unchanged for existing callers. Adds a class test covering all four rejection cases and both exemptions, including that a negative index surfaces as MissingInformation. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
…nce runs (#9817) The identification-only overload derived run_file_name ONCE per ProteinIdentification and stamped it on every protein-group row. A merged run spanning N files therefore emitted an EMPTY run_file_name -- a QPX primary-key component the spec says MUST NOT be null, and one that quantms' pg_adapter silently DROPS, so those groups vanished downstream rather than being flagged. Melt instead, as the ConsensusMap overload already does: resolve each PSM's origin through IdentifierMSRunMapper and emit one row per (group, run) for the runs where a member accession actually has peptide evidence. peptides and peptide_counts are scoped to the emitted run. The encoding is no longer a judgement call: bigbio/qpx#51 settled it on 2026-07-29 -- protein groups are taken to be globally defined and identical across runs, so one row per run is correct. No sentinel, no empty value. Two policies this needs: * A single-file run keeps its groups even without peptide evidence. One possible origin means no key ambiguity, and without this a group whose accessions carry no evidence would go 1 row -> 0 rows for ProSE. * A merged run with no evidence anywhere is skipped with a diagnostic. Nothing can key the row, and an empty key is the failure mode being fixed. Merged input whose PSMs lack a usable id_merge_index is now refused (IdentifierMSRunMapper::validateMergeIndex) rather than resolved to the run's first file, and stem collisions warn, matching the psm and feature views. Both overloads now share buildRunMapper/indexEvidenceRuns/evidenceRuns, and both report repeated (anchor_protein, run_file_name) keys. Emitting both rows is deliberate -- dropping one loses data and there is no rule for reconciling two group probabilities -- but it must not be silent, since qpxc validate reports duplicate PKs at severity "warning" and its is_valid ignores warnings. Not done: estimated_rows is now neither an upper nor a lower bound. It is a Reserve hint only, and an exact count would need a full pre-pass over every group's evidence runs before any builder exists. Verified: 153/153 TOPP tests, and the ConsensusMap overload's BSA output is unchanged (40 rows, identical primary-key multiset, no duplicates). Note that no TOPP test exercises the identification-only pg path -- ProSE's pg.parquet has 0 rows in every checked-in configuration -- so the class tests are its only coverage. Two existing assertions change: a merged run goes from one empty-keyed row to one row per evidence run, and a run without spectra_data now emits none. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
…t, do not abort Two defects in the identification-only pg melt, both found by asking what an actual protein-inference result looks like rather than what its callers pass. 1. The id_merge_index preflight ran over every PeptideIdentification before the per-run loop, so it fired for runs that contribute no protein group at all. BayesianProteinInference_test.idXML -- 2 spectra_data paths, 9 PSMs, no id_merge_index, no groups -- aborted an export it has no say in. Scope the check to the PSMs of runs that actually contribute groups. It still refuses a merged run that does contribute groups, which is the case worth refusing. 2. Inference output typically has NO spectra_data at all: Epifany_1_out.idXML carries 163 indistinguishable groups, no run path, no base_name and no id_merge_index, and 25 of 28 checked-in group-bearing idXML files look the same. Every group was therefore skipped and the fact announced at INFO -- an empty output file that reads as "nothing to export" rather than "your input could not be keyed". The rows are still not emitted: run_file_name is a QPX primary-key component, and the empty value the old code wrote is silently dropped by quantms, so it was an invisible downstream loss rather than a real export. What changes is that the user now finds out at the source. Report the two skip causes separately at WARN, each naming its remedy -- setPrimaryMSRunPath() for a run with no path, id_merge_index for a merged run with no evidence. Also wrap ProSE's QPX output block in try/catch, like its idXML and .pin siblings. The block documents that a failure in one output mode must not skip the sibling modes, and the QPX exporters can throw on input they cannot key. Measured with a probe calling the exporter directly on real files: Epifany_1_out 163 groups -> 0 rows + WARN; ProteinInference_1_output 1 -> 0 + WARN; BayesianProteinInference_test no longer throws. 153/153 TOPP tests. Known limitation, unchanged and not a regression: when inference sits in one run of a multi-run file, only that run's PSMs are consulted for evidence, so sibling runs cannot receive a row. Belongs with the cross-run questions in #9817. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
…eptide_counts The two pg overloads disagreed about what peptide_counts.unique_sequences means. The ConsensusMap overload keys on toUnmodifiedString() (:218, :539) and leaves peptidoform-plus-charge to feature_counts.unique_features (:540); the identification-only overload keyed on toString(), i.e. the peptidoform. So the same column of the same file format meant "distinct sequences" or "distinct peptidoforms" depending on which overload produced the file, with nothing in the output to tell a consumer which. Align the id-only path on the unmodified sequence. feature_counts needs no counterpart here -- it is AppendNull() in this overload, there being no features to count without a ConsensusMap. Every existing fixture in both test files uses unmodified peptides, so no test could distinguish the two meanings. Added one that can: two peptidoforms of one sequence must give unique_sequences == 1. Verified it discriminates -- with the previous keying it fails with "got '2', expected '1'". Also catch std::exception around ProSE's QPX output block, after the existing Exception::BaseException handler. Exception::BaseException derives from std::runtime_error, so catching it does not catch parquet::ParquetException or std::bad_alloc, and this is the only ProSE output mode that calls into Arrow/Parquet. The write helpers check arrow::Status rather than throwing (ArrowIOHelpers.cpp: WriteTable, Close and FileOutputStream::Open are all Status/Result checked), so this covers allocation and internal parquet failures rather than the ordinary error path -- but letting one escape would skip the remaining outputs for that input, which is exactly the contract the block documents at ProSE.cpp:550-552. 153/153 TOPP tests; Arrow/QPX class tests green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
…alidate the table
Four defects from an adversarial review of the pg melt. The first three are
regressions this branch introduced.
1. Duplicate identification-run identifiers silently miskeyed a group.
IdentifierMSRunMapper keys its forward map on the identifier and overwrites
without complaint, so two runs sharing one leave only the last one's paths --
and a group belonging to {A,B} is then emitted under C. Nothing downstream
could detect it: one row, so not even the primary-key watch fires. Introduced
here, because the previous code read prot_id.getPrimaryMSRunPath() directly
rather than routing resolution through an identifier-keyed mapper. Refuse it.
Real identifiers embed a timestamp and hash, so this does not occur in shipped
data (checked against Epifany/ProteinInference outputs: 3 runs, 3 distinct ids).
2. Lifting the mapper construction into a shared helper widened
catch (Exception::InvalidValue) to catch (Exception::BaseException). Only
InvalidValue -- the duplicate-path-list case -- leaves the forward map complete;
anything else means it is partial, and continuing on it turns malformed
spectra_data from a loud failure into a successful zero-row table. Narrowed.
3. Appends discard their arrow::Status throughout this file, so a failed one
leaves a short column while every Finish() still succeeds independently and
Table::Make is called without validation. The melt makes that newly reachable
by emitting several rows where one was reserved. Validate() at both return
sites, so the documented "nullptr on failure" holds instead of a malformed
table being handed back.
The review also proposed refusing a stale 'id_merge_index' on a single-path run.
Implemented, and QPXFile_test rejected it: importFromArrow's shell branch rebuilds
a one-path run whose PSMs keep their original indices, and that round trip is
correct today because each hit's 'reference_file_name' takes precedence during
resolution. Refusing it would reject output that is right. The diagnosis was
sound, though -- such a PSM contributes to no peptide count -- so instead of
throwing, the melt counts them and warns once with the likely cause.
153/153 TOPP tests; Arrow/QPX class tests green.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
486b74e to
735567e
Compare
Found by an adversarial review after #9832. All three predate that PR. 1. gg_accessions/gg_names lost positional alignment with pg_accessions. pg_accessions appends one entry per group member unconditionally and pg_names appends "" on a lookup miss, but the gene lists appended only inside `if (hit found)` AND `if (has_ga || has_gn)`. An unannotated member contributed nothing, so the lists came out short and every later gene shifted onto the wrong protein -- a partially gene-annotated FASTA is all it takes. The comment claimed the lists were "symmetric so they can be zipped"; they were symmetric with each other, which is not the symmetry a consumer needs. The identification-only overload already did this right. 2. peptide_counts.total_sequences counted features. It was `group_features.size()`, character-identical to the feature_counts expression two lines below, so total_sequences always equalled total_features -- while peptides[] in the same row was built from distinct sequences. Now accumulated from the same per-member seqs.size() that peptides[] emits, so the two agree by construction. This is the sibling field of the unique_sequences divergence fixed in #9832, which corrected one half of the struct and left the other. 3. The psm view wrote an empty run_file_name with no log output. QPX makes it a non-nullable primary-key component and the key psm is joined to feature and pg on; an empty string satisfies Arrow while violating the spec. Protein-inference output triggers it with no malformed metadata, since inference commonly drops spectra_data -- and the pg exporter warns loudly on the same input while the psm exporter said nothing. The row is still written: a PSM is a primary record and dropping it would discard an identification, unlike a protein group, which is a per-run aggregate that cannot exist without a run. Only the diagnostic was missing. buildQPXPSMTableRange runs inside an OpenMP region, so the count is an out-parameter written through a per-worker slot and summed by the caller after the region; both the streaming and single-shot paths report once per export. Each defect was invisible for a specific reason: no fixture had a partially gene-annotated group, every fixture had exactly one feature per sequence (the one case where the two count meanings coincide), and the empty-key path wrote a valid file silently. The two new sections target those gaps and were both confirmed to fail against the previous code -- reverting gives "GENE_OF_B" at index 0 and total_sequences 2 instead of 1. 153/153 TOPP tests; Arrow/QPX class tests green; no reference-file churn. Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…9835, #9836 (#9841) Backfills the QPX export spec-conformance series, the macOS PKG notarization fix, and the Windows GUI DLL export fix that merged into develop without changelog entries. #9805 and #9821 were intentionally skipped (test-only / comment-only, no user-visible behavior change), and #9818 was already documented. Claude-Session: https://claude.ai/code/session_0118Yt3TZEMzhMhH6FwZPDVt Co-authored-by: Claude <[email protected]>
Closes the remaining half of #9817 Defect A. #9825 fixed the
ConsensusMapoverload of the protein-group export; this does the same for the identification-only overload.The defect
ProteinGroupArrowExport::exportToArrow(const std::vector<ProteinIdentification>&, const PeptideIdentificationList&)derivedrun_file_nameonce perProteinIdentificationand stamped it on every group row. A merged run spanning N files has no single origin, so it emitted an emptyrun_file_name— a QPX primary-key component the spec says MUST NOT be null, and one that quantms'pg_adaptersilently drops. Those groups vanished downstream rather than being flagged.The fix
Melt, exactly as the sibling overload already does: resolve each PSM's origin through
IdentifierMSRunMapperand emit one row per (group, run) for the runs where a member accession actually has peptide evidence.peptidesandpeptide_countsare scoped to the emitted run, so the same group in two runs reports what was seen in each.The encoding is no longer a judgement call. bigbio/qpx#51 settled it on 2026-07-29: protein groups are taken to be globally defined and identical across runs, so one row per run is correct. No sentinel, no empty value, no separate provenance table. This PR is a port, not a design.
Two policies it needs
Merged input is refused rather than mislabelled
A PSM in a merged run without a usable
id_merge_indexresolves to the run's first file, so the key would be wrong rather than missing. The psm view already refuses this; the check lived inQPXFile.cpp's anonymous namespace with internal linkage, so no other exporter could apply it. The first commit moves it ontoIdentifierMSRunMapper, which owns the resolution it guards, andQPXFile's wrappers delegate — one implementation, not two.One detail worth keeping: the value is read as
long long, notSize. Casting aDataValueto an unsigned type raises its ownConversionErroron a negative value, which would escape as an undiagnosed exception instead of the located message.Duplicate keys are surfaced, not resolved
Two
ProteinIdentifications whose paths share a stem produce byte-different rows — different scores, counts,global_qvalue— under one primary key. Both are kept: dropping one loses data, and there is no rule for reconciling two group probabilities. But it is no longer silent — both overloads now count repeated(anchor_protein, run_file_name)pairs and warn with examples. Nothing downstream enforces the key either:qpxc validatereports duplicate PKs at severitywarningand itsis_validignores warnings.Both overloads also now share
buildRunMapper/indexEvidenceRuns/evidenceRuns, so the melt logic exists once.Verification
ProteomicsLFQ,ProSE,ProteinQuantifier,IsobaricAnalyzer);IdentifierMSRunMapper,ProteinGroupArrowExport,QPXFileandConsensusMapArrowExportclass tests pass.ConsensusMapoverload is behaviour-preserving on real data — the part of this change most likely to regress something that already worked, since it was rewired onto the new shared helpers. Re-running the BSAProteomicsLFQexport and diffing the pg output against the pre-change run: 40 rows both times, identical(anchor_protein, run_file_name)multiset, no duplicates, no empty keys. The new duplicate-key warning does not fire.Coverage caveat, stated plainly: no TOPP test exercises the identification-only pg path.
TOPP_ProSE_3_qpxproduces a pg.parquet with 0 rows — the per-file path yields no indistinguishable groups in that configuration, and-FDR:proteinapplies only to-out_merged. The class tests are its only coverage, before and after this PR.That leaves ProSE's invariance as an argument rather than a measurement: it always passes a single-path
ProteinIdentification,qpxRunFileNameis literallyFile::stemName, and for a single-path run the melt resolves to that same stem whether the group has evidence (evidence path) or not (escape hatch). Pinned by a class test either way.Test changes
Two existing assertions flip, both deliberately:
run_file_name == ""{runA, runB}spectra_datarun_file_name == ""The first carried a
TODO(#9817)saying it pinned current behaviour rather than a contract. New sections cover evidence-scoped melting (no fan-out onto runs without evidence), the refusal on a missingid_merge_index, the single-file escape hatch, a merged run with no evidence anywhere, and the stem-collision duplicate key.What protein-inference input does
Worth stating explicitly, because it is the export's own target use case and the answer is not obvious: protein inference does not annotate a run name.
Epifany_1_out.idXMLcarries 163 indistinguishable groups across three IdentificationRuns and none of them hasspectra_data;ProteinInference_1_output.idXMLwritesvalue="[]". 25 of 28 checked-in group-bearing idXML files have no usable run path.There is therefore no
run_file_nameto derive, and the melt emits nothing for them. That is deliberate —run_file_nameis a primary-key component, and the empty value the old code wrote is silently dropped by quantms, so those rows were an invisible downstream loss rather than a real export. What changes is that the user finds out at the source, via aWARNnaming the remedy (setPrimaryMSRunPath()), instead of discovering an empty table three tools later.Measured with a probe calling the exporter directly on real files:
Epifany_1_out.idXMLProteinInference_1_output.idXMLBayesianProteinInference_test.idXMLid_merge_indexThe third one is a defect this PR fixes rather than introduces: the
id_merge_indexpreflight originally ran over every PSM before the group loop, so a merged run that contributes no group could abort an export it has no say in. It is now scoped to the PSMs of runs that actually contribute groups, and still refuses a merged run that does.ProSE's QPX output block is also wrapped intry/catchlike its idXML and.pinsiblings — the block documents that one mode's failure must not skip the others, and these exporters can throw on input they cannot key.Known limitation, not a regression
When inference sits in one run of a multi-run file, only that run's PSMs are consulted for evidence, so sibling runs cannot receive a row. The old code was equally limited — it keyed everything on the inference run's first path — so this is not a regression, but it is a real limitation and belongs with the cross-run questions #9817 already tracks rather than being settled quietly here.
Observed while testing, not fixed here:
IdentifierMSRunMapper::create()treats two runs that both have empty path lists as a duplicate-path collision, so a multi-run inference file logs a confusing "ambiguous MS run paths" warning before the actionable one. Harmless (the forward map is intact) but worth a separate tidy-up.Not done
estimated_rowsis now neither an upper nor a lower bound after the melt. It is aReservehint only, and an exact count would need a full pre-pass over every group's evidence runs before any builder exists — a duplicate traversal to save one Arrow regrow.Still open on #9817
The cross-run dedup question — whether two
ProteinIdentifications carrying the same accession group should be merged — is untouched and remains a semantic decision. Defect C'simportFromArrowshell branch also remains; it needs the OpenMS-native format to carry an ordered path list.🤖 Generated with Claude Code
https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
Summary by CodeRabbit
New Features
Bug Fixes
Documentation