torchcell.sequence.calculate_window_bounds
- calculate_window_bounds(start: int, end: int, strand: str, window_size: int, chromosome_length: int) tuple[int, int][source]
Calculate the window bounds for genomic sequences.
This function calculates window bounds for genomic sequences while considering strand direction. It ensures the window does not exceed the chromosome length.
- Parameters:
- Returns:
The calculated start and end points of the window.
- Return type:
- Raises:
ValueError – If the strand is neither “+” nor “-”, if the end position is out of bounds of the chromosome, if the start position is greater than or equal to the end position, or if the window size is greater than the chromosome length.
Examples
>>> calculate_window_bounds(0, 20, "+", 40, 100) (0, 40) >>> calculate_window_bounds(5, 25, "+", 50, 100) (0, 50) >>> calculate_window_bounds(75, 95, "+", 50, 100) (50, 100) >>> calculate_window_bounds(0, 20, "-", 40, 100) (0, 40)