Skip to content

Commit

Permalink
Introduce CigarLike type
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Oct 23, 2024
1 parent bd5840c commit 718c7da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/aligntools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .coordinate_mapping import CoordinateMapping
from .int_dict import FrozenIntDict
from .cigar_actions import CigarActions
from .cigar import Cigar
from .cigar import Cigar, CigarLike

__all__ = [
'CigarError',
Expand All @@ -22,4 +22,5 @@
'connect_cigar_hits',
'CoordinateMapping',
'FrozenIntDict',
'CigarLike',
]
5 changes: 4 additions & 1 deletion src/aligntools/cigar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import aligntools.exceptions as ex


CigarLike = Union['Cigar', str, Iterable[Tuple[int, CigarActions]]]


class Cigar:
"""
Represents an alignment between a query sequence and a reference
Expand Down Expand Up @@ -42,7 +45,7 @@ def __init__(self, data: Iterable[Tuple[int, CigarActions]]) -> None:
= tuple(Cigar.normalize(data))

@staticmethod
def coerce(obj: Union['Cigar', str, Iterable[Tuple[int, CigarActions]]]) \
def coerce(obj: CigarLike) \
-> 'Cigar':
if isinstance(obj, Cigar):
return obj
Expand Down

0 comments on commit 718c7da

Please sign in to comment.