Repository navigation
[FIX] QPX export: resolve run_file_name per PSM and drop path/extension (#9816) - #9818
Conversation
…on (#9816) Two independent defects in the QPX Parquet export, both in a column the spec marks Required and uses as the Hive partition key and the psm/feature/pg join key. 1. quantms.psm.parquet labelled every PSM with the first MS run of its identification run. ProteomicsLFQ (and IDMerger) merge all inputs into a single ProteinIdentification whose 'spectra_data' lists every input file, with each PeptideIdentification selecting one via 'id_merge_index'. QPXFile keyed a map on the run identifier alone and stored only ms_runs[0], so a 120-run dataset produced one distinct run_file_name instead of 120. Resolution now goes through IdentifierMSRunMapper, which reads that index - the same source the mzTab exporter written by the same invocation already used. Merged input carrying no usable index is refused with Exception::MissingInformation rather than silently mislabelled; for the streaming export the check is a serial pre-pass that runs before the output file is opened, since a throw from inside the OpenMP region would be swallowed by its exception firewall and leave a truncated .parquet behind. The identical collapse in the internal PSMSchema 'reference_file_name' is fixed too (full paths there, which the internal format must round-trip): importFromArrow restores that value as a per-hit metavalue that the QPX writer prefers over the run-derived fallback, so leaving it would have re-introduced the bug after any internal-format round trip. 2. run_file_name was emitted as a full path with extension. The three QPX tables derive it from three unrelated sources and only the protein-group quantification path already normalized it, so they could not be joined. The psm, feature and identification-only protein-group writers now apply File::stemName() at the point of append. The quantified protein-group path is deliberately left alone: PeptideAndProteinQuant already stems those values and FileHandler::stripExtension is not idempotent (for an unrecognized extension it strips at the last dot), so stemming twice would turn a legitimate stem like 'HeLa_1.2ug' into 'HeLa_1'. Distinct paths collapsing onto one stem are warned about once per export and still exported - the origin is known, only the spec's representation cannot express it. The identification-only protein-group export additionally emits an empty run_file_name for a run spanning several MS files, because a group inferred across runs has no single origin file. Verified on the full ProteomicsLFQ pipeline test (5 mzMLs): psm and feature now both report the same 5 bare stems, where psm previously reported 1 value with '.mzML'. ProteinGroupArrowExport gains a class test; it had none. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0178t42vQUwSPgeSzeCinQeF
…on (#9816) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0178t42vQUwSPgeSzeCinQeF
📝 WalkthroughWalkthroughQPX and Arrow exporters now resolve per-PSM MS origins through ChangesQPX run-origin handling
Sequence Diagram(s)sequenceDiagram
participant QPXFile
participant IdentifierMSRunMapper
participant buildQPXPSMTableRange
participant Parquet
QPXFile->>IdentifierMSRunMapper: Build mappings and validate merged indices
QPXFile->>buildQPXPSMTableRange: Pass shared mapper
buildQPXPSMTableRange->>IdentifierMSRunMapper: Resolve each PSM origin
IdentifierMSRunMapper-->>buildQPXPSMTableRange: Return full source path
buildQPXPSMTableRange->>Parquet: Write stemmed run_file_name
Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openms/source/FORMAT/QPXFile.cpp (1)
335-341: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueValidation happens after Arrow builders are already allocated/reserved.
In
exportToArrow,buildRunMapper/validateMergeIndicesrun at line 340-341, but the column builders and their capacity reservations (lines 184-333) already executed. If a merged run withoutid_merge_indexis fed in, the function still does all that allocation work before throwing. Contrast withexportPSMsToQPXArrow(line 1505-1506) andexportToParquetStreaming(line 1633-1639), which both validate first. Moving the mapper build/validation to the top ofexportToArrowwould fail fast consistently with the other two entry points.♻️ Suggested reordering
// -- Simple column builders -- - arrow::StringBuilder sequence_builder, peptidoform_builder; + const IdentifierMSRunMapper mapper = buildRunMapper(protein_identifications); + validateMergeIndices(mapper, peptide_identifications); + + arrow::StringBuilder sequence_builder, peptidoform_builder; arrow::StringBuilder reference_file_builder, score_type_builder; ... - // Resolve each PSM's origin file. ... - const IdentifierMSRunMapper mapper = buildRunMapper(protein_identifications); - validateMergeIndices(mapper, peptide_identifications);🤖 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/QPXFile.cpp` around lines 335 - 341, Move the buildRunMapper and validateMergeIndices calls to the beginning of exportToArrow, before any Arrow builders are allocated or capacity is reserved. Preserve the existing mapper and validation behavior, and keep the later export logic using the validated mapper without repeating 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.
Nitpick comments:
In `@src/openms/source/FORMAT/QPXFile.cpp`:
- Around line 335-341: Move the buildRunMapper and validateMergeIndices calls to
the beginning of exportToArrow, before any Arrow builders are allocated or
capacity is reserved. Preserve the existing mapper and validation behavior, and
keep the later export logic using the validated mapper without repeating
validation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a5fabfcc-de53-4b6f-a70c-703b3edecf82
📒 Files selected for processing (9)
CHANGELOGsrc/openms/source/FORMAT/ConsensusMapArrowExport.cppsrc/openms/source/FORMAT/ProteinGroupArrowExport.cppsrc/openms/source/FORMAT/QPXFile.cppsrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ConsensusMapArrowExport_test.cppsrc/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cppsrc/tests/class_tests/openms/source/QPXFile_test.cppsrc/tests/topp/CMakeLists.txt
The new test calls arrow::Table::GetColumnByName / ChunkedArray::chunk / BaseBinaryArray::GetString directly, so it needs the same explicit target_link_libraries entry the other Arrow class tests already have. Linux and macOS resolved these transitively through libOpenMS; on Windows the Arrow symbols are __declspec(dllimport) and the link failed with LNK2019. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0178t42vQUwSPgeSzeCinQeF
|
Flagging one behaviour in this PR as provisional, from spec research done after the plan was handed off. The identification-only protein-group export now emits an empty // ProteinGroupArrowExport.cpp
else if (run_paths.size() > 1)
{
OPENMS_LOG_WARN << "... protein groups have no single "
<< "origin file, leaving run_file_name empty for its rows.";
}That is semantically the honest choice, and it is what an independent review preferred. But the QPX spec goes the other way:
No action needed in this PR. The branch is unreachable from any TOPP tool — ProSE, the only caller of that overload, always passes a single-path run — so nothing changes in practice, and it is strictly better than the previous silent The tension is honest-but-dropped versus lossy-but-visible, and it is genuinely unsettled upstream: bigbio/qpx#51 is open on exactly this and names OpenMS. Tracked as Defect A in #9817 (option A1 there), which is where it should be decided. Worth a |
…9817) The identification-only protein-group export emits an empty run_file_name for a run spanning several MS files. That is the semantically honest choice, but the QPX spec goes the other way: (pg_accessions, run_file_name) is the pg primary key and both fields must be non-null, and quantms silently drops rows whose run_file_name is empty, so such groups would vanish downstream instead of being flagged. qpx's own converters emit a stable non-empty token instead. Honest-but-dropped vs. lossy-but-visible is unresolved upstream (bigbio/qpx#51) and is to be decided in #9817, so record that next to the warning and next to the test that pins the value. No behaviour change: the branch is unreachable from any TOPP tool, since ProSE (its only caller) always passes a single-path run. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0178t42vQUwSPgeSzeCinQeF
|
Added the
Behaviour unchanged, and I've left the decision to #9817. Generated by Claude Code |
#9818 resolves each PSM's run and stems it inline via File::stemName. The label and melt work that follows needs the same reduction in ConsensusMapArrowExport and ProteinGroupArrowExport, so factor it into ArrowIOHelpers::qpxRunFileName() rather than repeating the call and its rationale at each site. This commit originally also carried a per-PSM run resolver and a hard-error preflight on run-name stem collisions. Both are dropped: #9818 landed the same resolution first (and additionally guards a missing id_merge_index, which this version did not), and its warn-and-continue collision policy is the project's choice -- same-named files in different directories are a legitimate layout. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
…lapsed rows Two defects from an adversarial review of the melt. A consensus feature can hold PeptideIdentification objects that are all hitless. The scan column guarded on !pep_ids.empty() and then dereferenced the selected identification, which is null in exactly that case -- a crash, introduced when the identification-level columns were rebound from pep_ids[0] to the winner. Guard on the selected identification instead. The melt grouped rows by the already-stemmed run name, so two runs whose paths differ only in directory (/frac_a/run1.mzML, /frac_b/run1.mzML -- the routine fractionated layout) were merged into ONE row carrying both runs' intensities. That is worse than the ambiguous-but-separate rows #9818 warns about: it fuses records rather than making a key ambiguous. Group by the source path and emit the stem only as the output value. Channels of one isobaric run share ColumnHeader::filename, so they still group into a single row, which is the intent. Both are covered by new tests: a feature whose identifications are all hitless, and two column headers sharing a stem asserted to produce two rows with one intensity each. Also records, without changing it, that explicit rt_start/rt_stop metavalues are authored on the ConsensusFeature and so are inherited unchanged by melted per-run rows. Where the handle RT diverges from the consensus RT that window does not bracket the row's own RT. Overriding an authored value is a semantic change beyond this PR, and existing coverage pins the current behaviour; the width fallback does use the row's own coordinates. 153/153 TOPP tests and 11/11 Arrow class tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
…ure and pg #9818 established the policy for source paths that collapse onto one run_file_name: warn and continue, because same-named files in different directories are a legitimate layout and only the spec's representation cannot express the distinction. That warning lived solely in the PSM exporter, so feature and pg hit the same condition silently even though they derive the same key. Lift it into ArrowIOHelpers::qpxWarnOnRunNameCollisions() and call it from all three views, so one collection reports the ambiguity once per exporter rather than once, and the policy has a single definition instead of being restated per view. The feature melt now groups rows by source path rather than by stem, so an ambiguous key is reported but the rows themselves stay separate -- the warning describes a key that cannot be told apart, never records that were merged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
…re and pg views The QPX feature and pg views record ONE peptide per feature -- singular sequence, peptidoform and charge, and no ConsensusFeature identifier linking alternatives. A feature whose identifications disagree on the top peptide cannot be represented: the feature view published a chosen interpretation while silently discarding the others, and the pg view counted evidence contributed by one peptide under another's identity. Make that a contract instead of a silent projection. ConsensusMapArrowExport:: requireUnambiguousIdentities() throws IllegalArgument on FEATURE_ID_MULTIPLE_DIVERGENT, naming the offending feature and the three resolvers, and is called by both the feature and pg exporters. It replaces the warn-and-skip added in the previous commit, which left the feature view publishing what the pg view refused. Ambiguity-preserving output already has a home: consensusparquet (ConsensusMapArrowIO) keeps every hit and the consensus feature association, and IDConflictResolver accepts it as input. So this is not "QPX loses a permissive mode" -- QPX never had one; its schema cannot express the ambiguity, and pretending otherwise produced a lossy projection wearing the name of an intermediate format. Several identifications agreeing on the same modified sequence (FEATURE_ID_MULTIPLE_SAME) remain accepted -- that is the deliberate output of IDConflictResolverAlgorithm::resolve() with keep_matching, which ProteomicsLFQ uses. The check is a PREFLIGHT, deliberately: buildFeatureTableRange() runs inside an OpenMP region whose worker catch-all would flatten an exception into a boolean, and an exception escaping such a region is std::terminate. It therefore runs before the parallel build and before the output file is opened, matching the merged-run validation #9818 established. Impact is narrow: ProteomicsLFQ resolves conflicts, IsobaricWorkflow builds one identification per feature, ProSE uses the id-only overload. Only ProteinQuantifier fed an unresolved consensusXML is affected, and its own documentation already states that such features are excluded from quantification. Two tests needed rework because their scenarios are now unreachable. The identification-coherence test gives both identifications the same peptide with different acquisition metadata, asserting scan and ion mobility come from the same one. The score orientation test is removed, with a note: observing which of two identifications won required them to name different peptides, which the contract now rejects. 153/153 TOPP tests and 11/11 Arrow class tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
…and joinable (#9825) * [FIX] QPX export: spec-conformant file metadata on all three views The Arrow schemas already transcribe the bigbio/qpx YAML schemas faithfully, but the file-level key-value metadata did not match the serialization spec: - feature.parquet carried NO metadata at all -- neither exportToParquet() nor exportToParquetStreaming() stamped any. - file_type used the bare view names ("psm", "pg") where the spec's tokens are "psm_file", "feature_file", "pg_file". - compression_format was never written. - software_provider was the bare string "OpenMS" with no version. - scan_format was hard-coded to "scan", which is wrong for index=-style native IDs and meaningless for tables that carry no spectrum references at all. - ProSE's merged quantms.*.parquet inherited the first per-run file's uuid and creation_date via plain table concatenation, instead of having an identity. Introduce ArrowIOHelpers::qpxFileMetadata() as a metadata *factory* rather than a table wrapper: streaming needs one identity per file, reused for the writer schema and every batch, so a per-batch wrapper would mint differing uuids and mismatch the writer schema. It refuses LZ4, which Parquet supports but QPX defines no compression_format token for. scan_format is now derived from the spectrum native IDs via ArrowIOHelpers::qpxScanFormat(). When the IDs disagree, the key is omitted and a warning logged rather than asserting a token that describes only part of the file; unrecognized IDs carry no evidence and do not veto an otherwise consistent set. Because a built table no longer carries native IDs, the table-taking QPXFile::exportToParquet() overload gained a defaulted scan_format parameter. Also fixes a latent out-of-bounds in ProteinGroupArrowExport: has_quant checked the float and string data arrays but not the integer one, while the loop below dereferences getIntegerDataArrays()[0]. The OpenMS-native Arrow writers (ConsensusMapArrowIO, FeatureMapArrowIO, ProteinIdentificationArrowIO) are deliberately untouched -- their file_type values belong to a different format and are not QPX views. Verified on the regenerated BSA collection: all three views tokened, in-vocabulary and with distinct uuids. No reference-file churn -- the -out_qpx TOPP tests only sha256sum for existence, and every FuzzyDiff'd mzTab/consensusXML/idXML comparison passes untouched. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: add a shared run_file_name normalization helper #9818 resolves each PSM's run and stems it inline via File::stemName. The label and melt work that follows needs the same reduction in ConsensusMapArrowExport and ProteinGroupArrowExport, so factor it into ArrowIOHelpers::qpxRunFileName() rather than repeating the call and its rationale at each site. This commit originally also carried a per-PSM run resolver and a hard-error preflight on run-name stem collisions. Both are dropped: #9818 landed the same resolution first (and additionally guards a missing id_merge_index, which this version did not), and its warn-and-continue collision policy is the project's choice -- same-named files in different directories are a legitimate layout. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: write canonical channel labels instead of channel numbers intensities[].label is the second documented QPX join key -- the spec matches it against the unnested run.samples[].label of run.parquet (docs/spec/views.md) -- so it has to carry a canonical channel token. pg.parquet wrote the raw channel number ("1" for every label-free row), which joins against nothing. Add ArrowIOHelpers::qpxIntensityLabel(), which maps a ConsensusMap column header to its label: "LFQ" for label-free, and the method family prefix plus OpenMS' own reporter name for isobaric channels ("TMT126", "TMT127N", "ITRAQ114"). All plexes name their channels bare ("126", "127N", ...), so a per-family prefix is sufficient and no per-plex exception table is needed. OpenMS' channel names are authoritative: TMT 10-plex channel 10 is "TMT131". qpx's own converter map is 11-plex-indexed and calls that channel "TMT131N"; that is an upstream issue (bigbio/qpx#163), not something to encode here. Pinned by a test so it cannot drift silently. iTRAQ is spelled uppercase ("ITRAQ114"), consistent with the TMT prefix. qpx's intensities.md example spells it "iTRAQ114", but no qpx converter actually emits an iTRAQ channel label -- its channel map is TMT-only and the iTRAQ path passes the raw tool value through -- so there is no implementation to match, only a doc example. The lookup is keyed on (run, channel) rather than channel alone, so a map whose runs used different methods stays correct. A channel whose quantitation method cannot be identified aborts the export rather than emitting a guessed token: a wrong join key is worse than a failed write. A channel with no describing column header falls back to "LFQ" when it is the only channel (label-free by construction) and otherwise warns loudly, since hand-built or foreign ConsensusMaps can reach this path. Feature-view labels are deliberately NOT changed here. Collapsing every label-free entry on a still-wide feature row to "LFQ" would destroy the per-run attribution the filename currently provides; they change together with the row melt. Adds class coverage for the isobaric path, which has no TOPP test at all (IsobaricWorkflow ships none) -- including that the mapping works without setExperimentType, which IsobaricWorkflow never calls. 145/145 TOPP tests and 10/10 Arrow class tests pass; no reference churn. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: melt feature and pg views to the spec's long row shape The QPX feature view is defined as "a quantified peptidoform in a specific run file" (docs/spec/feature.md), and pg as "one row per protein group per run" (docs/spec/pg.md). Both were emitted wide. feature.parquet held one row per ConsensusFeature with one intensity per contributing run, so run_file_name was an arbitrary pick among those runs and the intensities were distinguishable only by a non-conformant label. Melt to one row per (ConsensusFeature, run). The coordinate rule is mode-dependent: - label-free: each FeatureHandle carries its own run's RT / m/z / charge, so the row takes its quantitative coordinates from that handle rather than from the consensus centroid. - isobaric: the handles are reporter ions -- m/z is the reporter mass and RT the quantification scan -- while precursor coordinates live on the ConsensusFeature. Keep the consensus values and use the handles only for channel intensities. Taking handle coordinates here would have written a reporter mass into observed_mz. Feature intensity labels move to canonical tokens with the melt, not before it: collapsing them on a wide row would have destroyed the per-run attribution the source file name was accidentally providing. pg.parquet emitted unquantified groups with an empty run_file_name -- a primary-key component the spec says MUST NOT be null, and which quantms silently drops. Melt them onto the runs where the group actually has identification evidence, with null intensities. Evidence comes from the assigned PSMs' features and from unassigned PSMs (resolved through id_merge_index), so a group is never asserted into a run it was not seen in; fanning out across all column headers would have turned 13 unattributed rows into up to 65 fabricated ones. Groups with no evidence anywhere are skipped with a logged count rather than given a null key. peptides, peptide_counts and feature_counts are now populated per (group, run) using quantms semantics -- "unique" means deduplicated, not proteotypic. DIA-NN's converter reads those fields as proteotypic counts, so the numbers are only comparable within quantms-derived collections; noted at the call site. Feature identity now comes from the best-scoring hit across ALL of a feature's identifications instead of pep_ids[0].getHits()[0]. That also repairs a latent bug: a feature whose *first* identification carried no hits lost its identity entirely even when a later one had one. id_run_file_name is resolved from the identification that actually holds the winning hit. This needed a new IDFilter::getBestHit overload reporting the winning identification's index. Note the existing best_id_it is NOT that -- it is the score-type reference and stays pinned to the first non-empty identification -- so the winner is tracked separately. The three-argument form now delegates, keeping one implementation. getBestHit throws on mixed score types (unreachable for our tools, possible for a foreign map), so the caller falls back to the positional pick and warns once rather than failing the export. Consensus features with no handles produce no row: they have neither quantification nor a run to key on. No shipped tool emits them (IsobaricWorkflow filters zero-intensity features at :780), so this is a guard for foreign input. On the BSA collection: feature 39 wide rows -> 60 long rows, one LFQ intensity each; pg 38 -> 40 rows with zero empty run_file_name (was 13). All three views now share one run vocabulary, the primary keys hold, and no required string is empty. 145/145 TOPP tests and 10/10 Arrow class tests pass; no reference churn. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: feature anchor_protein is nullable (bigbio/qpx#212) bigbio/qpx#212 ("de novo peptide sequencing workflows (no database search)", merged 2026-07-29) added `nullable: true` to feature.anchor_protein in both the spec and runtime schemas, keeping `required: true`: anchor_protein: type: string required: true nullable: true doc: "Representative protein; null when no protein mapping was performed" Match it: QPXFeatureSchema declares the field nullable, and a feature with no protein mapping now writes null instead of "". An empty string satisfied the non-nullable column while being neither an accession nor an absence -- exactly the class of value-level defect a schema check cannot see. pg.anchor_protein is untouched: #212 changed only feature.yaml and psm.yaml, so the pg view keeps `required: true` with no nullable, and its non-nullable assertion in QPXFile_test stands. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: one identification and one coordinate source per melted row Two defects introduced by the feature melt, both invisible to the existing tests because every fixture gave a feature a single identification and identical coordinates. A ConsensusFeature can carry several PSMs. The melt started taking sequence, scores and id_run_file_name from the best-scoring identification while posterior_error_probability, scan and ion_mobility still read pep_ids[0], so one row could report peptide A's identity beside peptide B's acquisition metadata. Bind the winner once and use it for every identification-level column. The mixed-score-type fallback also reverted to pep_ids[0] unconditionally, which reintroduced the empty-first-identification bug the best-hit selection exists to fix; it now falls back to the first identification that actually has a hit. Likewise for coordinates: observed_mz switched to the run's FeatureHandle for label-free rows, but calculated_mz and mass_error_ppm were still computed against the consensus centroid and rt_start/rt_stop against the consensus RT and width. The reported ppm error was therefore measured against an m/z the row does not contain. Resolve the row's coordinate source once -- handle for label-free, consensus for isobaric, whose handles are reporter ions -- and derive charge, observed/calculated m/z, ppm error, RT and the RT bounds from that single binding. Both are covered by new tests: a feature whose better-scoring identification is *not* first, asserting sequence, scan and ion mobility all describe it; and a label-free feature whose handle coordinates differ from the consensus centroid, asserting the ppm error is measured against the m/z the row reports and not against the centroid. Found by an adversarial review of the melt commit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: document the concatenate metadata parameter, drop a dead one Two CI failures, both introduced by this branch. Doxygen_Warning_test failed on every platform: the `metadata` parameter added to ArrowIOHelpers::concatenateAndWriteToParquet() was never documented, and the gate treats an undocumented parameter as an error. It only skips lines containing "Consider increasing DOT_GRAPH_MAX_NODES" (Doxygen_Warning_Checker.cpp:44), so nothing else absorbed it. This does not reproduce locally without graphviz: without HAVE_DOT, doxygen emits "ignoring \dot command" warnings that the gate also counts, so the test fails for an unrelated reason and masks whether a real warning was added. Verified by running the doc target and confirming the metadata warning is gone, leaving only the two HAVE_DOT lines. Also removes `distinct_peptides_for_run` from the pg emitRow lambda. It became dead when the peptide/feature counts moved to the per-(group, run) evidence index, and was raising -Wunused-parameter. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: localize best-hit selection, hoist per-run derivations Reverts the IDFilter::getBestHit overload added earlier in this branch and moves the selection into ConsensusMapArrowExport as selectFeatureIdentity(). The overload had exactly one caller and could not absorb the existing hand-rolled variants (MapAlignmentAlgorithmIdentification::getBestScoringHit is protected, works within a single identification and returns a pointer; MzTab aggregates scores with different tie-breaking; QTClusterFinder's is a threshold filter, not a selection), so it was public API in a widely-included header with no second user. Score comparison is not duplicated -- the local version delegates to PeptideIdentification::getScoreComparator, the same primitive those sites use -- and mixed score types are now detected directly instead of via a thrown exception used for control flow. Also from a quality review of the melt: The run name and intensity label are now derived once per column header into FeatureIdLookups instead of once per FeatureHandle per row. Both are pure functions of the header, of which there are at most a few dozen, while the export loop touches them per handle per row. File::stemName() scans a 73-entry file-type table, and reading channel_name by string takes the MetaInfoRegistry omp-critical lock -- which buildFeatureTableRange goes out of its way to keep out of the loop for exactly this reason (see the pre-resolved metavalue index block), and which the label lookup had reintroduced inside the parallel batch build. Isobaric detection no longer relies solely on sniffing channel_name. A map counts as isobaric if it declares a labelled experiment type OR annotates channels: neither signal alone is reliable, since IsobaricWorkflow annotates channels without ever calling setExperimentType, while ConsensusMapArrowExport_test's own TMT fixture declares "labeled_MS2" with no channel_name. Getting this wrong writes reporter-ion m/z into observed_mz. The sibling pg exporter already trusted the experiment type, so the two views now agree on how the question is answered. qpxIntensityLabel()'s contract that callers must handle an empty result is now honoured: a channel whose quantitation method cannot be identified fails the export rather than writing an empty string into a documented join key, matching what the pg exporter already did. The family prefix is derived from the method's canonical identifier instead of a nine-case switch whose default silently returned "" -- a dropped join key -- for any method added later. 153/153 TOPP tests and 11/11 Arrow class tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: null deref on hitless identifications, and stem-collapsed rows Two defects from an adversarial review of the melt. A consensus feature can hold PeptideIdentification objects that are all hitless. The scan column guarded on !pep_ids.empty() and then dereferenced the selected identification, which is null in exactly that case -- a crash, introduced when the identification-level columns were rebound from pep_ids[0] to the winner. Guard on the selected identification instead. The melt grouped rows by the already-stemmed run name, so two runs whose paths differ only in directory (/frac_a/run1.mzML, /frac_b/run1.mzML -- the routine fractionated layout) were merged into ONE row carrying both runs' intensities. That is worse than the ambiguous-but-separate rows #9818 warns about: it fuses records rather than making a key ambiguous. Group by the source path and emit the stem only as the output value. Channels of one isobaric run share ColumnHeader::filename, so they still group into a single row, which is the intent. Both are covered by new tests: a feature whose identifications are all hitless, and two column headers sharing a stem asserted to produce two rows with one intensity each. Also records, without changing it, that explicit rt_start/rt_stop metavalues are authored on the ConsensusFeature and so are inherited unchanged by melted per-run rows. Where the handle RT diverges from the consensus RT that window does not bracket the row's own RT. Overriding an authored value is a semantic change beyond this PR, and existing coverage pins the current behaviour; the width fallback does use the row's own coordinates. 153/153 TOPP tests and 11/11 Arrow class tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: apply #9818's warn-on-stem-collision policy to feature and pg #9818 established the policy for source paths that collapse onto one run_file_name: warn and continue, because same-named files in different directories are a legitimate layout and only the spec's representation cannot express the distinction. That warning lived solely in the PSM exporter, so feature and pg hit the same condition silently even though they derive the same key. Lift it into ArrowIOHelpers::qpxWarnOnRunNameCollisions() and call it from all three views, so one collection reports the ambiguity once per exporter rather than once, and the policy has a single definition instead of being restated per view. The feature melt now groups rows by source path rather than by stem, so an ambiguous key is reported but the rows themselves stay separate -- the warning describes a key that cannot be told apart, never records that were merged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: select a feature's identity with one score orientation selectFeatureIdentity() built a comparator from each identification's own isHigherScoreBetter(), so a feature whose identifications disagreed on orientation was compared in two directions within a single selection and the winner depended on identification order. It also carried a fallback that, on a score-type mismatch, kept the best of the already-scanned prefix while the warning claimed it was using the first hit found -- code and message disagreeing. Take the orientation from the first identification that has a hit and use that one comparator throughout. The winner is now well defined and order-independent. The fallback is removed rather than corrected. Identifications that disagree on score type or orientation are a pipeline defect, not a case to recover from: scores of different types are not comparable, harmonizing them is an explicit step (IDScoreSwitcher / IDScoreSwitcherAlgorithm, which ProteomicsLFQ, Epifany and FalseDiscoveryRate all run), and IDFilter::getBestHit -- the codebase's shared primitive -- throws outright on the same condition, with no caller catching it. The export now warns and proceeds with the reference orientation instead of inventing a recovery that would turn a broken input into an arbitrary answer. Throwing was considered and rejected: it would fail exports the tool previously accepted. Tests: identifications declaring the same score type with contradictory orientations, asserted from both orderings, so a reintroduced per-identification comparator changes an answer; and a leading hitless identification, which the original positional pick silently discarded the feature's identity for. 153/153 TOPP tests and 11/11 Arrow class tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: exclude divergently-annotated features from pg counts The pg view attributes a feature to ONE peptide: its sequence, peptidoform and charge feed peptides[], peptide_counts and feature_counts. The evidence index stored one identity per ConsensusFeature -- taken from the first identification with hits -- while attaching evidence from EVERY identification, so an accession contributed by peptide B was counted using peptide A's identity. It also mis-set unique_sequences and unique_features whenever two features reported different first identifications. Exclude features whose identifications disagree on the top peptide, warning once with the count. This matches what quantification already does: ProteinQuantifier documents that "only features/feature groups with unambiguous peptide annotation are used for peptide quantification", so the counts now agree with the abundances in the same export. ProteomicsLFQ and IsobaricWorkflow already satisfy the condition -- the former resolves conflicts, the latter builds one identification per feature. Uses the existing BaseFeature::getAnnotationState() rather than a new predicate. An earlier version of this change added BaseFeature::hasSingleIdentification(), which was wrong three ways: it duplicated AnnotationState; it inspected only the legacy peptides_ container, ignoring id_matches_; and it rejected FEATURE_ID_MULTIPLE_SAME -- several identifications agreeing on the same modified sequence, which is the deliberate output of IDConflictResolverAlgorithm::resolve(.., keep_matching=true) as called by ProteomicsLFQ. Only FEATURE_ID_MULTIPLE_DIVERGENT is a real conflict, the same distinction PeptideAndProteinQuant and MzTab already make. Also fixes an unterminated START_SECTION: an apostrophe in a section title opens a character literal and swallows the rest of the file, so the two identity-selection tests added earlier never compiled. They pass now. 153/153 TOPP tests and 11/11 Arrow class tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: require unambiguous feature identities in the feature and pg views The QPX feature and pg views record ONE peptide per feature -- singular sequence, peptidoform and charge, and no ConsensusFeature identifier linking alternatives. A feature whose identifications disagree on the top peptide cannot be represented: the feature view published a chosen interpretation while silently discarding the others, and the pg view counted evidence contributed by one peptide under another's identity. Make that a contract instead of a silent projection. ConsensusMapArrowExport:: requireUnambiguousIdentities() throws IllegalArgument on FEATURE_ID_MULTIPLE_DIVERGENT, naming the offending feature and the three resolvers, and is called by both the feature and pg exporters. It replaces the warn-and-skip added in the previous commit, which left the feature view publishing what the pg view refused. Ambiguity-preserving output already has a home: consensusparquet (ConsensusMapArrowIO) keeps every hit and the consensus feature association, and IDConflictResolver accepts it as input. So this is not "QPX loses a permissive mode" -- QPX never had one; its schema cannot express the ambiguity, and pretending otherwise produced a lossy projection wearing the name of an intermediate format. Several identifications agreeing on the same modified sequence (FEATURE_ID_MULTIPLE_SAME) remain accepted -- that is the deliberate output of IDConflictResolverAlgorithm::resolve() with keep_matching, which ProteomicsLFQ uses. The check is a PREFLIGHT, deliberately: buildFeatureTableRange() runs inside an OpenMP region whose worker catch-all would flatten an exception into a boolean, and an exception escaping such a region is std::terminate. It therefore runs before the parallel build and before the output file is opened, matching the merged-run validation #9818 established. Impact is narrow: ProteomicsLFQ resolves conflicts, IsobaricWorkflow builds one identification per feature, ProSE uses the id-only overload. Only ProteinQuantifier fed an unresolved consensusXML is affected, and its own documentation already states that such features are excluded from quantification. Two tests needed rework because their scenarios are now unreachable. The identification-coherence test gives both identifications the same peptide with different acquisition metadata, asserting scan and ion mobility come from the same one. The score orientation test is removed, with a note: observing which of two identifications won required them to name different peptides, which the contract now rejects. 153/153 TOPP tests and 11/11 Arrow class tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] ProteinQuantifier: drop divergently-annotated features, abort on QPX write failure ProteinQuantifier was the only shipped path that could trip the QPX feature/pg identity contract, because it is the only one that neither resolves ID conflicts nor builds one identification per feature. It does not need to. Such features already contribute nothing: PeptideAndProteinQuant::getAnnotation_() returns an empty PeptideHit when the top sequences disagree (PeptideAndProteinQuant.cpp:104-107), so they are absent from every abundance the tool computes -- which is what the tool's own documentation has always said. Remove them after loading and warn with the count, naming the three resolvers. That makes the exclusion explicit rather than implicit, and keeps a QPX export describing exactly the features that produced the intensities in the same run. Exporting them would have published protein-level evidence for features absent from every abundance; failing the export would have rejected input the tool otherwise handles. Filtering is unconditional rather than gated on -out_qpx: since the features are already ignored, removing them cannot change a result, and a conditional would add a branch with no observable effect outside QPX. Verified -- all 43 ProteinQuantifier TOPP tests pass unchanged. With this, every in-tree caller establishes the contract (ProteomicsLFQ resolves, IsobaricWorkflow builds one identification per feature, ProteinQuantifier filters), so requireUnambiguousIdentities() is an invariant assertion rather than something a user can trip. Also makes a failed QPX write abort. All three exports logged the error and continued, so a partial collection was left behind with a zero exit code -- indistinguishable from success. The enclosing helper returns ExperimentalDesign, so this throws UnableToCreateFile rather than returning an exit code. 153/153 TOPP tests and 11/11 Arrow class tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm * [FIX] QPX export: reattach the exportToArrow doc block to its declaration The requireUnambiguousIdentities() declaration was inserted between exportToArrow()'s doc block and exportToArrow() itself, so both blocks attached to requireUnambiguousIdentities -- each documenting @PARAM cmap -- and exportToArrow was left undocumented. Doxygen reports this as ConsensusMapArrowExport.h:54: warning: argument 'cmap' from the argument list of OpenMS::ConsensusMapArrowExport::requireUnambiguousIdentities has multiple @PARAM documentation sections which failed Doxygen_Warning_test on all five CI platforms. Move the new declaration below exportToArrow so each block documents its own function. Comment placement only; no API or behaviour change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 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]>
Two independent defects in the QPX Parquet export, both in a column the spec
marks Required and uses as the Hive partition key and the psm/feature/pg join key.
quantms.psm.parquet labelled every PSM with the first MS run of its
identification run. ProteomicsLFQ (and IDMerger) merge all inputs into a
single ProteinIdentification whose 'spectra_data' lists every input file,
with each PeptideIdentification selecting one via 'id_merge_index'. QPXFile
keyed a map on the run identifier alone and stored only ms_runs[0], so a
120-run dataset produced one distinct run_file_name instead of 120.
Resolution now goes through IdentifierMSRunMapper, which reads that index -
the same source the mzTab exporter written by the same invocation already
used. Merged input carrying no usable index is refused with
Exception::MissingInformation rather than silently mislabelled; for the
streaming export the check is a serial pre-pass that runs before the output
file is opened, since a throw from inside the OpenMP region would be
swallowed by its exception firewall and leave a truncated .parquet behind.
The identical collapse in the internal PSMSchema 'reference_file_name' is
fixed too (full paths there, which the internal format must round-trip):
importFromArrow restores that value as a per-hit metavalue that the QPX
writer prefers over the run-derived fallback, so leaving it would have
re-introduced the bug after any internal-format round trip.
run_file_name was emitted as a full path with extension. The three QPX
tables derive it from three unrelated sources and only the protein-group
quantification path already normalized it, so they could not be joined.
The psm, feature and identification-only protein-group writers now apply
File::stemName() at the point of append. The quantified protein-group path
is deliberately left alone: PeptideAndProteinQuant already stems those
values and FileHandler::stripExtension is not idempotent (for an
unrecognized extension it strips at the last dot), so stemming twice would
turn a legitimate stem like 'HeLa_1.2ug' into 'HeLa_1'.
Distinct paths collapsing onto one stem are warned about once per export and
still exported - the origin is known, only the spec's representation cannot
express it. The identification-only protein-group export additionally emits
an empty run_file_name for a run spanning several MS files, because a group
inferred across runs has no single origin file.
Verified on the full ProteomicsLFQ pipeline test (5 mzMLs): psm and feature now
both report the same 5 bare stems, where psm previously reported 1 value with
'.mzML'. ProteinGroupArrowExport gains a class test; it had none.
Co-Authored-By: Claude Opus 5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_0178t42vQUwSPgeSzeCinQeF
Summary by CodeRabbit
Bug Fixes
run_file_namein Arrow/QPX exports to use spectrum filename stems only (no paths or extensions), including consistent per-PSM labeling for merged runs.reference_file_namepopulation and clarified protein-grouprun_file_namebehavior: populated for single-run groups, empty for multi-run groups.id_merge_indexand warns on ambiguous stem collisions.Tests