Skip to content

[FIX,API,TEST] Key the Sample* design mappings by sample name - #9874

Merged
timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:fix/design-sample-name-keys
Aug 6, 2026
Merged

timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:fix/design-sample-name-keys

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

ExperimentalDesign's two Sample* mappings have the same signature and opposite key spaces, and the consumers of both resolve them the same way — so one of them throws for essentially every real design.

The bug

keyed by
getSampleToPrefractionationMapping() sample name
getSampleToConditionMapping() stringified zero-based row index

Both getPathLabelTo*Mapping() consumers did:

ret.emplace(entry.first, sToPreFrac.at(StringUtils::toStr(entry.second)));  // entry.second is the INDEX

So the prefractionation one asks a name-keyed map for "0" and throws a bare std::out_of_range — message map::at, naming neither the sample nor the design, and not deriving from Exception::Base so OpenMS error handling never sees it.

It only works when the sample names are the stringified indices — which is exactly what fromIdentifications() and fromConsensusMap() mint (sample_name = toStr(sample)). That is why nothing caught it: the paths OpenMS generates itself make name and index coincide, and every path where a human or sdrf-pipelines supplies names breaks.

Note that includes purely numeric names: sdrf-pipelines numbers samples from 1 while rows are 0-based, so "1","2" never coincides with 0,1 either. Epifany's extended model reaches this path (#9864 §A5 — this is its root cause, and more precise than that issue's description).

The fix

Both mappings are keyed by name, and both lookups go through it.

SampleSection::getSampleName() cannot supply the reverse — it reads content_.at(row).at(columnname_to_columnindex_.at("Sample")), i.e. the Sample column of the content, which a section built with addSample() or inferred from a map does not have. So sampleRowToName_() reverses the authoritative sample_to_rowindex_ store instead.

Two things found along the way:

  • the factorless getSampleToConditionMapping() branch ran for (i = 0; i <= getNumberOfSamples(); ++i), reporting one sample more than the section holds, and fabricated keys "0".."N" that only mean anything under the wrong assumption. It now enumerates the actual samples.
  • getNumberOfSamples() is documented // @return the number of samples measured (= highest sample index) but returns the row count. With zero-based samples those differ by one — and that comment is precisely how this class of bug gets written. Corrected.

Breaking

getSampleToConditionMapping()'s keys change from stringified indices to names. It has no in-tree caller and no pyOpenMS binding, so the practical blast radius is the two consumers fixed here.

Test

Builds two designs — "1"/"2" (the sdrf-pipelines shape) and "BSA1"/"BSA2" — and asserts both mappings cover every sample by name, that neither reports a phantom extra sample, and that both per-(path,label) resolutions succeed.

Verified it fails without the fix, for the right reason:

checking ([EXTRA] sample names that are not stringified row indices must not break the derived mappings) ...
Error: Caught unexpected std::exception
 - Message: map::at

Full local ctest: 2800/2802, 8 failures, all pre-existing environmental (6 CometAdapter version-string, PercolatorAdapter numerics, Doxygen_Warning_test HAVE_DOT) — identical to the baseline.

Found while auditing the sample/fraction_group numbering conventions for #9864. Independent of #9869; if that merges first this rebases cleanly apart from an adjacent test section.

Second commit: getSampleName works for both section shapes

The same root cause, one level down. A sample name lives in two places, and which is filled depends on how the section was built — a parsed design file fills the content table and a "Sample" column; a section assembled with addSample() (how fromConsensusMap() and fromIdentifications() build theirs) fills only the name→row store and pushes an empty content row.

getSampleName() read only the column:

return content_.at(sample_row).at(columnname_to_columnindex_.at("Sample"));

so it threw std::out_of_range for every inferred design, though the name sat in sample_to_rowindex_ the whole time. annotateColumnHeaders() worked around it by catching the throw and dropping the name.

It now reads the column when there is one and falls back to the name→row store otherwise. A row present in neither raises ElementNotFound naming the row and the section size, instead of a bare map::at. getSampleRow() gets the same treatment for an unknown name.

Behaviour change worth reviewing: an inferred design now annotates a sample_name onto consensus-map headers where it previously annotated none, because the workaround no longer fires. No shipped reference moves — but that is a vacuous result, not a reassuring one: the only test reaching annotateColumnHeaders passes -exp_design, i.e. a parsed design, which always had the column. That is precisely why the path was never covered, so both halves are now tested directly.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Corrected sample-to-condition and sample-to-prefractionation mappings to consistently use sample names.
    • Fixed mapping behavior for custom and numeric sample names.
    • Prevented extra sample entries in designs without factors.
    • Improved path and label lookups for reliable mapping resolution.
    • Note: Consumers of sample-to-condition mappings may need updates due to this behavior change.
  • Documentation

    • Clarified mapping and sample-count behavior.
  • Tests

    • Added regression coverage for varied sample naming schemes and inferred designs.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

ExperimentalDesign now keys sample-to-condition and sample-to-prefractionation mappings by sample names. Path-label lookups use the same keys. Factorless condition mappings cover existing samples without an extra entry. Tests cover numeric and arbitrary sample names.

Changes

ExperimentalDesign mapping corrections

Layer / File(s) Summary
Sample-name lookup contract
src/openms/include/OpenMS/METADATA/ExperimentalDesign.h, src/openms/source/METADATA/ExperimentalDesign.cpp, src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp
Documentation and lookup helpers define sample-name keys, sample-section row handling, inferred-design resolution, and missing-sample errors.
Name-keyed mappings and validation
src/openms/source/METADATA/ExperimentalDesign.cpp, src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp, CHANGELOG
Mapping logic resolves sample rows to names, removes the extra factorless condition entry, updates path-label lookups, and tests numeric and arbitrary sample names. The breaking key change is documented.

Possibly related PRs

  • OpenMS/OpenMS#9836: Both changes modify ExperimentalDesign sample-name resolution and inferred-design handling.
  • OpenMS/OpenMS#9841: Both changes document fixes to ExperimentalDesign behavior.
  • OpenMS/OpenMS#9869: Both changes modify sample mapping behavior and related tests.

Poem

A rabbit checked each sample name,
Then matched every row the same.
No extra condition hopped ahead,
Path labels found the names they read.
Numeric or arbitrary, keys align.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main API and test change: key ExperimentalDesign Sample* mappings by sample name.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/openms/include/OpenMS/METADATA/ExperimentalDesign.h (1)

212-213: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the required Doxygen block format for changed API documentation.

  • src/openms/include/OpenMS/METADATA/ExperimentalDesign.h#L212-L213: Convert the getSampleToPrefractionationMapping() documentation to a /** */ block with @brief.
  • src/openms/include/OpenMS/METADATA/ExperimentalDesign.h#L243-L244: Convert the getSampleToConditionMapping() documentation to a /** */ block with @brief.
  • src/openms/include/OpenMS/METADATA/ExperimentalDesign.h#L256-L258: Convert the getNumberOfSamples() documentation to a /** */ block with @brief and @return.

As per coding guidelines, “Doxygen comments must use /** */ with @ tags; @brief is required.”

🤖 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/ExperimentalDesign.h` around lines 212 -
213, Update the documentation for getSampleToPrefractionationMapping() at
src/openms/include/OpenMS/METADATA/ExperimentalDesign.h:212-213 to use a /** */
Doxygen block with `@brief`; apply the same format to
getSampleToConditionMapping() at :243-244, and add both `@brief` and `@return` tags
to getNumberOfSamples() at :256-258.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp`:
- Around line 803-836: Extend the test setup around designWithSampleNames to
create a factor-based ExperimentalDesign using SampleSection::addSample with
each sample’s name, sample factor, and a non-replicate factor such as “control”.
Add assertions that getSampleToConditionMapping() contains every sample name and
that getPathLabelToConditionMapping(false) resolves both samples through the
factor-backed condition mapping, covering the getFactors() branch.

---

Nitpick comments:
In `@src/openms/include/OpenMS/METADATA/ExperimentalDesign.h`:
- Around line 212-213: Update the documentation for
getSampleToPrefractionationMapping() at
src/openms/include/OpenMS/METADATA/ExperimentalDesign.h:212-213 to use a /** */
Doxygen block with `@brief`; apply the same format to
getSampleToConditionMapping() at :243-244, and add both `@brief` and `@return` tags
to getNumberOfSamples() at :256-258.
🪄 Autofix

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: 1dd4fa21-d583-4524-af75-768780b37ccf

📥 Commits

Reviewing files that changed from the base of the PR and between 7a7aa8f and 09d6968.

📒 Files selected for processing (4)
  • CHANGELOG
  • src/openms/include/OpenMS/METADATA/ExperimentalDesign.h
  • src/openms/source/METADATA/ExperimentalDesign.cpp
  • src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp

timosachsenberg and others added 2 commits August 6, 2026 09:13
ExperimentalDesign's two Sample* mappings have the same signature and
opposite key spaces: getSampleToPrefractionationMapping() is keyed by
sample NAME, getSampleToConditionMapping() used the stringified
zero-based sample row index. Both getPathLabelTo* consumers resolved them
by stringifying that index, so the prefractionation one asked a
name-keyed map for "0" and threw a bare std::out_of_range -- "map::at",
naming neither the sample nor the design.

It works only when the names ARE the stringified indices, which is
exactly what fromIdentifications() and fromConsensusMap() mint
(sample_name = toStr(sample)). Every design a human or sdrf-pipelines
writes breaks: sdrf-pipelines numbers samples from 1, so even purely
numeric names never coincide with their 0-based rows. Epifany's extended
model reaches this path.

Both mappings are keyed by name now and both lookups go through it.
SampleSection::getSampleName() cannot provide the reverse -- it reads the
"Sample" COLUMN of the content, which a section built with addSample(),
or inferred from a map, does not have -- so sampleRowToName_() reverses
the authoritative name->row store instead.

The factorless getSampleToConditionMapping() branch also ran to
i <= getNumberOfSamples() and reported one sample more than the section
holds; it now enumerates the actual samples. getNumberOfSamples() is
documented as "highest sample index" but returns the row count; with
zero-based samples those differ by one, and that comment is how this
class of bug gets written. Corrected.

BREAKING for getSampleToConditionMapping()'s keys. It has no in-tree
caller and no pyOpenMS binding, so the practical blast radius is the two
consumers fixed here.

The new test builds designs named "1"/"2" (the sdrf-pipelines shape) and
"BSA1"/"BSA2", and asserts both mappings cover every sample by name and
that both per-(path,label) resolutions succeed. It fails on develop with
"Caught unexpected std::exception - Message: map::at".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…d ones

A sample name lives in two places in SampleSection, and which one is
filled depends on how the section was built. A parsed design file fills
the content table and a column called "Sample"; a section assembled with
addSample() - which is how fromConsensusMap() and fromIdentifications()
build theirs - fills only the name->row store and pushes an empty content
row.

getSampleName() read only the column:

  return content_.at(sample_row).at(columnname_to_columnindex_.at("Sample"));

so it threw std::out_of_range for every inferred design, even though the
name was sitting in sample_to_rowindex_ the whole time. annotateColumnHeaders()
worked around it by catching the throw and dropping the name.

It now answers from the column when there is one and falls back to the
name->row store, which every construction path fills. A row that exists
in neither raises ElementNotFound naming the row and the section size,
instead of a bare "map::at". getSampleRow() gets the same treatment for
an unknown name.

Behaviour change worth knowing: an inferred design now annotates a
sample_name onto consensus map headers where it previously annotated
none, because the workaround no longer fires. No shipped reference moves
- the only test that reaches annotateColumnHeaders passes -exp_design, so
a parsed design, which always had the column. That is exactly why the
path was never covered, so both halves are now tested directly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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/tests/class_tests/openms/source/ExperimentalDesign_test.cpp`:
- Around line 828-829: Update the assertions in the cmap header test to validate
the actual sample_name metadata values, expecting "0" for the first header and
"1" for the second, rather than only checking key existence. Keep the existing
header access through getColumnHeaders().at() and assert both generated names.
🪄 Autofix

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: 71a73fb9-0820-4b30-8ee5-bbcda7b2cbff

📥 Commits

Reviewing files that changed from the base of the PR and between 09d6968 and bdad383.

📒 Files selected for processing (2)
  • src/openms/source/METADATA/ExperimentalDesign.cpp
  • src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openms/source/METADATA/ExperimentalDesign.cpp

Comment on lines +828 to +829
TEST_TRUE(cmap.getColumnHeaders().at(0).metaValueExists("sample_name"))
TEST_TRUE(cmap.getColumnHeaders().at(1).metaValueExists("sample_name"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert each annotated sample_name value.

These assertions only verify that the metadata key exists. Incorrect or duplicated sample names would pass this test. Assert the expected generated names, "0" and "1", for the two headers.

As per coding guidelines, write unit tests for new functionality and update relevant tests.

🤖 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/ExperimentalDesign_test.cpp` around lines
828 - 829, Update the assertions in the cmap header test to validate the actual
sample_name metadata values, expecting "0" for the first header and "1" for the
second, rather than only checking key existence. Keep the existing header access
through getColumnHeaders().at() and assert both generated names.

Source: Coding guidelines

@timosachsenberg
timosachsenberg force-pushed the fix/design-sample-name-keys branch from bdad383 to 91cddf0 Compare August 6, 2026 07:29
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@timosachsenberg
timosachsenberg merged commit 042c324 into OpenMS:develop Aug 6, 2026
33 checks passed
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…ow counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that OpenMS#9869/OpenMS#9874/OpenMS#9876 touched - so it
now VERIFIES rather than assumes OpenMS#9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of OpenMS#9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…ow counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that OpenMS#9869/OpenMS#9874/OpenMS#9876 touched - so it
now VERIFIES rather than assumes OpenMS#9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of OpenMS#9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…ow counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that OpenMS#9869/OpenMS#9874/OpenMS#9876 touched - so it
now VERIFIES rather than assumes OpenMS#9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of OpenMS#9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit that referenced this pull request Aug 6, 2026
…es 1-2) (#9879)

* [TEST] QPX: pin values against text references, not just schema and row counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that #9869/#9874/#9876 touched - so it
now VERIFIES rather than assumes #9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of #9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

* [FIX,TEST] Address review: escape the backslash, and make the row-floor test mean what it says

Three findings from CodeRabbit on #9879, all valid.

1. dumpToTsv could forge an escape. A tab is rendered as the two characters '\'
   't' to keep one row on one line - but a value that ALREADY contained a
   backslash followed by 't' rendered to those same two characters. Two
   genuinely different tables therefore produced identical text and the
   reference comparison accepted them as equal, which is the exact failure a
   value reference exists to rule out. The backslash is now escaped first and
   unconditionally.

   Verified in both directions rather than assumed: two tables differing only in
   'literal backslash-t' versus 'a real tab' now render as X\\tY and X\tY, and
   with the fix reverted the new regression section fails on
   TEST_NOT_EQUAL(text_a, text_b) because both collapse to [X\tY]. The section
   also asserts that neither dump contains a raw tab, which would split a row.

   None of the four committed references contains a backslash, so none of them
   moves - checked, and all 51 QPX/ParquetDiff tests still pass against the
   unchanged files.

2. TOPP_ParquetDiff_8 passed for the wrong reason. It exists to show the row
   floor applies to the SECOND input, and it did fail - but its two fixtures have
   disjoint primary keys, so it would have failed on the key mismatch even if
   'min_rows' never looked at 'in2' at all. 'schema_only' now removes every other
   failure cause, leaving the floor as the only thing that can go red.

3. The documented canonical key order was backwards, in both the CHANGELOG and
   the CMake comment. Length-prefixing puts the six-character 'TMT126' and
   'TMT131' ahead of the seven-character 'TMT127C', not 'TMT127C' before
   'TMT131'.

Full local ctest unchanged at 2826 tests, 9 pre-existing environmental failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant