schemarecomb.breakpoints.block_indices¶
- schemarecomb.breakpoints.block_indices(breakpoints, aln_len)¶
Get the blocks’ start and end indices given a list of breakpoints.
The start index is inclusive and the end index is exclusive, i.e. slice indexing. For example, if a block starts at 40 and ends at 83, a parent sequence can be sliced by these indices to result in a chimeric block as such: p2_block1 = parent2[40:83]. This also implies that the end index of this block is the start index of the next block, e.g. p2_block2 = parent2[83:132].
This function also handles the presence or absence of breakpoints at the zero position and alignment length position. These positions usually have fixed breakpoints (across all libraries) corresponding to the target vector that will hold the assembled chimera, but may be omitted depending on application. Regardless, this function will temporarily add breakpoint indices at the first and last positions (0 and aln_len) if necessary to correctly compute the chimeric blocks’ start and end indicies.
- Parameters
breakpoints (
list[BreakPoint]) – BreakPoints where the parent alignment is cut, usually comes from a library.aln_len (
int) – The length of the alignment. This is the end index of the last block, which may already be in breakpoints. Generally passed in as len(parents.alignment), where parents is a ParentSequences.
- Return type
list[tuple[int,int]]- Returns
The (start, end) indices of each chimeric block.
- Raises
ValueError – If breakpoints is empty.