Skip to content

refactor: Store IDs outside of spectra. - #7974

Merged
timosachsenberg merged 42 commits into
developfrom
openms-pr-5547
May 21, 2025
Merged

timosachsenberg merged 42 commits into
developfrom
openms-pr-5547

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Apr 9, 2025 •

Copy link
Copy Markdown
Contributor

Description

Splits ID data from MSExperiment. (Revives #5547)

Summary by CodeRabbit

  • New Features

    • Introduced the AnnotatedMSRun data structure for integrated management of spectra and peptide/protein identifications.
    • Added support for AnnotatedMSRun in file I/O, visualization, and filtering components.
  • Refactor

    • Replaced legacy PeakMap and related types with AnnotatedMSRun across core libraries and GUI modules.
    • Streamlined data access by routing spectrum and identification operations through AnnotatedMSRun.
    • Updated GUI and plotting components to utilize the new data structure.
  • Removals

    • Removed deprecated tools: SpecLibCreator, SpecLibSearcher, and IDMassAccuracy.
    • Deleted related documentation, tests, and build entries for these tools.
    • Eliminated peptide and protein identification management from SpectrumSettings and ExperimentalSettings.
  • Tests

    • Added comprehensive tests for AnnotatedMSRun.
    • Removed tests covering deprecated tools and legacy data structures.
  • Documentation

    • Updated code examples and user guides to reflect the new data handling approach.
    • Cleaned up references to removed tools and features.
  • Chores

    • Updated build configurations and dependencies to include AnnotatedMSRun and remove obsolete components.

Summary by CodeRabbit

  • New Features

    • Introduced the AnnotatedMSRun data structure to unify spectra with peptide and protein identifications.
    • Enabled AnnotatedMSRun support in file I/O, ID mapping, filtering, alignment, and GUI components.
    • Updated code examples to demonstrate usage of AnnotatedMSRun.
  • Removals

    • Removed SpecLibCreator, SpecLibSearcher, and IDMassAccuracy tools, along with their documentation, tests, and build entries.
    • Eliminated peptide and protein identification accessors from SpectrumSettings and ExperimentalSettings.
  • Bug Fixes

    • Enhanced data consistency and error handling by enforcing alignment between spectra and peptide identifications.
    • Fixed potential out-of-range access and improved debug output in identification visualization.
  • Documentation

    • Updated user and developer documentation to remove references to deprecated tools and reflect data structure changes.
  • Tests

    • Added detailed tests for AnnotatedMSRun functionality.
    • Removed or adapted tests related to deprecated tools and legacy data structures.
  • Chores

    • Refactored codebase to access experiment data via AnnotatedMSRun’s MSExperiment interface.
    • Cleaned up build scripts and dependency lists to accommodate new data structures and remove obsolete components.

@coderabbitai

coderabbitai Bot commented Apr 9, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This update introduces a new AnnotatedMSRun data structure to encapsulate spectra, peptide, and protein identifications, replacing previous approaches that stored identifications within spectra or experimental settings. All core algorithms, file I/O, visualization, and test code are refactored to use this new abstraction. Simultaneously, outdated tools (SpecLibCreator, SpecLibSearcher, IDMassAccuracy) and their documentation and tests are removed.

Changes

File(s) / Group Change Summary
src/openms/include/OpenMS/METADATA/AnnotatedMSRun.h, src/openms/source/METADATA/AnnotatedMSRun.cpp, src/openms/source/METADATA/sources.cmake, src/openms/include/OpenMS/METADATA/sources.cmake, src/pyOpenMS/pxds/AnnotatedMSRun.pxd, src/tests/class_tests/openms/source/AnnotatedMSRun_test.cpp, src/tests/class_tests/openms/executables.cmake Introduce new AnnotatedMSRun class and Cython bindings, add unit tests, and include in build system.
src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h, src/openms/source/ANALYSIS/ID/IDMapper.cpp, src/tests/class_tests/openms/source/IDMapper_test.cpp Refactor IDMapper to use AnnotatedMSRun instead of PeakMap, update tests accordingly.
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h, src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp Update retention time extraction to use AnnotatedMSRun, add C++20 concepts for type constraints.
src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h, src/openms/source/PROCESSING/ID/IDFilter.cpp, src/tests/class_tests/openms/source/IDFilter_test.cpp Shift filtering operations from PeakMap to AnnotatedMSRun, add concepts and new overloads, remove old tests.
src/openms/include/OpenMS/FORMAT/MSPFile.h, src/openms/source/FORMAT/MSPFile.cpp, src/tests/class_tests/openms/source/MSPFile_test.cpp Refactor MSP file I/O to use AnnotatedMSRun, update signatures and tests.
src/openms/include/OpenMS/KERNEL/MSExperiment.h, src/openms/source/KERNEL/MSExperiment.cpp Remove and comment out peptide identification accessors from MSExperiment.
src/openms/include/OpenMS/METADATA/SpectrumSettings.h, src/openms/source/METADATA/SpectrumSettings.cpp, src/pyOpenMS/pxds/SpectrumSettings.pxd, src/tests/class_tests/openms/source/SpectrumSettings_test.cpp Remove peptide identification storage and access from SpectrumSettings and related Python bindings and tests.
src/openms/include/OpenMS/METADATA/ExperimentalSettings.h, src/openms/source/METADATA/ExperimentalSettings.cpp, src/pyOpenMS/pxds/ExperimentalSettings.pxd, src/tests/class_tests/openms/source/ExperimentalSettings_test.cpp Remove protein identification storage and access from ExperimentalSettings and related Python bindings and tests.
src/openms/include/OpenMS/DATASTRUCTURES/ParamValue.h Qualify ssize_ type with std:: namespace.
src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h, src/openms_gui/source/VISUAL/LayerDataBase.cpp, src/openms_gui/include/OpenMS/VISUAL/LayerData1DPeak.h, src/openms_gui/include/OpenMS/VISUAL/LayerData1DChrom.h, src/openms_gui/include/OpenMS/VISUAL/LayerDataPeak.h, src/openms_gui/include/OpenMS/VISUAL/LayerDataChrom.h, src/openms_gui/source/VISUAL/LayerDataPeak.cpp, src/openms_gui/source/VISUAL/LayerDataChrom.cpp Refactor all layer data classes to use AnnotatedMSRun as experiment type, update all access to spectra/chromatograms via getMSExperiment().
src/openms_gui/include/OpenMS/VISUAL/MetaDataBrowser.h, src/openms_gui/source/VISUAL/MetaDataBrowser.cpp Remove direct dependency and visualization of identifications from spectrum/experimental settings.
src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp Refactor peptide identification access to use AnnotatedMSRun, add debug output, improve data access and checks.
src/openms_gui/source/VISUAL/SpectraTreeTab.cpp, src/openms_gui/source/VISUAL/Plot1DCanvas.cpp, src/openms_gui/source/VISUAL/Plot2DCanvas.cpp, src/openms_gui/source/VISUAL/Plot3DCanvas.cpp, src/openms_gui/source/VISUAL/Plot3DOpenGLCanvas.cpp, src/openms_gui/source/VISUAL/PlotCanvas.cpp, src/openms_gui/source/VISUAL/Painter2DBase.cpp, src/openms_gui/source/VISUAL/APPLICATIONS/TOPPViewBase.cpp, src/openms_gui/source/VISUAL/TVIdentificationViewController.cpp, src/openms_gui/source/VISUAL/TVSpectraViewController.cpp Update all access to spectra and chromatograms to use getMSExperiment() from AnnotatedMSRun, update meta value and annotation handling, add debug output, improve error handling.
doc/code_examples/Tutorial_GUI_Plot1D.cpp Update example to use AnnotatedMSRun and shared pointers.
src/openms_gui/source/VISUAL/LayerDataBase.cpp Add commented-out methods for cache and annotation management; update annotator logic to use getMSExperiment().
src/topp/IDSplitter.cpp, src/topp/MapAlignerIdentification.cpp Remove support for mzML as input/reference type in tools, update logic and documentation.
src/openms/source/APPLICATIONS/ToolHandler.cpp, doc/doxygen/public/TOPP.doxygen, doc/doxygen/public/developer_tutorial.doxygen, CHANGELOG Remove references and documentation for deprecated tools: SpecLibCreator, SpecLibSearcher, IDMassAccuracy.
src/topp/SpecLibCreator.cpp, src/topp/SpecLibSearcher.cpp, src/topp/IDMassAccuracy.cpp Remove deprecated tool implementations.
src/topp/executables.cmake, src/tests/topp/CMakeLists.txt Remove deprecated tools from build and test lists.
src/tests/topp/SpecLibSearcher_1.*, src/tests/topp/IDMassAccuracy_* Remove test data and tests for deprecated tools.
contrib, vcpkg Update subproject commit references.
CMakeLists.txt Remove trailing blank line.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FileIO
    participant AnnotatedMSRun
    participant Algorithm
    participant Visualization

    User->>FileIO: Load spectra and identifications
    FileIO->>AnnotatedMSRun: Populate spectra, peptide, protein IDs
    User->>Algorithm: Run mapping/filtering/analysis
    Algorithm->>AnnotatedMSRun: Access spectra & IDs via unified interface
    User->>Visualization: Display experiment
    Visualization->>AnnotatedMSRun: Retrieve spectra & IDs for display
Loading

Poem

🐇
In fields of code where spectra run,
A rabbit hops—its work begun!
Old tools retire, new types arise,
Annotated runs—what a prize!
Now spectra, peptides, proteins align,
In one neat home, their data shine.
Hop, hop, hooray for code refined!

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@timosachsenberg timosachsenberg changed the title Continuation of Openms PR 5547 Store IDs outside of spectra. Continuation of Openms PR 5547 Apr 9, 2025

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

🔭 Outside diff range comments (2)
src/topp/IDSplitter.cpp (1)

152-152: ⚠️ Potential issue

Inconsistent check for MZML

This line still contains a check for in_type != FileTypes::MZML even though MZML handling has been removed from the conditional at line 105.

Update this line to remove the reference to MZML since it's no longer a supported input type:

-      if (in_type != FileTypes::MZML) removeDuplicates_(peptides);
+      removeDuplicates_(peptides);
src/openms/source/METADATA/SpectrumSettings.cpp (1)

189-204: 💡 Verification agent

🧩 Analysis chain

Methods for accessing peptide identifications have been commented out

The methods for accessing and setting peptide identifications have been commented out rather than being removed or deprecated properly. This is likely part of the refactoring to use AnnotatedMSRawData for managing peptide identifications.

There are potential issues with this approach:

  1. The identification_ member is still used in the equality operator at line 49 and the unify method at line 83
  2. No deprecation notice is provided to guide users to the new approach

Consider either:

  1. Properly removing the methods and updating the equality operator and unify method
  2. Using proper deprecation annotations instead of commenting out the code
  3. Adding comments to explain the change and direct users to the new AnnotatedMSRawData class

🏁 Script executed:

#!/bin/bash
# Check for references to identification_ in the class
grep -n "identification_" src/openms/source/METADATA/SpectrumSettings.cpp

Length of output: 371


Refactor Peptide Identification Handling

The accessor methods for peptide identifications have been commented out as part of the migration to using AnnotatedMSRawData. However, the member identification_ is still actively used in the equality operator (line 49) and the unify method (line 83), which can lead to inconsistent behavior.

Please address one of the following:

  • Remove the commented-out methods and update the equality operator and unify method to no longer rely on identification_.
  • Reinstate the methods with proper deprecation annotations and include documentation/comments explicitly guiding users to use AnnotatedMSRawData instead.

Affected file:

  • src/openms/source/METADATA/SpectrumSettings.cpp
    • Equality operator usage at line 49.
    • unify method usage at line 83.
🧹 Nitpick comments (13)
src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp (2)

703-705: Avoid copying spectrum with structured binding.

Using for (auto [spectrum, peptide_ids] : *layer_->getPeakData()) copies each pair. Prefer const references (e.g., for (const auto& [spectrum, peptide_ids] : *layer_->getPeakData())) to avoid unnecessary copying.


752-755: Repeated structured binding copy.

Similarly, extracting auto [spectrum, peptide_ids] = (*layer_->getPeakData())[i] copies data. For large data, consider referencing (e.g., const auto& [spectrum, peptide_ids]) to reduce overhead.

src/openms/source/FORMAT/MSPFile.cpp (3)

326-340: Reuse of PeakMap loading logic.

This method leverages the existing load for a PeakMap and then transfers data into AnnotatedMSRawData. Confirm performance is acceptable for large files, or consider a direct approach if repeated conversions are costly.


363-364: TODO for store format.

There is a noted //TODO regarding adapting the output format. Offer to expand or finalize this logic to ensure compatibility with any advanced MSP features or custom modifications.


378-382: Check structured binding with potential copying.

Using for (auto [spectrum, peptide_ids] : exp) will copy each spectrum. Where practical, use references to avoid copying large data. Also check that peptide_ids.begin()->getHits() is valid after the empty checks.

src/openms/source/ANALYSIS/ID/IDMapper.cpp (1)

207-209: Potential optimization: pass FeatureMap as const reference.
Currently, the function copies the entire FeatureMap argument. For large feature maps, passing as a const reference could improve performance if you don't need an internal copy.

-void IDMapper::annotate(AnnotatedMSRawData& map, FeatureMap fmap, const bool clear_ids, const bool map_ms1)
+void IDMapper::annotate(AnnotatedMSRawData& map, const FeatureMap& fmap, const bool clear_ids, const bool map_ms1)
src/tests/class_tests/openms/source/IDMapper_test.cpp (2)

84-84: Check macro signature to avoid static analysis warnings.
The extra parentheses in START_SECTION((template <typename PeakType>...)) can sometimes trigger parser issues in static analysis tools. If compilation works fine, you can ignore it. Otherwise, you may remove one set of parentheses.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 84-84: syntax error

(syntaxError)


159-159: Another macro signature.
Same observation about parentheses around the template in START_SECTION(...). Harmless if it compiles, but can confuse some static analyzers.

src/openms_gui/source/VISUAL/LayerDataBase.cpp (2)

75-88: Use std::make_shared for clarity.
In setChromatogramAnnotation(OSWData&& data), consider using std::make_shared<OSWData>(std::move(data)) instead of the raw new expression to improve readability and reduce potential errors, even though the current code works.


244-342: Consider modularizing updatePeptideHitAnnotations_.
This method contains complex logic for parsing annotation text, extracting charge information, and constructing PeakAnnotations. Either verify comprehensive tests exist covering all parsing scenarios or consider decomposing steps (e.g., into separate functions that handle parsing, mapping, updating) to simplify maintainability and testing.

src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (1)

67-71: clearAllPeptideIdentifications() usage.
The swap with an empty vector effectively clears the data. Confirm that any references or iterators to peptide_ids become invalidated. Calling code should be aware of this.

src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (2)

15-19: Consider removing duplicate includes and consolidating.
Currently, <OpenMS/KERNEL/MSExperiment.h> is included here (line 16) and again at line 23 without any apparent difference in included content. Redundant includes may occasionally cause maintenance issues.

 #include <OpenMS/DATASTRUCTURES/String.h>

-#include <OpenMS/KERNEL/MSExperiment.h>
+#include <OpenMS/KERNEL/MSExperiment.h> // keep only one if no differences in usage
 #include <OpenMS/KERNEL/AnnotatedMSRawData.h>
 #include <OpenMS/KERNEL/StandardTypes.h>
 
 // ...

425-431: Implementation caution: generating new PeptideIdentifications/PeptideHits.
synchronizePeakAnnotations() and removePeakAnnotationsFromPeptideHit(...) create or update peptide-level data automatically if missing. This is convenient but be mindful of unintended side effects if the existence of these IDs is expected elsewhere. Consider thorough testing to ensure correct behavior.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b36cdec and 974d9cc.

📒 Files selected for processing (43)
  • CMakeLists.txt (1 hunks)
  • doc/doxygen/public/TOPP.doxygen (0 hunks)
  • doc/doxygen/public/developer_tutorial.doxygen (0 hunks)
  • src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h (3 hunks)
  • src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (6 hunks)
  • src/openms/include/OpenMS/DATASTRUCTURES/ParamValue.h (1 hunks)
  • src/openms/include/OpenMS/FORMAT/MSPFile.h (2 hunks)
  • src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (1 hunks)
  • src/openms/include/OpenMS/KERNEL/MSExperiment.h (1 hunks)
  • src/openms/include/OpenMS/KERNEL/sources.cmake (1 hunks)
  • src/openms/include/OpenMS/METADATA/SpectrumSettings.h (1 hunks)
  • src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (5 hunks)
  • src/openms/source/ANALYSIS/ID/IDMapper.cpp (7 hunks)
  • src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (3 hunks)
  • src/openms/source/APPLICATIONS/ToolHandler.cpp (0 hunks)
  • src/openms/source/FORMAT/MSPFile.cpp (6 hunks)
  • src/openms/source/KERNEL/AnnotatedMSRawData.cpp (1 hunks)
  • src/openms/source/KERNEL/MSExperiment.cpp (2 hunks)
  • src/openms/source/KERNEL/sources.cmake (1 hunks)
  • src/openms/source/METADATA/SpectrumSettings.cpp (2 hunks)
  • src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (6 hunks)
  • src/openms_gui/include/OpenMS/VISUAL/MetaDataBrowser.h (0 hunks)
  • src/openms_gui/source/VISUAL/LayerDataBase.cpp (3 hunks)
  • src/openms_gui/source/VISUAL/MetaDataBrowser.cpp (0 hunks)
  • src/openms_gui/source/VISUAL/PlotCanvas.cpp (1 hunks)
  • src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp (8 hunks)
  • src/tests/class_tests/openms/executables.cmake (1 hunks)
  • src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp (1 hunks)
  • src/tests/class_tests/openms/source/IDFilter_test.cpp (0 hunks)
  • src/tests/class_tests/openms/source/IDMapper_test.cpp (7 hunks)
  • src/tests/class_tests/openms/source/MSPFile_test.cpp (1 hunks)
  • src/tests/class_tests/openms/source/SpectrumSettings_test.cpp (0 hunks)
  • src/tests/topp/CMakeLists.txt (0 hunks)
  • src/tests/topp/SpecLibSearcher_1.MSP (0 hunks)
  • src/tests/topp/SpecLibSearcher_1.MzData (0 hunks)
  • src/tests/topp/SpecLibSearcher_1.idXML (0 hunks)
  • src/tests/topp/SpecLibSearcher_1.mzML (0 hunks)
  • src/topp/IDMassAccuracy.cpp (20 hunks)
  • src/topp/IDSplitter.cpp (2 hunks)
  • src/topp/MapAlignerIdentification.cpp (0 hunks)
  • src/topp/SpecLibCreator.cpp (0 hunks)
  • src/topp/SpecLibSearcher.cpp (0 hunks)
  • src/topp/executables.cmake (0 hunks)
💤 Files with no reviewable changes (16)
  • src/openms_gui/include/OpenMS/VISUAL/MetaDataBrowser.h
  • src/tests/topp/SpecLibSearcher_1.MSP
  • doc/doxygen/public/developer_tutorial.doxygen
  • src/topp/MapAlignerIdentification.cpp
  • doc/doxygen/public/TOPP.doxygen
  • src/tests/topp/SpecLibSearcher_1.MzData
  • src/openms_gui/source/VISUAL/MetaDataBrowser.cpp
  • src/openms/source/APPLICATIONS/ToolHandler.cpp
  • src/topp/SpecLibCreator.cpp
  • src/tests/topp/SpecLibSearcher_1.mzML
  • src/topp/executables.cmake
  • src/tests/class_tests/openms/source/IDFilter_test.cpp
  • src/tests/topp/SpecLibSearcher_1.idXML
  • src/topp/SpecLibSearcher.cpp
  • src/tests/class_tests/openms/source/SpectrumSettings_test.cpp
  • src/tests/topp/CMakeLists.txt
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/openms/source/FORMAT/MSPFile.cpp (2)
src/openms/include/OpenMS/FORMAT/MSPFile.h (3)
  • load (61-61)
  • load (73-73)
  • store (80-80)
src/tests/class_tests/openms/source/MSPFile_test.cpp (2)
  • load (60-60)
  • store (120-120)
src/tests/class_tests/openms/source/IDMapper_test.cpp (2)
src/tests/class_tests/openms/source/MSPFile_test.cpp (4)
  • START_SECTION (40-40)
  • START_SECTION (50-50)
  • START_SECTION (60-60)
  • START_SECTION (120-120)
src/openms/source/ANALYSIS/ID/IDMapper.cpp (8)
  • annotate (78-204)
  • annotate (78-82)
  • annotate (207-224)
  • annotate (207-207)
  • annotate (248-640)
  • annotate (248-254)
  • annotate (642-975)
  • annotate (642-647)
🪛 Cppcheck (2.10-2)
src/tests/class_tests/openms/source/IDMapper_test.cpp

[error] 84-84: syntax error

(syntaxError)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (windows-2022, cl.exe, default)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: cppcheck-test
🔇 Additional comments (92)
src/openms/include/OpenMS/KERNEL/sources.cmake (1)

6-6: Addition of new header file looks good

This change adds the AnnotatedMSRawData.h header file to the build system, which is consistent with the PR's goal of integrating the new AnnotatedMSRawData class throughout the code base.

src/openms/source/KERNEL/sources.cmake (1)

6-6: Addition of new source file looks good

This change adds the AnnotatedMSRawData.cpp implementation file to the build system, which aligns with the header file addition in the include directory. This is required for the class to be properly built and linked.

src/openms/include/OpenMS/KERNEL/MSExperiment.h (1)

1276-1277:

Details

✅ Verification successful

Verify all callers of this method are updated

Commenting out this method could break existing code that relies on it. We need to ensure all callers have been updated to use the new approach.


🏁 Script executed:

#!/bin/bash
# Search for all uses of hasPeptideIdentifications method across the codebase

echo "Searching for all calls to hasPeptideIdentifications()..."
rg -A 2 -B 2 "\bhasPeptideIdentifications\(\)" --type cpp

Length of output: 964


Review Update: Verified Removal of Unused Caller for hasPeptideIdentifications()

We confirmed via the grep search that the only reference to hasPeptideIdentifications() appears in its own definition in src/openms/source/KERNEL/MSExperiment.cpp, and the declaration in the header is commented out. There are no external calls found in the codebase that would be affected. It appears that all callers have been updated to the new approach.

Please double-check any test files or internal dependencies to ensure that no indirect usage remains before removing the method entirely.

src/openms/include/OpenMS/DATASTRUCTURES/ParamValue.h (1)

352-352: Good improvement: Added std namespace qualifier

The change from ptrdiff_t to std::ptrdiff_t is a good practice that makes the code more explicit about where the type comes from, improving code readability and maintainability.

src/openms/source/KERNEL/MSExperiment.cpp (1)

852-864:

Details

❓ Verification inconclusive

Commented out method as part of refactoring to AnnotatedMSRawData

The hasPeptideIdentifications method has been commented out as part of the broader refactoring effort to transition from PeakMap to AnnotatedMSRawData.

Ensure that the functionality of this method is available in the AnnotatedMSRawData class to maintain backward compatibility with any code that might be using this method.


🏁 Script executed:

#!/bin/bash
# Check if there's a similar method in AnnotatedMSRawData
echo "Searching for equivalent functionality in AnnotatedMSRawData..."
rg -A 3 -B 3 "hasPeptideIdentifications|peptide.*identifications" --type cpp src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h

Length of output: 1300


Action: Verify backward compatibility for peptide identification handling

The hasPeptideIdentifications method in MSExperiment.cpp (lines 852–864) was commented out as part of the refactor moving from PeakMap to AnnotatedMSRawData. The new AnnotatedMSRawData class now provides multiple methods for accessing peptide identifications (e.g., getPeptideIdentifications(size_t), getAllPeptideIdentifications(), and their const variants). Please ensure that any code previously relying on the hasPeptideIdentifications functionality is updated to use these new accessor methods—such as checking if the container returned by getAllPeptideIdentifications() is non-empty—to maintain the expected behavior.

src/tests/class_tests/openms/executables.cmake (1)

131-131: LGTM: New test entry for AnnotatedMSRawData

The addition of AnnotatedMSRawData_test to the kernel_executables_list is appropriate and follows the correct alphabetical ordering convention in the list.

src/tests/class_tests/openms/source/MSPFile_test.cpp (2)

120-123: Good refactoring to use AnnotatedMSRawData

The method signature has been updated to use the new AnnotatedMSRawData class instead of the legacy PeakMap. This is consistent with the broader refactoring effort.


125-130: Good implementation of the test for the refactored functionality

The test has been properly updated to use the new data structure while maintaining the same validation logic. The explicit declaration of PeakMap and vector<PeptideIdentification> after loading the file ensures that the test still validates the same functionality with the new data structure.

src/topp/IDSplitter.cpp (1)

15-15: LGTM: Added include for new data structure

Added include for AnnotatedMSRawData.h which is consistent with the refactoring effort.

src/openms/include/OpenMS/METADATA/SpectrumSettings.h (2)

127-127: Revisit removal of const accessor.

Commenting out the read-only accessor for peptide identifications may break existing client code and remove safe const-only access. Verify that there is no use case requiring a const getter, or consider reintroducing it to maintain const-correctness.


131-131: Confirm impacts of removing setter.

By removing the setter method for peptide identifications, direct assignment is no longer supported. Ensure all relevant code paths have been updated to reflect this model change, or reintroduce if external components still rely on it.

src/openms/include/OpenMS/FORMAT/MSPFile.h (4)

14-14: Include statement aligns with refactoring.

Including the AnnotatedMSRawData.h header is consistent with the new data structure usage and avoids incomplete type issues in potential inline methods.


20-20: Forward declaration is good practice.

Using a forward declaration for AnnotatedMSRawData can help reduce compile-time dependencies, provided you don’t need the full definition here.


63-73: New load method for AnnotatedMSRawData.

The new overload loading directly into AnnotatedMSRawData increases code clarity and reduces conversion overhead for callers who no longer need a PeakMap. Verify documentation details (e.g., thrown exceptions) remain accurate.


80-80: Storing annotated experiment data.

Changing the store method to accept AnnotatedMSRawData is consistent with the broader shift away from PeakMap. Ensure downstream calls are updated to reflect this signature change.

src/openms_gui/source/VISUAL/SpectraIDViewTab.cpp (5)

410-411: Check null-safety and references.

Accessing *layer_->getPeakData() and then annotated_exp.getMSExperiment() relies on layer_ being non-null and containing valid data. Consider adding defensive checks to avoid unexpected dereferencing errors.


420-422: Validate precursor retrieval safety.

When computing prec_it using current_spectrum_index, confirm it’s within valid range. Otherwise, iterators might become invalid. Consider verifying current_spectrum_index < exp.size() before calling getPrecursorSpectrum().


429-430: Emit signals outside boundary checks.

Emitting signals for selection and requesting a new visible area are fine, but ensure prec_it is valid. Currently, you guard using if (prec_it != exp.getSpectra().end() && ...), which is good. No further concerns here.


460-462: Index bound checks for ID retrieval.

Accessing annotated_exp.getPeptideIdentifications(current_spectrum_index)[current_identification_index].getHits()[current_peptide_hit_index] risks out-of-range errors. Double-check that these indices are validated or guaranteed correct upstream.


785-786: Loop over peptide hits is clear.

The loop indexes each peptide hit for further processing. This is straightforward and does not present any immediate issues.

src/openms/source/FORMAT/MSPFile.cpp (3)

13-13: Header inclusion supports annotated data.

Adding <OpenMS/KERNEL/AnnotatedMSRawData.h> is consistent with the new load/store methods that operate on AnnotatedMSRawData.


32-32: New default parameter for partial peak info.

Enabling partial parsing of peak annotation data can improve efficiency. Document any limitations if users expect full annotation by default.


443-443: Normalize intensities guard is reasonable.

Setting max_int to zero as a default and verifying it to avoid division by zero is good practice. Current approach is solid; no other issues noted.

src/topp/IDMassAccuracy.cpp (20)

22-22: Includes updated to use AnnotatedMSRawData instead of MSExperiment

The file now includes AnnotatedMSRawData.h which replaces the older MSExperiment.h import based on the AI summary. This is part of a broader refactoring to use the new data structure throughout the codebase.


113-113: Improved code style with proper spacing

The spacing in the type cast has been improved for better readability.


126-126: Improved code style with proper spacing

The spacing in the UInt cast has been improved for better readability.


140-141: More explicit type specification

The code now uses the explicit vector type declaration rather than relying on auto-deduction, which improves code clarity.


164-169: Migrating from PeakMap to AnnotatedMSRawData

This code segment introduces the AnnotatedMSRawData structure as a replacement for PeakMap. The maps are moved into the new data structure using std::move, which is an efficient approach to avoid unnecessary copying.


172-175: Updated IDMapper to use AnnotatedMSRawData

The mapper.annotate call has been updated to work with the new AnnotatedMSRawData structure instead of PeakMap. This is consistent with the overall refactoring strategy.


179-194: Improved spectrum normalization with structured data

The old code that iterates through maps_raw has been commented out and replaced with a more structured approach using AnnotatedMSRawData. This new implementation uses range-based for loops and better expresses the intent of normalizing each spectrum.


200-251: Improved precursor statistics generation

The old implementation has been commented out and replaced with a more modern approach using the AnnotatedMSRawData structure. The new code:

  1. Uses structured binding with auto[spectrum, peptide_ids] to iterate through data
  2. Uses range-based for loops for cleaner iteration
  3. Maintains the same logical flow but with better readability

This refactoring maintains functionality while improving code quality.


265-330: Improved fragment ion statistics generation

Similar to the precursor statistics, the fragment ion statistics generation has been updated to use AnnotatedMSRawData. The new implementation follows the same pattern of using structured binding and range-based for loops to improve readability while maintaining the original logic.


340-375: Modernized loops and improved variable declaration

The code has been updated to use range-based for loops throughout this block, which makes the code more readable and less prone to off-by-one errors. The declaration of bin_size has also been improved with explicit casting.


383-384: Improved code style with proper spacing

The spacing in the type cast has been improved for better readability in the histogram calculation.


392-392: Improved code style with proper spacing

The spacing in the Size cast has been improved for better readability.


402-402: Improved code style with proper spacing

The division by 500.0 is now clearer with the modified syntax.


424-427: Modernized iteration with range-based for loop

The code now uses a range-based for loop with const auto& reference, which is more readable and idiomatic C++.


443-475: Modernized loops for fragment error calculation

The fragment error calculation has been updated to use range-based for loops, which improves readability and reduces potential for errors compared to the old iterator-based approach.


484-485: Improved code style with proper spacing

The spacing in the calculation has been improved for better readability.


493-493: Improved code style with proper spacing

The spacing in the Size cast has been improved for better readability.


502-502: Improved code style with proper spacing

The division by 100.0 is now clearer with the modified syntax.


524-527: Modernized iteration with range-based for loop

Similar to earlier in the code, the iteration now uses a range-based for loop with const auto& reference for better readability.


543-543: Minor formatting change to main function

The return type int is now explicit in the main function declaration, which is a good practice for clarity.

src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (6)

28-30: Added IsFCMap concept for type safety

A new concept IsFCMap has been introduced to ensure type safety when handling either FeatureMap or ConsensusMap types. This is a good use of C++20 concepts to enforce constraints at compile-time rather than runtime.


32-32: Added forward declaration for AnnotatedMSRawData

A forward declaration for AnnotatedMSRawData has been added, which is good practice to avoid unnecessary includes and reduce compilation dependencies.


64-65: Improved method signature formatting

The setReference method signature has been reformatted across two lines for better readability, especially when viewing in editors with limited width.


84-86: Updated documentation to reflect API changes

The documentation has been updated to remove references to PeakMap, which is consistent with the API changes to use AnnotatedMSRawData instead.


211-211: Updated method signature to use AnnotatedMSRawData

The getRetentionTimes_ method now accepts AnnotatedMSRawData instead of PeakMap, aligning with the overall refactoring to use the new data structure.


227-227: Using concept to constrain template parameter

The method now uses the IsFCMap concept to constrain the template parameter, ensuring that only FeatureMap or ConsensusMap types can be passed. This is a good use of C++20 concepts.

src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (3)

13-13: Added include for AnnotatedMSRawData

The file now includes AnnotatedMSRawData.h, which is necessary for the new data structure used in the implementation.


97-108: Modernized loop with range-based for loop

The code has been updated to use a range-based for loop, which is more readable and less prone to errors than the previous iterator-based approach. This is a good modernization of the code.


181-189: Updated method to use AnnotatedMSRawData

The getRetentionTimes_ implementation now accepts AnnotatedMSRawData instead of PeakMap and uses a range-based for loop to iterate through peptide identifications. This update maintains the same functionality while adopting the new data structure.

src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h (3)

25-25: Added forward declaration for AnnotatedMSRawData

A forward declaration for AnnotatedMSRawData has been added, which is good practice to avoid unnecessary includes and reduce compilation dependencies.


69-69: Updated annotate method to use AnnotatedMSRawData

The annotate method now accepts AnnotatedMSRawData instead of PeakMap (MSExperiment), aligning with the overall refactoring to use the new data structure while maintaining the same functionality.


86-86: Updated second annotate method to use AnnotatedMSRawData

Similar to the first annotate method, this overload has also been updated to use AnnotatedMSRawData instead of PeakMap, maintaining consistency across the API.

src/openms/source/ANALYSIS/ID/IDMapper.cpp (9)

12-12: Include of AnnotatedMSRawData looks correct.
This addition is consistent with the new usage of AnnotatedMSRawData in the code.


78-82: New overload accepting AnnotatedMSRawData is consistent.
This updated method signature correctly replaces PeakMap usage. All parameters appear correctly integrated, and the function name aligns well with the class purpose.


89-90: Ensure clearing IDs is intentional.
Calling map.clearAllPeptideIdentifications() and then clearing map.getMSExperiment().getProteinIdentifications() completely resets all existing IDs. This is valid as long as the caller expects an empty slate when clear_ids is true.


96-96: Appending protein IDs.
Merging the incoming protein_ids into the existing protein identifications of the MSExperiment aligns with previous patterns. No issues found.


98-98: Populating SpectrumLookup with updated spectra.
Using lookup.readSpectra(map.getMSExperiment()) ensures the SpectrumLookup includes all new spectrum references from AnnotatedMSRawData. This looks correct.


118-118: Validate spectrum_idx usage.
Appending to map.getPeptideIdentifications(spectrum_idx) is fine if spectrum_idx is guaranteed to be in range, as provided by the SpectrumLookup. Confirm it never goes out of bounds for edge cases.

Do you want to run a script to verify no negative or overflow indices are encountered in complex datasets?


133-133: Iterating over MSExperiment size.
This simple for-loop is standard and clearly indexes each spectrum. No issues.


179-179: Precursor iteration is aligned with new data structure.
Accessing the precursors via map.getMSExperiment()[index].getPrecursors() remains consistent with the existing logic. No problems found.


190-190: Mapping peptide IDs by experiment iterator.
Pushing back into map.getPeptideIdentifications(...) matches the style in line 118. This is coherent with the updated approach.

src/tests/class_tests/openms/source/IDMapper_test.cpp (11)

20-20: Header include for AnnotatedMSRawData is valid.
This allows the tests to invoke the new interface properly.


104-105: Instantiating AnnotatedMSRawData in tests.
Creating the local AnnotatedMSRawData instance and referencing experiment via getMSExperiment() aligns with the new data structure usage.


131-131: Testing annotate(...) with MS1 mapping enabled.
Invoking mapper.annotate(annotated_experiment, fm, true, true) is a crucial test scenario verifying IDs are cleared first and then mapped. Looks solid.


134-145: Verifying new data structure content.
These assertion lines (TEST_EQUAL(...)) ensure peptides are placed onto the correct scan indices. Appropriately checks multiple dimensions (MZ, hits, etc.).


147-155: Testing no MS1 mapping behavior.
By calling mapper.annotate(annotated_experiment, fm, true, false), the test ensures that no peptide identifications map when MS1 alignment is off. This coverage is good.


188-189: Initial setup for new test scenario.
Using another AnnotatedMSRawData instance ensures the test is isolated. Referencing MSExperiment& experiment = annotated_experiment.getMSExperiment() is consistent.


213-213: Ensuring RT-based annotation is tested.
mapper.annotate(annotated_experiment, identifications, protein_identifications); covers the scenario with RT tolerance checks. Good coverage.


216-230: Verifying assigned protein and peptide results.
These tests confirm correct assignment of proteins and peptides to the appropriate scans. Approvals for verifying the new data structure post-annotation.


236-237: Second experiment instance for native ID testing.
The code consistently sets up annotated_experiment2 and references experiment2. This further extends test coverage.


264-264: Testing native ID-based annotation.
mapper2.annotate(annotated_experiment2, identifications2, protein_identifications2); verifies the alternate mapping route by IDs.


267-281: Assertions confirm correct native ID alignment.
Consistent with the prior test block, verifying that peptides show up on the intended scans.

src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (5)

16-16: Including AnnotatedMSRawData inside IDFilter.
This is necessary for the new filter functions that operate on AnnotatedMSRawData.


34-34: Documenting new feature set.
Adding or modifying the doc-block to reference integrated data structure usage is helpful for clarity.


1131-1155: filterHitsByScore for AnnotatedMSRawData.
This new method applies threshold filtering on both peptides and proteins within AnnotatedMSRawData. There's a @TODO note on removing unreferenced proteins. If needed, that can be implemented in future. The function otherwise appears correct.

Would you like to confirm whether removing unreferenced proteins is beneficial for your workflows, or should the code remain as-is?


1156-1173: keepNBestHits for AnnotatedMSRawData.
Collecting all peptides and then consolidating them after rank-based filtering is a good approach. The subsequent step removing unreferenced proteins keeps the data consistent.


1338-1362: keepHitsMatchingProteins for AnnotatedMSRawData.
Filtering both protein hits in MSExperiment and each MS2-level set of peptide IDs is logically consistent. The final calls to removeEmptyIdentifications(...) and updateHitRanks(...) ensure data integrity. No issues found.

src/openms_gui/source/VISUAL/LayerDataBase.cpp (1)

119-122: Ensure cache coherence in getCurrentSpectrum().
getCurrentSpectrum() returns the cached spectrum without verifying that updateCache_() has been invoked or the index remains valid. If current_spectrum_idx_ has changed without an intermediate cache update, this could yield outdated data. Verify in calling code that the cache stays in sync with current_spectrum_idx_.

src/openms/source/KERNEL/AnnotatedMSRawData.cpp (2)

23-31: All-peptide getters look fine.
The methods getAllPeptideIdentifications() and their const variants correctly expose the entire container. Just ensure that calling code handles empty or unexpected states gracefully.


43-51: MSExperiment getters are straightforward.
Returning references here is a valid approach. Ensure that external code does not inadvertently modify the underlying experiment in unexpected ways, since it's returned by non-const reference in one of the methods. Otherwise, these methods are fine.

src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (5)

25-37: Constructors and move-semantics look good.
The default constructor and the explicit move constructor for MSExperiment are correctly defined to allow efficient initialization.


40-48: Safe access to protein_ids_.
Both getProteinIdentifications() methods provide direct mutable and const access. Ensure that external modifications maintain consistency with the rest of the data. Otherwise, no issues detected.


50-66: Complete coverage for peptide ID sets/gets.
These methods align well with the definitions in the .cpp file but be mindful of index bounds. The same advice about boundary checks and safe usage applies here.


73-116: Iterators and operator[] are convenient but rely on matching vector sizes.
The PairIterator iterates in parallel over data.getSpectra() and peptide_ids. If these differ in size, advancing the iterator could lead to mismatched pairs. Consider an assert or length check to ensure consistent container sizes.


168-172: Approve private member structure.
Storing peptide_ids, protein_ids_, and data in the same class is logical and well-structured for combining MS data with related ID data.

src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (4)

45-46: Forward declaration looks fine.
Forward declaring OnDiscMSExperiment is appropriate here and reduces build-time dependencies. No concerns.


130-130: New typedef aligns with annotated data usage.
Replacing the old typedef MSExperiment with AnnotatedMSRawData is consistent with the broader refactoring toward annotated data structures. Ensure corresponding downstream references to ExperimentType are updated correctly.


282-305: Add bounds checking or docs for potential out-of-range access.
These 1D annotation-access methods index into annotations_1d[current_spectrum_idx_] or annotations_1d[spectrum_index] with no visible checks. If the index is invalid, this may lead to out-of-bounds reads/writes. Consider adding an assertion or documenting that the caller must ensure valid indices.


306-405: Verify meta value usage consistency.
The new methods (isIonMobilityData, labelAsIonMobilityData, isDIAData, labelAsDIAData, and chromatogram flag methods) set or check meta values such as "is_ion_mobility", "is_dia_data", and "is_chromatogram". They look sound, but there's an inconsistency compared to the chromatogram flag, which can be removed. Consider adding complementary “removeIonMobility” / “removeDIAData” flags if reversibility is relevant.

Comment thread CMakeLists.txt Resolved
Comment thread src/topp/IDSplitter.cpp Resolved

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 974d9cc and 9a97fab.

📒 Files selected for processing (5)
  • src/openms/include/OpenMS/METADATA/ExperimentalSettings.h (0 hunks)
  • src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (5 hunks)
  • src/openms/source/ANALYSIS/ID/IDMapper.cpp (5 hunks)
  • src/openms/source/METADATA/ExperimentalSettings.cpp (0 hunks)
  • src/tests/class_tests/openms/source/IDMapper_test.cpp (7 hunks)
💤 Files with no reviewable changes (2)
  • src/openms/include/OpenMS/METADATA/ExperimentalSettings.h
  • src/openms/source/METADATA/ExperimentalSettings.cpp
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/tests/class_tests/openms/source/IDMapper_test.cpp (1)
src/openms/source/ANALYSIS/ID/IDMapper.cpp (8)
  • annotate (78-208)
  • annotate (78-82)
  • annotate (211-228)
  • annotate (211-211)
  • annotate (252-644)
  • annotate (252-258)
  • annotate (646-979)
  • annotate (646-651)
🪛 Cppcheck (2.10-2)
src/tests/class_tests/openms/source/IDMapper_test.cpp

[error] 84-84: syntax error

(syntaxError)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-and-test (windows-2022, cl.exe, default)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: cppcheck-test
🔇 Additional comments (25)
src/tests/class_tests/openms/source/IDMapper_test.cpp (7)

20-20: Clean addition of the AnnotatedMSRawData header.

The new include statement is appropriately placed among the other kernel headers.


104-105: Good refactoring to use AnnotatedMSRawData.

The code correctly creates an AnnotatedMSRawData object and retrieves a reference to the underlying MSExperiment for further manipulation, showing a clean transition to the new data structure.


131-147: Proper method call adaptation.

The test case correctly uses the new annotate method with AnnotatedMSRawData and adapts all subsequent assertions to access peptide identifications through the new data structure.


190-192: Consistent use of AnnotatedMSRawData in the second test case.

The test properly instantiates AnnotatedMSRawData and accesses the underlying experiment, maintaining consistency with the design approach used throughout the file.


219-234: Updated test assertions for the new data structure.

All test assertions have been properly updated to work with the AnnotatedMSRawData structure, accessing peptide identifications through the appropriate methods.


239-240: Consistent refactoring in the third test case.

This test section maintains consistency with the refactoring approach used throughout the file, creating an AnnotatedMSRawData object and accessing the underlying experiment.


270-284: Final test assertions properly updated.

The final test assertions correctly use the new AnnotatedMSRawData methods to verify the behavior of the identifier mapping functionality.

src/openms/source/ANALYSIS/ID/IDMapper.cpp (10)

12-12: Appropriate inclusion of the AnnotatedMSRawData header.

The new include statement is correctly placed with the other kernel headers.


78-83: Updated method signature to use AnnotatedMSRawData.

The method signature has been properly updated to accept AnnotatedMSRawData instead of the templated MSExperiment<PeakType>, reflecting the structural change in the data model.


89-91: Refactored code to use AnnotatedMSRawData methods.

The code now uses the clearAllPeptideIdentifications() and getProteinIdentifications() methods from AnnotatedMSRawData instead of directly manipulating the underlying data structures, improving encapsulation.


96-98: Updated protein identification handling.

The code correctly uses the getProteinIdentifications() method to access and update protein identifications in the AnnotatedMSRawData object.


100-101: Proper setup of lookup table using MSExperiment.

The code correctly accesses the underlying MSExperiment using getMSExperiment() to set up the lookup table for spectra.


122-123: Updated peptide identification assignment.

The code now uses map.getPeptideIdentifications(spectrum_idx) to access and update peptide identifications for a specific spectrum, maintaining encapsulation.


136-138: Consistent use of getMSExperiment().

The code consistently uses getMSExperiment() to access the underlying experiment when needed, such as for retrieving retention times.


182-182: Precursor access through MSExperiment.

The code correctly accesses precursors through the underlying MSExperiment using map.getMSExperiment().


194-194: Updated peptide identification assignment for matches.

Upon finding a match, the code correctly updates the peptide identifications using map.getPeptideIdentifications().


211-211: Updated overloaded method signature.

The second overload of the annotate method has also been updated to use AnnotatedMSRawData instead of the templated MSExperiment<PeakType>.

src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (8)

16-16: Added include for AnnotatedMSRawData.

The header file correctly includes the AnnotatedMSRawData.h header to support the new filtering functions.


1131-1132: Updated section comment for AnnotatedMSRawData filter functions.

The comment has been appropriately updated to indicate that the following functions are for AnnotatedMSRawData rather than MSExperiment.


1134-1153: Implemented filterHitsByScore for AnnotatedMSRawData.

The method properly filters both protein and peptide hits based on score thresholds, using the appropriate access methods from AnnotatedMSRawData.


1146-1151: Good use of range-based for loop for peptide identifications.

The code uses a modern range-based for loop to iterate over all peptide identifications, making the code more readable and maintainable.


1155-1171: Implemented keepNBestHits for AnnotatedMSRawData.

The method correctly keeps only the N best peptide hits for each spectrum and updates protein references accordingly.


1162-1168: Effective use of AnnotatedMSRawData methods.

The code efficiently uses the getAllPeptideIdentifications() method to access all peptide identifications, applies the filtering, and updates protein references.


1337-1362: Implemented keepHitsMatchingProteins for AnnotatedMSRawData.

The method correctly filters both protein and peptide hits to keep only those matching the provided proteins, using appropriate iteration over the spectra in the AnnotatedMSRawData object.


1352-1361:

Details

✅ Verification successful

Interesting use of structured binding for iteration.

The code uses C++17's structured binding to iterate over pairs of spectra and their associated peptide identifications, which is a modern and efficient approach.

However, note that this assumes the AnnotatedMSRawData class supports iteration in this form, which should be verified.


🏁 Script executed:

#!/bin/bash
# Check if AnnotatedMSRawData supports the range-based for loop with structured binding
grep -r "begin\(.*\)" --include="*.h" src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h
grep -r "end\(.*\)" --include="*.h" src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h
grep -r "operator*" --include="*.h" src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h

Length of output: 1399


Structured Binding Verification Confirmed

The use of structured binding in iterating over the spectrum and peptide ID pairs is appropriate and modern. The verification confirms that the AnnotatedMSRawData class indeed supports range-based for loops with structured binding, as indicated by the implemented begin(), end(), and associated iterator functions (including operator*).

timosachsenberg and others added 2 commits April 9, 2025 19:12
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

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

🧹 Nitpick comments (2)
src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (2)

15-19: Consolidate repeated includes and remove unnecessary forward declarations.

Lines 16 and 23 repeat includes for <OpenMS/KERNEL/MSExperiment.h>, and line 45 forward-declares OnDiscMSExperiment, while line 24 already includes its header. Reducing redundant includes and forward declarations helps keep headers lean and improves compile times.


45-46: Confirm the necessity of forward declaration after including the header.

After including <OpenMS/KERNEL/OnDiscMSExperiment.h> (line 24), having the forward declaration here (line 45) may be superfluous. Removing it could simplify maintenance.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a97fab and 004dece.

📒 Files selected for processing (3)
  • CMakeLists.txt (0 hunks)
  • src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (5 hunks)
  • src/tests/class_tests/openms/source/IDMapper_test.cpp (7 hunks)
💤 Files with no reviewable changes (1)
  • CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/class_tests/openms/source/IDMapper_test.cpp
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (2)
src/openms/include/OpenMS/PROCESSING/MISC/DataFilters.h (1)
  • index (102-102)
src/openms/source/PROCESSING/MISC/DataFilters.cpp (2)
  • index (260-267)
  • index (260-260)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (windows-2022, cl.exe, default)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: cppcheck-test
🔇 Additional comments (4)
src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (4)

130-130: Adoption of AnnotatedMSRawData looks good.

Replacing the old typedef (e.g., PeakMap) with AnnotatedMSRawData aligns with the broader transition to the updated data structure. This is consistent and improves clarity.


306-333: Ensure “current spectrum” references are always valid.

The “current spectrum” retrieval and caching logic introduces possible mismatch if current_spectrum_idx_ is out of range. Confirm that updating current_spectrum_idx_ without additional checks never leads to accessing nonexistent entries in cached_spectrum_ or annotations_1d.


335-345: Verify shared pointer logic when constructing full chromatogram data.

The ternary evaluation in getFullChromData() can yield null or partial data if getChromatogramData() is uninitialized. Confirm at runtime that peak_map_ and the returned pointer from getChromatogramData() are never null in production code.


425-431: Confirm resilience of peak annotation synchronization methods.

synchronizePeakAnnotations() and removePeakAnnotationsFromPeptideHit(...) can fail if the layer’s data structures (e.g., PeptideIdentification, PeptideHit) are not properly initialized or are unexpectedly empty. Ensure thorough unit testing or runtime checks to handle these edge cases.

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

♻️ Duplicate comments (6)
src/openms/source/KERNEL/AnnotatedMSRawData.cpp (3)

13-16: Add range checks for index to prevent out-of-bounds access.

Similar to a past review comment, this implementation does not guard against invalid indices. Consider throwing an exception or asserting that index < peptide_ids.size() before accessing peptide_ids[index].


18-21: Add range checks for index to prevent out-of-bounds access (const version).

As noted before, ensure safe access by validating that index < peptide_ids.size() before returning peptide_ids[index].


33-36: Enforce size checks when setting peptide IDs.

This method should verify index < peptide_ids.size() before assigning to peptide_ids[index]. This was suggested previously; please ensure it is addressed to avoid undefined behavior for out-of-range indices.

src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (3)

78-79: Add range checks for index to prevent out-of-bounds access.

Like the implementation, this declaration should note or enforce valid indices for the function contract. These checks mirror a prior suggestion.


85-86: Reinforce safe indexing for the const version.

Similar to the non-const overload, ensure a documented or enforced precondition that index < peptide_ids.size().


104-105: Validate index before assignment.

Returning a reference to peptide_ids[index] should be guarded by a range check, consistent with previous feedback.

🧹 Nitpick comments (13)
src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp (3)

43-53: Consider adding negative test scenarios for getProteinIdentifications().
While this block verifies basic functionality by testing the size and accessing elements, consider adding tests that check behavior on an empty container or invalid indices to ensure robust error handling.


73-83: Validate out-of-range access.
Here, you resize the peptide identifications to match the experiment’s spectra. Consider adding a test for cases where the user attempts to retrieve a peptide identification by an out-of-range index to verify graceful error handling or assertion checks.


288-288: Structured bindings might trigger compiler compatibility issues.
Line 288 uses C++17 structured bindings (for (auto [spectrum, peptide_id] : annotated_data)). Some compilers or older build environments may flag this as a syntax error. If targeting earlier C++ standards, consider reverting to a more traditional iterator-based approach.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 288-288: syntax error

(syntaxError)

src/openms/source/FORMAT/MSPFile.cpp (3)

326-336: Check for consistency between IDs and spectra.
When transferring data into the AnnotatedMSRawData (lines 334-336), verify that the size/ordering of peptide identifications matches the MSExperiment’s spectra if that’s an expected invariant. Otherwise, consider adding a consistency check.


374-385: Generalized modification handling.
Currently, only oxidations of methionine (M(O)) are explicitly handled. This may cause maintenance issues if new modifications need special formatting. Consider adding a more generic logic for modifications to avoid future manual handling or partial coverage.


374-374: Structured bindings again.
Similar to other files, the for (auto [spectrum, peptide_id] : exp) loop requires C++17 support. Ensure your build environment is up to date or revert to an iterator-based loop if you must support older compilers.

src/tests/class_tests/openms/source/IDMapper_test.cpp (2)

84-161: Remove or clarify the commented-out test block.
This large chunk of commented-out code may introduce confusion for future maintainers. If it is no longer needed, remove it; otherwise, add context explaining why it remains commented.


163-283: DRY considerations for repeated test setup.
The block from lines 163–283 appears to repeat logic for experiment creation, parameter setting, and verification steps seen earlier. Consider extracting a helper routine to reduce duplication and improve maintainability.

src/openms/source/ANALYSIS/ID/IDMapper.cpp (3)

78-92: Check for potential duplication of merged hits.
When merging multiple PeptideIdentification hits into the same spectrum (lines 123–126, 199–203), ensure that no downstream processes inadvertently interpret duplicates as distinct IDs. If duplicates are possible, consider de-duplication or explicit user warnings.


187-196: Efficient data structure for large-scale RT matching.
As you map identifications to spectra by RT, this manual approach may be costly for very large data sets. Consider employing interval trees or binary searching if performance becomes an issue.


110-116: Fallback to RT-based matching if native ID is missing.
This fallback strategy ensures flexibility. Just ensure documentation clarifies how conflicts are resolved when a mismatch occurs between RT-based and native ID-based references.

src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (1)

1009-1016: Consider rank reassignment after filtering.

After calling keepMatchingItems(...) on the hits, the ranks may be invalid. In some contexts, calling an update method such as assignRanks() may be useful if ranks are needed elsewhere.

src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (1)

213-283: Address the TODO by verifying vector lengths.

The comment suggests confirming that data.getSpectra() and peptide_ids always have matching sizes. Consider implementing a runtime check or an invariant to avoid misaligned iterators and undefined behavior.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef279d and 2bd4501.

📒 Files selected for processing (17)
  • CHANGELOG (1 hunks)
  • doc/doxygen/public/TOPP.doxygen (0 hunks)
  • src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h (3 hunks)
  • src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (1 hunks)
  • src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (10 hunks)
  • src/openms/source/ANALYSIS/ID/IDMapper.cpp (7 hunks)
  • src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (3 hunks)
  • src/openms/source/APPLICATIONS/ToolHandler.cpp (0 hunks)
  • src/openms/source/FORMAT/MSPFile.cpp (6 hunks)
  • src/openms/source/KERNEL/AnnotatedMSRawData.cpp (1 hunks)
  • src/pyOpenMS/pxds/ExperimentalSettings.pxd (0 hunks)
  • src/pyOpenMS/pxds/SpectrumSettings.pxd (0 hunks)
  • src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp (1 hunks)
  • src/tests/class_tests/openms/source/IDMapper_test.cpp (7 hunks)
  • src/tests/topp/CMakeLists.txt (0 hunks)
  • src/topp/IDMassAccuracy.cpp (0 hunks)
  • src/topp/executables.cmake (0 hunks)
💤 Files with no reviewable changes (7)
  • src/pyOpenMS/pxds/SpectrumSettings.pxd
  • doc/doxygen/public/TOPP.doxygen
  • src/pyOpenMS/pxds/ExperimentalSettings.pxd
  • src/openms/source/APPLICATIONS/ToolHandler.cpp
  • src/topp/IDMassAccuracy.cpp
  • src/topp/executables.cmake
  • src/tests/topp/CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp
  • src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp (2)
src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (15)
  • AnnotatedMSRawData (33-296)
  • AnnotatedMSRawData (40-40)
  • AnnotatedMSRawData (46-47)
  • AnnotatedMSRawData (46-46)
  • AnnotatedMSRawData (50-50)
  • AnnotatedMSRawData (53-53)
  • getPeptideIdentification (78-78)
  • getPeptideIdentification (85-85)
  • getPeptideIdentifications (91-91)
  • getPeptideIdentifications (97-97)
  • setPeptideIdentifications (110-110)
  • clearAllPeptideIdentifications (115-119)
  • clearAllPeptideIdentifications (115-115)
  • getMSExperiment (125-125)
  • getMSExperiment (131-131)
src/openms/source/KERNEL/AnnotatedMSRawData.cpp (14)
  • getPeptideIdentification (13-16)
  • getPeptideIdentification (13-13)
  • getPeptideIdentification (18-21)
  • getPeptideIdentification (18-18)
  • getPeptideIdentifications (23-26)
  • getPeptideIdentifications (23-23)
  • getPeptideIdentifications (28-31)
  • getPeptideIdentifications (28-28)
  • setPeptideIdentifications (38-41)
  • setPeptideIdentifications (38-38)
  • getMSExperiment (43-46)
  • getMSExperiment (43-43)
  • getMSExperiment (48-51)
  • getMSExperiment (48-48)
src/openms/source/KERNEL/AnnotatedMSRawData.cpp (1)
src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (8)
  • getPeptideIdentification (78-78)
  • getPeptideIdentification (85-85)
  • getPeptideIdentifications (91-91)
  • getPeptideIdentifications (97-97)
  • setPeptideIdentification (104-104)
  • setPeptideIdentifications (110-110)
  • getMSExperiment (125-125)
  • getMSExperiment (131-131)
🪛 Cppcheck (2.10-2)
src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp

[error] 288-288: syntax error

(syntaxError)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (windows-2022, cl.exe, default)
  • GitHub Check: cppcheck-test
🔇 Additional comments (9)
CHANGELOG (2)

14-15: LGTM! Clear documentation of architectural change.

The new entry in the Library section correctly documents the ID information being factored out of MSSpectrum, which aligns with the PR title. This is important information for users upgrading to the new version.


17-19: LGTM! Properly documented tool removal.

The removal of SpecLibCreator and SpecLibSearch tools is clearly documented following the established format in the CHANGELOG. This provides users with important information about breaking changes in the upcoming release.

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

307-344: Good coverage of operator[] functionality.
This section thoroughly checks read and write access to spectra and peptide identifications. The approach ensures the tested class is robust to typical usage scenarios, and no immediate issues are found.

src/openms/source/FORMAT/MSPFile.cpp (1)

438-460: Zero-intensity edge case handled well.
You’ve included a check (line 457) to handle spectra with zero intensities by printing a warning message. This is a good practice and helps diagnose data issues at runtime.

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

268-282: Broad test coverage for RT and spectrum references.
This test thoroughly checks both time-based (RT) and nativeID-based mappings. The approach ensures robust coverage of different scenarios. Good job!

src/openms/source/ANALYSIS/ID/IDMapper.cpp (1)

213-216: Helpful diagnostic logging.
Logging the number of assigned/unassigned peptides is useful for debugging. Ensure that the logging is either configurable or minimal for production deployments.

src/openms/source/KERNEL/AnnotatedMSRawData.cpp (1)

23-31: Looks good.

Returning the full vector without additional processing is straightforward and correct for these accessor methods.

src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (2)

633-641: LGTM.

This function correctly generalizes parameterizing over feature/consensus map types for peptide identifications removal.


760-765: No concerns with rank update logic.

Invoking assignRanks() here is straightforward and helps ensure consistency. The approach seems correct.

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

🧹 Nitpick comments (8)
src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp (2)

14-25: Constructor test coverage is thorough.
Verifies successful instantiation and confirms pointer validity. Consider adding negative or edge-case tests, e.g., verifying behavior when the underlying MSExperiment is empty or uninitialized.


66-83: Index-based access test for PeptideIdentifications is valid.
You correctly resize PeptideIdentifications to match the number of spectra and verify that inserted hits remain accessible. Meta-tests (e.g., out-of-range index) could provide additional safety checks.

src/openms/source/KERNEL/AnnotatedMSRawData.cpp (1)

23-26: Move semantics are applied correctly.
Setting the member via std::move(ids) avoids unnecessary copies. If concurrency might emerge in the future, consider adding thread-safety or synchronization.

src/openms/source/ANALYSIS/ID/IDMapper.cpp (3)

186-188: Precursor matching logic checks.
Looping through each spectrum’s precursors ensures thorough coverage for matching. Consider adding debug logs when no matching precursor is found to ease troubleshooting.


199-202: Merging hits into an existing PeptideIdentification.
Appending hits from peptide_ids[i] into existing_id is correct. For large data sets, consider performance implications of repeated insertions.


218-219: Temporarily commented-out code block.
Large chunk of code is commented out (lines 218–237). Evaluate whether it should be removed or reintroduced to avoid confusion.

src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (2)

71-71: Consistent field naming recommended.
peptide_ids is a private member, while protein_ids_ has a trailing underscore. Consider renaming peptide_ids to peptide_ids_ for consistency.


192-266: PairIterator is well-implemented.
Automatically pairing spectra and identifications simplifies iteration. Including a length check during construction could prevent mismatched container sizes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2bd4501 and 3827a3c.

📒 Files selected for processing (4)
  • src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (1 hunks)
  • src/openms/source/ANALYSIS/ID/IDMapper.cpp (7 hunks)
  • src/openms/source/KERNEL/AnnotatedMSRawData.cpp (1 hunks)
  • src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/openms/source/KERNEL/AnnotatedMSRawData.cpp (1)
src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (5)
  • getPeptideIdentifications (77-77)
  • getPeptideIdentifications (83-83)
  • setPeptideIdentifications (89-89)
  • getMSExperiment (104-104)
  • getMSExperiment (110-110)
src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp (1)
src/openms/source/KERNEL/AnnotatedMSRawData.cpp (10)
  • getPeptideIdentifications (13-16)
  • getPeptideIdentifications (13-13)
  • getPeptideIdentifications (18-21)
  • getPeptideIdentifications (18-18)
  • setPeptideIdentifications (23-26)
  • setPeptideIdentifications (23-23)
  • getMSExperiment (28-31)
  • getMSExperiment (28-28)
  • getMSExperiment (33-36)
  • getMSExperiment (33-33)
🪛 Cppcheck (2.10-2)
src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp

[error] 288-288: syntax error

(syntaxError)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (windows-2022, cl.exe, default)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: cppcheck-test
🔇 Additional comments (14)
src/tests/class_tests/openms/source/AnnotatedMSRawData_test.cpp (4)

1-7: Header and licensing look good.
No issues found in the license header or authorship declaration.


31-41: Move constructor usage is correct.
The move constructor test ensures minimal overhead when creating an AnnotatedMSRawData from an MSExperiment. Good coverage for verifying RT preservation and MS level.


307-344: Operator[] functionality is well-tested.
Tests verifying the pair of references (spectrum and peptide_id) for both mutable and const access confirm correctness.


266-305:

Details

❓ Verification inconclusive

Iterator functionality well-exercised but watch for static analysis warnings.
Line 288 uses C++17’s structured bindings (for (auto [spectrum, peptide_id] : annotated_data)), which may trigger older tool warnings. Confirm your build environment supports C++17 or higher.


🏁 Script executed:

#!/bin/bash
# Verify that the compiler is set to at least C++17 to avoid false syntax errors with structured bindings.
grep -R 'CXX_STANDARD' CMakeLists.txt

Length of output: 37


Confirm C++17 Support in Build Configuration

The iterator functionality test is solid. However, the use of C++17 structured bindings (e.g., for (auto [spectrum, peptide_id] : annotated_data)) requires ensuring that your build environment explicitly enables C++17 or later. Our initial check via grep -R 'CXX_STANDARD' CMakeLists.txt returned no results, so please manually verify or update the build configuration (for example, by setting set(CMAKE_CXX_STANDARD 17) in your CMakeLists.txt) to guarantee proper compatibility and avoid static analysis warnings.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 288-288: syntax error

(syntaxError)

src/openms/source/KERNEL/AnnotatedMSRawData.cpp (2)

13-16: Non-const reference return is appropriate.
Exposing a non-const reference to peptide_ids allows direct editing of the underlying container. Ensure that callers handle the returned reference carefully to avoid unexpected side effects.


18-21: Const reference return best practice.
Returning a const reference to peptide_ids prevents mutation in read-only contexts, safeguarding internal state.

src/openms/source/ANALYSIS/ID/IDMapper.cpp (6)

12-12: New include for AnnotatedMSRawData recognized.
Including <OpenMS/KERNEL/AnnotatedMSRawData.h> aligns with the shift from PeakMap to AnnotatedMSRawData.


78-82: New annotate(...) overload for AnnotatedMSRawData.
Parameters are clear, and optional clearing of existing IDs is straightforward. This helps unify the ID mapping workflow around the new data structure.


88-90: Clearing existing IDs.
Calling map.clearAllPeptideIdentifications() and map.getProteinIdentifications().clear() ensures a clean state if clear_ids is set.


110-132: Flexible identification via RT or native ID.
This code supports both RT-based mapping (lines 114–115) and nativeID-based mapping (lines 118–127). Great approach for heterogeneous data. The fallback in lines 129–131 is particularly robust.


140-142: Building a map of RT to spectrum index.
Storing (RT, index) in a multimap is efficient for subsequent lookups. Ensure the same approach is used consistently in other relevant ID mapping code for uniform patterns.


98-100:

Details

❓ Verification inconclusive

Resizing peptide IDs to match spectra.
Resizing the PeptideIdentifications vector to match the MSExperiment helps keep them in sync. Verify that subsequent logic doesn’t assume an exact 1-to-1 mapping in edge cases.


🏁 Script executed:

#!/bin/bash
# Confirm all usage of getPeptideIdentifications() is always preceded by logic ensuring
# it matches MSExperiment size, including any edge cases.
rg 'getPeptideIdentifications\(\)\.resize\(' -A 3

Length of output: 8532


Attention: Verify Edge Case Handling for PeptideIdentifications Resize

The change to resize the PeptideIdentifications vector based on the number of spectra (using
map.getPeptideIdentifications().resize(map.getMSExperiment().getSpectra().size());) aligns with similar patterns elsewhere in the codebase. However, please verify that downstream logic—specifically, the subsequent setup of the lookup table via lookup.readSpectra(map.getMSExperiment())—does not inadvertently assume a strict one-to-one mapping between peptide identifications and spectra. Pay special attention to edge cases where, for example, the spectrum count might be zero or differ from expectations due to processing anomalies.

  • Action Item: Manually review subsequent indexing or looping constructs to ensure they safely handle a resized vector that may be empty or not perfectly aligned with assumptions of a one-to-one relationship.
src/openms/include/OpenMS/KERNEL/AnnotatedMSRawData.h (2)

33-33: Class-level documentation is clear.
Comprehensively explains the purpose of storing spectra alongside ID data.


94-98: Simple, efficient clearing of peptides.
Using swap with an empty vector is a neat trick for clearing.

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

🧹 Nitpick comments (4)
src/openms/source/ANALYSIS/ID/IDMapper.cpp (4)

78-82: Consider renaming or documenting the boolean parameter for clarity.
The introduction of map_ms1 is logical, but the name is slightly vague. A more descriptive parameter name or an explanatory docstring could help readability.


89-90: Consider providing a unified method to clear all IDs.
Currently, peptide and protein identifications are cleared separately. A dedicated method (e.g., clearAllIdentifications()) might simplify future maintainability.


186-186: Optionally skip iteration if no relevant precursors exist.
You might short-circuit the loop when map_ms1 == false and getPrecursors() is empty, improving performance for large data sets.


218-237: Remove or retain commented-out annotate method intentionally.
Having extensive commented-out code can be confusing. If it's no longer needed, consider removing it or moving it to a separate reference.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3827a3c and 5d488c3.

📒 Files selected for processing (1)
  • src/openms/source/ANALYSIS/ID/IDMapper.cpp (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (windows-2022, cl.exe, default)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: cppcheck-test
🔇 Additional comments (4)
src/openms/source/ANALYSIS/ID/IDMapper.cpp (4)

12-12: Include is consistent with the new data structure usage.
No issues found; this new header is required for handling AnnotatedMSRawData.


98-101: Verify safe resizing when not clearing existing IDs.
Resizing map.getPeptideIdentifications() could overwrite or truncate existing entries if clear_ids == false. Please confirm that this usage scenario is fully intended.


110-133: Good fallback logic for missing spectrum references.
The approach of switching to RT-based mapping if a native ID lookup fails is well-handled, and merging multiple hits into a single PeptideIdentification aligns with the updated design.


140-142: Straightforward construction of precursor-RT mapping.
Populating experiment_precursors for each spectrum is well-structured.

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

♻️ Duplicate comments (2)
src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (2)

282-305: Check for out-of-range access in annotation containers.

Methods like getAnnotations(Size spectrum_index) and getCurrentAnnotations() return containers by indexing annotations_1d. However, there's no boundary check for spectrum_index or current_spectrum_idx_. Consider verifying valid range or throwing an exception when the index is out of bounds.


347-403: Re-evaluate const correctness of labelAsIonMobilityData and similar methods.

These methods are declared const but modify meta values on the underlying data (peak_map_). This usage can be confusing to maintainers, as "const" conventionally implies immutability. Consider removing const or marking peak_map_ as mutable if intentional.

🧹 Nitpick comments (21)
src/topp/IDSplitter.cpp (1)

15-15: New Header Inclusion
The newly added header <OpenMS/KERNEL/AnnotatedMSRun.h> is not referenced in this file. If it is not needed for future changes, consider removing it to avoid clutter.

-#include <OpenMS/KERNEL/AnnotatedMSRun.h>
src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h (2)

69-69: Doc Update for AnnotatedMSRun
The documentation still refers to "peak maps," but this parameter has transitioned to AnnotatedMSRun. Please update the doc comments to avoid confusion.

-      @brief Mapping method for peak maps
+      @brief Mapping method for AnnotatedMSRun

86-86: Remove or Justify Commented-Out Code
This function signature is now commented out. If it is no longer needed, remove it; if it must remain, consider explaining why it is commented out.

-    // void annotate(AnnotatedMSRun& map, FeatureMap fmap, const bool clear_ids = false, const bool map_ms1 = false);
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (3)

64-65: Templated Reference Setter
You have broadened setReference to accept a generic DataType. Ensure the documentation is updated to describe the expected data types and possible constraints (e.g., feature/consensus maps or ID data).


211-211: Signature Change to AnnotatedMSRun
Switching from PeakMap& to AnnotatedMSRun& is consistent with the broader refactoring. However, consider updating the surrounding comments so they do not reference "peak maps" exclusively.


245-299: Complex Loop Logic
This loop locates the closest peptide to the feature’s RT, manages score checking, and optionally gathers unassigned peptides. While logically sound, consider splitting out steps (e.g., best-peptide search, adding RT data) into smaller helper methods to reduce complexity and improve readability.

src/openms/source/FORMAT/MSPFile.cpp (4)

32-32: Confirm default parsing behavior.
Enabling parse_firstpeakinfo_only by default may omit annotations for subsequent peaks. Verify that this default aligns with typical user requirements.


374-381: Potential copying in structured bindings.
Using for (auto [spectrum, peptide_id] : exp) copies the items in each loop iteration. If large spectra or many hits are involved, consider using references:

-for (auto [spectrum, peptide_id] : exp)
+for (auto& [spectrum, peptide_id] : exp)

435-435: Maintain consistent labeling.
Printing "Num peaks:" for each spectrum is fine. Ensure other labeling conventions (e.g., “NumPeaks:” or “Num peaks:”) remain consistent if used elsewhere.


438-438: Cloning spectrum data.
Assigning PeakSpectrum rich_spec = spectrum; duplicates data in memory. This is acceptable for transformations but be mindful of potential performance overhead if spectrum sizes grow large.

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

84-161: Large block of commented-out test code.
There is a sizable test block wrapped in a comment. If it’s no longer needed, consider removing it for clarity. If it’s temporarily disabled, add an explanatory comment or a TODO.

src/openms/source/ANALYSIS/ID/IDMapper.cpp (2)

78-82: New annotate overload for AnnotatedMSRun.
The additional overload is well-structured. Confirm that documentation (doxygen) is updated to reflect this new variant.


111-130: Native ID vs. RT fallback logic.
The approach to first try native ID, then fall back to RT if it’s not found, is robust. Just be mindful of potential collisions if multiple spectra share the same RT.

src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (4)

632-640: Refine naming for clarity.
removeMatchingPeptideIdentifications could be confused with removeMatchingPeptideHits. Consider using a shorter or more consistent naming scheme, e.g., removeMatchingPeptideIDs.


755-766: Repeated rank assignment.
id.assignRanks() is invoked directly. For large datasets, repeatedly assigning ranks may affect performance if called multiple times. Consider limiting repeated rank assignments to the necessary points in the workflow.


1152-1172: Filter accuracy and reference consistency.
After removing low-scoring proteins or peptides, confirm that no references in peptide hits point to missing proteins. Optionally, remove peptides referencing missing proteins to keep data consistent.


1174-1204: Consider consolidating passes.
keepNBestHits updates each PeptideIdentification individually and then updates references. A single pass approach might be more performant if large datasets are involved.

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

70-80: Add boundary-check tests.
Consider testing out-of-range indices in getPeptideIdentification() or operator[] to confirm robust error handling, even if exceptions are the intended behavior.

src/openms/include/OpenMS/KERNEL/AnnotatedMSRun.h (1)

201-205: Potential sanity checks.
You may want to assert that data.getSpectra().size() matches peptide_ids.size() inside PairIterator or operator[] to prevent silent out-of-bound operations if these vectors become desynchronized.

src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (2)

335-346: Consider using nullptr instead of get() == nullptr check.

The condition could be simplified for better readability and modern C++ practices.

ExperimentSharedPtrType getFullChromData()
{
-  ExperimentSharedPtrType exp_sptr(getChromatogramData().get() == nullptr ||
-                                           getChromatogramData().get()->getNrChromatograms() == 0 ?
-                                       getPeakDataMuteable() :
-                                       getChromatogramData());
+  ExperimentSharedPtrType exp_sptr(!getChromatogramData() || 
+                                   getChromatogramData()->getNrChromatograms() == 0 ?
+                                   getPeakDataMuteable() :
+                                   getChromatogramData());
  return exp_sptr;
}

425-431: Provide documentation on peak annotation sync.

The methods for synchronizing peak annotations are well-defined, but additional documentation on when these should be called and their expected behavior in edge cases would be helpful for maintainers.

Consider adding extended documentation:

/// updates the PeakAnnotations in the current PeptideHit with manually changed annotations
/// if no PeptideIdentification or PeptideHit for the spectrum exist, it is generated
+/// 
+/// @note This should be called whenever annotations are manually added or modified in the UI
+/// to ensure consistency between the visual annotations and the underlying data model
void synchronizePeakAnnotations();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d488c3 and ca60467.

📒 Files selected for processing (20)
  • src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h (3 hunks)
  • src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (6 hunks)
  • src/openms/include/OpenMS/FORMAT/MSPFile.h (2 hunks)
  • src/openms/include/OpenMS/KERNEL/AnnotatedMSRun.h (1 hunks)
  • src/openms/include/OpenMS/KERNEL/MSExperiment.h (0 hunks)
  • src/openms/include/OpenMS/KERNEL/sources.cmake (1 hunks)
  • src/openms/include/OpenMS/METADATA/SpectrumSettings.h (0 hunks)
  • src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (10 hunks)
  • src/openms/source/ANALYSIS/ID/IDMapper.cpp (6 hunks)
  • src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (3 hunks)
  • src/openms/source/FORMAT/MSPFile.cpp (6 hunks)
  • src/openms/source/KERNEL/AnnotatedMSRun.cpp (1 hunks)
  • src/openms/source/KERNEL/sources.cmake (1 hunks)
  • src/openms/source/METADATA/SpectrumSettings.cpp (0 hunks)
  • src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (5 hunks)
  • src/tests/class_tests/openms/executables.cmake (1 hunks)
  • src/tests/class_tests/openms/source/AnnotatedMSRun_test.cpp (1 hunks)
  • src/tests/class_tests/openms/source/IDMapper_test.cpp (7 hunks)
  • src/tests/class_tests/openms/source/MSPFile_test.cpp (1 hunks)
  • src/topp/IDSplitter.cpp (2 hunks)
💤 Files with no reviewable changes (3)
  • src/openms/include/OpenMS/KERNEL/MSExperiment.h
  • src/openms/source/METADATA/SpectrumSettings.cpp
  • src/openms/include/OpenMS/METADATA/SpectrumSettings.h
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/openms/include/OpenMS/KERNEL/sources.cmake
  • src/openms/source/KERNEL/sources.cmake
  • src/tests/class_tests/openms/source/MSPFile_test.cpp
  • src/tests/class_tests/openms/executables.cmake
  • src/openms/include/OpenMS/FORMAT/MSPFile.h
  • src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/openms/source/KERNEL/AnnotatedMSRun.cpp (1)
src/openms/include/OpenMS/KERNEL/AnnotatedMSRun.h (8)
  • getPeptideIdentifications (77-77)
  • getPeptideIdentifications (83-83)
  • setPeptideIdentifications (89-89)
  • setPeptideIdentifications (95-95)
  • getMSExperiment (101-101)
  • getMSExperiment (107-107)
  • setMSExperiment (113-113)
  • setMSExperiment (119-119)
src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (1)
src/openms/source/PROCESSING/ID/IDFilter.cpp (23)
  • id (153-157)
  • id (153-153)
  • id (170-174)
  • id (170-170)
  • acc_filter (223-223)
  • acc_filter (251-251)
  • acc_filter (273-273)
  • acc_filter (296-296)
  • acc_filter (319-319)
  • acc_filter (352-352)
  • acc_filter (389-389)
  • updateProteinReferences (302-337)
  • updateProteinReferences (302-302)
  • updateProteinReferences (339-370)
  • updateProteinReferences (339-339)
  • updateProteinReferences (372-405)
  • updateProteinReferences (372-372)
  • removeUnreferencedProteins (229-254)
  • removeUnreferencedProteins (229-229)
  • removeUnreferencedProteins (256-275)
  • removeUnreferencedProteins (256-256)
  • removeUnreferencedProteins (277-299)
  • removeUnreferencedProteins (277-277)
src/tests/class_tests/openms/source/AnnotatedMSRun_test.cpp (2)
src/openms/include/OpenMS/KERNEL/AnnotatedMSRun.h (12)
  • AnnotatedMSRun (33-284)
  • AnnotatedMSRun (40-40)
  • AnnotatedMSRun (46-47)
  • AnnotatedMSRun (46-46)
  • AnnotatedMSRun (50-50)
  • AnnotatedMSRun (53-53)
  • getPeptideIdentifications (77-77)
  • getPeptideIdentifications (83-83)
  • setPeptideIdentifications (89-89)
  • setPeptideIdentifications (95-95)
  • getMSExperiment (101-101)
  • getMSExperiment (107-107)
src/openms/source/KERNEL/AnnotatedMSRun.cpp (12)
  • getPeptideIdentifications (13-16)
  • getPeptideIdentifications (13-13)
  • getPeptideIdentifications (18-21)
  • getPeptideIdentifications (18-18)
  • setPeptideIdentifications (23-26)
  • setPeptideIdentifications (23-23)
  • setPeptideIdentifications (28-31)
  • setPeptideIdentifications (28-28)
  • getMSExperiment (33-36)
  • getMSExperiment (33-33)
  • getMSExperiment (38-41)
  • getMSExperiment (38-38)
🪛 Cppcheck (2.10-2)
src/tests/class_tests/openms/source/AnnotatedMSRun_test.cpp

[error] 285-285: syntax error

(syntaxError)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (windows-2022, cl.exe, default)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: cppcheck-test
🔇 Additional comments (41)
src/topp/IDSplitter.cpp (1)

105-125: FeatureXML Branch Review
The logic of extracting peptide and protein identifications from the FeatureMap and clearing them from the source looks correct for the intended splitting operation. Just ensure that the expected scenario is indeed to remove identifications completely from the features. Also be mindful of adding additional error handling or verification if the loadFeatures call fails (e.g., corrupt file).

src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h (1)

25-25: Forward Declaration
The forward declaration for AnnotatedMSRun appears valid. No issues observed.

src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (4)

28-31: Use of Concepts
Introducing the IsFCMap concept is a clean approach to constrain template parameters to feature or consensus maps.


32-32: Forward Declaration
Forward declaring AnnotatedMSRun is consistent with its usage later. No issues.


84-84: Extended Documentation
Updating the documentation to reference feature/consensus maps and peptide IDs clarifies functionality and aligns with the new code. Looks good.


227-227: Generic Retention Time Collection
Introducing IsFCMap auto& parameter simplifies code by handling both feature and consensus maps with one function.

src/openms/source/FORMAT/MSPFile.cpp (3)

13-13: Header inclusion aligns with changes.
Including <OpenMS/KERNEL/AnnotatedMSRun.h> is necessary and appropriate for managing the new data structure.


326-337: Efficient reuse of existing load routine.
Reusing the existing load function to populate AnnotatedMSRun is concise and coherent. Ensure that any previously set data in annot_exp is properly cleared or merged as intended before populating it.


359-359: New signature for store.
Accepting AnnotatedMSRun instead of PeakMap is consistent with the refactoring. Make sure all callers adjust accordingly.

src/tests/class_tests/openms/source/IDMapper_test.cpp (12)

20-20: Necessary for AnnotatedMSRun tests.
Including <OpenMS/KERNEL/AnnotatedMSRun.h> ensures correct references to the new data structure in your test suite.


190-190: Refined testing approach for RT mapping.
Defining AnnotatedMSRun annotated_experiment before verifying RT mapping is logical. Confirm that you also test edge cases, such as boundary RT values, to ensure robust coverage.

Also applies to: 192-192


218-218: Annotate usage verification.
Calling mapper.annotate(annotated_experiment, identifications, protein_identifications); is straightforward. Confirm that all test items (protein and peptide IDs) are properly associated.


220-223: Protein identification checks look solid.
Validating protein identification sizes and accessions helps detect linking issues quickly. No concerns here.


225-227: Peptide identification checks.
Ensuring each peptide ID has the correct sequence enforces correctness. These test statements appear comprehensive.


229-229: Coverage of empty hits scenario.
Testing when getHits().size() returns zero is valuable for negative or boundary coverage.


231-232: Verifying additional peptides under different RT.
Explicitly checks new peptides at alternative RT (index 2). This ensures robust coverage for corner cases.


238-240: Second experiment object.
Creating annotated_experiment2 and experiment2 is a good approach to isolate new test conditions.


266-266: Second annotate call for coverage.
Invoking mapper2.annotate(...) with different inputs assures variety in test coverage.


269-272: Repeated validation for protein IDs.
Re-checking the size and accessions on the new data structure ensures consistent annotation behavior.


274-278: Multiple hits validation in test.
Confirming that multiple hits can occur for a single spectrum is a key scenario. These tests help prevent regressions.


280-281: Single peptide check.
Validating exactly one peptide for the last spectrum (index 2) covers minimal but non-empty hits. Good coverage.

src/openms/source/ANALYSIS/ID/IDMapper.cpp (10)

12-12: Essential header inclusion.
Including <OpenMS/KERNEL/AnnotatedMSRun.h> is necessary for the new refactored annotate method.


89-90: Clearing existing IDs conditionally.
Calling clear() on existing peptide/protein IDs when clear_ids is true is correct. If partial merges are possible, consider documenting that.


98-98: Resizing ID container.
Resizing map.getPeptideIdentifications() to match getSpectra().size() ensures one PeptideIdentification per spectrum. Great for consistent indexing.


100-100: Lookup table usage.
The comment clarifies the approach to store referencing. Good documentation of the mapping strategy.


110-110: Skipping empty IDs.
Early continue for empty PeptideIdentification is helpful to avoid unnecessary processing.


140-142: Building experiment precursors map.
Populating a multimap keyed by RT is effective. Ensuring it’s sorted by RT helps maintain O(n) complexity in subsequent steps.


186-186: map_ms1 fallback usage.
Looping over precursors only if map_ms1 is false is a neat approach. Confirm that you handle tandem spectra with multiple precursors correctly.


198-203: Merging hits per spectrum.
Merging all hits into one PeptideIdentification ensures no duplication in multiple ID containers. This design is consistent with the single-spectrum → single-ID approach.


215-215: Clear logging of unmapped peptides.
Reporting “Unmapped (empty) peptides” clarifies how many IDs lacked a valid mapping. Good for debugging.


1081-1081: Closing namespace comment.
Retains the code’s structure clarity. No issues noted.

src/openms/source/KERNEL/AnnotatedMSRun.cpp (2)

13-31: Consider verifying alignment of 'peptide_ids' with 'data.getSpectra()'.
When setPeptideIdentifications is called with a vector size that doesn't match data.getSpectra().size(), the iteration across pairs might become off-sync. Consider adding an assertion or exception to ensure these sizes align, preventing unexpected mismatches.


28-51: Use of default destructor is safe.
Your default destructor introduces no issues here, as resource management is straightforward. This approach is recommended when no specialized cleanup is required.

src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (3)

34-40: Validate C++20 concepts usage.
Defining IsPeptideOrProteinIdentification and IsFeatureOrConsensusMap is a neat approach for type safety. Ensure the build environment is configured with at least -std=c++20.


1009-1015: Corner case for empty protein set.
If accessions is empty, you may remove or retain all hits, depending on logic. Confirm whether this behavior matches your design intent.


1369-1394: Ensure consistent spectra–peptides alignment.
When calling keepHitsMatchingProteins, any prior removal or addition of spectra or peptide IDs may desynchronize their counts. If getSpectra().size() and getPeptideIdentifications().size() differ, iteration could go out of range.

src/tests/class_tests/openms/source/AnnotatedMSRun_test.cpp (2)

14-15: Extensive coverage is commendable.
The tests validate constructors, move semantics, index-based spectrum access, and iteration. Good job ensuring thorough coverage.


285-302: Consider empty data iteration.
When looping via for (auto [spectrum, peptide_id] : annotated_data), a scenario with zero peptide IDs would ensure no unexpected iteration or index issues occur.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 285-285: syntax error

(syntaxError)

src/openms/include/OpenMS/KERNEL/AnnotatedMSRun.h (1)

33-51: Clear, well-structured documentation.
The class overview is detailed, clearly explaining how the MSExperiment, spectra, and identifications correlate.

src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h (2)

15-19: Appropriate includes and reorganization.

Good refactoring to include the AnnotatedMSRun.h header file and reorganize related includes. This aligns with the goal of replacing the legacy PeakMap with AnnotatedMSRun.


130-130: Core type change: PeakMap to AnnotatedMSRun.

This is the key change in the refactoring that replaces the legacy data structure with the new one. The change is clean and consistent with the PR objectives.

@timosachsenberg timosachsenberg changed the title refactor: Store IDs outside of spectra. Continuation of Openms PR 5547 refactor: Store IDs outside of spectra. May 19, 2025
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

ready for review

@timosachsenberg
timosachsenberg requested a review from poshul May 20, 2025 06:32
@timosachsenberg
timosachsenberg merged commit 8b30bf3 into develop May 21, 2025
@timosachsenberg
timosachsenberg deleted the openms-pr-5547 branch May 21, 2025 06:37
This was referenced May 22, 2025
@poshul poshul mentioned this pull request Jul 9, 2025
This was referenced Jul 28, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Aug 19, 2025
4 of 5 tasks
cbielow added a commit to cbielow/OpenMS that referenced this pull request Mar 25, 2026
…rge mzML tages ages, due to copying of the whole map multiple times)
timosachsenberg pushed a commit that referenced this pull request Mar 25, 2026
* fix performance bug introduced in #7974 (right clicking in a large mzML tages ages, due to copying of the whole map multiple times)

* limit number of fragment scans
timosachsenberg added a commit that referenced this pull request Oct 21, 2026
…#10685)

src/openms/source/METADATA/AnnotatedMSRun.h was an outdated copy of
src/openms/include/OpenMS/METADATA/AnnotatedMSRun.h. It was added
alongside the real header in #7974 and never wired up: it is not listed
in any sources.cmake/CMakeLists.txt and nothing includes it (all
includes use <OpenMS/METADATA/AnnotatedMSRun.h>). Its declarations
have drifted from the real header, so it only misleads greps for API
users.


Claude-Session: https://claude.ai/code/session_011PDe2F8izmxEr4LzrXExtJ

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