Skip to content

Commit

Permalink
feat: Add reversed property to BedStrand
Browse files Browse the repository at this point in the history
  • Loading branch information
msto committed Apr 24, 2024
1 parent 972682b commit bd0776b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pybedlite/bed_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class BedStrand(enum.Enum):
Positive = "+"
Negative = "-"

@property
def reversed(self) -> BedStrand:
"""Return the opposite strand of the current strand."""
return BedStrand.Positive if self is BedStrand.Negative else BedStrand.Negative


@attr.s(frozen=True, auto_attribs=True, kw_only=True, slots=True)
class BedRecord:
Expand Down
8 changes: 8 additions & 0 deletions pybedlite/tests/test_pybedlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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


SNIPPET_BED = """\
Expand Down Expand Up @@ -203,3 +204,10 @@ def test_preopened_bed_writing(
record_number=i,
num_fields=bed_field_number,
)


def test_bedstrand_reversed() -> None:
"""Test that we can reverse a BedStrand."""

assert BedStrand.Positive.reversed is BedStrand.Negative
assert BedStrand.Negative.reversed is BedStrand.Positive

0 comments on commit bd0776b

Please sign in to comment.