Repository navigation
Annotate original native IDs in MaRaClusterAdapter consensus spectra - #8607
timosachsenberg wants to merge 2 commits into
Conversation
When generating consensus spectra output, annotate each spectrum with metadata about the original spectra that were clustered together: - 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 Uses SpectrumMetaDataLookup to efficiently map scan numbers to native IDs from the original input files. This preserves traceability from consensus spectra back to their source spectra, addressing the request in issue #4474.
📝 WalkthroughWalkthroughThe change enhances Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom Pre-merge checks in the settings. ✨ Finishing touches
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: 0
🧹 Nitpick comments (1)
src/topp/MaRaClusterAdapter.cpp (1)
518-542: LGTM with optional cleanup suggestion.The annotation logic correctly maps cluster IDs and builds the metadata. The
static_cast<Int>on line 540 is appropriate.🔎 Optional: Use StringList for cleaner string concatenation
Consider using
StringListwithListUtils::concatenatefor building comma-separated values:const auto& refs = clusterid_to_original_refs[cluster_id]; // Build comma-separated list of original native IDs - String original_native_ids; - String original_file_origins; - for (Size j = 0; j < refs.size(); ++j) - { - if (j > 0) - { - original_native_ids += ","; - original_file_origins += ","; - } - original_file_origins += refs[j].first; - original_native_ids += refs[j].second; - } + StringList native_id_list; + StringList file_origin_list; + for (const auto& ref : refs) + { + file_origin_list.push_back(ref.first); + native_id_list.push_back(ref.second); + } + String original_native_ids = ListUtils::concatenate(native_id_list, ","); + String original_file_origins = ListUtils::concatenate(file_origin_list, ","); exp[i].setMetaValue("maracluster_original_native_ids", original_native_ids);
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/topp/MaRaClusterAdapter.cpp
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx}: Never usestd::coutorstd::cerrdirectly; use OpenMS logging macros instead
Always use braces for control structures, even for single-line blocks (trivial one-liners may stay single-line)
Braces for control structures must align with opening/closing braces on their own lines
Files:
src/topp/MaRaClusterAdapter.cpp
**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx,h,hpp,hxx}: Never usestd::endl; use\nfor performance
Use 2-space indentation for C++/headers; no tabs; Unix line endings
Use classes/types/namespaces in PascalCase
Use lowerCamelCase for method names
Use snake_case for variable names
Use trailing underscore for private/protected member variable names
Use UPPER_SNAKE_CASE for enums and macros
Include space after keywords (if,for,while) and around binary operators
Avoid the C++ preprocessor; preferenum classover macro constants
Files:
src/topp/MaRaClusterAdapter.cpp
src/topp/**/*.cpp
📄 CodeRabbit inference engine (AGENTS.md)
src/topp/**/*.cpp: Define tool parameters inregisterOptionsAndFlags_()method and read withgetStringOption_and related helpers
UseProgressLoggerin TOPP tools for progress reporting
Files:
src/topp/MaRaClusterAdapter.cpp
🧠 Learnings (6)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/topp/MaRaClusterAdapter.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Follow the established error handling patterns
Applied to files:
src/topp/MaRaClusterAdapter.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Applied to files:
src/topp/MaRaClusterAdapter.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/topp/MaRaClusterAdapter.cpp
📚 Learning: 2026-01-07T06:33:27.194Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.194Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Derive custom exceptions from `Exception::Base`; throw with file/line/`OPENMS_PRETTY_FUNCTION`; catch by reference
Applied to files:
src/topp/MaRaClusterAdapter.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/topp/MaRaClusterAdapter.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: build-macos-arm
- GitHub Check: build-lnx
- GitHub Check: build-lnx-arm
- GitHub Check: build-win
- GitHub Check: build-and-test (ubuntu-24.04, g++, 13)
- GitHub Check: build-and-test (ubuntu-24.04-arm, g++, 13)
- GitHub Check: build-and-test (macos-14, xcode, 15.4)
- GitHub Check: build-and-test (windows-2025, cl.exe, 14.44)
- GitHub Check: build-and-test (ubuntu-24.04, clang++, 17)
🔇 Additional comments (3)
src/topp/MaRaClusterAdapter.cpp (3)
18-18: LGTM!Include added for the new metadata lookup functionality.
471-494: LGTM!The reverse mapping construction with fallback handling is well structured. Exception handling follows OpenMS patterns (catching by reference per learnings), and the fallback to
"scan=X"format provides graceful degradation when the lookup fails.
458-469: API usage is correct; no changes needed.The
SpectrumMetaDataLookup::readSpectra()method properly populates the internal lookup, and subsequentfindByScanNumber()calls work as expected. The code follows all guidelines: snake_case variables, lowerCamelCase methods, PascalCase types, proper brace alignment, and 2-space indentation. The pattern matches existing usage throughout the codebase.
When generating consensus spectra output, annotate each spectrum with
metadata about the original spectra that were clustered together:
Uses SpectrumMetaDataLookup to efficiently map scan numbers to native IDs
from the original input files.
This preserves traceability from consensus spectra back to their source
spectra, addressing the request in issue #4474.
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.