Skip to content

Commit

Permalink
Allow the OverlapDetector to be generic over input feature types
Browse files Browse the repository at this point in the history
  • Loading branch information
clintval committed Jun 27, 2024
1 parent d547f16 commit a03bf2d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pybedlite/overlap_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def __iter__(self) -> Iterator[_GenericGenomicSpan]:
return itertools.chain(*self._refname_to_intervals.values())

@staticmethod
def _reference_name(interval: GenomicSpan) -> str:
def _reference_sequence_name(interval: GenomicSpan) -> str:
"""Return the reference name of a given interval."""
if isinstance(interval, Interval) or hasattr(interval, "refname"):
return interval.refname
Expand Down Expand Up @@ -264,7 +264,7 @@ def add(self, interval: _GenericGenomicSpan) -> None:
if not isinstance(interval, Hashable):
raise ValueError(f"Interval feature is not hashable but should be: {interval}")

refname = self._reference_name(interval)
refname = self._reference_sequence_name(interval)
if refname not in self._refname_to_tree:
self._refname_to_tree[refname] = cr.cgranges() # type: ignore
self._refname_to_indexed[refname] = False
Expand Down Expand Up @@ -302,7 +302,7 @@ def overlaps_any(self, interval: GenomicSpan) -> bool:
True if and only if the given interval overlaps with any interval in this
detector.
"""
refname = self._reference_name(interval)
refname = self._reference_sequence_name(interval)
tree = self._refname_to_tree.get(refname)
if tree is None:
return False
Expand All @@ -326,7 +326,7 @@ def get_overlaps(self, interval: GenomicSpan) -> List[_GenericGenomicSpan]:
The list of intervals in this detector that overlap the given interval, or the empty
list if no overlaps exist. The intervals will be return in ascending genomic order.
"""
refname = self._reference_name(interval)
refname = self._reference_sequence_name(interval)
tree = self._refname_to_tree.get(refname)
if tree is None:
return []
Expand All @@ -345,7 +345,7 @@ def get_overlaps(self, interval: GenomicSpan) -> List[_GenericGenomicSpan]:
intv.start,
intv.end,
self._is_negative(intv),
self._reference_name(intv),
self._reference_sequence_name(intv),
),
)

Expand Down

0 comments on commit a03bf2d

Please sign in to comment.