Skip to content

Conversation

@RalfG
Copy link
Member

@RalfG RalfG commented Oct 20, 2025

Add validation and exception raising for PSM and spectrum ID regex patterns:

  • Implemented _validate_regular_expressions function to check regex patterns in configuration.
  • Added tests for regex validation, covering valid, invalid, and edge cases.
  • Updated parse_psms and parse_spectra to apply ID patterns and handle errors accordingly.

…tterns

- Implemented _validate_regular_expressions function to check regex patterns in configuration.
- Added tests for regex validation, covering valid, invalid, and edge cases.
- Updated parse_psms and parse_spectra to apply ID patterns and handle errors accordingly.
@RalfG RalfG added this to the v3.2.0 milestone Oct 20, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Add stricter validation and application of regex patterns for PSM and spectrum IDs, with targeted exceptions and tests to prevent silent mismatches.

  • Add _validate_regular_expressions to validate regex syntax and ensure exactly one capturing group.
  • Apply psm_id_pattern early in parse_psms with invariant check on unique IDs; add spectrum ID remapping in parse_spectra with clearer configuration errors.
  • Add tests covering valid/invalid regex patterns and ID mapping edge cases.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_parse_spectra.py Adds factory and a new test for non-matching spectrum_id_pattern; updates expected exception types.
tests/test_parse_psms.py New tests verifying psm_id_pattern extraction and uniqueness-invariance errors.
tests/test_config_parser.py Adds tests for _validate_regular_expressions including valid, invalid, and edge cases.
ms2rescore/parse_spectra.py Introduces _apply_spectrum_id_pattern and integrates it into _get_precursor_values; refines exception types and messages.
ms2rescore/parse_psms.py Moves and strengthens psm_id_pattern handling with a uniqueness check; removes duplicate application later in the function.
ms2rescore/config_parser.py Implements _validate_regular_expressions and wires it into parse_configurations; minor import adjustments.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@RalfG RalfG requested a review from Copilot October 20, 2025 11:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@RalfG RalfG requested a review from Copilot October 20, 2025 11:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@RalfG RalfG merged commit e4f7a4b into main Oct 20, 2025
5 of 7 checks passed
@RalfG RalfG deleted the feature/add-regex-validation branch October 20, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants