# Path: hgvs/utils/norm.py
# def normalize_alleles(ref, start, stop, alleles, bound, ref_step, left, shuffle=True):
#     if left:
#         return normalize_alleles_left(ref, start, stop, alleles, bound, ref_step, shuffle)
#     else:
#         return normalize_alleles_right(ref, start, stop, alleles, bound, ref_step, shuffle)
# 
# Path: hgvs/exceptions.py
# class HGVSDataNotAvailableError(HGVSError):
#     pass
# 
# class HGVSUnsupportedOperationError(HGVSError):
#     pass
# 
# class HGVSInvalidVariantError(HGVSError):
#     """Exception raised when variant is inconsistent or invalid"""
#     pass


import copy
import logging
import hgvs
import hgvs.validator
import hgvs.variantmapper
from bioutils.sequences import reverse_complement
from hgvs.utils.norm import normalize_alleles
from hgvs.exceptions import HGVSDataNotAvailableError, HGVSUnsupportedOperationError, HGVSInvalidVariantError
                if stop < len(ref_seq) or start == orig_start:
                    break
                # if stop at the end of the window, try to extend the shuffling to the right
                base += start - orig_start
                stop -= start - orig_start
                start = orig_start

        elif self.shuffle_direction == 5:
            if var.posedit.edit.type == "ins":
                base = max(var.posedit.pos.start.base - win_size, 1)
                start = var.posedit.pos.end.base - base
                stop = var.posedit.pos.end.base - base
            elif var.posedit.edit.type == "dup":
                base = max(var.posedit.pos.start.base - win_size, 1)
                start = var.posedit.pos.end.base - base + 1
                stop = var.posedit.pos.end.base - base + 1
            else:
                base = max(var.posedit.pos.start.base - win_size, 1)
                start = var.posedit.pos.start.base - base
                stop = var.posedit.pos.end.base - base + 1

            while True:
                if base < boundary[0] + 1:
                    start -= boundary[0] + 1 - base
                    stop -= boundary[0] + 1 - base
                    base = boundary[0] + 1
                ref_seq = self._fetch_bounded_seq(var, base - 1, base + stop - 1, start, boundary)
                if ref_seq == "":
                    break
                orig_start, orig_stop = start, stop

# Path: hgvs/utils/norm.py
# def normalize_alleles(ref, start, stop, alleles, bound, ref_step, left, shuffle=True):
#     if left:
#         return normalize_alleles_left(ref, start, stop, alleles, bound, ref_step, shuffle)
#     else:
#         return normalize_alleles_right(ref, start, stop, alleles, bound, ref_step, shuffle)
# 
# Path: hgvs/exceptions.py
# class HGVSDataNotAvailableError(HGVSError):
#     pass
# 
# class HGVSUnsupportedOperationError(HGVSError):
#     pass
# 
# class HGVSInvalidVariantError(HGVSError):
#     """Exception raised when variant is inconsistent or invalid"""
#     pass


# Path: hgvs/normalizer.py
import copy
import logging
import hgvs
import hgvs.validator
import hgvs.variantmapper
from bioutils.sequences import reverse_complement
from hgvs.utils.norm import normalize_alleles
from hgvs.exceptions import HGVSDataNotAvailableError, HGVSUnsupportedOperationError, HGVSInvalidVariantError

                if stop < len(ref_seq) or start == orig_start:
                    break
                # if stop at the end of the window, try to extend the shuffling to the right
                base += start - orig_start
                stop -= start - orig_start
                start = orig_start

        elif self.shuffle_direction == 5:
            if var.posedit.edit.type == "ins":
                base = max(var.posedit.pos.start.base - win_size, 1)
                start = var.posedit.pos.end.base - base
                stop = var.posedit.pos.end.base - base
            elif var.posedit.edit.type == "dup":
                base = max(var.posedit.pos.start.base - win_size, 1)
                start = var.posedit.pos.end.base - base + 1
                stop = var.posedit.pos.end.base - base + 1
            else:
                base = max(var.posedit.pos.start.base - win_size, 1)
                start = var.posedit.pos.start.base - base
                stop = var.posedit.pos.end.base - base + 1

            while True:
                if base < boundary[0] + 1:
                    start -= boundary[0] + 1 - base
                    stop -= boundary[0] + 1 - base
                    base = boundary[0] + 1
                ref_seq = self._fetch_bounded_seq(var, base - 1, base + stop - 1, start, boundary)
                if ref_seq == "":
                    break
                orig_start, orig_stop = start, stop

                start, stop, (ref, alt) = normalize_alleles(ref_seq, start, stop, (ref, alt), 0,