Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SpectrumLookup example #471

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

add SpectrumLookup example #471

wants to merge 3 commits into from

Conversation

cbielow
Copy link
Contributor

@cbielow cbielow commented Apr 3, 2025

fixes #7526

Summary by CodeRabbit

  • Documentation
    • Enhanced the user guide to clearly explain efficient mass spectra filtering that avoids loading unnecessary data.
    • Clarified how scan number filtering works and its potential differences from vendor identifiers.
    • Introduced a new section on advanced filtering techniques with updated examples to help users apply native ID-based filtering.

Copy link

coderabbitai bot commented Apr 3, 2025

Walkthrough

The documentation for mass spectra filtering has been updated. The changes expand on the efficient use of PeakFileOptions by clarifying that unwanted data is not loaded into memory. A note now explains that scan numbers used for filtering are based on file indices rather than vendor scan numbers. Additionally, a new section titled "Advanced Filtering of NativeID via SpectrumLookup" has been introduced, featuring code examples that leverage the SpectrumLookup class and related method calls.

Changes

File Summary of Changes
docs/.../ms_data.rst Expanded explanation of PeakFileOptions memory efficiency; added a note on scan number origins from mzML files; introduced the "Advanced Filtering of NativeID via SpectrumLookup" section with new code examples using readSpectra(inp, "scan=(?<SCAN>\d+)") and findByScanNumber(v_scan_nrs)

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant API
    participant SpectrumLookup
    User->>API: Call readSpectra(inp, "scan=(?<SCAN>\\d+)")
    Note over API: Load spectra efficiently without unwanted data
    API->>SpectrumLookup: Invoke findByScanNumber(v_scan_nrs)
    SpectrumLookup-->>API: Return filtered spectra
    API-->>User: Deliver filtered MSExperiment data
Loading

Poem

I'm a bunny with a curious mind,
Hopping through docs that are newly refined.
Memory saved with each clever tweak,
SpectrumLookup secrets that we now seek.
With code and carrots, my joy's defined!
🐇🌸
Hop on and enjoy the rhyme of change!


📜 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 5698ab1 and 24b397a.

📒 Files selected for processing (1)
  • docs/source/user_guide/ms_data.rst (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/source/user_guide/ms_data.rst
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-test
  • GitHub Check: build-test

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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/ms_data.rst (2)

656-657: Spelling and Clarity in PeakFileOptions Explanation

The added text clarifies that unwanted data is not loaded into memory when using :py:class:~.PeakFileOptions. Please correct “chose” to “choose” to improve grammatical accuracy and consider a slight rephrase for clarity.


697-717: New SpectrumLookup Example Implementation

This example effectively demonstrates how to use the :py:class:~.SpectrumLookup class to extract spectra based on vendor scan numbers extracted from native IDs. A few points for improvement:

  • Regex Pattern Verification: The code uses the pattern "scan=(?<SCAN>\d+)". Note that in standard Python regex syntax, named groups are usually defined with (?P<SCAN>\d+). If the SpectrumLookup API specifically requires the <SCAN> syntax, it would be helpful to include a comment or reference to the documentation confirming this.
  • Variable Naming: In the loop, the variable v_scan_nrs represents a single scan number. Renaming it (e.g., to v_scan_nr) could improve clarity.
  • Example Consistency: The comment notes that the test.mzML file contains 4 spectra starting at scan=19, yet the example only processes scan numbers [19, 20]. Make sure that this example accurately represents the expected data set or add a clarifying comment if the intent is to filter a subset.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c9c4752 and 5698ab1.

📒 Files selected for processing (1)
  • docs/source/user_guide/ms_data.rst (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-test
  • GitHub Check: build-test
🔇 Additional comments (2)
docs/source/user_guide/ms_data.rst (2)

691-693: Clarification Note for Scan Numbers

The note explaining that the scan numbers correspond to the indices in the mzML file rather than the vendor scan numbers is useful. It provides important context, especially in cases where the data might have been previously sliced or filtered.


694-696: Section Title for SpectrumLookup Example

The new section title “Advanced Filtering of NativeID via SpectrumLookup” is clearly set off with the appropriate underline style and clearly signals the introduction of a new advanced filtering technique.

@cbielow cbielow requested a review from jpfeuffer April 4, 2025 06:21
# Bruker may have:
# <spectrum index="0" id="scan=19" defaultArrayLength="15">
# thus we can use (this would also work for Thermo native IDs)
lookup.readSpectra(inp, "scan=(?<SCAN>\d+)") ## required: creates an internal look-up table
Copy link
Contributor

Choose a reason for hiding this comment

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

I forgot but don't we autodetect between multiple regexes?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we do that in some downstream tools only by calling getRegexFromNativeId.

And we also have a default value for the regex in readSpectra for which the overload is missing in the pxd

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.

Filtering by Scan Number not working as intended?
2 participants