Skip to content

MzTabFile: read and write colunit metadata as specified by mzTab 1.0 - #10524

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
ManasBagul23:pr/12-mztab-colunit-roundtrip
Oct 15, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
ManasBagul23:pr/12-mztab-colunit-roundtrip

Conversation

@ManasBagul23

@ManasBagul23 ManasBagul23 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

The column-unit metadata could not be round-tripped:

  • the writer emitted MTD\tcolunit-PSM<value>: the PSM key was upper case (the specification uses colunit-psm) and no tab separated the key from the value for any of the four colunit sections;
  • the reader expected an index in the key (colunit[n]-psm), which the specification does not have. A specification-conform line therefore failed with a ConversionError, and an indexed one assigned into the still-empty std::vector, past its end.

Write MTD\tcolunit-<section>\t<value> and append one entry per colunit-<section> line when reading, matching the one-line-per-column, no-index shape the mzTab 1.0 spec actually uses. The reader's new condition also checks meta_key_fields.size() == 2 before indexing meta_key_fields[1], removing an unguarded index that the old hasPrefix check didn't protect.

Added a regression test (MzTabFile_test): sets colunit_protein/colunit_psm entries, stores, confirms the written line matches the spec's shape exactly, then reloads and confirms every entry survives in order.

Verified in Docker: without the fix, the written line has no tab/wrong case and the written file can't even be read back (Parse Error); with it, both read and write round-trip correctly.

Tracked in #10148 (X-14), extended to the reader.

Summary by CodeRabbit

  • Bug Fixes

    • Improved compatibility with mzTab 1.0 column-unit metadata by correctly reading and writing entries for proteins, peptides, PSMs, and small molecules.
    • Corrected the serialized PSM metadata key and restored the required separator between keys and values.
  • Tests

    • Added coverage for saving and reloading column-unit metadata.

The column-unit metadata could not be round-tripped:

- the writer emitted "MTD\tcolunit-PSM<value>": the PSM key was upper
  case (the specification uses colunit-psm) and no tab separated the key
  from the value for any of the four colunit sections;
- the reader expected an index in the key ("colunit[n]-psm"), which the
  specification does not have. A specification-conform line therefore
  failed with a ConversionError, and an indexed one assigned into the
  still empty std::vector, past its end.

Write "MTD\tcolunit-<section>\t<value>" and append one entry per
colunit-<section> line when reading.

Tracked in OpenMS#10148 (X-14), extended to the reader.
Copilot AI balanced review requested due to automatic review settings October 11, 2026 18:50

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 23d1515b-2c79-4280-be4c-7e3f1079413a

📥 Commits

Reviewing files that changed from the base of the PR and between dac9590 and 08483f9.


📒 Files selected for processing (2)
  • src/openms/source/FORMAT/MzTabFile.cpp
  • src/tests/class_tests/openms/source/MzTabFile_test.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.



📝 Walkthrough

Walkthrough

The mzTab loader now reads supported column-unit metadata into section lists. The writer emits tab-separated metadata keys and values, including the lowercase PSM key. A test checks serialized output and reloaded metadata.

Changes

mzTab Column Unit Metadata

Layer / File(s) Summary
Column-unit metadata round trip
src/openms/source/FORMAT/MzTabFile.cpp, src/tests/class_tests/openms/source/MzTabFile_test.cpp
The loader appends supported column-unit values to their section lists. The writer separates keys and values with a tab and uses lowercase colunit-psm. The test checks serialized output and reloaded entries.

Suggested reviewers: timosachsenberg


Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 08483

No actionable merge-blocking issue is evident from the supplied changes; the PR is mergeable after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: reading and writing colunit metadata according to mzTab 1.0.
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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks each column line
The tabs fall neatly into place
Four section names come hopping through
The PSM key wears lowercase
Stored, reloaded, order stays
The rabbit nods and nibbles hay

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

@timosachsenberg timosachsenberg 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.

Approving. This matches mzTab 1.0.0 (6.2.60–6.2.63): MTD colunit-<section> <column>=<param>, with one line per column and a lower-case section name. The old reader's colunit[ index parsing could never handle spec-conform files.

Non-blocking: please add a CHANGELOG entry.


Generated by Claude Code

@timosachsenberg
timosachsenberg merged commit b5dfad1 into OpenMS:develop Oct 15, 2026
32 checks passed
timosachsenberg pushed a commit that referenced this pull request Oct 15, 2026
…ersion, #10583, #10492, #10525, #10524, #10346, #9782)

Conflicts in ConversionHelper and its test: develop removes
MapConversion::convert(PeakMap -> ConsensusMap) and moves its peak
selection tests to MapAlignmentAlgorithmPoseClustering_test; this branch
keeps the identification data handling of the remaining conversions
(convertIdentifications() and its test section). FileConverter: develop's
comment about OMS input is dropped, as this branch removes .oms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
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.

3 participants