Skip to content

(osw,percolator): Add Percolator based scoring for OSW results - #9695

Merged
timosachsenberg merged 11 commits into
OpenMS:developfrom
singjc:add/osw_percolator
Jul 1, 2026
Merged

timosachsenberg merged 11 commits into
OpenMS:developfrom
singjc:add/osw_percolator

Conversation

@singjc

@singjc singjc commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

This pull request introduces the OpenSwathPercolatorScoring class and associated test and build system updates to support Percolator-based scoring of OpenSWATH results. The main goal is to enable in-process Percolator scoring for OpenSwath results, to eventually deprecate/archive PyProphet, since most of PyProphet has be transferred directly into OpenMS now..

Performance Comparison to PyProphet

Test file: 20200505_Evosep_200SPD_SG06-16_MLHeLa_200ng_py8_S3-A1_1_2737.mzML (PXD017703)

Percolator's score distribution closely matches PyProphets SVM (Sklearn) score distribution.

image

Fairly similar performance in number of precursor IDs at 1% comparing PyProphet's SVM to Percolator.

image image

Of overlapping precursors, most are assigned the same peak-group feature

image

New Feature: Percolator Scoring Integration

  • Added the OpenSwathPercolatorScoring class, which provides rescoring of OpenSWATH OSW and OSWPQ results using Percolator. This includes support for multiple scoring levels (MS1, MS2, MS1MS2, and transition), and handles both SQLite and Parquet input/output formats. (OpenSwathPercolatorScoring.h, [1] [2]
  • Registered OpenSwathPercolatorScoring as a TOPP tool and documented it in the Doxygen manual and tool handler map. (TOPP.doxygen, ToolHandler.cpp, [1] [2]

Build System and Source Integration

  • Added OpenSwathPercolatorScoring to the OpenMS build system, including CMake source lists for both header and implementation files, and ensured correct linking for tests. (sources.cmake, [1] [2] [3] [4]

Testing

  • Introduced a comprehensive unit test (OpenSwathPercolatorScoring_test.cpp) covering all supported scoring levels, input formats, and error cases. The test verifies correct output, error handling, and integration with SQLite and Parquet backends. (OpenSwathPercolatorScoring_test.cpp, src/tests/class_tests/openms/source/OpenSwathPercolatorScoring_test.cppR1-R248)
  • Added integration tests for the new tool to the TOPP test suite, including both .osw and .oswpq input/output cases. (CMakeLists.txt, [1] [2]

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

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.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

  • New Features

    • Added OpenSwathPercolatorScoring for in-process Percolator rescoring of OpenSWATH result containers.
    • Supports rescoring at multiple levels (including transition) and writes either in-place or to a specified output.
    • Works with both OSW (SQLite) and OSWPQ/Parquet inputs.
  • Bug Fixes

    • Improved validation of requested levels/output handling and robustness when features are missing.
  • Tests

    • Added unit tests and TOPP end-to-end cases for supported levels and output verification.
  • Documentation

    • Documented the new tool and updated the public TOPP list/changelog entry.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

  • singjc

Please consider applying the following patch:

--- AUTHORS	2026-07-01 05:00:54.555427918 +0000
+++ AUTHORS.new	2026-07-01 05:01:00.037089365 +0000
@@ -113,6 +113,7 @@
  - Sandro Andreotti
  - Santhil
  - Simon Gene Gottlieb
+ - singjc
  - Steffen Sass
  - Stephan Aiche
  - Sven Nahnsen

@coderabbitai

coderabbitai Bot commented Jul 1, 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: 88c8671e-8184-4caa-b6ae-d9db21797b9f

📥 Commits

Reviewing files that changed from the base of the PR and between fe27f2e and 34103c6.

📒 Files selected for processing (4)
  • src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.h
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.cpp
  • src/tests/class_tests/openms/source/OpenSwathPercolatorScoring_test.cpp
  • src/topp/OpenSwathPercolatorScoring.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.h
  • src/tests/class_tests/openms/source/OpenSwathPercolatorScoring_test.cpp
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.cpp
  • src/topp/OpenSwathPercolatorScoring.cpp

📝 Walkthrough

Walkthrough

This PR adds OpenSwathPercolatorScoring as a new OpenMS library component and TOPP tool for rescoring OpenSWATH OSW/OSWPQ results with Percolator. It also wires the new tool into build files, documentation, changelog, and tests.

Changes

OpenSwathPercolatorScoring feature

Layer / File(s) Summary
Public contract and header
src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.h, src/openms/include/OpenMS/ANALYSIS/OPENSWATH/sources.cmake
Defines the public scorer API, level enum, score summary, pimpl storage, and adds the header to the OpenSWATH source list.
Scoring engine and file output
src/openms/source/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.cpp, src/openms/source/ANALYSIS/OPENSWATH/sources.cmake
Implements feature extraction, candidate filtering, Percolator scoring, ranking, summary computation, and SQLite/Parquet output writing; registers the source file in CMake.
TOPP wrapper and registration
src/topp/OpenSwathPercolatorScoring.cpp, src/topp/executables.cmake, src/openms/source/APPLICATIONS/ToolHandler.cpp, doc/doxygen/public/TOPP.doxygen, CHANGELOG
Adds the command-line wrapper, level parsing, executable and tool registration, Doxygen entry, and changelog note.
Class and TOPP tests
src/tests/class_tests/openms/source/OpenSwathPercolatorScoring_test.cpp, src/tests/class_tests/openms/CMakeLists.txt, src/tests/class_tests/openms/executables.cmake, src/tests/topp/CMakeLists.txt
Adds class and TOPP tests for SQLite and Parquet outputs, fixture setup, and test target wiring.

Possibly related PRs

  • OpenMS/OpenMS#9280: Also updates ToolHandler::getTOPPToolList() to register a new OpenSWATH TOPP tool in the targeted category.

Suggested reviewers: jpfeuffer, timosachsenberg

Poem

A rabbit scored the OSW runs bright,
With Percolator in a hopping light.
MS1, MS2, and transition glow,
Then Parquet columns sprouted row by row. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.35% 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 clearly matches the main change: adding Percolator-based scoring for OSW results.
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.
✨ 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.

@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: 5

🤖 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/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.h`:
- Line 21: Remove the public String alias from OpenSwathPercolatorScoring.h and
rely on the existing OpenMS String type instead of introducing a new
std::string-based alias. Update any uses in OpenSwathPercolatorScoring or
related symbols to refer to the canonical OpenMS::String definition so the
header no longer creates a conflicting declaration.

In `@src/openms/source/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.cpp`:
- Around line 1043-1051: The directory-input validation in
OpenSwathPercolatorScoring should reject archive-shaped targets even when the
output path does not yet exist. Update the checks around the directory OSWPQ
branch and prepareParquetWorkspace_() so that a directory input only accepts a
true directory destination, not a path ending in .zip or similar
archive/container extension. Use the existing input_path/output_path validation
logic in OpenSwathPercolatorScoring.cpp to enforce the directory-to-directory
contract before workspace creation.
- Around line 1081-1164: The SCORE_* rewrite is not atomic because `DROP TABLE
IF EXISTS` and `CREATE TABLE` run before `BEGIN TRANSACTION`, so a later failure
in the `insert_stmt` loop can leave the old score table destroyed and the new
one incomplete. Move the full table replacement flow in the
OpenSwathPercolatorScoring write path into a single transaction in this method:
start the transaction before executing `create_sql`, keep the existing inserts
inside it, and only commit with `END TRANSACTION` after all rows are written
successfully. If anything fails, ensure the transaction is rolled back so
`SCORE_MS2`/`SCORE_TRANSITION` is never left partially rewritten.

In `@src/openms/source/APPLICATIONS/ToolHandler.cpp`:
- Around line 147-149: The tools_map entries in ToolHandler::registerTools are
not in alphabetical order, specifically OpenSwathPercolatorScoring is placed
before OpenSwathMzMLFileCacher even though M should come before P. Reorder the
affected insertions in the tool registration block so the OpenSwath* entries
follow alphabetical order consistently with the surrounding entries and the
file’s convention.

In `@src/tests/class_tests/openms/source/OpenSwathPercolatorScoring_test.cpp`:
- Around line 167-244: The boolean checks in OpenSwathPercolatorScoring_test
should use the dedicated truthiness assertions instead of equality comparisons.
Update the TEST_EQUAL(<expr>, true) cases in this test to TEST_TRUE(<expr>) and
any false checks to TEST_FALSE(<expr>), keeping the same expressions and
coverage around scorer.score, querySqliteInt64_, and checkParquetFeatureColumns_
so the assertions match the project’s test style.
🪄 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: 248e92e4-cb83-401a-bef1-da4ad8a11487

📥 Commits

Reviewing files that changed from the base of the PR and between e83520d and 35136d9.

📒 Files selected for processing (12)
  • doc/doxygen/public/TOPP.doxygen
  • src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.h
  • src/openms/include/OpenMS/ANALYSIS/OPENSWATH/sources.cmake
  • src/openms/source/ANALYSIS/OPENSWATH/OpenSwathPercolatorScoring.cpp
  • src/openms/source/ANALYSIS/OPENSWATH/sources.cmake
  • src/openms/source/APPLICATIONS/ToolHandler.cpp
  • src/tests/class_tests/openms/CMakeLists.txt
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/OpenSwathPercolatorScoring_test.cpp
  • src/tests/topp/CMakeLists.txt
  • src/topp/OpenSwathPercolatorScoring.cpp
  • src/topp/executables.cmake

@timosachsenberg

Copy link
Copy Markdown
Contributor

Nice!

@timosachsenberg
timosachsenberg merged commit f0c6480 into OpenMS:develop Jul 1, 2026
39 checks passed
timosachsenberg pushed a commit that referenced this pull request Jul 1, 2026
…XIPMParquetFile Doxygen

- OpenSwathPercolatorScoring (added in #9695) had no Python binding, unlike
  sibling OSW classes (OpenSwathOSWWriter, Percolator); expose the class,
  its Level enum, and ScoreSummary struct following the existing
  Percolator binding pattern (def_DefaultParamHandler, nested types scoped
  under the class handle).
- XIPMParquetFile.h (added in #9684) had only a one-line class @brief and
  no per-member documentation; bring it in line with the XICParquetFile.h /
  XIMParquetFile.h sibling readers added in the same PR wave.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Po25Mh5kdPa6b8AFn5hagb
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.

2 participants