Skip to content

Add class tests for IdentifierMSRunMapper and ProteinModificationSummary - #9579

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/metadata-mapper-modsummary
Jun 18, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/metadata-mapper-modsummary

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Part of the OpenMS 3.6.0 pre-release testing plan (#9460): adds class tests for two previously untested METADATA classes.

IdentifierMSRunMapper

Two-way mapping between protein-identification identifiers and MS-run-paths (used e.g. for USI building / resolving the source file of a peptide ID). Tests cover:

  • construction from ProteinIdentifications and create() (including that it clears prior content)
  • empty(), size(), hasIdentifier()
  • getMSRunPaths() (and empty list returned for unknown identifiers)
  • getIdentifiers() ordering, getIdentifier() (full path-list match, and Exception::ElementNotFound on miss)
  • hasRunPath() / tryGetIdentifier()
  • getPrimaryMSRunPath() resolution via id_merge_index (default index 0, valid index, out-of-range → empty, unknown identifier → empty)
  • duplicate ms-run-path rejection (Exception::InvalidValue)

ProteinModificationSummary

Maps a protein position → modification → statistics. Tests cover:

  • Statistics::operator== over all four fields (count, frequency, FLR, probability)
  • ProteinModificationSummary::operator== across differing position / modification / statistics
  • nested type aliases (ModificationsToStatistics, AALevelSummary) and map semantics

Expected values were pinned by probing the built library before writing assertions; both tests build and pass locally with no warnings (aside from the standard dtor-only "no subtests" notice).

Tests only — no production code changes.

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit test coverage for IdentifierMSRunMapper, including construction, mapping lookups, and run-path resolution logic.
    • Added comprehensive unit test coverage for ProteinModificationSummary, validating construction, equality semantics, and container behavior.

Both METADATA classes were previously untested (OpenMS 3.6.0 pre-release
testing plan, OpenMS#9460).

IdentifierMSRunMapper_test:
- construction from ProteinIdentifications and create() (incl. clearing)
- empty/size, hasIdentifier, getMSRunPaths (and empty-on-unknown)
- getIdentifiers ordering, getIdentifier (full path-list match + throws)
- hasRunPath / tryGetIdentifier
- getPrimaryMSRunPath via id_merge_index (default, valid, out-of-range,
  unknown identifier)
- duplicate ms-run-path rejection (Exception::InvalidValue)

ProteinModificationSummary_test:
- Statistics::operator== over all four fields
- ProteinModificationSummary::operator== across position/modification/stats
- nested type aliases and map semantics

Tests only; no production code changes.
@github-actions

Copy link
Copy Markdown
Contributor

@timosachsenberg The following names might be missing from the AUTHORS file:

  • Timo Sachsenberg

Please consider applying the following patch:

--- AUTHORS	2026-06-16 05:51:50.461150455 +0000
+++ AUTHORS.new	2026-06-16 05:51:55.735812362 +0000
@@ -23,8 +23,8 @@
  - Chirag Dave
  - Chris Bauer
  - Chris Bielow
- - Christie Mathews
  - Christian Ehrlich
+ - Christie Mathews
  - Clemens Groepl
  - Cornelia Friedle
  - Daniel Jameson

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Two new OpenMS unit test files are added—IdentifierMSRunMapper_test.cpp and ProteinModificationSummary_test.cpp—and both are registered in executables.cmake by appending their names to metadata_executables_list.

Changes

New metadata class unit tests

Layer / File(s) Summary
IdentifierMSRunMapper test and CMake registration
src/tests/class_tests/openms/executables.cmake, src/tests/class_tests/openms/source/IdentifierMSRunMapper_test.cpp
Registers ProteinModificationSummary_test and IdentifierMSRunMapper_test in metadata_executables_list. Adds a full test suite for IdentifierMSRunMapper covering construction/clearing, empty()/size(), hasIdentifier, getMSRunPaths, getIdentifiers/getIdentifier (including exception paths), hasRunPath, tryGetIdentifier, and getPrimaryMSRunPath with merge-index selection and out-of-range/unknown-identifier edge cases.
ProteinModificationSummary test
src/tests/class_tests/openms/source/ProteinModificationSummary_test.cpp
Adds a test suite for ProteinModificationSummary covering default construction, Statistics::operator== across all four fields (count, frequency, FLR, probability), ProteinModificationSummary::operator== across empty/matching/differing-stats/differing-position scenarios, and AALevelSummary container semantics (size, count for present and absent positions). Uses "Oxidation" on "M" from ModificationsDB as the test key.

🐇 Two new tests hop into the suite,
mapping runs and mods with care so neat.
Oxidation on M, merge indices too—
each assertion checks what the classes do.
The cmake list grows by two little names,
and coverage blooms like spring in the lanes! 🌸

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: adding class tests for two specific classes (IdentifierMSRunMapper and ProteinModificationSummary).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tests/class_tests/openms/source/ProteinModificationSummary_test.cpp`:
- Around line 115-116: The modification object ox retrieved from
ModificationsDB::getInstance()->getModification() is used without validating
that it is not null, which could lead to silent test failures. Add a
TEST_NOT_EQUAL assertion immediately after the getModification call to verify
that ox is not null before using it as a key or in any subsequent operations.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b2f87a5a-732e-4ec7-ae4e-ab3d5712ae5e

📥 Commits

Reviewing files that changed from the base of the PR and between a1ca62b and 4205ca4.

📒 Files selected for processing (3)
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/IdentifierMSRunMapper_test.cpp
  • src/tests/class_tests/openms/source/ProteinModificationSummary_test.cpp

Comment on lines +115 to +116
const ResidueModification* ox = ModificationsDB::getInstance()->getModification("Oxidation", "M", ResidueModification::ANYWHERE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a null-check for the fetched modification in this section.

Line 115 retrieves ox and it is used as a key without asserting non-null in this section. Add a local TEST_NOT_EQUAL(ox, nullptr) before insertion to avoid a silent false-positive test path.

Suggested patch
 START_SECTION([EXTRA] (nested type aliases and map semantics))
 {
   const ResidueModification* ox = ModificationsDB::getInstance()->getModification("Oxidation", "M", ResidueModification::ANYWHERE);
+  TEST_NOT_EQUAL(ox, nullptr)

   ProteinModificationSummary s;
   ProteinModificationSummary::Statistics st;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/ProteinModificationSummary_test.cpp`
around lines 115 - 116, The modification object ox retrieved from
ModificationsDB::getInstance()->getModification() is used without validating
that it is not null, which could lead to silent test failures. Add a
TEST_NOT_EQUAL assertion immediately after the getModification call to verify
that ox is not null before using it as a key or in any subsequent operations.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

An unexpected error occurred while generating fixes: Not Found - https://docs.github.com/rest/git/refs#get-a-reference

Copy link
Copy Markdown
Contributor Author

Adversarial review result:

I did not find a blocking issue in this pass. This is a test-only addition for IdentifierMSRunMapper and ProteinModificationSummary; the map-order and duplicate-path expectations match the current implementation. I did not find tracker references in source comments. I did not run the tests locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant