Repository navigation
Improve Tolerance Determination for Sequence Tags - #8319
Conversation
WalkthroughReplaces the ppm-only parameter with a unified Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Tagger
participant AALookup
Caller->>Tagger: Tagger(min_len, tolerance, ..., tol_is_ppm)
Note over Tagger: stores tolerance_ and tol_is_ppm_
Caller->>Tagger: getTag_(mass_sequence)
Tagger->>AALookup: getAAByMass_(m)
alt tol_is_ppm_ == true
Note right of AALookup #D6EAF8: delta = m * tolerance_ / 1e6 (ppm)
else tol_is_ppm_ == false
Note right of AALookup #FDEBD0: delta = tolerance_ (absolute Da)
end
AALookup->>AALookup: scan residues, compute distance to target mass
AALookup-->>Tagger: return closest residue within delta or 'no match'
Tagger-->>Caller: assembled tag / result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/openms/include/OpenMS/CHEMISTRY/Tagger.h (1)
86-86: Improve the inline comment grammar.The comment would be clearer with more formal phrasing.
Apply this diff to improve the comment:
- bool use_absolute_mz_tol_ = false; /// if set, the absolute m/z value is used to determine mass tolerance instead of m/z difference value. + bool use_absolute_mz_tol_ = false; ///< when true, use absolute m/z value to determine mass tolerance instead of m/z difference value
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/CHEMISTRY/Tagger.h(1 hunks)src/openms/source/CHEMISTRY/Tagger.cpp(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/include/OpenMS/CHEMISTRY/Tagger.hsrc/openms/source/CHEMISTRY/Tagger.cpp
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/CHEMISTRY/Tagger.h
🧬 Code graph analysis (1)
src/openms/include/OpenMS/CHEMISTRY/Tagger.h (1)
src/openms/source/CHEMISTRY/Tagger.cpp (4)
setUseAbsoluteMzForTol(187-190)setUseAbsoluteMzForTol(187-187)getAAByMass_(22-45)getAAByMass_(22-22)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: build-and-test (macos-15-intel, xcode, 16.0.0)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (macos-26, xcode, 26.0)
🔇 Additional comments (3)
src/openms/source/CHEMISTRY/Tagger.cpp (3)
63-63: LGTM: Correct conditional logic for tolerance mode.The conditional call correctly passes the absolute m/z value (
mzs[j]) when the flag is enabled, and falls back to the original behavior otherwise. This aligns well with the PR objectives for top-down proteomics support.
187-190: LGTM: Straightforward setter implementation.The implementation correctly sets the flag to enable absolute m/z-based tolerance calculation.
31-44: Verify that existing tests pass with the new best-match behavior.The behavior has changed from returning the first amino acid within tolerance to searching for the closest match (smallest mass difference). While the code comment "return the most exact one" indicates this was intentional, the change should be validated by confirming that the existing test expectations still hold.
Run
Tagger_testto verify the tag counts remain as expected (890, 1006, 1094, 667, 739 for the respective test cases) and that all tag presence/absence assertions pass with the new matching logic.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/openms/source/CHEMISTRY/Tagger.cpp (1)
32-33: Initialize min_delta with the actual distance of the first candidate.The variable
min_deltais initialized todelta(the tolerance window) instead of the actual distance of the first candidate (fabs(left->first - m)). This causes incorrect best-match selection when multiple candidates are within tolerance.Example scenario:
- First candidate at distance 0.8 from target
- Second candidate at distance 0.9 from target
- With
min_delta = delta(e.g., 1.0), the comparison0.9 < 1.0succeeds and incorrectly selects the second candidate- With correct initialization
min_delta = 0.8, the comparison0.9 < 0.8fails and correctly keeps the first candidateApply this diff to fix the initialization:
if (fabs(left->first - m) >= delta) return ' '; // return the most exact one. auto best_aa = left; - double min_delta = delta; + double min_delta = fabs(left->first - m);
🧹 Nitpick comments (1)
src/openms/source/CHEMISTRY/Tagger.cpp (1)
188-191: Consider accepting a boolean parameter for more flexibility.The current implementation only allows enabling the absolute m/z tolerance mode but doesn't provide a way to disable it. While this may be intentional for the current use case, accepting a boolean parameter would make the API more flexible and align with common setter patterns.
- void Tagger::setUseAbsoluteMzForTol() + void Tagger::setUseAbsoluteMzForTol(bool enable) { - use_absolute_mz_tol_ = true; + use_absolute_mz_tol_ = enable; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/CHEMISTRY/Tagger.h(1 hunks)src/openms/source/CHEMISTRY/Tagger.cpp(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/include/OpenMS/CHEMISTRY/Tagger.h
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/CHEMISTRY/Tagger.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: cppcheck-test
| void Tagger::setUseAbsoluteMzForTol() | ||
| { | ||
| use_absolute_mz_tol_ = true; | ||
| } |
There was a problem hiding this comment.
Add documentation for the new public API method.
The new setUseAbsoluteMzForTol() method lacks documentation explaining its purpose, when it should be used, and its effect on tag generation. Public API methods in OpenMS should include comments describing their functionality, especially for non-obvious features like this tolerance mode.
Add a documentation comment above the method:
+ /**
+ * @brief Enable absolute m/z-based tolerance for amino acid matching.
+ *
+ * When enabled, tolerance is calculated based on the fragment m/z value
+ * rather than the amino acid mass difference. This is useful for top-down
+ * proteomics where fragment masses are large relative to amino acid masses.
+ */
void Tagger::setUseAbsoluteMzForTol()
{
use_absolute_mz_tol_ = true;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| void Tagger::setUseAbsoluteMzForTol() | |
| { | |
| use_absolute_mz_tol_ = true; | |
| } | |
| /** | |
| * @brief Enable absolute m/z-based tolerance for amino acid matching. | |
| * | |
| * When enabled, tolerance is calculated based on the fragment m/z value | |
| * rather than the amino acid mass difference. This is useful for top-down | |
| * proteomics where fragment masses are large relative to amino acid masses. | |
| */ | |
| void Tagger::setUseAbsoluteMzForTol() | |
| { | |
| use_absolute_mz_tol_ = true; | |
| } |
There was a problem hiding this comment.
this is definitely not restricted to top-down
There was a problem hiding this comment.
@timosachsenberg, you're absolutely right! The feature isn't restricted to top-down proteomics—it's useful in any scenario where fragment masses are large relative to amino acid mass differences. Here's a revised documentation suggestion that's more general:
/**
* @brief Enable absolute m/z-based tolerance for amino acid matching.
*
* When enabled, tolerance is calculated based on the fragment m/z value
* rather than the amino acid mass difference. This is useful when working
* with large fragment masses where tolerance based on small amino acid
* mass differences would be overly restrictive.
*/
void Tagger::setUseAbsoluteMzForTol()
{
use_absolute_mz_tol_ = true;
}This focuses on the technical condition (large fragment masses) rather than tying it to a specific proteomics workflow.
|
|
||
| When enabled, the tagger uses the absolute m/z value of the node | ||
| to determine the mass tolerance window instead of the m/z difference value. | ||
| This is particularly useful for top-down proteomics where fragment masses |
There was a problem hiding this comment.
not only for top-down. to me it does not make sense to use ppm relative to AAs
timosachsenberg
left a comment
There was a problem hiding this comment.
see comments.
I wonder if tolerances relative to AAs masses even make sense.
Can you also check where it is currently used?
|
For Top down this tolerance using absolute m/z improved the performance drastically. Oh this code is not for TDP.. I will take a look.. |
|
Yeah my argument would be that it could make sense to only use your approach. Could prevent some unexpected results … |
I agree. I am using my own code base. So it is a separate PR from @t0mdavid-m . |
|
I agree. The new behavior should be the default. |
default behavior or only behavior? If possible, I would say only behavior. ;) |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/openms/source/CHEMISTRY/Tagger.cpp (1)
28-29: Add defensive check for iterator validity.Before dereferencing
left->firston line 29, verify thatleft != mass2aa_.end(). While the boundary check at line 25 should preventlower_boundfrom returningend()in normal cases, floating-point precision edge cases or unexpected tolerance calculations could causem - deltato exceed all map keys. Adding this check improves robustness.Apply this diff:
const double delta = tol_is_ppm_ ? Math::ppmToMass(tolerance_, m) : tolerance_; auto left = mass2aa_.lower_bound(m - delta); + if (left == mass2aa_.end()) return ' '; if (fabs(left->first - m) >= delta) return ' ';
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/openms/include/OpenMS/CHEMISTRY/Tagger.h(2 hunks)src/openms/source/CHEMISTRY/Tagger.cpp(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/include/OpenMS/CHEMISTRY/Tagger.h
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/CHEMISTRY/Tagger.cpp
🧠 Learnings (9)
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
PR: OpenMS/OpenMS#8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
📚 Learning: 2025-08-29T19:09:45.997Z
Learnt from: jcharkow
PR: OpenMS/OpenMS#8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/**/*.h : Add Doxygen comments for new public methods and classes in pyOpenMS bindings
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
PR: OpenMS/OpenMS#8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
📚 Learning: 2025-07-29T10:05:48.139Z
Learnt from: poshul
PR: OpenMS/OpenMS#8133
File: src/openms/include/OpenMS/ANALYSIS/TARGETED/TargetedExperimentHelper.h:0-0
Timestamp: 2025-07-29T10:05:48.139Z
Learning: In the Nuctide class in TargetedExperimentHelper.h, the Modification struct is intentionally defined but not used (no mods_ member or related methods). This is by design and should be documented with a comment to avoid confusion.
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Ensure existing tests pass before suggesting changes
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/source/CHEMISTRY/Tagger.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: cppcheck-test
- GitHub Check: build-and-test (macos-15-intel, xcode, 16.0.0)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- 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 (ubuntu-22.04-arm, g++, 11)
- GitHub Check: build-and-test (macos-26, xcode, 26.0)
🔇 Additional comments (2)
src/openms/source/CHEMISTRY/Tagger.cpp (2)
93-94: Constructor refactoring looks correct.The signature change from
ppmtotolerancewith thetol_is_ppmflag properly supports both ppm-based and absolute tolerance modes. The defaulttol_is_ppm = truemaintains backward compatibility for existing code that passes ppm values. Usingfabs(tolerance)ensures the tolerance is always positive.
137-146: Gap bounds calculation correctly implements dual tolerance modes.The conditional initialization properly handles both ppm-based tolerance (calculated at boundary masses) and absolute tolerance (constant value). This aligns with the tolerance calculation in
getAAByMass_and correctly establishes the valid mass range for amino acid matching.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
src/tests/class_tests/openms/source/Tagger_test.cpp (4)
310-347: Add specific assertions to validate tolerance behavior.This test has excellent explanatory comments about the theoretical difference (100 ppm on ~100 Da AA mass = 0.01 Da tolerance vs. 100 ppm on 2000 Da fragment = 0.2 Da tolerance), but the assertion only checks that
tags_da_wide.size() >= tags_ppm_tight.size().Given the intentional 0.05 Da shift and the theoretical tolerance calculations, you can make more specific assertions:
- The ppm mode (0.01 Da tolerance on AA mass) should miss matches with 0.05 Da shift
- The Da mode (0.2 Da tolerance on fragment m/z) should successfully match despite the 0.05 Da shift
- Verify specific expected tags (e.g., "PE") are found in Da mode but not in ppm mode
Apply this pattern to strengthen the test:
// With the larger shift, ppm mode (tight on AA mass) should find fewer or no tags // Da mode (wide on fragment m/z) should find tags despite the shift // The exact counts depend on matching, but Da mode should be >= ppm mode TEST_EQUAL(tags_da_wide.size() >= tags_ppm_tight.size(), true) + + // Specifically verify that Da mode finds tags while ppm mode does not (due to 0.05 Da shift) + bool found_pe_ppm = std::find(tags_ppm_tight.begin(), tags_ppm_tight.end(), "PE") != tags_ppm_tight.end(); + bool found_pe_da = std::find(tags_da_wide.begin(), tags_da_wide.end(), "PE") != tags_da_wide.end(); + + // With 0.05 Da shift, ppm mode (0.01 Da tol) should miss, Da mode (0.2 Da tol) should find + TEST_EQUAL(found_pe_ppm, false) + TEST_EQUAL(found_pe_da, true)
349-370: Compare tag content, not just size, for robust backward compatibility verification.The test only compares
tags_default.size()withtags_explicit_ppm.size(), but two result sets could have the same size yet contain different tags. For robust backward compatibility verification, compare the actual tag contents.Additionally, verify that the Tagger constructor has proper overloads: the test uses a 5-parameter constructor (line 360) expecting it to default
tol_is_ppmtotrue, while the new signature shown in the code snippets has 8 parameters. Ensure the 5-parameter overload exists and properly defaults the new parameter.Apply this diff to strengthen the test:
// Both should produce identical results (backward compatibility) TEST_EQUAL(tags_default.size(), tags_explicit_ppm.size()) + + // Verify actual content is identical, not just size + std::sort(tags_default.begin(), tags_default.end()); + std::sort(tags_explicit_ppm.begin(), tags_explicit_ppm.end()); + TEST_EQUAL(tags_default == tags_explicit_ppm, true)
372-393: Strengthen test with specific tolerance boundary verification.The test uses realistic high-resolution mass errors (1-2 milliDa) and correctly calculates that 10 ppm at 1500 Da equals 15 milliDa tolerance, but only verifies
tags_hires.size() != 0. This doesn't confirm that the tolerance calculation is correct.Consider adding:
- Specific assertions about which tags should be found (given 1-2 milliDa shifts are well within 15 milliDa tolerance)
- A boundary test case with a shift at or just beyond the tolerance limit (e.g., 0.016 Da shift) to verify it's correctly excluded
- Comparison with a tighter tolerance (e.g., 5 ppm = 7.5 milliDa) that should miss some of the 2 milliDa shifts
237-393: Add edge case and error handling tests.All five new test sections exercise the happy path but don't test edge cases or error handling for the new
tol_is_ppmparameter. Consider adding tests for:
- Invalid tolerance values: negative tolerance, zero tolerance, extremely large tolerance
- Boundary conditions: tolerance exactly matching mass difference, just under/over tolerance limit
- Interaction with modifications: how
tol_is_ppmbehaves with fixed and variable modifications (the existing tests with modifications don't exercise the new parameter)- Internal state verification: verify that
min_gap_andmax_gap_are calculated correctly for both tolerance modes (as shown in the Tagger.cpp constructor snippet)The coding guidelines require unit tests for new functionality, and these edge cases are important for ensuring robustness.
Based on coding guidelines
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/tests/class_tests/openms/source/Tagger_test.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/tests/class_tests/openms/**/*.cpp
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for new functionality
Files:
src/tests/class_tests/openms/source/Tagger_test.cpp
🧠 Learnings (6)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
PR: OpenMS/OpenMS#8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/tests/**/*.py : Write pyOpenMS tests for new Python bindings
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
🧬 Code graph analysis (1)
src/tests/class_tests/openms/source/Tagger_test.cpp (1)
src/openms/source/CHEMISTRY/Tagger.cpp (1)
Tagger(94-148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (python)
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/tests/class_tests/openms/source/Tagger_test.cpp (3)
340-345: Strengthen assertion to verify the specific claim.The comment states that tags requiring the 0.025 Da error match should NOT be found (since PEP chain is broken by the large error), but line 345 only checks
tags_good_tol.size() != 0without verifying that specific claim. Consider adding an explicit assertion to verify that tags from the properly-matched portion are found while tags requiring the out-of-tolerance match are absent.Apply this diff to add a more specific assertion:
// Should NOT find tags requiring the 0.025 Da error match (PEP chain broken by large error) // The tag "PEP" might not be found because the third P has 0.025 Da error (outside tolerance) - // But we should still find tags from the good portion of the sequence + // But we should still find tags from the good portion of the sequence (PE with 0.015 Da error) TEST_NOT_EQUAL(tags_good_tol.size(), 0) // Should find some tags + TEST_EQUAL(tags_good_tol.find("PE") != tags_good_tol.end(), true) // Should find PE (0.015 Da error within 0.02 Da tolerance)
456-477: Backward compatibility verified, consider strengthening.The test correctly verifies that omitting the
tol_is_ppmparameter preserves the default ppm behavior. However, it only checks size equality. Consider also verifying that the actual tag sets are identical, not just their sizes, to strengthen the backward compatibility guarantee.Apply this diff to verify content equality:
// Both should produce identical results (backward compatibility) TEST_EQUAL(tags_default.size(), tags_explicit_ppm.size()) + + // Verify actual tag contents are identical, not just sizes + std::set<std::string> set_default(tags_default.begin(), tags_default.end()); + std::set<std::string> set_explicit(tags_explicit_ppm.begin(), tags_explicit_ppm.end()); + TEST_EQUAL(set_default == set_explicit, true)
479-500: Strengthen test to verify specific expected behavior.This test only checks that
tags_hires.size() != 0, which is insufficient to validate that the absolute Da tolerance mode correctly handles realistic high-resolution mass errors. The test setup deliberately creates 1-2 milliDa shifts that should be matched with 10 ppm tolerance (0.015 Da at 1500 Da), but doesn't verify this matching occurs.Apply this diff to add more specific assertions:
// Use 10 ppm in absolute Da mode // At 1500 Da: 10 ppm = 0.015 Da = 15 milliDa (covers our 1-2 milliDa shifts) Tagger tagger_hires = Tagger(2, 10, 3, 1, 1, StringList(), StringList(), false); tagger_hires.getTag(mzs_hires, tags_hires); - // Should find tags with realistic high-resolution mass errors + // Should find tags with realistic high-resolution mass errors (1-2 milliDa within 15 milliDa tolerance) TEST_NOT_EQUAL(tags_hires.size(), 0) + + // Verify we find at least a minimum number of tags given the good quality data + // With 4 peaks and small errors, expect at least one 2-AA tag + TEST_EQUAL(tags_hires.size() >= 1, true) + + // Compare with overly tight tolerance to prove the realistic tolerance is needed + std::vector<std::string> tags_too_tight; + Tagger tagger_too_tight = Tagger(2, 0.0005, 3, 1, 1, StringList(), StringList(), false); // 0.5 milliDa - too tight + tagger_too_tight.getTag(mzs_hires, tags_too_tight); + TEST_EQUAL(tags_hires.size() > tags_too_tight.size(), true) // Realistic tolerance should find more
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/tests/class_tests/openms/source/Tagger_test.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/tests/class_tests/openms/**/*.cpp
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for new functionality
Files:
src/tests/class_tests/openms/source/Tagger_test.cpp
🧠 Learnings (7)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
PR: OpenMS/OpenMS#8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/tests/**/*.py : Write pyOpenMS tests for new Python bindings
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Ensure existing tests pass before suggesting changes
Applied to files:
src/tests/class_tests/openms/source/Tagger_test.cpp
🧬 Code graph analysis (1)
src/tests/class_tests/openms/source/Tagger_test.cpp (1)
src/openms/source/CHEMISTRY/Tagger.cpp (1)
Tagger(94-148)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- 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, 14.36)
🔇 Additional comments (2)
src/tests/class_tests/openms/source/Tagger_test.cpp (2)
237-313: Well-designed test with comprehensive assertions.This test effectively validates the difference between ppm and absolute Da tolerance modes with multiple strong assertions:
- Verifies both modes find tags (non-zero checks)
- Confirms the sets differ (addressing the key feature)
- Validates Da mode finds more tags (≥ comparison)
- Proves Da mode finds exclusive tags not found by ppm mode
- Requires at least 10% improvement in Da mode
The test setup with deliberate 0.01 Da errors on large fragments (1000-2000 Da) properly demonstrates the practical benefit of the new feature for top-down proteomics workflows.
417-454: Clear demonstration of the tolerance mode difference.This test effectively illustrates the practical motivation for the new feature: at large m/z values (2000 Da), applying tolerance to the fragment m/z (Da mode) provides ~20× wider tolerance than applying it to amino acid mass (ppm mode). The 0.05 Da shift scenario demonstrates that Da mode will successfully match fragments that ppm mode would miss.
Description
In TDP, we are dealing with relatively large fragment masses. This creates an issue in the current tagging algorithm: the (comparably very small) amino acid mass difference is used to determine the tolerance for matching amino acids, resulting in overly restrictive tolerance windows that miss valid matches. This PR adds the option to use absolute m/z values of the nodes for tolerance determination.
Credit goes to @KyowonJeong
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
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