Repository navigation
refactor: Store IDs outside of spectra. - #7974
Conversation
… identification is needed
…RawData" Build target "OpenMS" is successfully compiling now.
WalkthroughThis update introduces a new Changes
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
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit 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. Note ⚡️ Faster reviews with cachingCodeRabbit 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 ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 12
🔭 Outside diff range comments (2)
src/topp/IDSplitter.cpp (1)
152-152:⚠️ Potential issueInconsistent check for MZML
This line still contains a check for
in_type != FileTypes::MZMLeven 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
AnnotatedMSRawDatafor managing peptide identifications.There are potential issues with this approach:
- The
identification_member is still used in the equality operator at line 49 and theunifymethod at line 83- No deprecation notice is provided to guide users to the new approach
Consider either:
- Properly removing the methods and updating the equality operator and
unifymethod- Using proper deprecation annotations instead of commenting out the code
- Adding comments to explain the change and direct users to the new
AnnotatedMSRawDataclass
🏁 Script executed:
#!/bin/bash # Check for references to identification_ in the class grep -n "identification_" src/openms/source/METADATA/SpectrumSettings.cppLength 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 memberidentification_is still actively used in the equality operator (line 49) and theunifymethod (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
unifymethod to no longer rely onidentification_.- Reinstate the methods with proper deprecation annotations and include documentation/comments explicitly guiding users to use
AnnotatedMSRawDatainstead.Affected file:
src/openms/source/METADATA/SpectrumSettings.cpp
- Equality operator usage at line 49.
unifymethod 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
loadfor aPeakMapand then transfers data intoAnnotatedMSRawData. 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
//TODOregarding 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 thatpeptide_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 entireFeatureMapargument. 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 inSTART_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 inSTART_SECTION(...). Harmless if it compiles, but can confuse some static analyzers.src/openms_gui/source/VISUAL/LayerDataBase.cpp (2)
75-88: Usestd::make_sharedfor clarity.
InsetChromatogramAnnotation(OSWData&& data), consider usingstd::make_shared<OSWData>(std::move(data))instead of the rawnewexpression to improve readability and reduce potential errors, even though the current code works.
244-342: Consider modularizingupdatePeptideHitAnnotations_.
This method contains complex logic for parsing annotation text, extracting charge information, and constructingPeakAnnotations. 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 topeptide_idsbecome 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()andremovePeakAnnotationsFromPeptideHit(...)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
📒 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 goodThis change adds the
AnnotatedMSRawData.hheader file to the build system, which is consistent with the PR's goal of integrating the newAnnotatedMSRawDataclass throughout the code base.src/openms/source/KERNEL/sources.cmake (1)
6-6: Addition of new source file looks goodThis change adds the
AnnotatedMSRawData.cppimplementation 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 cppLength 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 insrc/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 qualifierThe change from
ptrdiff_ttostd::ptrdiff_tis 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
hasPeptideIdentificationsmethod has been commented out as part of the broader refactoring effort to transition fromPeakMaptoAnnotatedMSRawData.Ensure that the functionality of this method is available in the
AnnotatedMSRawDataclass 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.hLength of output: 1300
Action: Verify backward compatibility for peptide identification handling
The
hasPeptideIdentificationsmethod inMSExperiment.cpp(lines 852–864) was commented out as part of the refactor moving fromPeakMaptoAnnotatedMSRawData. The newAnnotatedMSRawDataclass 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 thehasPeptideIdentificationsfunctionality is updated to use these new accessor methods—such as checking if the container returned bygetAllPeptideIdentifications()is non-empty—to maintain the expected behavior.src/tests/class_tests/openms/executables.cmake (1)
131-131: LGTM: New test entry for AnnotatedMSRawDataThe addition of
AnnotatedMSRawData_testto 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 AnnotatedMSRawDataThe method signature has been updated to use the new
AnnotatedMSRawDataclass instead of the legacyPeakMap. This is consistent with the broader refactoring effort.
125-130: Good implementation of the test for the refactored functionalityThe test has been properly updated to use the new data structure while maintaining the same validation logic. The explicit declaration of
PeakMapandvector<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 structureAdded include for
AnnotatedMSRawData.hwhich 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.hheader 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
AnnotatedMSRawDatacan 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
AnnotatedMSRawDataincreases code clarity and reduces conversion overhead for callers who no longer need aPeakMap. Verify documentation details (e.g., thrown exceptions) remain accurate.
80-80: Storing annotated experiment data.Changing the
storemethod to acceptAnnotatedMSRawDatais consistent with the broader shift away fromPeakMap. 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 thenannotated_exp.getMSExperiment()relies onlayer_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_itusingcurrent_spectrum_index, confirm it’s within valid range. Otherwise, iterators might become invalid. Consider verifyingcurrent_spectrum_index < exp.size()before callinggetPrecursorSpectrum().
429-430: Emit signals outside boundary checks.Emitting signals for selection and requesting a new visible area are fine, but ensure
prec_itis valid. Currently, you guard usingif (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 onAnnotatedMSRawData.
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_intto 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 MSExperimentThe file now includes
AnnotatedMSRawData.hwhich replaces the olderMSExperiment.himport 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 spacingThe spacing in the type cast has been improved for better readability.
126-126: Improved code style with proper spacingThe spacing in the UInt cast has been improved for better readability.
140-141: More explicit type specificationThe code now uses the explicit
vectortype declaration rather than relying on auto-deduction, which improves code clarity.
164-169: Migrating from PeakMap to AnnotatedMSRawDataThis 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 AnnotatedMSRawDataThe 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 dataThe 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 generationThe old implementation has been commented out and replaced with a more modern approach using the AnnotatedMSRawData structure. The new code:
- Uses structured binding with auto[spectrum, peptide_ids] to iterate through data
- Uses range-based for loops for cleaner iteration
- Maintains the same logical flow but with better readability
This refactoring maintains functionality while improving code quality.
265-330: Improved fragment ion statistics generationSimilar 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 declarationThe 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 spacingThe spacing in the type cast has been improved for better readability in the histogram calculation.
392-392: Improved code style with proper spacingThe spacing in the Size cast has been improved for better readability.
402-402: Improved code style with proper spacingThe division by 500.0 is now clearer with the modified syntax.
424-427: Modernized iteration with range-based for loopThe 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 calculationThe 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 spacingThe spacing in the calculation has been improved for better readability.
493-493: Improved code style with proper spacingThe spacing in the Size cast has been improved for better readability.
502-502: Improved code style with proper spacingThe division by 100.0 is now clearer with the modified syntax.
524-527: Modernized iteration with range-based for loopSimilar 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 functionThe 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 safetyA new concept
IsFCMaphas 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 AnnotatedMSRawDataA forward declaration for AnnotatedMSRawData has been added, which is good practice to avoid unnecessary includes and reduce compilation dependencies.
64-65: Improved method signature formattingThe 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 changesThe 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 AnnotatedMSRawDataThe 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 parameterThe 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 AnnotatedMSRawDataThe 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 loopThe 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 AnnotatedMSRawDataThe 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 AnnotatedMSRawDataA 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 AnnotatedMSRawDataThe 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 AnnotatedMSRawDataSimilar 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 ofAnnotatedMSRawDatain the code.
78-82: New overload accepting AnnotatedMSRawData is consistent.
This updated method signature correctly replacesPeakMapusage. All parameters appear correctly integrated, and the function name aligns well with the class purpose.
89-90: Ensure clearing IDs is intentional.
Callingmap.clearAllPeptideIdentifications()and then clearingmap.getMSExperiment().getProteinIdentifications()completely resets all existing IDs. This is valid as long as the caller expects an empty slate whenclear_idsis true.
96-96: Appending protein IDs.
Merging the incomingprotein_idsinto the existing protein identifications of the MSExperiment aligns with previous patterns. No issues found.
98-98: Populating SpectrumLookup with updated spectra.
Usinglookup.readSpectra(map.getMSExperiment())ensures theSpectrumLookupincludes all new spectrum references fromAnnotatedMSRawData. This looks correct.
118-118: Validate spectrum_idx usage.
Appending tomap.getPeptideIdentifications(spectrum_idx)is fine ifspectrum_idxis guaranteed to be in range, as provided by theSpectrumLookup. 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 viamap.getMSExperiment()[index].getPrecursors()remains consistent with the existing logic. No problems found.
190-190: Mapping peptide IDs by experiment iterator.
Pushing back intomap.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 localAnnotatedMSRawDatainstance and referencingexperimentviagetMSExperiment()aligns with the new data structure usage.
131-131: Testing annotate(...) with MS1 mapping enabled.
Invokingmapper.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 callingmapper.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 anotherAnnotatedMSRawDatainstance ensures the test is isolated. ReferencingMSExperiment& 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 upannotated_experiment2and referencesexperiment2. 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 onAnnotatedMSRawData.
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 withinAnnotatedMSRawData. There's a@TODOnote 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 inMSExperimentand each MS2-level set of peptide IDs is logically consistent. The final calls toremoveEmptyIdentifications(...)andupdateHitRanks(...)ensure data integrity. No issues found.src/openms_gui/source/VISUAL/LayerDataBase.cpp (1)
119-122: Ensure cache coherence ingetCurrentSpectrum().
getCurrentSpectrum()returns the cached spectrum without verifying thatupdateCache_()has been invoked or the index remains valid. Ifcurrent_spectrum_idx_has changed without an intermediate cache update, this could yield outdated data. Verify in calling code that the cache stays in sync withcurrent_spectrum_idx_.src/openms/source/KERNEL/AnnotatedMSRawData.cpp (2)
23-31: All-peptide getters look fine.
The methodsgetAllPeptideIdentifications()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 forMSExperimentare correctly defined to allow efficient initialization.
40-48: Safe access toprotein_ids_.
BothgetProteinIdentifications()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.cppfile but be mindful of index bounds. The same advice about boundary checks and safe usage applies here.
73-116: Iterators andoperator[]are convenient but rely on matching vector sizes.
ThePairIteratoriterates in parallel overdata.getSpectra()andpeptide_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.
Storingpeptide_ids,protein_ids_, anddatain 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 declaringOnDiscMSExperimentis appropriate here and reduces build-time dependencies. No concerns.
130-130: New typedef aligns with annotated data usage.
Replacing the oldtypedef MSExperimentwithAnnotatedMSRawDatais consistent with the broader refactoring toward annotated data structures. Ensure corresponding downstream references toExperimentTypeare updated correctly.
282-305: Add bounds checking or docs for potential out-of-range access.
These 1D annotation-access methods index intoannotations_1d[current_spectrum_idx_]orannotations_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.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
AnnotatedMSRawDataobject and retrieves a reference to the underlyingMSExperimentfor further manipulation, showing a clean transition to the new data structure.
131-147: Proper method call adaptation.The test case correctly uses the new
annotatemethod withAnnotatedMSRawDataand 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
AnnotatedMSRawDataand 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
AnnotatedMSRawDatastructure, 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
AnnotatedMSRawDataobject and accessing the underlying experiment.
270-284: Final test assertions properly updated.The final test assertions correctly use the new
AnnotatedMSRawDatamethods 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
AnnotatedMSRawDatainstead of the templatedMSExperiment<PeakType>, reflecting the structural change in the data model.
89-91: Refactored code to use AnnotatedMSRawData methods.The code now uses the
clearAllPeptideIdentifications()andgetProteinIdentifications()methods fromAnnotatedMSRawDatainstead 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 theAnnotatedMSRawDataobject.
100-101: Proper setup of lookup table using MSExperiment.The code correctly accesses the underlying
MSExperimentusinggetMSExperiment()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
MSExperimentusingmap.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
annotatemethod has also been updated to useAnnotatedMSRawDatainstead of the templatedMSExperiment<PeakType>.src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h (8)
16-16: Added include for AnnotatedMSRawData.The header file correctly includes the
AnnotatedMSRawData.hheader 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
AnnotatedMSRawDatarather thanMSExperiment.
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
AnnotatedMSRawDataobject.
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
AnnotatedMSRawDataclass 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.hLength 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
AnnotatedMSRawDataclass indeed supports range-based for loops with structured binding, as indicated by the implementedbegin(),end(), and associated iterator functions (includingoperator*).
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
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-declaresOnDiscMSExperiment, 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
📒 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 updatingcurrent_spectrum_idx_without additional checks never leads to accessing nonexistent entries incached_spectrum_orannotations_1d.
335-345: Verify shared pointer logic when constructing full chromatogram data.The ternary evaluation in
getFullChromData()can yield null or partial data ifgetChromatogramData()is uninitialized. Confirm at runtime thatpeak_map_and the returned pointer fromgetChromatogramData()are never null in production code.
425-431: Confirm resilience of peak annotation synchronization methods.
synchronizePeakAnnotations()andremovePeakAnnotationsFromPeptideHit(...)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.
There was a problem hiding this comment.
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 accessingpeptide_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 returningpeptide_ids[index].
33-36: Enforce size checks when setting peptide IDs.This method should verify
index < peptide_ids.size()before assigning topeptide_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 theAnnotatedMSRawData(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, thefor (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 multiplePeptideIdentificationhits 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 asassignRanks()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()andpeptide_idsalways 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
📒 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.
There was a problem hiding this comment.
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 viastd::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 frompeptide_ids[i]intoexisting_idis 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_idsis a private member, whileprotein_ids_has a trailing underscore. Consider renamingpeptide_idstopeptide_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
📒 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.txtLength 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 viagrep -R 'CXX_STANDARD' CMakeLists.txtreturned no results, so please manually verify or update the build configuration (for example, by settingset(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.
Callingmap.clearAllPeptideIdentifications()andmap.getProteinIdentifications().clear()ensures a clean state ifclear_idsis 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 amultimapis 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 3Length 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 vialookup.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.
There was a problem hiding this comment.
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 ofmap_ms1is 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 whenmap_ms1 == falseandgetPrecursors()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
📒 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 handlingAnnotatedMSRawData.
98-101: Verify safe resizing when not clearing existing IDs.
Resizingmap.getPeptideIdentifications()could overwrite or truncate existing entries ifclear_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 singlePeptideIdentificationaligns with the updated design.
140-142: Straightforward construction of precursor-RT mapping.
Populatingexperiment_precursorsfor each spectrum is well-structured.
There was a problem hiding this comment.
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)andgetCurrentAnnotations()return containers by indexingannotations_1d. However, there's no boundary check forspectrum_indexorcurrent_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
constbut modify meta values on the underlying data (peak_map_). This usage can be confusing to maintainers, as "const" conventionally implies immutability. Consider removingconstor markingpeak_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 toAnnotatedMSRun. 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 broadenedsetReferenceto accept a genericDataType. 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 fromPeakMap&toAnnotatedMSRun&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.
Enablingparse_firstpeakinfo_onlyby default may omit annotations for subsequent peaks. Verify that this default aligns with typical user requirements.
374-381: Potential copying in structured bindings.
Usingfor (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.
AssigningPeakSpectrum 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: Newannotateoverload 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.
removeMatchingPeptideIdentificationscould be confused withremoveMatchingPeptideHits. 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.
keepNBestHitsupdates eachPeptideIdentificationindividually 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 ingetPeptideIdentification()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 thatdata.getSpectra().size()matchespeptide_ids.size()insidePairIteratoror 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
📒 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 theFeatureMapand 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 theloadFeaturescall fails (e.g., corrupt file).src/openms/include/OpenMS/ANALYSIS/ID/IDMapper.h (1)
25-25: Forward Declaration
The forward declaration forAnnotatedMSRunappears valid. No issues observed.src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (4)
28-31: Use of Concepts
Introducing theIsFCMapconcept is a clean approach to constrain template parameters to feature or consensus maps.
32-32: Forward Declaration
Forward declaringAnnotatedMSRunis 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
IntroducingIsFCMap auto¶meter 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 existingloadfunction to populateAnnotatedMSRunis concise and coherent. Ensure that any previously set data inannot_expis properly cleared or merged as intended before populating it.
359-359: New signature forstore.
AcceptingAnnotatedMSRuninstead ofPeakMapis 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.
DefiningAnnotatedMSRun annotated_experimentbefore 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.
Callingmapper.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 whengetHits().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.
Creatingannotated_experiment2andexperiment2is a good approach to isolate new test conditions.
266-266: Second annotate call for coverage.
Invokingmapper2.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 refactoredannotatemethod.
89-90: Clearing existing IDs conditionally.
Callingclear()on existing peptide/protein IDs whenclear_idsis true is correct. If partial merges are possible, consider documenting that.
98-98: Resizing ID container.
Resizingmap.getPeptideIdentifications()to matchgetSpectra().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 emptyPeptideIdentificationis 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_ms1fallback usage.
Looping over precursors only ifmap_ms1is 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 onePeptideIdentificationensures 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()'.
WhensetPeptideIdentificationsis called with a vector size that doesn't matchdata.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.
DefiningIsPeptideOrProteinIdentificationandIsFeatureOrConsensusMapis 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.
Ifaccessionsis 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 callingkeepHitsMatchingProteins, any prior removal or addition of spectra or peptide IDs may desynchronize their counts. IfgetSpectra().size()andgetPeptideIdentifications().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 viafor (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.hheader 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.
|
ready for review |
…rge mzML tages ages, due to copying of the whole map multiple times)
* 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
…#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]>
Description
Splits ID data from MSExperiment. (Revives #5547)
Summary by CodeRabbit
New Features
AnnotatedMSRundata structure for integrated management of spectra and peptide/protein identifications.AnnotatedMSRunin file I/O, visualization, and filtering components.Refactor
PeakMapand related types withAnnotatedMSRunacross core libraries and GUI modules.AnnotatedMSRun.Removals
SpecLibCreator,SpecLibSearcher, andIDMassAccuracy.SpectrumSettingsandExperimentalSettings.Tests
AnnotatedMSRun.Documentation
Chores
AnnotatedMSRunand remove obsolete components.Summary by CodeRabbit
New Features
Removals
Bug Fixes
Documentation
Tests
Chores