Skip to content

Commit

Permalink
test: refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msto committed Jul 15, 2024
1 parent 38561e0 commit 2f0f545
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pybedlite/tests/test_overlap_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,23 +195,27 @@ def test_construction_from_interval(bed_records: List[BedRecord]) -> None:

def test_construction_from_ucsc() -> None:
"""
Test that we can convert a UCSC position to an Interval and back.
`Interval.from_ucsc()` should convert a UCSC position-formatted string to an `Interval`.
"""

assert Interval.from_ucsc("chr1:101-200") == Interval("chr1", 100, 200)
assert Interval.from_ucsc("chr10_GL383545v1_alt:101-200") == Interval(
"chr10_GL383545v1_alt", 100, 200
)

# Check strand
assert Interval.from_ucsc("chr1:101-200(+)") == Interval("chr1", 100, 200, negative=False)
assert Interval.from_ucsc("chr1:101-200(-)") == Interval("chr1", 100, 200, negative=True)

@pytest.mark.parametrize("strand", ["+", "-"])
def test_construction_from_ucsc_with_strand(strand: str) -> None:
"""
`Interval.from_ucsc()` should correctly parse UCSC position-formatted strings with strands.
"""
expected_interval = Interval("chr1", 100, 200, negative=(strand == "-"))
assert Interval.from_ucsc(f"chr1:101-200({strand})") == expected_interval


@pytest.mark.parametrize("contig", ["chrUn_JTFH01001499v1_decoy", "HLA-DRB1*15:01:01:02"])
@pytest.mark.parametrize(
"contig", ["chrUn_JTFH01001499v1_decoy", "HLA-DRB1*15:01:01:02", "chr10_GL383545v1_alt"]
)
def test_construction_from_ucsc_other_contigs(contig: str) -> None:
"""
Test that we can construct an interval with non-human/decoy/custom/other contig names
`Interval.from_ucsc()` should accomodate non-human, decoy, custom, and other contig names.
"""

assert Interval.from_ucsc(f"{contig}:101-200") == Interval(contig, 100, 200)

0 comments on commit 2f0f545

Please sign in to comment.