diff --git a/fgpyo/sam/__init__.py b/fgpyo/sam/__init__.py index 78c3386..395e842 100644 --- a/fgpyo/sam/__init__.py +++ b/fgpyo/sam/__init__.py @@ -572,11 +572,14 @@ def get_alignment_offsets(self, reverse: bool = False) -> Tuple[int, int]: elements = self.elements if not reverse else reversed(self.elements) for cig_el in elements: if cig_el.operator.is_clipping and not alignment_began: + # We are in the clipping operators preceding the alignment start_offset += cig_el.length_on_query end_offset += cig_el.length_on_query elif cig_el.operator.is_clipping: + # We have exited the alignment and are in the clipping operators after the alignment break else: + # We are within the alignment alignment_began = True end_offset += cig_el.length_on_query