torchcell.sequence.calculate_window_bounds_symmetric
- calculate_window_bounds_symmetric(start: int, end: int, window_size: int, chromosome_length: int) tuple[int, int][source]
Calculate symmetric window bounds considering chromosome limits.
This function calculates symmetric window bounds for genomic sequences, taking the chromosome length into account to avoid exceeding it, and also ensuring that the window size, start and end positions are valid within these limits.
- Parameters:
- Returns:
The calculated start and end points of the symmetric window.
- Return type:
- Raises:
ValueError – If the end position is out of chromosome bounds, start position is not less than end position, or window size is greater than chromosome length.
Examples
>>> calculate_window_bounds_symmetric(5, 15, 30, 100) (0, 20) >>> calculate_window_bounds_symmetric(80, 95, 30, 100) (75, 100) >>> calculate_window_bounds_symmetric(45, 55, 30, 100) (35, 65)
Note
The function also asserts that the calculated window is within the desired limits, symmetric around the middle of the sequence, and the start and end of the window are appropriately bounded within the sequence limits.