Skip to content

Commit

Permalink
Add method is_clipping to CigarOp (#54)
Browse files Browse the repository at this point in the history
* Added is_clipping() to CigarOp
  • Loading branch information
kockan authored Aug 28, 2023
1 parent 0289d8d commit 42d8ead
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fgpyo/sam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ def is_indel(self) -> bool:
"""Returns true if the operator is an indel, false otherwise."""
return self == CigarOp.I or self == CigarOp.D

@property
def is_clipping(self) -> bool:
"""Returns true if the operator is a soft/hard clip, false otherwise."""
return self == CigarOp.S or self == CigarOp.H


@attr.s(frozen=True, slots=True)
class CigarElement:
Expand Down
3 changes: 3 additions & 0 deletions fgpyo/sam/tests/test_sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ def test_is_indel() -> None:
indels = [op for op in CigarOp if op.is_indel]
assert indels == [CigarOp.I, CigarOp.D]

def test_is_clipping() -> None:
clips = [op for op in CigarOp if op.is_clipping]
assert clips == [CigarOp.S, CigarOp.H]

def test_isize() -> None:
builder = SamBuilder()
Expand Down

0 comments on commit 42d8ead

Please sign in to comment.