Skip to content

Conversation

@cbielow
Copy link
Contributor

@cbielow cbielow commented Jul 31, 2025

fixes OpenMS/OpenMS#8139

Summary by CodeRabbit

  • Documentation
    • Updated the user guide to clarify the creation and usage of an empty MSExperiment object in code examples, and revised method arguments for improved clarity.

@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 2025

Walkthrough

A code snippet in the user guide was updated to explicitly create an empty MSExperiment object named spectra and pass it as a positional argument to the IDMapper.annotate method, replacing the previous use of spectra=None and keyword arguments.

Changes

Cohort / File(s) Change Summary
User Guide Example Update
docs/source/user_guide/PSM_to_features.rst
Modified code example to instantiate an empty MSExperiment object and pass it positionally to IDMapper.annotate, replacing keyword arguments and spectra=None.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MSExperiment
    participant IDMapper

    User->>MSExperiment: Create empty instance (spectra)
    User->>IDMapper: annotate(feature_map, peptide_ids, protein_ids, True, True, spectra)
    IDMapper->>MSExperiment: Uses spectra for annotation
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Assessment against linked issues

Objective Addressed Explanation
Update tutorial code to avoid error in IDMapper.annotate by passing a valid MSExperiment instance instead of None (#8139)

Suggested reviewers

  • timosachsenberg

Poem

The guide now shines with code anew,
An empty spectra joins the crew!
No more errors, just smooth delight,
As features map and peptides write.
A hop, a skip, a doc improved—
This bunny’s whiskers are quite moved! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 78d6024 and 33c7a02.

📒 Files selected for processing (1)
  • docs/source/user_guide/PSM_to_features.rst (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/source/user_guide/PSM_to_features.rst
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cbielow-patch-1

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 generate unit tests to generate unit tests for 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/source/user_guide/PSM_to_features.rst (2)

72-73: Add a brief explanation for creating an empty MSExperiment

The snippet now instantiates spectra = oms.MSExperiment() solely to satisfy the type requirement of IDMapper.annotate. A short inline comment (e.g., # empty experiment required by annotate) or a one-sentence note above the cell would help readers understand why this seemingly unused object is necessary.


73-73: Positional flags reduce readability; leave a reminder to revert to keywords

Switching to positional arguments (True, True, spectra) works around the current binding issue but obscures the meaning of each flag and ties the example to the exact parameter order. Consider adding a TODO comment indicating that, once the pyOpenMS binding accepts keyword arguments again, the call should be restored to a clearer form:

# TODO: switch back once fixed upstream
# id_mapper.annotate(feature_map, peptide_ids, protein_ids,
#                    use_centroid_rt=True, use_centroid_mz=True, spectra=spectra)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fbdfcac and 78d6024.

📒 Files selected for processing (1)
  • docs/source/user_guide/PSM_to_features.rst (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-test
  • GitHub Check: build-test

Copy link
Contributor

Choose a reason for hiding this comment

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

[blacken-docs] reported by reviewdog 🐶

Feature Map Annotation with Peptide Identifications
===================================================
A :term:`feature map` is usually obtained from running a :term:`feature finder`, e.g. :py:class:`~.FeatureFinderAlgorithmPicked` (see `Feature Detection <feature_detection.html>`_).
A logical next step is to compare features across runs using `Map Alignment <map_alignment.html>`_ and `Feature Linking <feature_linking.html>`_.
However, most map aligners in pyOpenMS require features which are annotated with PSMs (see `Identication Data <identification_data.html>`_).
To link features to their respective PSMs (as obtained from a search engine, such as Comet), we can use the :py:class:`~.IDMapper`.
Step 0: Download Example data
-----------------------------
.. code-block:: python
:linenos:
import pyopenms as oms
from urllib.request import urlretrieve
base_url = (
"https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master/src/data/"
)
feature_file = "BSA1_F1.featureXML"
urlretrieve(base_url + feature_file, feature_file)
idxml_file = "BSA1_F1.idXML"
urlretrieve(base_url + idxml_file, idxml_file)
Step 1: Load the Feature Map
----------------------------
First, load the FeatureMap from a `.featureXML` file:
.. code-block:: python
import pyopenms as oms
feature_map = oms.FeatureMap()
oms.FeatureXMLFile().load(feature_file, feature_map)
Step 2: Load Peptide Identifications
------------------------------------
Next, load the PeptideIdentifications from an `.idXML` file:
.. code-block:: python
peptide_ids = []
protein_ids = []
oms.IdXMLFile().load(idxml_file, protein_ids, peptide_ids)
Step 3: Initialize and Configure `IDMapper`
-------------------------------------------
Now, configure `IDMapper` to apply **retention time (RT) and m/z tolerance settings**:
.. code-block:: python
id_mapper = oms.IDMapper()
params = id_mapper.getParameters()
params.setValue("rt_tolerance", 5.0) # RT tolerance in seconds
params.setValue("mz_tolerance", 10.0) # m/z tolerance in ppm
id_mapper.setParameters(params)
Step 4: Annotate the FeatureMap
-------------------------------
Use the configured `IDMapper` to link peptide IDs to the FeatureMap:
.. code-block:: python
# annotate() can optionally use the underlying raw MS data (spectra) to annotate unidentified MS/MS scans to features in the FeatureMap
# We don't need this here, so we provide an empty default.
spectra = oms.MSExperiment()
id_mapper.annotate(feature_map, peptide_ids, protein_ids, True, True, spectra)
Step 5: Save the Annotated FeatureMap
--------------------------------------
Finally, store the modified FeatureMap back to a file:
.. code-block:: python
oms.FeatureXMLFile().store("BSA1_F1_annotated.featureXML", feature_map)
.. tip::
You can visualize the annotated FeatureMap using OpenMS visualization tools like `TOPPView`.
You have successfully **annotated a FeatureMap** with PeptideIdentifications using `IDMapper`. This allows further downstream analysis in (py)OpenMS workflows.

@cbielow cbielow merged commit 275bf95 into master Jul 31, 2025
6 checks passed
@cbielow cbielow deleted the cbielow-patch-1 branch July 31, 2025 09:58
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.

FeatureMap annotation can not handle FeatureMapDF

2 participants