Skip to content

Commit

Permalink
chore: add one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
clintval committed Dec 30, 2024
1 parent 5cb47f5 commit 2b4197c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/fgpyo/sam/test_secondary_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,21 @@ def test_many_from_rec_returns_no_secondaries_when_unmapped() -> None:
builder = SamBuilder()
rec = builder.add_single()
assert rec.is_unmapped
assert len(list(SecondaryAlignment.many_sam_from_rec(rec))) == 0
assert len(list(SecondaryAlignment.many_from_rec(rec))) == 0


def test_many_from_rec_raises_with_more_context_when_fails() -> None:
"""Test that many_from_rec raises exceptions with more context when it fails to parse."""
invalid_value: str = "chr9,104599381,49M,4"
builder = SamBuilder()
rec = builder.add_single(name="hi-mom")
rec.set_tag("XA", invalid_value)

with pytest.raises(
ValueError,
match="Could not parse secondary alignments for read: hi-mom",
):
SecondaryAlignment.many_from_rec(rec)


def test_xa_many_from_rec() -> None:
Expand Down Expand Up @@ -303,6 +317,14 @@ def test_xb_many_from_rec() -> None:
]


def test_many_sam_from_rec_returns_no_secondaries_when_unmapped() -> None:
"""Test that many_sam_from_rec returns no secondaries when unmapped."""
builder = SamBuilder()
rec = builder.add_single()
assert rec.is_unmapped
assert len(list(SecondaryAlignment.many_sam_from_rec(rec))) == 0


def test_xa_many_sam_from_rec() -> None:
"""Test that we return secondary alignments as SAM records from a record with multiple XAs."""
value: str = "chr9,-104599381,49M,4;chr3,+170653467,49M,4;;;" # with trailing ';'
Expand Down

0 comments on commit 2b4197c

Please sign in to comment.