Skip to content

Commit

Permalink
Introduce Comparable protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Oct 25, 2024
1 parent e420ded commit 9f358e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/aligntools/cigar_hit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from aligntools.coordinate_mapping import CoordinateMapping
from aligntools.cigar_actions import CigarActions
from aligntools.cigar import Cigar
from aligntools.comparable import Comparable
import aligntools.exceptions as ex


Expand Down Expand Up @@ -397,7 +398,7 @@ def __str__(self):


def drop_overlapping_cigar_hits(cigar_hits: Iterable[CigarHit],
quality: Callable[[CigarHit], int]) \
quality: Callable[[CigarHit], Comparable]) \
-> Iterator[CigarHit]:
"""
Filter overlapping CigarHit objects based on a quality criterion.
Expand Down
13 changes: 13 additions & 0 deletions src/aligntools/comparable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import Protocol, TypeVar, runtime_checkable

T = TypeVar('T', bound='Comparable')


@runtime_checkable
class Comparable(Protocol):
def __lt__(self, other: T) -> bool: ...
def __le__(self, other: T) -> bool: ...
def __gt__(self, other: T) -> bool: ...
def __ge__(self, other: T) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...

0 comments on commit 9f358e4

Please sign in to comment.