diff --git a/src/aligntools/__init__.py b/src/aligntools/__init__.py index 12dbbaa..886395d 100644 --- a/src/aligntools/__init__.py +++ b/src/aligntools/__init__.py @@ -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', @@ -22,4 +22,5 @@ 'connect_cigar_hits', 'CoordinateMapping', 'FrozenIntDict', + 'CigarLike', ] diff --git a/src/aligntools/cigar.py b/src/aligntools/cigar.py index 7ccfec7..505521d 100644 --- a/src/aligntools/cigar.py +++ b/src/aligntools/cigar.py @@ -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 @@ -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