Skip to content

[FIX] IsobaricWorkflow: annotate the resolved design onto the column headers - #9836

Merged
timosachsenberg merged 2 commits into
developfrom
isobaric-annotate-fraction-group
Jul 31, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
isobaric-annotate-fraction-group

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

IsobaricChannelExtractor sets only the four channel meta values on a ConsensusMap::ColumnHeader, so once IsobaricWorkflow resolved an ExperimentalDesign the fraction structure lived in the design object and nowhere else. Anything reading the map back — exporters, converters — could not tell two fractions of one sample from two independent runs. ProteomicsLFQ has annotated its headers this way for label-free all along; the isobaric path never did.

Measured on the shipped fractionated plex (MSstatsConverter_2_in.consensusXML + MSstatsConverter_2_design.tsv, 2 files × 10 channels):

before after
headers carrying fraction_group 0 of 20 20 of 20
grouping recoverable from the map no fraction_group=1 shared, fraction 1 and 2

Where the logic lives

This is the inverse of ExperimentalDesign::fromConsensusMap(), so it sits next to it as ExperimentalDesign::annotateColumnHeaders() rather than inline in a TOPP tool. Three reasons: it is unit-testable there, ProteomicsLFQ does the same thing inline and now has somewhere to converge, and the (file, label) key derivation is design knowledge rather than tool knowledge.

It returns the number of headers with no matching design row instead of logging, leaving the policy to callers. IsobaricWorkflow warns on a non-zero return — silent non-annotation is the failure mode, since a wrong key derivation would simply annotate nothing while looking like it worked.

Second fix in the same place

ExperimentalDesign::fromConsensusMap() was called unconditionally and only then overwritten by -exp_design. Besides the wasted work it logged "No fractions annotated in consensusXML. Assuming unfractionated." once per column header — 20 times on the fixture above — even when a design file said otherwise.

Verification

  • New class test asserting the property that matters: two fraction files of one quantification unit share a fraction_group and differ by fraction; an unmatched header is counted rather than silently skipped.
  • Confirmed the test discriminates — neutering the lookup gives got '4', expected '0' plus both metavalue assertions failing.
  • 155/155 tests (ProteomicsLFQ, ProSE, ProteinQuantifier, IsobaricAnalyzer, ExperimentalDesign); no reference-file churn.

Coverage caveat: IsobaricWorkflow still has no functional TOPP test — that block is commented out with a TODO and every add_test disabled. So the sweep above exercises IsobaricAnalyzer, not this tool; its coverage here is the class test plus the design fixture. That gap is why this went unnoticed.

Why now

Prerequisite for QPX 1.1 (bigbio/qpx#220), which keys the pg view on grouped_runs — the set of raw files aggregated into one quantification unit. Without fraction_group on the headers the isobaric path has no way to compute that grouping. Context in #9817.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm

Summary by CodeRabbit

  • New Features

    • Consensus-map column headers are now annotated with fraction group, fraction, and sample metadata when matched to an experimental design.
    • Isobaric workflows can use a supplied experimental-design file or derive design information from the consensus map.
  • Bug Fixes

    • Unmatched or ambiguous file and channel columns are detected, left unannotated, and reported with a warning.

…headers

IsobaricChannelExtractor sets only the four channel meta values on a column
header, so after IsobaricWorkflow resolves an ExperimentalDesign the fraction
structure existed in the design object and nowhere else. Anything reading the
map back -- exporters, converters -- could not tell two fractions of one sample
from two independent runs. ProteomicsLFQ has annotated its headers this way for
label-free all along; the isobaric path never did.

Concretely, on the shipped fractionated plex (MSstatsConverter_2_in.consensusXML
with MSstatsConverter_2_design.tsv, 2 files x 10 channels): all 20 headers now
carry fraction_group=1 with fraction 1 and 2, so the two files are identifiable
as fractions of one quantification unit. Before, all 20 carried only
channel_name/channel_id/channel_description/channel_center.

The logic is the inverse of ExperimentalDesign::fromConsensusMap(), so it lives
next to it as ExperimentalDesign::annotateColumnHeaders() rather than inline in
a TOPP tool -- which also makes it testable, and gives ProteomicsLFQ somewhere
to converge later. It returns the number of headers with no matching design row
instead of logging, leaving the policy to callers; IsobaricWorkflow warns on a
non-zero return, since silent non-annotation is the failure mode.

Also stop calling fromConsensusMap() unconditionally before the -exp_design
override. It logged "No fractions annotated in consensusXML. Assuming
unfractionated." once per column header even when a design file said otherwise
-- 20 times on the fixture above.

Class test asserts the property that matters: two fraction files of one
quantification unit share a fraction_group and differ by fraction, and an
unmatched header is counted rather than silently skipped. Verified it
discriminates -- neutering the lookup gives "got '4', expected '0'".

155/155 tests (ProteomicsLFQ, ProSE, ProteinQuantifier, IsobaricAnalyzer,
ExperimentalDesign). Note IsobaricWorkflow itself still has no functional TOPP
test -- that block is commented out with a TODO -- so this tool's own coverage
remains the class test plus the design fixture above.

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

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds ExperimentalDesign::annotateColumnHeaders, tests metadata assignment and unmatched columns, and integrates annotation into IsobaricWorkflow after explicit or derived design resolution.

Changes

Experimental design annotation

Layer / File(s) Summary
Annotation API and validation
src/openms/include/OpenMS/METADATA/ExperimentalDesign.h, src/openms/source/METADATA/ExperimentalDesign.cpp, src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp
The API matches consensus-map columns by basename and 1-based label. It assigns fraction-group, fraction, and optional sample metadata. It counts unmatched and ambiguous columns. Tests cover matching, inferred designs without sample columns, unmatched columns, and ambiguous matches.
Workflow design resolution
src/topp/IsobaricWorkflow.cpp
The workflow uses the supplied experimental design when available. Otherwise, it derives a design from the consensus map, annotates column headers, and warns about unmatched columns.

Sequence Diagram(s)

sequenceDiagram
  participant IsobaricWorkflow
  participant ExperimentalDesign
  participant ConsensusMap
  IsobaricWorkflow->>ExperimentalDesign: resolve explicit or derived design
  IsobaricWorkflow->>ExperimentalDesign: annotateColumnHeaders(ConsensusMap)
  ExperimentalDesign->>ConsensusMap: assign matching metadata
  ExperimentalDesign-->>IsobaricWorkflow: return unmatched header count
  IsobaricWorkflow->>IsobaricWorkflow: issue warning for unmatched columns
Loading

Suggested reviewers: cbielow

Poem

Poem

I’m a rabbit who matches each row,
With fractions arranged in a flow.
Headers gain names,
Ambiguity refrains,
Unmatched columns are counted below.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: annotating the resolved experimental design onto IsobaricWorkflow column headers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch isobaric-annotate-fraction-group

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: 3

🧹 Nitpick comments (2)
src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp (1)

690-698: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use NEW_TMP_FILE for the design fixture.

Create design_path with NEW_TMP_FILE so the class-test harness owns cleanup of the generated TSV file.

As per coding guidelines, class tests “should use NEW_TMP_FILE for outputs.”

🤖 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
690 - 698, Replace the manual temporary file creation using
File::getTemporaryFile() with the NEW_TMP_FILE macro to allow the class-test
harness to own and manage cleanup of the temporary design fixture file. Keep the
subsequent ofstream initialization and the TSV content being written exactly
as-is, just substitute the file path acquisition method.

Source: Coding guidelines

src/openms/source/METADATA/ExperimentalDesign.cpp (1)

64-71: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Format each conditional block on separate lines.

Lines 65, 69, and 71 place braces and statements on one line. Put each block brace on its own aligned line.

As per coding guidelines, “braces on their own aligned lines; always use braces for blocks.”

🤖 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/ExperimentalDesign.cpp` around lines 64 - 71,
Reformat the three conditional blocks that check the map lookups and set
metadata values so that each follows the coding guideline of placing braces on
their own aligned lines. Specifically, the if statements checking pl2f.find(key)
and pl2s.find(key) (which call setMetaValue for fraction and sample_name), along
with the earlier check of pl2fg.find(key), should each have their opening brace
on the same line as the if condition, the body on the next indented line, and
the closing brace on its own aligned line below the body.

Source: Coding guidelines

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

Inline comments:
In `@src/openms/source/METADATA/ExperimentalDesign.cpp`:
- Around line 70-71: Update the sample-name annotation around pl2s lookup in
ExperimentalDesign::fromConsensusMap (or its enclosing builder) so derived
designs do not call SampleSection::getSampleName on rows lacking a Sample
column. Resolve sample_name from the matching MSFileSectionEntry, or ensure a
valid SampleSection is constructed before annotation, while preserving existing
behavior for explicit designs. Add a regression test covering an
IsobaricWorkflow design derived from a ConsensusMap.

In `@src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp`:
- Around line 703-714: Extend the assertions in the annotateColumnHeaders test
to verify the sample_name metadata contract: headers representing channel 1 must
contain sample_name "1", and headers representing channel 2 must contain
sample_name "2". Keep the existing fraction_group and fraction assertions
unchanged, using the headers collection entries for the corresponding channels.

In `@src/topp/IsobaricWorkflow.cpp`:
- Around line 812-829: Add a functional regression test for IsobaricWorkflow
that covers both design-resolution branches: one test case invoking the workflow
with the -exp_design parameter set to a file containing multiple fractions, and
another test case without -exp_design to exercise the
ExperimentalDesign::fromConsensusMap fallback path. For both branches, verify
that the design.annotateColumnHeaders operation persists the fraction
annotations correctly on the consensus map column headers, confirming that
downstream consumers can access the annotation information.

---

Nitpick comments:
In `@src/openms/source/METADATA/ExperimentalDesign.cpp`:
- Around line 64-71: Reformat the three conditional blocks that check the map
lookups and set metadata values so that each follows the coding guideline of
placing braces on their own aligned lines. Specifically, the if statements
checking pl2f.find(key) and pl2s.find(key) (which call setMetaValue for fraction
and sample_name), along with the earlier check of pl2fg.find(key), should each
have their opening brace on the same line as the if condition, the body on the
next indented line, and the closing brace on its own aligned line below the
body.

In `@src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp`:
- Around line 690-698: Replace the manual temporary file creation using
File::getTemporaryFile() with the NEW_TMP_FILE macro to allow the class-test
harness to own and manage cleanup of the temporary design fixture file. Keep the
subsequent ofstream initialization and the TSV content being written exactly
as-is, just substitute the file path acquisition method.
🪄 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: d4daea14-f1fb-47cc-81f4-d4b7c61b705a

📥 Commits

Reviewing files that changed from the base of the PR and between 0c0c399 and 2aabe2b.

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

Comment on lines +703 to +714
const auto& headers = cmap.getColumnHeaders();
for (const auto& [mi, h] : headers)
{
TEST_TRUE(h.metaValueExists("fraction_group"))
TEST_TRUE(h.metaValueExists("fraction"))
TEST_EQUAL(static_cast<int>(h.getMetaValue("fraction_group")), 1) // shared across both files
}
// ... and the fraction distinguishes the two files, channel by channel.
TEST_EQUAL(static_cast<int>(headers.at(0).getMetaValue("fraction")), 1) // run1, ch1
TEST_EQUAL(static_cast<int>(headers.at(1).getMetaValue("fraction")), 1) // run1, ch2
TEST_EQUAL(static_cast<int>(headers.at(2).getMetaValue("fraction")), 2) // run2, ch1
TEST_EQUAL(static_cast<int>(headers.at(3).getMetaValue("fraction")), 2) // run2, ch2

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Assert the sample_name metadata contract.

annotateColumnHeaders() also writes sample_name, but this test checks only fraction_group and fraction. Assert that headers for channel 1 have sample "1" and headers for channel 2 have sample "2".

As per coding guidelines, “Write unit tests for new functionality.”

🤖 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
703 - 714, Extend the assertions in the annotateColumnHeaders test to verify the
sample_name metadata contract: headers representing channel 1 must contain
sample_name "1", and headers representing channel 2 must contain sample_name
"2". Keep the existing fraction_group and fraction assertions unchanged, using
the headers collection entries for the corresponding channels.

Source: Coding guidelines

Comment on lines +812 to +829
// Only fall back to deriving a design from the map when none was supplied. Calling
// fromConsensusMap() unconditionally logged "No fractions annotated in consensusXML.
// Assuming unfractionated." once per column header even when -exp_design says otherwise.
ExperimentalDesign design = (exp_design != "") ? ExperimentalDesignFile::load(exp_design, true)
: ExperimentalDesign::fromConsensusMap(cmap);

// Annotate the resolved design back onto the column headers. IsobaricChannelExtractor sets
// only the channel meta values, so without this the fraction structure is known here and
// nowhere else -- consumers reading the map cannot tell two fractions of one sample from
// two independent runs.
if (const Size unannotated = design.annotateColumnHeaders(cmap); unannotated > 0)
{
design = ExperimentalDesignFile::load(exp_design, true);
OPENMS_LOG_WARN << "IsobaricWorkflow: " << unannotated << " of " << cmap.getColumnHeaders().size()
<< " (file, channel) column(s) have no matching row in the experimental "
"design, so they carry no fraction annotation. Downstream fraction-aware "
"output cannot group them." << std::endl;
}

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 | 🟠 Major | 🏗️ Heavy lift

Add a functional IsobaricWorkflow regression test.

Test both design-resolution branches. Use -exp_design with multiple fractions and verify persisted column-header annotations. Also test the no--exp_design fallback, because it exercises the derived-design path.

As per coding guidelines, “Do not skip tests when making code changes; add or 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/topp/IsobaricWorkflow.cpp` around lines 812 - 829, Add a functional
regression test for IsobaricWorkflow that covers both design-resolution
branches: one test case invoking the workflow with the -exp_design parameter set
to a file containing multiple fractions, and another test case without
-exp_design to exercise the ExperimentalDesign::fromConsensusMap fallback path.
For both branches, verify that the design.annotateColumnHeaders operation
persists the fraction annotations correctly on the consensus map column headers,
confirming that downstream consumers can access the annotation information.

Source: Coding guidelines

…uous headers

Two defects found reviewing the previous commit.

1. The no--exp_design path threw. fromConsensusMap() builds sample ROWS but no
   "Sample" COLUMN, so getSampleName() raised std::out_of_range on its internal
   column lookup -- and that is the design every caller gets when none is
   supplied, i.e. the default IsobaricWorkflow invocation. Verified directly:
   annotating with an inferred design went "THREW std: map::at" -> "OK".

   The name is optional decoration; fraction and fraction_group are what callers
   group on, so a design that cannot supply one must not cost them the
   annotation. Guarded rather than skipped, which also keeps earlier headers'
   fraction data valid if it does fire.

   My original probe missed this because it loaded a design from TSV, which has
   a Sample column. One input shape verified, then generalised.

2. Headers that collapse onto one design row were both annotated from it.
   ColumnHeader::getLabelAsUInt() returns 1 for any header with no 'channel_id'
   -- what the Multiplex tools emit, carrying the channel in 'label' instead --
   so a light/heavy pair of one file both resolve to label 1. The second was
   stamped with the first channel's sample, and the return value reported zero
   unannotated, so nothing indicated a problem. Such headers are now counted and
   left alone: the design row cannot be attributed to either of them.

Both tests verified to discriminate -- reverting gives "Caught unexpected
std::exception" and both sample_name assertions failing respectively.

155/155 tests.

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

@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: 3

🧹 Nitpick comments (2)
src/openms/source/METADATA/ExperimentalDesign.cpp (1)

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

Format the changed if block with aligned braces.

Line 77 puts both braces on the control-flow line. Put each brace on its own aligned line.

Proposed formatting change
-        if (key_uses[key] > 1) { ++unannotated; continue; } // ambiguous: several headers, one row
+        if (key_uses[key] > 1)
+        {
+          ++unannotated;
+          continue;
+        } // ambiguous: several headers, one row

As per coding guidelines, “braces [must be] 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/ExperimentalDesign.cpp` at line 77, Reformat the
if block in the surrounding metadata-processing code so its opening and closing
braces each appear on separate, aligned lines; preserve the existing condition
and continue behavior unchanged.

Source: Coding guidelines

src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp (1)

768-775: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use NEW_TMP_FILE for the temporary design file.

This test creates an output file with File::getTemporaryFile(). Use NEW_TMP_FILE so the test framework manages the temporary output consistently.

As per coding guidelines, class tests “should use NEW_TMP_FILE for outputs.”

🤖 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
768 - 775, Replace the File::getTemporaryFile-based design_path setup in the
ExperimentalDesign test with the test framework’s NEW_TMP_FILE mechanism, while
preserving the existing file contents and ExperimentalDesignFile::load behavior.

Source: Coding guidelines

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

Inline comments:
In `@src/openms/source/METADATA/ExperimentalDesign.cpp`:
- Around line 77-90: Update the public API documentation for
annotateColumnHeaders to state that unannotatedCount includes both headers
without a matching design row and headers with ambiguous matches, and that
matched headers may omit sample_name when the design lacks a Sample column, as
with inferred designs. Also update any corresponding nanobind/addon bindings,
pyOpenMS tests, and relevant documentation required by the C++ API documentation
change.
- Around line 85-90: Update the sample annotation near
getSampleSection().getSampleName() to first check whether the design contains
the Sample factor/column, and only skip sample_name when it is absent. Do not
catch all std::exception failures; allow invalid sample indices or incomplete
sample rows from explicit designs to propagate and report invalid design data.

In `@src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp`:
- Around line 777-779: Extend the assertions following
design.annotateColumnHeaders(cmap) to verify that both column headers lack the
fraction_group and fraction metadata values, in addition to the existing
sample_name checks. Keep the expected rejection result and existing sample_name
assertions unchanged.

---

Nitpick comments:
In `@src/openms/source/METADATA/ExperimentalDesign.cpp`:
- Line 77: Reformat the if block in the surrounding metadata-processing code so
its opening and closing braces each appear on separate, aligned lines; preserve
the existing condition and continue behavior unchanged.

In `@src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp`:
- Around line 768-775: Replace the File::getTemporaryFile-based design_path
setup in the ExperimentalDesign test with the test framework’s NEW_TMP_FILE
mechanism, while preserving the existing file contents and
ExperimentalDesignFile::load behavior.
🪄 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: 4ed2d164-3196-4888-b5b2-29a9d2b4ee0f

📥 Commits

Reviewing files that changed from the base of the PR and between 2aabe2b and 7587f70.

📒 Files selected for processing (2)
  • src/openms/source/METADATA/ExperimentalDesign.cpp
  • src/tests/class_tests/openms/source/ExperimentalDesign_test.cpp

Comment on lines +77 to +90
if (key_uses[key] > 1) { ++unannotated; continue; } // ambiguous: several headers, one row

header.setMetaValue("fraction_group", fg->second);
auto fr = pl2f.find(key);
if (fr != pl2f.end()) { header.setMetaValue("fraction", fr->second); }
auto sa = pl2s.find(key);
if (sa != pl2s.end())
{
// A design inferred by fromConsensusMap() has sample rows but no "Sample" COLUMN, so
// getSampleName() throws std::out_of_range on its internal column lookup. The name is
// optional decoration here -- fraction and fraction_group are what callers group on --
// so a design that cannot supply one must not cost them the annotation entirely.
try { header.setMetaValue("sample_name", getSampleSection().getSampleName(sa->second)); }
catch (const std::exception&) { /* no Sample column; fraction data above still stands */ }

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the annotateColumnHeaders() API documentation.

The public documentation says that only headers without a matching design row are counted. Line 77 also counts ambiguous headers. It also says that every matched header receives sample_name, but inferred designs intentionally omit that metadata. Document both conditions.

As per coding guidelines, “When changing a C++ API, update nanobind bindings or addons, pyOpenMS tests, and relevant documentation.”

🤖 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/ExperimentalDesign.cpp` around lines 77 - 90,
Update the public API documentation for annotateColumnHeaders to state that
unannotatedCount includes both headers without a matching design row and headers
with ambiguous matches, and that matched headers may omit sample_name when the
design lacks a Sample column, as with inferred designs. Also update any
corresponding nanobind/addon bindings, pyOpenMS tests, and relevant
documentation required by the C++ API documentation change.

Source: Coding guidelines

Comment on lines +85 to +90
// A design inferred by fromConsensusMap() has sample rows but no "Sample" COLUMN, so
// getSampleName() throws std::out_of_range on its internal column lookup. The name is
// optional decoration here -- fraction and fraction_group are what callers group on --
// so a design that cannot supply one must not cost them the annotation entirely.
try { header.setMetaValue("sample_name", getSampleSection().getSampleName(sa->second)); }
catch (const std::exception&) { /* no Sample column; fraction data above still stands */ }

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Do not suppress unexpected sample lookup failures.

The catch treats every std::exception as a missing Sample column. If an explicit design has an invalid sample index or incomplete sample row, annotation silently leaves sample_name unset. Check for the Sample factor before lookup. Let other errors report invalid design data.

Proposed fix
-        if (sa != pl2s.end())
+        if (sa != pl2s.end() && getSampleSection().hasFactor("Sample"))
         {
-          // A design inferred by fromConsensusMap() has sample rows but no "Sample" COLUMN, so
-          // getSampleName() throws std::out_of_range on its internal column lookup. The name is
-          // optional decoration here -- fraction and fraction_group are what callers group on --
-          // so a design that cannot supply one must not cost them the annotation entirely.
-          try { header.setMetaValue("sample_name", getSampleSection().getSampleName(sa->second)); }
-          catch (const std::exception&) { /* no Sample column; fraction data above still stands */ }
+          header.setMetaValue("sample_name", getSampleSection().getSampleName(sa->second));
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// A design inferred by fromConsensusMap() has sample rows but no "Sample" COLUMN, so
// getSampleName() throws std::out_of_range on its internal column lookup. The name is
// optional decoration here -- fraction and fraction_group are what callers group on --
// so a design that cannot supply one must not cost them the annotation entirely.
try { header.setMetaValue("sample_name", getSampleSection().getSampleName(sa->second)); }
catch (const std::exception&) { /* no Sample column; fraction data above still stands */ }
if (sa != pl2s.end() && getSampleSection().hasFactor("Sample"))
{
header.setMetaValue("sample_name", getSampleSection().getSampleName(sa->second));
}
🤖 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/ExperimentalDesign.cpp` around lines 85 - 90,
Update the sample annotation near getSampleSection().getSampleName() to first
check whether the design contains the Sample factor/column, and only skip
sample_name when it is absent. Do not catch all std::exception failures; allow
invalid sample indices or incomplete sample rows from explicit designs to
propagate and report invalid design data.

Comment on lines +777 to +779
TEST_EQUAL(design.annotateColumnHeaders(cmap), 2) // both refused, neither guessed at
TEST_FALSE(cmap.getColumnHeaders().at(0).metaValueExists("sample_name"))
TEST_FALSE(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 that all annotation metadata remains absent.

This test only checks sample_name. It passes if a regression writes fraction_group or fraction before it rejects the ambiguous headers. Assert that both metadata values are absent on both headers.

Proposed assertions
   TEST_EQUAL(design.annotateColumnHeaders(cmap), 2)   // both refused, neither guessed at
+  TEST_FALSE(cmap.getColumnHeaders().at(0).metaValueExists("fraction_group"))
+  TEST_FALSE(cmap.getColumnHeaders().at(0).metaValueExists("fraction"))
   TEST_FALSE(cmap.getColumnHeaders().at(0).metaValueExists("sample_name"))
+  TEST_FALSE(cmap.getColumnHeaders().at(1).metaValueExists("fraction_group"))
+  TEST_FALSE(cmap.getColumnHeaders().at(1).metaValueExists("fraction"))
   TEST_FALSE(cmap.getColumnHeaders().at(1).metaValueExists("sample_name"))

As per coding guidelines, “Write unit tests for new functionality.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
TEST_EQUAL(design.annotateColumnHeaders(cmap), 2) // both refused, neither guessed at
TEST_FALSE(cmap.getColumnHeaders().at(0).metaValueExists("sample_name"))
TEST_FALSE(cmap.getColumnHeaders().at(1).metaValueExists("sample_name"))
TEST_EQUAL(design.annotateColumnHeaders(cmap), 2) // both refused, neither guessed at
TEST_FALSE(cmap.getColumnHeaders().at(0).metaValueExists("fraction_group"))
TEST_FALSE(cmap.getColumnHeaders().at(0).metaValueExists("fraction"))
TEST_FALSE(cmap.getColumnHeaders().at(0).metaValueExists("sample_name"))
TEST_FALSE(cmap.getColumnHeaders().at(1).metaValueExists("fraction_group"))
TEST_FALSE(cmap.getColumnHeaders().at(1).metaValueExists("fraction"))
TEST_FALSE(cmap.getColumnHeaders().at(1).metaValueExists("sample_name"))
🤖 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
777 - 779, Extend the assertions following design.annotateColumnHeaders(cmap) to
verify that both column headers lack the fraction_group and fraction metadata
values, in addition to the existing sample_name checks. Keep the expected
rejection result and existing sample_name assertions unchanged.

Source: Coding guidelines

@timosachsenberg
timosachsenberg merged commit 552802a into develop Jul 31, 2026
38 of 39 checks passed
@timosachsenberg
timosachsenberg deleted the isobaric-annotate-fraction-group branch July 31, 2026 18:44
timosachsenberg added a commit that referenced this pull request Aug 3, 2026
…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]>
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