Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate interval tree from cgranges to superintervals #42

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add failing unit test
TedBrookings committed Dec 3, 2024
commit 8ebed611b168b998225db96cf263ed782bf982b9
15 changes: 15 additions & 0 deletions pybedlite/tests/test_overlap_detector.py
Original file line number Diff line number Diff line change
@@ -384,3 +384,18 @@ def test_the_overlap_detector_can_be_built_from_a_bed_file(tmp_path: Path) -> No
detector: OverlapDetector[BedRecord] = OverlapDetector.from_bed(bed)
overlaps: List[BedRecord] = detector.get_overlaps(Interval("chr1", 1, 2))
assert overlaps == [BedRecord(chrom="chr1", start=1, end=2)]


def test_alternating_query_and_adding_intervals() -> None:
detector: OverlapDetector[Interval] = OverlapDetector()

query = Interval("1", 10, 15)
target1 = Interval("1", 10, 100, name="target1")
detector.add(target1)
# Test get_overlaps()
assert detector.get_overlaps(query) == [target1]

target2 = Interval("1", 11, 101, name="target2")
detector.add(target2)
# Test get_overlaps()
assert detector.get_overlaps(query) == [target1, target2]