diff --git a/pybedlite/overlap_detector.py b/pybedlite/overlap_detector.py index 7759928..a35a9b5 100644 --- a/pybedlite/overlap_detector.py +++ b/pybedlite/overlap_detector.py @@ -281,20 +281,15 @@ def get_enclosed(self, interval: Interval) -> List[Interval]: @classmethod def from_bed(cls, path: Path) -> "OverlapDetector": - """Builds an :class:`~samwell.overlap_detector.OverlapDetector` from a BED file. + """Builds an :class:`~pybedlite.overlap_detector.OverlapDetector` from a BED file. Args: path: the path to the BED file Returns: An overlap detector for the regions in the BED file. """ detector = OverlapDetector() + for region in BedSource(path): - locatable = Interval( - refname=region.chrom, - start=region.start, - end=region.end, - negative=region.strand == BedStrand.Negative, - name=region.name, - ) - detector.add(locatable) + detector.add(Interval.from_bedrecord(region)) + return detector