Skip to content

Commit

Permalink
refactor: extract BedStrand to avoid circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
msto committed Mar 8, 2024
1 parent 18bc1c2 commit 931d569
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pybedlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
from pybedlite.bed_source import BedSource
from pybedlite.bed_source import BedPath
from pybedlite.bed_record import BedRecord
from pybedlite.bed_record import BedStrand
from pybedlite.bed_strand import BedStrand


def reader(path: BedPath) -> "BedSource":
Expand Down
7 changes: 1 addition & 6 deletions pybedlite/bed_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@
from typing import Type

from pybedlite.overlap_detector import Interval
from pybedlite.bed_strand import BedStrand


"""Maximum BED fields that can be present in a well formed BED file written to specification"""
MAX_BED_FIELDS: int = 12


@enum.unique
class BedStrand(enum.Enum):
Positive = "+"
Negative = "-"


@attr.s(frozen=True, auto_attribs=True, kw_only=True, slots=True)
class BedRecord:
"""Lightweight class for storing BED records. A more comprehensive description of BED format
Expand Down
3 changes: 2 additions & 1 deletion pybedlite/bed_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- :class:`~pybedtools.bed_source.BedSource` -- Reader class for parsing BED files and iterate
over their contained records
"""

import io
from typing import IO
from typing import Optional
Expand All @@ -27,7 +28,7 @@
from typing import Dict
from typing import Any

from pybedlite.bed_record import BedStrand
from pybedlite.bed_strand import BedStrand
from pybedlite.bed_record import BedRecord

"""The classes that should be treated as file-like classes"""
Expand Down
11 changes: 11 additions & 0 deletions pybedlite/bed_strand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
The BedStrand enum.
"""

import enum


@enum.unique
class BedStrand(enum.Enum):
Positive = "+"
Negative = "-"
2 changes: 1 addition & 1 deletion pybedlite/overlap_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import attr
import cgranges as cr

from pybedlite.bed_record import BedStrand
from pybedlite.bed_strand import BedStrand
from pybedlite.bed_source import BedSource


Expand Down
2 changes: 1 addition & 1 deletion pybedlite/tests/test_pybedlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pybedlite.bed_writer import BedWriter
from pybedlite.bed_source import BedSource
from pybedlite.bed_record import BedRecord
from pybedlite.bed_record import BedStrand
from pybedlite.bed_strand import BedStrand


@pytest.fixture
Expand Down

0 comments on commit 931d569

Please sign in to comment.