Skip to content

fix: more pyopenms fixes - #8065

Merged
timosachsenberg merged 1 commit into
developfrom
fix_py
May 26, 2025
Merged

timosachsenberg merged 1 commit into
developfrom
fix_py

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented May 26, 2025 •

Copy link
Copy Markdown
Contributor

Description

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 new methods to set protein identifications with both copy and move options for improved flexibility.
  • Bug Fixes

    • Simplified and streamlined class interfaces by removing redundant or specialized methods and constructors.
  • Documentation

    • Clarified method documentation to better describe recalculation of global ranges for spectra and chromatograms.
  • Chores

    • Updated internal comments to improve the wrapping process for class constructors in the Python interface.

@coderabbitai

coderabbitai Bot commented May 26, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This update removes the getRetentionTimes_ method for AnnotatedMSRun from both header and implementation files, eliminates related Python bindings for certain constructors and methods, and adds explicit setter methods (with copy and move semantics) for protein identifications in AnnotatedMSRun. Minor documentation and binding annotation changes are also included.

Changes

Files/Paths Change Summary
src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h,
src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp
Removed getRetentionTimes_ overload for AnnotatedMSRun.
src/openms/include/OpenMS/METADATA/AnnotatedMSRun.h Added setter methods for protein_ids_ with copy and move semantics.
src/pyOpenMS/pxds/AnnotatedMSRun.pxd Removed constructor accepting MSExperiment.
src/pyOpenMS/pxds/MapAlignmentAlgorithmIdentification.pxd Removed align and setReference methods accepting MSExperiment.
src/pyOpenMS/pxds/ProteinIdentification.pxd Removed assignRanks() method declaration.
src/pyOpenMS/pxds/MSExperiment.pxd Updated updateRanges() comment for clarification.
src/pyOpenMS/pxds/RangeManager.pxd Added # wrap-ignore before RangeManagerRtMzIntMob constructors.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AnnotatedMSRun
    participant MapAlignmentAlgorithmIdentification

    User->>AnnotatedMSRun: setProteinIdentifications(ids) / setProteinIdentifications(std::move(ids))
    AnnotatedMSRun-->>User: (protein_ids_ updated)

    %% The getRetentionTimes_ flow for AnnotatedMSRun is now removed
Loading

Possibly related PRs

  • OpenMS/OpenMS#7973: Modifies getRetentionTimes_ methods and adds const-correctness, directly related to retention time handling.
  • OpenMS/OpenMS#7974: Refactors retention times and integrates AnnotatedMSRun, closely connected to the present changes.
  • OpenMS/OpenMS#7981: Moves assignRanks() and refactors AnnotatedMSRun interface, overlapping with this PR’s simplification and method removals.

Suggested reviewers

  • cbielow

Poem

A rabbit hops through lines of code,
Old overloads now off the road.
New setters shine for proteins bright,
And Python bindings, trimmed just right.
With every leap, the code grows neat—
A garden tidy, swift, and sweet!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@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 (2)
src/pyOpenMS/pxds/MSExperiment.pxd (2)

83-83: Good documentation improvement.

The updated documentation for updateRanges() clearly specifies that it recalculates ranges for "both spectra and chromatograms," which improves API clarity for users. There's also a minor typo in "chromatrograms" that should be "chromatograms."

-        void updateRanges() except + nogil  # wrap-doc:Recalculate global ranges for both spectra and chromatrograms after changes to the data has been made.
+        void updateRanges() except + nogil  # wrap-doc:Recalculate global ranges for both spectra and chromatograms after changes to the data has been made.

118-118: Track the TODO for combinedRanges() functionality.

The TODO comment indicates that combinedRanges() functionality is not yet implemented. This should be tracked to ensure it's completed in a future iteration.

Would you like me to create an issue to track the implementation of the combinedRanges() functionality?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fabf538 and aaacefc.

📒 Files selected for processing (8)
  • src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h (0 hunks)
  • src/openms/include/OpenMS/METADATA/AnnotatedMSRun.h (2 hunks)
  • src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp (0 hunks)
  • src/pyOpenMS/pxds/AnnotatedMSRun.pxd (1 hunks)
  • src/pyOpenMS/pxds/MSExperiment.pxd (2 hunks)
  • src/pyOpenMS/pxds/MapAlignmentAlgorithmIdentification.pxd (0 hunks)
  • src/pyOpenMS/pxds/ProteinIdentification.pxd (1 hunks)
  • src/pyOpenMS/pxds/RangeManager.pxd (1 hunks)
💤 Files with no reviewable changes (3)
  • src/pyOpenMS/pxds/MapAlignmentAlgorithmIdentification.pxd
  • src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.cpp
  • src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmIdentification.h
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • 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 (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: cppcheck-test
🔇 Additional comments (4)
src/pyOpenMS/pxds/RangeManager.pxd (1)

123-123: Good practice: Controlling constructor bindings.

Adding the # wrap-ignore comment for the RangeManagerRtMzIntMob constructors is consistent with the pattern used for other RangeManager classes in this file. This helps control which constructors are exposed in the Python bindings, maintaining a cleaner API surface.

src/pyOpenMS/pxds/AnnotatedMSRun.pxd (1)

32-33:

Details

❓ Verification inconclusive

Verify impact of constructor removal.

The removal of the AnnotatedMSRun(MSExperiment) constructor simplifies the class interface, requiring users to use the default constructor followed by setMSExperiment(). This is a good simplification but represents a breaking change.


🏁 Script executed:

#!/bin/bash
# Search for usage of AnnotatedMSRun constructor with MSExperiment parameter
rg -A 3 -B 3 "AnnotatedMSRun.*MSExperiment" --type cpp --type python

Length of output: 101


To ensure we catch all direct uses of the now-removed AnnotatedMSRun(MSExperiment) constructor across C++ and Cython layers, let’s search in .cpp, .h, .pxd, .pxy, and .pyx files:


🏁 Script executed:

#!/bin/bash
# Search for any calls to AnnotatedMSRun(MSExperiment) in C++ and Cython files
rg -A3 -B3 'AnnotatedMSRun\s*\(\s*MSExperiment' -g '*.cpp' -g '*.h' -g '*.pxd' -g '*.pxy' -g '*.pyx'

Length of output: 1922


Verify external impact of removing MSExperiment constructor

We confirmed via grep across C++ and Cython wrapper files that:

  • The C++ class still defines AnnotatedMSRun(MSExperiment&&) (move constructor).
  • The Cython .pxd now only exposes the default and copy constructors.
  • There are no in-repo calls to AnnotatedMSRun(MSExperiment) in .cpp, .h, .pxd, .pxy, or .pyx files.

Since this change only affects downstream Cython/Python users who relied on the AnnotatedMSRun(MSExperiment) constructor, please review any external code, update documentation, and ensure clients migrate to:

run = AnnotatedMSRun()
run.setMSExperiment(exp)
src/openms/include/OpenMS/METADATA/AnnotatedMSRun.h (2)

81-98: Setter methods are well-implemented and follow best practices.

The addition of both copy and move setter methods for protein identifications is appropriate and follows the same pattern as the existing peptide identification setters. This provides flexibility for callers and enables efficient move semantics when transferring ownership.


112-112: Good documentation update for clarity.

The comment now accurately reflects that this is the move version of the setter, which helps distinguish it from the copy version on line 119.

void assignRanks() except + nogil # wrap-doc:Sorts the protein hits by score and assigns ranks (best score has rank 1)



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.

💡 Verification agent

🧩 Analysis chain

Verify removal of assignRanks() method usage.

The removal of the assignRanks() method aligns with the interface simplification efforts mentioned in the PR. However, ensure that all code that previously used this method has been updated or that alternative ranking mechanisms are in place.


🏁 Script executed:

#!/bin/bash
# Search for any remaining usage of assignRanks method in the codebase
rg -n "assignRanks" --type cpp --type python

Length of output: 75


🏁 Script executed:

#!/bin/bash
# Search for any remaining usage of assignRanks method across all files
rg -n 'assignRanks' .

Length of output: 346


Fix remaining assignRanks() references in tests

The assignRanks() method has been removed (per CHANGELOG), but there are still calls in the unit tests. Please update or remove these to use the new ranking API (e.g., sorting by score) so tests compile and pass.

• src/pyOpenMS/tests/unittests/test000.py:
– Line 4350: PeptideIdentification.assignRanks
– Line 4409: pi.assignRanks()

Ensure the tests reflect the replacement ranking mechanism.

🤖 Prompt for AI Agents
In src/pyOpenMS/pxds/ProteinIdentification.pxd at line 58, there is no code
present, but the review indicates that references to the assignRanks() method
still exist in the codebase and tests. The assignRanks() method has been
removed, so update or remove all calls to this method in the tests and code,
replacing them with the new ranking approach such as sorting by score.
Specifically, in src/pyOpenMS/tests/unittests/test000.py at lines 4350 and 4409,
remove or replace the assignRanks() calls to ensure tests compile and pass with
the new ranking mechanism.

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