Skip to content

Fix empty USI column in TextExporter (resolve MS run from spectra_data) - #9657

Merged
timosachsenberg merged 3 commits into
OpenMS:developfrom
jonasscheid:feature/textexporter-usi-msrun-fix
Jun 25, 2026
Merged

timosachsenberg merged 3 commits into
OpenMS:developfrom
jonasscheid:feature/textexporter-usi-msrun-fix

Conversation

@jonasscheid

@jonasscheid jonasscheid commented Jun 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #8470. The -id:add_usi option in TextExporter added a USI column header but emitted empty values for idXML and consensusXML — the exact formats that issue asked about.

Root cause

The USI ms_run component was sourced from PeptideIdentification::getBaseName(), which is only ever populated by PepXMLFile. The idXML/consensusXML/featureXML readers never set it, so ms_run was empty, which makes the whole USI invalid and USI::toString() return "".

Fix

Resolve ms_run from the protein run's spectra_data, selected per identification via the merge index, using the existing IdentifierMSRunMapper — i.e. the same "spectra_data + merge index" mechanism described in the issue. A small resolveUSIMSRun() helper keeps a base_name fallback for pepXML-derived inputs, and mapper construction is guarded so export never aborts on degenerate input. Applied to all three identification-bearing input branches (featureXML, consensusXML, idXML).

Result

  • idXML: mzspec:PXD000561:run.mzML:scan:2491:DEDEGEAADM[UNIMOD:35]EEY/2
  • merged consensusXML: each identification resolves to its correct source run via the merge index.

Testing

  • New TOPP test TOPP_TextExporter_10 (idXML input + expected output with populated USIs).
  • Full TOPP_TextExporter_* suite: 23/23 pass; no regressions (behavior is unchanged when -id:add_usi is off, since the mapper is only built then).

Usage:

TextExporter -in results.idXML -out results.tsv -id:add_usi -id:usi_dataset_id PXD000561

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved USI output in text exports so peptide rows now show the correct run information for idXML and consensusXML files, even when per-item metadata is incomplete.
    • Exported peptide identifiers are now more consistently linked to the originating mass spectrometry run.
  • Tests

    • Added regression coverage for the updated USI export behavior.

@github-actions

Copy link
Copy Markdown
Contributor

@jonasscheid The following names might be missing from the AUTHORS file:

  • jonasscheid

Please consider applying the following patch:

--- AUTHORS	2026-06-25 04:23:13.103747797 +0000
+++ AUTHORS.new	2026-06-25 04:23:18.098134378 +0000
@@ -61,6 +61,7 @@
  - Johannes Veit
  - Johannes von Kleist
  - Johan Teleman
+ - jonasscheid
  - Joshua Charkow
  - Juliane Schmachtenberg
  - Julianus Pfeuffer

@jonasscheid
jonasscheid marked this pull request as ready for review June 25, 2026 12:32
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4537fcfe-b13f-4370-9f8f-0ebaa301b8e2

📥 Commits

Reviewing files that changed from the base of the PR and between b102825 and 0db99d3.

📒 Files selected for processing (5)
  • CHANGELOG
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/TextExporter_10_input.idXML
  • src/tests/topp/TextExporter_10_output.txt
  • src/topp/TextExporter.cpp

📝 Walkthrough

Walkthrough

TextExporter now resolves USI MS-run names through IdentifierMSRunMapper in featureXML, consensusXML, and idXML export paths. The PR also adds an idXML regression fixture and expected output for TOPP_TextExporter_10, plus a changelog note for the USI fix.

Changes

TextExporter USI resolution

Layer / File(s) Summary
Mapper helpers
src/topp/TextExporter.cpp
Adds IdentifierMSRunMapper support, resolveUSIMSRun, and buildUSIMapper_ for USI MS-run lookup and fallback construction.
featureXML USI wiring
src/topp/TextExporter.cpp
featureXML and featureparquet export build a mapper per input and use it for unassigned and peptide USI fields.
consensus XML wiring
src/topp/TextExporter.cpp
consensusXML and consensusparquet export build a mapper per input and use it when writing unassigned and peptide USI fields.
idXML regression coverage
src/topp/TextExporter.cpp, src/tests/topp/CMakeLists.txt, src/tests/topp/TextExporter_10_input.idXML, src/tests/topp/TextExporter_10_output.txt, CHANGELOG
idXML and idparquet export build a mapper per input, and the new test fixture, expected output, test wiring, and changelog entry document the resulting USI output.

Sequence Diagram(s)

sequenceDiagram
  participant TextExporter
  participant IdentifierMSRunMapper
  participant resolveUSIMSRun
  participant PeptideWriteOptions
  TextExporter->>IdentifierMSRunMapper: buildUSIMapper_(prot_ids, add_usi)
  TextExporter->>resolveUSIMSRun: resolveUSIMSRun(usi_mapper, peptide)
  resolveUSIMSRun->>IdentifierMSRunMapper: primary MS run path
  IdentifierMSRunMapper-->>resolveUSIMSRun: mapped path or empty
  resolveUSIMSRun-->>TextExporter: USI MS-run basename
  TextExporter->>PeptideWriteOptions: set usi_ms_run
Loading

Possibly related PRs

  • OpenMS/OpenMS#9579: Adds tests for IdentifierMSRunMapper, which is directly related to the mapper-based USI resolution used here.

Poem

A bunny hopped through text at night,
And found each USI shining bright 🐇
With mapper paths and output rows,
The exporter now knows where run data goes.
A twitch of nose, a happy grin—
The textbox USIs hop right in.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing empty USI output in TextExporter by resolving the MS run from spectra_data.
Linked Issues check ✅ Passed The change addresses #8470 by making USIs appear in TextExporter output for idXML and consensusXML instead of leaving the column empty.
Out of Scope Changes check ✅ Passed The added tests, changelog note, and mapper-related code are all directly supporting the USI fix and do not appear unrelated.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

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.

Provide universal spectrum identifier with TextExporter

2 participants