Skip to content

Refactor Biosaur2Algorithm to follow FeatureFinderIdentification pattern and eliminate unnecessary MSExperiment copies - #8389

Merged
timosachsenberg merged 4 commits into
biosaur2from
copilot/sub-pr-8385-another-one
Nov 23, 2025
Merged

timosachsenberg merged 4 commits into
biosaur2from
copilot/sub-pr-8385-another-one

Conversation

Copilot AI commented Nov 23, 2025 •

Copy link
Copy Markdown
Contributor

Description

Refactored Biosaur2Algorithm to follow the established pattern used in FeatureFinderIdentificationAlgorithm, eliminating costly deep copies of MS data (hundreds of MB to GB for large LC-MS datasets) through better data management and move semantics support.

Changes

Architecture Refactoring

  • Internal data storage: MS data now stored as member variable ms_data_ instead of being passed to run()
  • Dual setMSData() methods:
    • setMSData(const MSExperiment&) - copy version for compatibility
    • setMSData(MSExperiment&&) - move version using std::move() to avoid copies
  • Data accessors: Added getMSData() methods (const and non-const) for direct access
  • Simplified run() signature: No longer takes MSExperiment parameter, works on internal data

TOPP Tool Integration

  • Direct loading: Changed from loading into temporary variable then passing to algorithm
  • Zero-copy pattern: mzml_file.load(in, algorithm.getMSData()) loads directly into algorithm storage
  • Efficient data flow: Data loaded once without intermediate copies

Python Bindings

  • Exposed new setMSData() and getMSData() methods
  • Updated run() signature to match new API

Example

Before:

MSExperiment exp;
mzml_file.load(in, exp);  // Load into temp
algorithm.run(exp, ...);  // Copy exp into algorithm

After:

mzml_file.load(in, algorithm.getMSData());  // Load directly, no copy
algorithm.run(...);  // Process internal data

Benefits

  • Zero-copy loading: Move semantics avoid deep copy when loading data
  • Cleaner architecture: Algorithm manages its own data lifecycle
  • Consistent with codebase: Matches pattern in FeatureFinderIdentificationAlgorithm
  • API flexibility: Supports both copy and move operations

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).


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai

coderabbitai Bot commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

Only copy the input MSExperiment when modifications are actually needed (MS level filtering, profile mode, or TOF mode). Use a const reference to the input when no modifications are required, avoiding costly deep copies for large LC-MS datasets.

Co-authored-by: timosachsenberg <[email protected]>
Copilot AI changed the title [WIP] Implement Biosaur2 algorithm in OpenMS Optimize MSExperiment copy in Biosaur2Algorithm to avoid unnecessary deep copies Nov 23, 2025
@timosachsenberg

Copy link
Copy Markdown
Contributor

@copilot take a Look at how intus done in featurefinderidentification and its algorithm class

- Add setMSData() methods (const& and &&) for copy/move semantics
- Add getMSData() methods for accessing internal MS data
- Store MS data as member variable ms_data_
- Update run() methods to work on internal data instead of taking MSExperiment parameter
- Update TOPP tool to load data directly into algorithm via getMSData()
- Update Python bindings to reflect new API
- Simplifies data flow and enables move semantics to avoid copies when loading data

Co-authored-by: timosachsenberg <[email protected]>

Copilot AI commented Nov 23, 2025

Copy link
Copy Markdown
Contributor Author

@copilot take a Look at how intus done in featurefinderidentification and its algorithm class

Refactored in commit 39d31c2 to follow the FeatureFinderIdentification pattern:

  • Added setMSData(const MSExperiment&) and setMSData(MSExperiment&&) for copy/move semantics
  • Added getMSData() accessors to allow direct loading into the algorithm
  • MS data now stored as internal member variable ms_data_
  • run() methods no longer take MSExperiment as parameter
  • TOPP tool now loads data with mzml_file.load(in, algorithm.getMSData())

This enables move semantics when loading data, avoiding the costly deep copy entirely.

Copilot AI changed the title Optimize MSExperiment copy in Biosaur2Algorithm to avoid unnecessary deep copies Refactor Biosaur2Algorithm to follow FeatureFinderIdentification pattern and eliminate unnecessary MSExperiment copies Nov 23, 2025
@timosachsenberg
timosachsenberg marked this pull request as ready for review November 23, 2025 19:16
@timosachsenberg
timosachsenberg merged commit 8c9b7c6 into biosaur2 Nov 23, 2025
@timosachsenberg
timosachsenberg deleted the copilot/sub-pr-8385-another-one branch November 23, 2025 19:16
timosachsenberg added a commit that referenced this pull request Nov 28, 2025
…ation (#8385)

* added biosaur2 imp

* move to algo

* add more tests

* inital tests (probably still wrong)

* forgot files

* reuse median calculation

* test update

* doc

* Fix FAIMS drift time validation in Biosaur2Algorithm (#8387)

* Initial plan

* Fix FAIMS validation to only throw for true ion mobility

Co-authored-by: timosachsenberg <[email protected]>

* Refactor: extract shouldThrowForMissingIM helper method

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>

* Replace hardcoded proton mass with Constants::PROTON_MASS_U (#8391)

* Initial plan

* Replace hardcoded proton mass with Constants::PROTON_MASS_U

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>

* Add error handling for file output operations in Biosaur2Algorithm (#8390)

* Initial plan

* Add error handling for file output operations in writeTSV and writeHills

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>

* Refactor Biosaur2Algorithm to follow FeatureFinderIdentification pattern and eliminate unnecessary MSExperiment copies (#8389)

* Initial plan

* Optimize MSExperiment copy to avoid unnecessary memory allocation

Only copy the input MSExperiment when modifications are actually needed (MS level filtering, profile mode, or TOF mode). Use a const reference to the input when no modifications are required, avoiding costly deep copies for large LC-MS datasets.

Co-authored-by: timosachsenberg <[email protected]>

* Refactor Biosaur2Algorithm to follow FeatureFinderIdentification pattern

- Add setMSData() methods (const& and &&) for copy/move semantics
- Add getMSData() methods for accessing internal MS data
- Store MS data as member variable ms_data_
- Update run() methods to work on internal data instead of taking MSExperiment parameter
- Update TOPP tool to load data directly into algorithm via getMSData()
- Update Python bindings to reflect new API
- Simplifies data flow and enables move semantics to avoid copies when loading data

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>
Co-authored-by: Timo Sachsenberg <[email protected]>

* Remove wrapping of nested classes in Biosaur2Algorithm.pxd (#8388)

* Initial plan

* Fix nested cdefs in Biosaur2Algorithm.pxd by moving to module level with qualified names

Co-authored-by: timosachsenberg <[email protected]>

* Remove wrapping of nested classes and methods that use them

Co-authored-by: timosachsenberg <[email protected]>

* Remove methods using unwrapped nested types (Hill, PeptideFeature)

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>
Co-authored-by: Timo Sachsenberg <[email protected]>

* closer to python implementation

* closer to python

* fix: put into neighboring bins

* rt apex check

* improve FAIMS support

* minor refactoring

* Add progress logging to Biosaur2 tool (#8392)

* Add progress logging to Biosaur2 tool

* Add timing logs for Biosaur2 subalgorithms

* add some output message

* speed up apex selection

* performance fix

* add doc

* reduce test size

* fix name (wrong in python)

* minor clarifications

* refactor out some functions

* fix non unique ID assignment

* simplify indexing code

* move debug code

* proper FAIMS parallelization

* greatly simplify FAIMS logic

* rename

* write out FAIMS_CV

* break complex functions down into smaller ones

* make avg calculation thread safe

* pasef seems to work

* minor corner case

* fix shift calculation

* Fix TOPP_Biosaur2 references to TOPP_FeatureFinderLFQ in documentation (#8397)

* Initial plan

* Fix tool name in TOPP.doxygen from TOPP_Biosaur2 to TOPP_FeatureFinderLFQ

Co-authored-by: timosachsenberg <[email protected]>

* Fix TOPP_Biosaur2 reference in Biosaur2Algorithm.h to TOPP_FeatureFinderLFQ

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>

* fix simd (#8402)

* Initial plan

* Add /openmp:experimental flag for MSVC to support #pragma omp simd

Co-authored-by: timosachsenberg <[email protected]>

* Improve comments explaining /openmp:experimental as superset of /openmp

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
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