Fix: Improve validation in _handle_region_coords #1183
Open
vinitjain2005 wants to merge 3 commits intomalariagen:masterfrom
Open
Fix: Improve validation in _handle_region_coords #1183vinitjain2005 wants to merge 3 commits intomalariagen:masterfrom
vinitjain2005 wants to merge 3 commits intomalariagen:masterfrom
Conversation
Author
|
@jonbrenas @tristanpwdennis please verify and merge the issue |
jonbrenas
approved these changes
Mar 22, 2026
Refactor error messages for clarity and consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR enhances the validation and error handling in the
_handle_region_coordsfunction, ensuring robust parsing of genomic region strings.Changes Made:
Implemented strict regex validation for region format (
contig:start-end)Added type checking for the
regioninputImproved error messages for better debugging
Removed silent failure (
Nonereturn) and replaced with explicit exceptionsAdded logical validation:
Added validation to ensure the contig exists
Added boundary checks against contig length
Before vs After:
Before:
NonesilentlyAfter:
Testing:
Tested with valid input:
"chr1:100-200"Tested invalid inputs:
"chr1-100-200""chr1:abc-xyz""chr1:200-100"All invalid cases now raise appropriate exceptions
Impact:
Improves reliability and prevents incorrect genomic region parsing, reducing the risk of downstream errors.
Related Issue:
Closes #1182
Github: @vinitjain2005