Skip to content

[TEST] Add OSWData_test (OpenSWATH in-memory data structure) - #9567

Merged
timosachsenberg merged 3 commits into
OpenMS:developfrom
timosachsenberg:test/oswdata-datastructure
Jul 8, 2026
Merged

timosachsenberg merged 3 commits into
OpenMS:developfrom
timosachsenberg:test/oswdata-datastructure

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Context

Part of the OpenMS 3.6.0 pre-release testing plan (#9460), §4 (OpenSwathWorkflow).

DATASTRUCTURES/OSWData — the in-memory OpenSWATH results structure (protein → peptide precursor → peak group → transition hierarchy) used by the OSW reader/UI — had no test file.

Change

Adds a class test covering:

  • the immutable value types OSWTransition / OSWPeakGroup (incl. the QVALUE_MISSING default) / OSWPeptidePrecursor / OSWProtein and their accessors;
  • OSWHierarchy::LevelName and OSWIndexTrace::isSet();
  • the OSWData container: addTransition (both overloads), transitionCount, getTransition/getTransitions, addProtein (incl. the referential-integrity check that rejects a protein referencing an unknown transition ID with Exception::Precondition), getProteins (full hierarchy reachable), setProtein, setSqlSourceFile/setRunID, clear vs clearProteins (the latter keeps the transitions), buildNativeIDResolver (run-id mismatch → Precondition) and fromNativeID (no resolver built → InvalidValue).

Notes

  • New test registered in executables.cmake (datastructures_executables_list).
  • Tests only — no production code changes.
  • Exception behaviors were read from the implementation before pinning.
  • Builds and passes locally; every OSWData method has a section (no untested-method warnings); all assertions execute against real values (verbose-confirmed).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added a new unit test suite for OSW data structures, covering hierarchy construction and navigation, default/missing sentinel behavior, accessor correctness, add/replace semantics, and native ID resolver error handling.
    • Ensured the new OSWData test executable is included in the collected executable-based test set.

DATASTRUCTURES/OSWData - the in-memory OpenSWATH results structure (protein ->
peptide precursor -> peak group -> transition hierarchy) used by the OSW
reader/UI - had no test.

Adds a class test covering:
- the immutable value types OSWTransition / OSWPeakGroup (incl. the
  QVALUE_MISSING default) / OSWPeptidePrecursor / OSWProtein and their accessors;
- OSWHierarchy::LevelName and OSWIndexTrace::isSet();
- the OSWData container: addTransition (both overloads), transitionCount,
  getTransition / getTransitions, addProtein (incl. the referential-integrity
  check that rejects a protein referencing an unknown transition ID with
  Exception::Precondition), getProteins (full hierarchy reachable), setProtein,
  setSqlSourceFile / setRunID, clear vs clearProteins (the latter keeps the
  transitions), buildNativeIDResolver (run-id mismatch -> Precondition) and
  fromNativeID (no resolver built -> InvalidValue).

Registered in executables.cmake (datastructures_executables_list). Part of the
OpenMS 3.6.0 pre-release testing plan (OpenMS#9460). Tests only; no production code
changes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 64faf55d-3bd3-461d-a040-944172863d95

📥 Commits

Reviewing files that changed from the base of the PR and between 741c238 and 239db5c.

📒 Files selected for processing (1)
  • src/tests/class_tests/openms/source/OSWData_test.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/class_tests/openms/source/OSWData_test.cpp

📝 Walkthrough

Walkthrough

A new unit test file OSWData_test.cpp is added, covering OSWData and its related value types (OSWTransition, OSWPeakGroup, OSWPeptidePrecursor, OSWProtein). The test is registered in executables.cmake under datastructures_executables_list.

Changes

OSWData Unit Test Suite

Layer / File(s) Summary
CMake registration and test file setup
src/tests/class_tests/openms/executables.cmake, src/tests/class_tests/openms/source/OSWData_test.cpp
Adds OSWData_test to datastructures_executables_list and defines the test file header, includes, and a makeData() helper that builds a full two-transition OSWData hierarchy used across all test sections.
Value type and hierarchy accessor tests
src/tests/class_tests/openms/source/OSWData_test.cpp
Tests OSWHierarchy::LevelName enum name mappings, OSWIndexTrace::isSet default and set semantics, and accessor correctness for OSWTransition, OSWPeakGroup (including QVALUE_MISSING sentinel), OSWPeptidePrecursor, and OSWProtein.
OSWData transition and protein API tests
src/tests/class_tests/openms/source/OSWData_test.cpp
Covers both addTransition overloads (const-ref and rvalue), transitionCount, getTransition, getTransitions map semantics, addProtein referential-integrity enforcement (throws Exception::Precondition on unknown transition reference), getProteins traversal, and setProtein replacement.
Metadata, clear, and native ID resolver tests
src/tests/class_tests/openms/source/OSWData_test.cpp
Tests setSqlSourceFile/getSqlSourceFile default and persistence, setRunID/getRunID round-tripping, clear and clearProteins count behavior (transitions retained on clearProteins), and negative tests asserting buildNativeIDResolver throws on incompatible MSExperiment and fromNativeID throws without a built resolver.

🐇 A new test hops into view,
checking each OSWData path through and through.
Transitions added, proteins in line,
referential checks working just fine.
The resolver throws when something's wrong—
and so the test suite grows along! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 accurately and concisely describes the main change: adding comprehensive test coverage for the OSWData class, an in-memory data structure used in OpenSWATH.
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

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

225-225: 💤 Low value

Simplify test assertion for readability.

The assertion TEST_EQUAL(d.getRunID() == 123456789ULL, true) tests a boolean expression. It's clearer to compare the value directly: TEST_EQUAL(d.getRunID(), 123456789ULL).

♻️ Proposed refactor
-  TEST_EQUAL(d.getRunID() == 123456789ULL, true)
+  TEST_EQUAL(d.getRunID(), 123456789ULL)
🤖 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/OSWData_test.cpp` at line 225, Simplify
the TEST_EQUAL assertion at the getRunID() test to improve readability. Replace
the current assertion that compares a boolean expression (d.getRunID() ==
123456789ULL) against true with a direct value comparison by removing the
equality operator and true operand, allowing TEST_EQUAL to directly compare
d.getRunID() with the expected value 123456789ULL.

26-26: 💤 Low value

Consider snake_case for helper function name.

The function makeData uses lowerCamelCase. While the coding guidelines specify lowerCamelCase for methods, OpenMS typically uses snake_case for free functions and variables to maintain consistency across the codebase.

♻️ Proposed refactor
-  OSWData makeData()
+  OSWData make_data()

(and update all call sites: lines 143, 149, 157, 166, 183, 196, 239, 248, 257, 266)

🤖 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/OSWData_test.cpp` at line 26, Rename the
free function `makeData` to `make_data` to follow OpenMS snake_case naming
conventions for free functions. After renaming the function definition, update
all call sites where `makeData()` is invoked to use the new `make_data()` name
instead.

Source: Coding guidelines


233-233: 💤 Low value

Simplify test assertion for readability.

Same pattern as line 225: prefer direct value comparison over boolean expression testing.

♻️ Proposed refactor
-  TEST_EQUAL(d.getRunID() == 42, true)
+  TEST_EQUAL(d.getRunID(), 42)
🤖 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/OSWData_test.cpp` at line 233, Simplify
the TEST_EQUAL assertion in the OSWData_test.cpp file by removing the
unnecessary boolean comparison. Instead of testing if d.getRunID() == 42 equals
true, directly compare the return value to the expected value by changing
TEST_EQUAL(d.getRunID() == 42, true) to TEST_EQUAL(d.getRunID(), 42). This makes
the assertion more readable and follows the same pattern used elsewhere in the
test file.
🤖 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/OSWData_test.cpp`:
- Around line 5-6: The file preamble contains empty maintainer and authors
markers that violate coding guidelines. Update the `$Maintainer: $` and
`$Authors: $` markers in the file header comments at the specified lines to
include the actual maintainer name and author names respectively, following the
project's conventions for populating these metadata fields in source files.

---

Nitpick comments:
In `@src/tests/class_tests/openms/source/OSWData_test.cpp`:
- Line 225: Simplify the TEST_EQUAL assertion at the getRunID() test to improve
readability. Replace the current assertion that compares a boolean expression
(d.getRunID() == 123456789ULL) against true with a direct value comparison by
removing the equality operator and true operand, allowing TEST_EQUAL to directly
compare d.getRunID() with the expected value 123456789ULL.
- Line 26: Rename the free function `makeData` to `make_data` to follow OpenMS
snake_case naming conventions for free functions. After renaming the function
definition, update all call sites where `makeData()` is invoked to use the new
`make_data()` name instead.
- Line 233: Simplify the TEST_EQUAL assertion in the OSWData_test.cpp file by
removing the unnecessary boolean comparison. Instead of testing if d.getRunID()
== 42 equals true, directly compare the return value to the expected value by
changing TEST_EQUAL(d.getRunID() == 42, true) to TEST_EQUAL(d.getRunID(), 42).
This makes the assertion more readable and follows the same pattern used
elsewhere in the test file.
🪄 Autofix (Beta)

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: 09b258f1-9e4d-468b-9ea7-bfcbb015ad97

📥 Commits

Reviewing files that changed from the base of the PR and between aacd941 and 741c238.

📒 Files selected for processing (2)
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/OSWData_test.cpp

@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 01:35:52.550286423 +0000
+++ AUTHORS.new	2026-06-16 01:35:57.851460195 +0000
@@ -23,8 +23,8 @@
  - Chirag Dave
  - Chris Bauer
  - Chris Bielow
- - Christie Mathews
  - Christian Ehrlich
+ - Christie Mathews
  - Clemens Groepl
  - Cornelia Friedle
  - Daniel Jameson

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 OSWData; the referential-integrity and resolver precondition checks match the current implementation. I did not find tracker references in source comments. I did not run the tests locally.

@timosachsenberg
timosachsenberg merged commit 48e7e26 into OpenMS:develop Jul 8, 2026
38 checks passed
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