# Path: hgvs/exceptions.py
# class HGVSInvalidIntervalError(HGVSError):
#     pass


import re
from hgvs.exceptions import HGVSInvalidIntervalError

    def __repr__(self):
        return f"CIGARMapper(cigar='{self.cigar}')"


    @property
    def ref_len(self):
        return self.ref_pos[-1]


    @property
    def tgt_len(self):
        return self.tgt_pos[-1]


    def map_ref_to_tgt(self, pos, end, strict_bounds=True):
        return self._map(from_pos=self.ref_pos, to_pos=self.tgt_pos, pos=pos, end=end, strict_bounds=strict_bounds)


    def map_tgt_to_ref(self, pos, end, strict_bounds=True):
        return self._map(from_pos=self.tgt_pos, to_pos=self.ref_pos, pos=pos, end=end, strict_bounds=strict_bounds)


    def _map(self, from_pos, to_pos, pos, end, strict_bounds):
        """Map position between aligned segments

        Positions in this function are 0-based, base-counting. 
        """

        if strict_bounds and (pos < 0 or pos > from_pos[-1]):

# Path: hgvs/exceptions.py
# class HGVSInvalidIntervalError(HGVSError):
#     pass


# Path: hgvs/utils/cigarmapper.py
import re
from hgvs.exceptions import HGVSInvalidIntervalError


    def __repr__(self):
        return f"CIGARMapper(cigar='{self.cigar}')"


    @property
    def ref_len(self):
        return self.ref_pos[-1]


    @property
    def tgt_len(self):
        return self.tgt_pos[-1]


    def map_ref_to_tgt(self, pos, end, strict_bounds=True):
        return self._map(from_pos=self.ref_pos, to_pos=self.tgt_pos, pos=pos, end=end, strict_bounds=strict_bounds)


    def map_tgt_to_ref(self, pos, end, strict_bounds=True):
        return self._map(from_pos=self.tgt_pos, to_pos=self.ref_pos, pos=pos, end=end, strict_bounds=strict_bounds)


    def _map(self, from_pos, to_pos, pos, end, strict_bounds):
        """Map position between aligned segments

        Positions in this function are 0-based, base-counting. 
        """

        if strict_bounds and (pos < 0 or pos > from_pos[-1]):

            raise HGVSInvalidIntervalError("Position is beyond the bounds of transcript record")