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



import attr
from hgvs.exceptions import HGVSUnsupportedOperationError
from hgvs.enums import ValidationLevel
        is raised; when False, the exception is caught and `None` is
        returned.  Callers might wish to pass `on_error_raise=False`
        in list comprehensions to avoid dealing with exceptions.

        """

        try:
            ilen = self.pos._length()
            (del_len, ins_len) = self.edit._del_ins_lengths(ilen)
            return ins_len - del_len
        except HGVSUnsupportedOperationError:
            if on_error_raise:
                raise
            return None

    def validate(self):
        if self.pos:
            (res, msg) = self.pos.validate()
            if res != ValidationLevel.VALID:
                return (res, msg)
            try:
                # Check ins length is 1
                if self.edit.type == "ins" and self.pos.end - self.pos.start != 1:
                    return (ValidationLevel.ERROR, "insertion length must be 1")
                # Check del length
                if self.edit.type in ["del", "delins"]:
                    ref_len = self.edit.ref_n
                    if ref_len is not None and ref_len != self.pos.end - self.pos.start + 1:
                        return (ValidationLevel.ERROR,
                                "Length implied by coordinates must equal sequence deletion length")

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



# Path: hgvs/posedit.py
import attr
from hgvs.exceptions import HGVSUnsupportedOperationError
from hgvs.enums import ValidationLevel

        is raised; when False, the exception is caught and `None` is
        returned.  Callers might wish to pass `on_error_raise=False`
        in list comprehensions to avoid dealing with exceptions.

        """

        try:
            ilen = self.pos._length()
            (del_len, ins_len) = self.edit._del_ins_lengths(ilen)
            return ins_len - del_len
        except HGVSUnsupportedOperationError:
            if on_error_raise:
                raise
            return None

    def validate(self):
        if self.pos:
            (res, msg) = self.pos.validate()
            if res != ValidationLevel.VALID:
                return (res, msg)
            try:
                # Check ins length is 1
                if self.edit.type == "ins" and self.pos.end - self.pos.start != 1:
                    return (ValidationLevel.ERROR, "insertion length must be 1")
                # Check del length
                if self.edit.type in ["del", "delins"]:
                    ref_len = self.edit.ref_n
                    if ref_len is not None and ref_len != self.pos.end - self.pos.start + 1:
                        return (ValidationLevel.ERROR,
                                "Length implied by coordinates must equal sequence deletion length")

            except HGVSUnsupportedOperationError as err: