Repository navigation
feat(MaRaClusterAdapter): annotate consensus spectra with original native IDs - #8864
Conversation
Use a Dockerfile with ARG TARGETARCH (set automatically by BuildKit, default since Docker 23.0) to select the correct base image. Falls back to amd64 when BuildKit is not available. ARM64 users can override via build args in devcontainer.json if auto-detection fails. Fixes #8740 Co-Authored-By: Claude Opus 4.6 <[email protected]>
…tive IDs Add metadata annotations to consensus spectra output preserving traceability to original source spectra: - maracluster_original_native_ids: comma-separated original native IDs - maracluster_original_file_origins: comma-separated source file paths - maracluster_cluster_size: number of spectra in the cluster Builds scan_nr -> native_id maps from input files and maps cluster IDs to consensus scan numbers using the established cluster_id - 1 offset. Fixes #4474 Co-Authored-By: Claude Opus 4.6 <[email protected]>
📝 WalkthroughWalkthroughThe PR adds multi-architecture Docker build support to the development container through a new Dockerfile with architecture-aware base image selection, and updates the devcontainer configuration to build from this Dockerfile. Additionally, it enhances MaRaClusterAdapter to annotate consensus spectra with original source metadata including native IDs, file origins, and cluster sizes. Changes
Sequence DiagramsequenceDiagram
participant Input as Input Files
participant Adapter as MaRaClusterAdapter
participant Cluster as Cluster Mapping
participant Spectra as Consensus Spectra
participant Output as Output mzML
Input->>Adapter: Re-read each input file
Adapter->>Adapter: Build scan → native ID map per file
Cluster->>Adapter: Provide cluster → scan associations
Adapter->>Adapter: Construct consensus_scan → (file_origin, native_id) mapping
Adapter->>Spectra: Iterate over consensus spectra
Adapter->>Spectra: Attach annotations:<br/>- maracluster_original_native_ids<br/>- maracluster_original_file_origins<br/>- maracluster_cluster_size
Spectra->>Output: Write annotated spectra to mzML
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/topp/MaRaClusterAdapter.cpp (1)
497-512: Consider adding bounds validation forres.file_idx.While the file index is validated implicitly via
filename_to_file_idx.at()inreadMClusterOutputAsMap_()(which throws on missing keys), if that exception propagates it may produce a confusing error message. An explicit bounds check here would provide clearer diagnostics:if (res.file_idx < 0 || static_cast<Size>(res.file_idx) >= file_scan_to_nativeid.size()) { OPENMS_LOG_WARN << "Invalid file index " << res.file_idx << " in cluster output, skipping." << std::endl; continue; }This is a minor defensive improvement—the current code should work correctly for valid inputs.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/MaRaClusterAdapter.cpp` around lines 497 - 512, Add an explicit bounds check for res.file_idx before accessing file_scan_to_nativeid[res.file_idx] inside the loop in MaRaClusterAdapter (the block building consensus_scan_to_refs), e.g. verify res.file_idx is non-negative and less than file_scan_to_nativeid.size(), log a warning mentioning the invalid res.file_idx and skip that entry (continue) to avoid confusing exceptions when filename_to_file_idx errors would otherwise propagate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/topp/MaRaClusterAdapter.cpp`:
- Around line 488-511: The current native-ID parsing uses getScanNumber_ which
only handles a few formats and can mismatch entries in file_scan_to_nativeid
when building consensus_scan_to_refs; replace calls to getScanNumber_ (used when
populating file_scan_to_nativeid and when resolving native_id from
MaRaClusterResult res) with
SpectrumNativeIDParser::extractScanNumber(spec.getNativeID(),
native_id_type_accession) (or the appropriate SpectrumNativeIDParser API) so you
canonicalize scan numbers consistently for all native ID types (handle
WIFF/index offsets per parser), ensuring lookups by res.file_idx/res.scan_nr
against file_scan_to_nativeid succeed and original native IDs from in_list are
preserved instead of falling back to synthetic "scan=" strings.
---
Nitpick comments:
In `@src/topp/MaRaClusterAdapter.cpp`:
- Around line 497-512: Add an explicit bounds check for res.file_idx before
accessing file_scan_to_nativeid[res.file_idx] inside the loop in
MaRaClusterAdapter (the block building consensus_scan_to_refs), e.g. verify
res.file_idx is non-negative and less than file_scan_to_nativeid.size(), log a
warning mentioning the invalid res.file_idx and skip that entry (continue) to
avoid confusing exceptions when filename_to_file_idx errors would otherwise
propagate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6442b622-f52e-4d95-b938-7f77bc1ea900
📒 Files selected for processing (3)
.devcontainer/Dockerfile.devcontainer/devcontainer.jsonsrc/topp/MaRaClusterAdapter.cpp
Add missing changelog entries for changes merged in the past 7 days: - PyOpenMS: PeptideAndProteinQuant.getPeptideResults/getProteinResults exposed (#8543) - PyOpenMS BREAKING: zero-copy _mv methods renamed to _view (#8857) - TOPP BREAKING: FeatureFinderMultiplex/MultiplexResolver parameter missed_cleavages renamed to max_nr_labelled_aas (#8911) - TOPP: MaRaClusterAdapter annotates consensus spectra with native IDs and cluster metadata (#8864) - TOPP: MetaboliteAdductDecharger adds multimer detection (#8888) - OpenMS Library BREAKING: ChromatogramPeak::IntensityType changed double -> float (#8857) - Build: CMake 4.x compat fix for Windows packaging (#8880) - Build: Fix pyOpenMS dev build RPATH (#8892) - Build: Correctly locate locally installed nanobind (#8874) Co-authored-by: Copilot <[email protected]>
…ions Add documentation for the three metadata values now added to each consensus spectrum in the output mzML (introduced in #8864): - maracluster_original_native_ids: original native IDs of source spectra - maracluster_original_file_origins: source file paths - maracluster_cluster_size: number of merged spectra Co-authored-by: Copilot <[email protected]>
Add missing changelog entries for changes merged in the past 7 days: - PyOpenMS: PeptideAndProteinQuant.getPeptideResults/getProteinResults exposed (#8543) - PyOpenMS BREAKING: zero-copy _mv methods renamed to _view (#8857) - TOPP BREAKING: FeatureFinderMultiplex/MultiplexResolver parameter missed_cleavages renamed to max_nr_labelled_aas (#8911) - TOPP: MaRaClusterAdapter annotates consensus spectra with native IDs and cluster metadata (#8864) - TOPP: MetaboliteAdductDecharger adds multimer detection (#8888) - OpenMS Library BREAKING: ChromatogramPeak::IntensityType changed double -> float (#8857) - Build: CMake 4.x compat fix for Windows packaging (#8880) - Build: Fix pyOpenMS dev build RPATH (#8892) - Build: Correctly locate locally installed nanobind (#8874) Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
…ions (#8918) Add documentation for the three metadata values now added to each consensus spectrum in the output mzML (introduced in #8864): - maracluster_original_native_ids: original native IDs of source spectra - maracluster_original_file_origins: source file paths - maracluster_cluster_size: number of merged spectra Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
Fixes #4474
Changes vs #8607
The original PR had these problems:
Off-by-one bug: Used raw cluster IDs from the map as lookup keys, but consensus scan numbers are
cluster_id - 1(as documented in the existing idXML annotation code at lines 390-391, 415-416). Lookups would never match.Unnecessary memory pressure: Loaded all input files and built lookups before running
maracluster consensus, keeping them in memory during the external process execution. Moved to after the consensus output is loaded.Over-engineered: Used
SpectrumMetaDataLookup(caches RT, precursor info, ms_level, etc.) when onlyscan_nr → native_idmapping is needed. Replaced with a simplestd::map<Int, String>per file using the existinggetScanNumber_()method.String concatenation: Used manual loop with
+=instead ofStringList+ListUtils::concatenate(which is the OpenMS pattern).Test plan
--consensus_outand verify consensus mzML containsmaracluster_original_native_ids,maracluster_original_file_origins, andmaracluster_cluster_sizemeta values🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Chores