Repository navigation
MapAlignmentAlgorithmIdentification: Made align function work on const data - #7973
Conversation
WalkthroughThe pull request updates several method signatures within the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Algorithm
Caller->>Algorithm: Call getRetentionTimes_(data, rt_data)
loop For each peptide in data
Algorithm->>Algorithm: Check if peptide hits exist
alt Hits available
Algorithm->>Algorithm: Sort hits and perform score check
else
Algorithm->>Algorithm: Skip processing for this peptide
end
end
Algorithm->>Caller: Return result (bool)
Assessment against linked issues
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 0
🧹 Nitpick comments (1)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (1)
221-299: Consider breaking down the complex methodThe static analysis hint flags this method as complex. While the current changes are good, consider future refactoring to break this method into smaller, more focused functions to improve readability and maintainability.
A potential refactoring approach would be to extract the feature handling logic (lines 241-275) and unassigned peptides logic (lines 281-286) into separate private methods.
🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-344: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L344
Complex Method
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h(6 hunks)src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (1)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (1)
better_(160-160)
🪛 GitHub Check: CodeFactor
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h
[notice] 221-344: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L344
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms (5)
- 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 (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)
🔇 Additional comments (8)
src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (2)
96-109: Improved code structure with better null-safetyThe restructuring of this method significantly improves safety by checking for empty hits before attempting to sort and access them. The nested conditionals make the control flow more explicit and prevent potential null reference issues.
181-183: Good change to enforce const correctnessChanging the parameter to
const PeakMap& experimentand usingConstIteratoris a proper application of const correctness. This ensures that the function doesn't modify the input data unintentionally and allows it to work with constant data.src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (6)
58-58: Good application of const correctness in setReferenceChanging the parameter type to
const DataType& datacorrectly indicates that this method doesn't modify the input data, allowing it to work with constant references.
86-87: Improved align method signature with const correctnessChanging the parameter to
const std::vector<DataType>& datais appropriate as the method should not modify the input vector. This allows the method to be called with constant data, improving usability.
204-204: Consistent const correctness applicationThis change to
const PeakMap& experimentmatches the implementation in the .cpp file and maintains the pattern of const correctness throughout the class.
221-222: Proper template method const correctnessMaking the template parameter const (
const MapType& features) aligns with the rest of the changes and allows this method to be called with constant data.🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-344: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L344
Complex Method
239-239: Correct iterator usage for const parameterUsing
ConstIteratorinstead ofIteratoris necessary when iterating over a const object. This change is required to maintain consistency with the const parameter change.
248-278: Well-implemented const correctness in nested codeThe changes to use const references and const pointers throughout this section properly implement const correctness at all levels. Particularly good is the use of
const auto&for iterating over peptide IDs and hits.
|
Please ensure OpenMS compiles locally before pushing to GitHub, since this will invoke CI needlessly. |
yes, will take care of that |
This reverts commit 94e59bd.
|
@cbielow , kindly check now |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (1)
221-295: Refined const usage with read-only iterators and best-scoring-hit checks.
- Switching to
MapType::ConstIterator(line 239) andstd::vector<PeptideIdentification>::const_iterator(line 248) clarifies that the code only reads map data.- The logic for finding and verifying the best-scoring hit with
getBestScoringHitensures a null pointer is never dereferenced (lines 259–262).Additionally, static analysis flags this method for complexity. Consider refactoring certain sections (e.g., unassigned peptides vs. feature-centroid logic) into smaller subroutines to improve maintainability.
🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h(10 hunks)src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (2)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (6)
getBestScoringHit(339-340)getRetentionTimes_(182-183)getRetentionTimes_(194-194)getRetentionTimes_(204-204)getRetentionTimes_(221-295)getRetentionTimes_(221-221)src/topp/FeatureFinderIdentification.cpp (1)
features(176-265)
🪛 GitHub Check: CodeFactor
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms (5)
- 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: build-and-test (windows-2022, cl.exe, default)
- GitHub Check: build-and-test (macos-13, xcode, 14.2)
🔇 Additional comments (8)
src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (5)
94-110: Adopt const references and ensure null checks remain valid.The updated function signature and the use of
const_iteratorcorrectly ensure that the input vector and its contents are not accidentally modified. The call togetBestScoringHitis safe under the conditionif (!pep_it->getHits().empty()), but keep in mind that the returned pointer can benullptrwhen called on empty hits in other contexts. Here, the null-check is implicitly guaranteed byif (!pep_it->getHits().empty()), so the usage is correct.
143-143: Good const correctness enhancement.Changing the signature of
getRetentionTimes_to accept aconst IdentificationData¶meter prevents unintentional modifications of the input data and aligns with best practices.
181-190: Const-qualification for PeakMap aligns usage with read-only semantics.Using
const PeakMap&andPeakMap::ConstIteratorensures the method cannot modify the underlying data. This is a solid improvement for clarity and correctness.
354-358: Consistent template instantiations with const references.Changing the explicit template instantiations to match the updated const references ensures consistency across the codebase and avoids linker mismatches.
359-372: Safely returning a pointer to the best-scoring hit.The new helper method correctly returns
nullptrif no hits are provided and otherwise returns a pointer to the best-scoring entry. Ensure that callers do not store this pointer beyond the lifetime of the original hits vector. Within the current usage, this is handled correctly.src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (3)
58-74: Improved const-correctness for setReference.Receiving the data as a
const DataType&prevents accidental mutations insidesetReference. This change matches the function’s usage, which only reads the input.
86-125: Align method updated to accept const reference.Fetching input data as
const std::vector<DataType>&underlines that the method doesn’t alter the original data. This is a beneficial practice to safeguard against unintended side effects.
340-340: Helper function declaration is clear.Declaring
getBestScoringHitin the header improves code accessibility and consolidates logic to retrieve the best peptide hit. No issues spotted here.
|
@cbielow @timosachsenberg .. is there any test file against which I can test my code. There are many in the code repository and I've tested it out and it's working fine but is there any specific test file that you would want me to test against? |
|
|
||
| const PeptideHit* MapAlignmentAlgorithmIdentification::getBestScoringHit( | ||
| const std::vector<PeptideHit>& hits, | ||
| const std::function<bool(double, double)>& better) |
There was a problem hiding this comment.
using better here is very dangerous since it may be defined as
better_ = [](double, double)
{return true;};
in which case sort() will fail at runtime.
You need to reproduce
void PeptideIdentification::sort()
{
if (higher_score_better_)
{
std::stable_sort(hits_.begin(), hits_.end(), PeptideHit::ScoreMore());
}
else
{
std::stable_sort(hits_.begin(), hits_.end(), PeptideHit::ScoreLess());
}
}
which is hard, since you basically need to copy the code (which is dangerous in terms of consistency and maintenance).
So either:
Refactor PeptideIdentification::sort(), so you can pull out the information you need from a fine-grained function which is used in both PeptideIdentification::sort() and your code, or bite the performance bullet and copy the hits, sort them like before (much less preferred, since your linear scan for the best hit is much better).
There was a problem hiding this comment.
okay, working on it
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (1)
194-194: Improved const-correctness for IdentificationData version.The comment about "id_data" not being "const" is now outdated since the parameter is now properly marked as const. Consider removing or updating this comment.
- // "id_data" can't be "const" here or template resolution will fail + // Parameter is now const as template resolution supports const parameters
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h(10 hunks)src/openms/include/OpenMS/METADATA/PeptideIdentification.h(1 hunks)src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp(4 hunks)src/openms/source/METADATA/PeptideIdentification.cpp(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/openms/source/METADATA/PeptideIdentification.cpp (1)
src/openms/include/OpenMS/METADATA/PeptideIdentification.h (2)
getScoreComparator(135-135)sort(142-142)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (3)
src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (2)
getBestScoringHit(359-371)getBestScoringHit(359-359)src/openms/include/OpenMS/METADATA/PeptideIdentification.h (1)
isHigherScoreBetter(103-103)src/openms/source/METADATA/PeptideIdentification.cpp (2)
isHigherScoreBetter(134-137)isHigherScoreBetter(134-134)
🪛 GitHub Check: CodeFactor
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms (5)
- 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-14, xcode, 15.0.1)
- GitHub Check: build-and-test (macos-13, xcode, 14.2)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
🔇 Additional comments (13)
src/openms/include/OpenMS/METADATA/PeptideIdentification.h (1)
134-135: Good addition of a utility method for score comparison.The new
getScoreComparatormethod abstracts the comparison logic based on the score orientation, which improves code reusability and readability.src/openms/source/METADATA/PeptideIdentification.cpp (2)
212-223: Clean implementation of the score comparator function.The implementation properly returns the appropriate comparator based on the score orientation parameter, enhancing modularity by separating comparison logic from sorting operations.
225-228: Good refactoring of the sort method.The updated implementation now uses the new
getScoreComparatorutility andstd::stable_sort, which preserves the relative order of equal elements, ensuring consistent results.src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (10)
58-58: Improved const-correctness for setReference method.Changing the parameter type to
const DataType&ensures the method doesn't modify the input data, which is the expected behavior for a setter method.
86-86: Enhanced const-correctness for align method.Using
const std::vector<DataType>&for the input parameter is appropriate since this method doesn't need to modify the input data, improving safety and potentially enabling compiler optimizations.
182-183: Appropriate const-correctness for getRetentionTimes_ method.Changing the parameter type to a const reference for the peptides vector ensures the method doesn't modify the input data.
204-204: Consistent const-correctness for PeakMap version.This change maintains consistency with the other method updates for const-correctness.
221-221: Enhanced const-correctness for MapType version.Changing the parameter type to
const MapType&aligns with the const-correctness improvements throughout the class.🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
239-239: Appropriate iterator type change.Using
ConstIteratorinstead ofIteratoris necessary to maintain const-correctness when iterating over a const container.
248-249: Proper const iterator usage.Using
std::vector<PeptideIdentification>::const_iteratoris consistent with the const-correctness improvements.
259-260: Good use of the new utility method.Using the new
getBestScoringHitmethod improves code readability and maintainability by abstracting the logic for finding the best-scoring hit.
262-262: Const-safety throughout the call chain.Consistent use of const references and pointers ensures const-correctness is maintained throughout the entire process.
331-340: Well-documented utility method addition.The new
getBestScoringHitmethod is well-documented with clear parameters and return value descriptions. This utility function encapsulates finding the best-scoring hit, which improves code reusability.The static analysis tool flagged the enclosing method as complex. While this isn't directly related to your current changes, you might want to consider further refactoring opportunities in this area in the future.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (2)
193-194: Update outdated comment above this line.The comment "id_data can't be const here or template resolution will fail" is no longer accurate since you've successfully made the parameter const.
- // "id_data" can't be "const" here or template resolution will fail + // Parameter is now const as the implementation no longer needs to modify it
221-295: Consider refactoring this complex method.The static analysis tool flagged this method as complex. While not directly related to your current changes, consider breaking it down into smaller, more focused methods in the future.
You could extract the logic for handling feature RTs (lines 242-270) and the logic for removing duplicates (lines 284-294) into separate private methods to reduce the complexity.
🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h(10 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeFactor
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- 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 (windows-2022, cl.exe, default)
- GitHub Check: build-and-test (macos-13, xcode, 14.2)
🔇 Additional comments (9)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (9)
58-58: Improved const-correctness for setReference method.This change ensures that the input data parameter is treated as read-only, which is a good practice for parameters that aren't modified.
86-86: Improved const-correctness for align method.The input data vector is now marked as const, preventing accidental modification and allowing the method to work with const references.
182-183: Improved const-correctness for getRetentionTimes_ method.This change correctly marks the peptides parameter as const since the method doesn't need to modify it.
204-204: Improved const-correctness for getRetentionTimes_ method (PeakMap overload).This change correctly marks the experiment parameter as const.
221-221: Improved const-correctness for getRetentionTimes_ template method.The features parameter is now properly marked as const.
🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
239-240: Updated iterator type to match const parameter.Changed from Iterator to ConstIterator to ensure compatibility with the const features parameter.
248-250: Updated to const_iterator for peptide identifications.This change ensures const-correctness is maintained throughout the method.
259-263: Added new helper method to find the best scoring hit.This is a good improvement that encapsulates the logic for finding the best hit and adds a null check before accessing the hit.
331-339: New utility method to find the best-scoring PeptideHit.This method abstracts the logic for finding the best-scoring hit, improving code organization and reusability. It properly handles the scoring direction (higher vs. lower is better) and returns nullptr for empty lists.
There was a problem hiding this comment.
Looks good, thanks.
I cannot find a test for MapAlignmentIdentification that uses more than one PeptideHit, so your refactoring of .sort() is currently not tested in this context.
Please replace
https://github.com/OpenMS/OpenMS/blob/develop/src/tests/class_tests/openms/data/MapAlignmentAlgorithmIdentification_test_1.idXML#L8
with something like:
<PeptideHit score="27.1" sequence="IGNORETHISSECONDBEST" charge="2" aa_before="K" aa_after="D" ></PeptideHit>
<PeptideHit score="29.1" sequence="VTAFIPPWVK" charge="2" aa_before="K" aa_after="D" ></PeptideHit>
(You should see the test MapAlignmentAlgorithmIdentification_test is still passing).
The solution with std::function surely works, but I'm not sure it does well in terms of performance. This would require some benchmarking. But let's not worry about that for now.
|
|
||
| @return Pointer to the best-scoring hit, or nullptr if the list is empty | ||
| */ | ||
| const PeptideHit* getBestScoringHit(const std::vector<PeptideHit>& hits, const bool isHigherScoreBetter); |
There was a problem hiding this comment.
| const PeptideHit* getBestScoringHit(const std::vector<PeptideHit>& hits, const bool isHigherScoreBetter); | |
| const PeptideHit* getBestScoringHit(const std::vector<PeptideHit>& hits, const bool is_higher_score_better); |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (1)
221-295: Consider refactoring complex methodThe static analysis tool flags this method as complex. While your current changes don't add to this complexity (and in fact help reduce it by extracting the getBestScoringHit functionality), you might want to consider further refactoring in the future.
Potential approaches:
- Extract smaller helper methods for different parts of the logic
- Simplify the nested conditional structure
- Consider using algorithm-based approaches instead of manual loops where possible
🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h(10 hunks)src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp
🧰 Additional context used
🪛 GitHub Check: CodeFactor
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms (4)
- 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 (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
🔇 Additional comments (11)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (11)
58-58: Improved const-correctness in setReferenceGood change - making the input parameter const ensures the method won't modify the input data, which aligns with the method's purpose of only reading data to establish a reference.
86-86: Improved const-correctness in align methodGood job making the input data parameter const. This properly communicates to users that the align method doesn't modify the input data vector, improving API clarity and safety.
182-183: Improved const-correctness for PeptideIdentification parameterMaking the peptides parameter const properly reflects that the method only reads from the identifications without modifying them.
194-194: Improved const-correctness for IdentificationData parameterMaking the id_data parameter const is a good change, correctly reflecting that this data is read-only within the method. This also removes the need for the explanatory comment on line 193, but you might want to keep it for clarity.
204-204: Improved const-correctness for PeakMap parameterGood change - making the experiment parameter const properly reflects that the method doesn't modify the input experiment data.
221-221: Improved const-correctness for MapType template methodMaking the features parameter const is consistent with the other getRetentionTimes_ methods and correctly indicates that the method doesn't modify the input data.
🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
239-240: Updated iterator type to match const parameterCorrectly updated to ConstIterator to match the now-const features parameter. This ensures const-correctness throughout the method.
248-250: Updated to const_iterator for consistencyGood change - using const_iterator is consistent with the const-correctness approach and properly reflects that you're not modifying the peptide identifications during iteration.
259-261: Improved handling of best scoring hitGood improvement! Using the new getBestScoringHit method instead of assuming the first hit is the best one makes the code more robust. The null check before accessing the score is also a good defensive programming practice.
262-262: Updated accessor syntax for pointerCorrectly changed from dot notation to arrow notation to match the new pointer return type from getBestScoringHit.
331-339: Well-designed utility method for finding best scoring hitThis new method is a good addition that enhances the functionality of the class. It properly handles the case of empty hit lists by returning nullptr, and takes into account whether higher or lower scores are better.
The method signature matches what reviewer cbielow suggested in previous comments. This is a good implementation of the requested change.
| <PeptideHit score="27.1" sequence="IGNORETHISSECONDBEST" charge="2" aa_before="K" aa_after="D" > | ||
| </PeptideHit> | ||
| <PeptideHit score="29.1" sequence="VTAFIPPWVK" charge="2" aa_before="K" aa_after="D" > |
There was a problem hiding this comment.
The tests are passing locally
I ran
ctest -R MapAlignmentAlgorithmIdentification_test
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (2)
182-183: Update the comment on line 193.Line 193 contains a comment stating "id_data" can't be "const" here or template resolution will fail", but the parameter on line 194 is now const. This comment is now inconsistent with the actual code.
- // "id_data" can't be "const" here or template resolution will fail + // Parameter is now const since the template resolution issue was resolvedAlso applies to: 193-194
221-295: Consider simplifying this complex method in the future.Static analysis flags this method as complex. While the current changes don't increase complexity, consider breaking this method down into smaller, more focused methods in future refactoring efforts.
🧰 Tools
🪛 GitHub Check: CodeFactor
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h(10 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeFactor
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h
[notice] 221-351: src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h#L221-L351
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms (5)
- 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: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (macos-13, xcode, 14.2)
🔇 Additional comments (6)
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (6)
58-58: Great improvement on const correctness.Making
setReferenceparameter const enforces that the input data will not be modified, which aligns well with the method's purpose of only using the data to establish a reference.
86-86: Good job enforcing const correctness for align method.Input data shouldn't be modified during alignment, and this change properly enforces that constraint.
204-204: Consistent application of const for remaining getRetentionTimes_ methods.Good work maintaining consistency across all overloads of this method.
Also applies to: 221-221
239-240: Proper iterator usage with const containers.Changing to
ConstIteratorandconst_iteratorcorrectly maintains const correctness when iterating over const containers.Also applies to: 248-250
259-263: Good approach for finding the best-scoring hit.Using a dedicated utility method
getBestScoringHitimproves code maintainability and readability compared to directly accessing hits. This addresses the previous review comment.
331-339: Well-designed utility method for finding best hit.The new
getBestScoringHitmethod has a clear purpose and signature, correctly handling potential empty hit lists by returning nullptr.
cbielow
left a comment
There was a problem hiding this comment.
looks good to me!
Thanks!
Description
Fixes #7972
The PR marks all input
dataconst so that they are not modified or re-assigned during runsChecklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outThe details of the action statuses at the end of the PR or the "Checks" tab.
http://cdash.seqan.de/index.php?project=OpenMS and look for your PR. Use the "Show filters" capability on the top right to search for your PR number.
If you click in the column that lists the failed tests you will get detailed error messages.
fixes Make align function work on const data #7972
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit
Summary by CodeRabbit
New Features
Refactor
Bug Fixes