# Path: hgvs/enums.py

# 
# Path: hgvs/utils/validation.py
# def validate_type_ac_pair(type, ac):
#     """validate that accession is correct for variant type AND that
#     accession is fully specified.
# 
#     """
# 
#     assert type in valid_pairs, "Unknown variant type " + type
#     if valid_pairs[type].match(ac):
#         return (ValidationLevel.VALID,
#                 "Accession ({ac}) is compatible with variant type {type}".format(ac=ac, type=type))
#     elif invalid_pairs[type].match(ac):
#         return (ValidationLevel.ERROR,
#                 "Accession ({ac}) is not compatible with variant type {type}".format(
#                     ac=ac, type=type))
#     else:
#         return (ValidationLevel.WARNING,
#                 "Accession ({ac}) is not known to be compatible with variant type {type}".format(
#                     ac=ac, type=type))


import attr
import re
import hgvs.variantmapper
from hgvs.enums import ValidationLevel
from hgvs.utils.validation import validate_type_ac_pair
    def __repr__(self):
        return "{0}({1})".format(
            self.__class__.__name__, ", ".join(
                (a.name + "=" + str(getattr(self, a.name))) for a in self.__attrs_attrs__))

    def fill_ref(self, hdp):
        # TODO: Refactor. SVs should not operate on themselves when
        # external resources are required
        # replace_reference should be moved outside function
        vm = hgvs.variantmapper.VariantMapper(hdp)
        type = None
        if isinstance(self.posedit, hgvs.posedit.PosEdit) and isinstance(
                self.posedit.edit, hgvs.edit.Edit):
            type = self.posedit.edit.type
        if type in ["del", "delins", "identity", "dup", "repeat"
                    ] and self.posedit.edit.ref_s is None:
            vm._replace_reference(self)
        if type == "identity" and isinstance(self.posedit.edit, hgvs.edit.NARefAlt):
            self.posedit.edit.alt = self.posedit.edit.ref
        return self

    def validate(self):
        (res, msg) = (ValidationLevel.VALID, None)
        if self.ac and self.type:
            (res, msg) = validate_type_ac_pair(self.type, self.ac)
            if res == ValidationLevel.ERROR:
                return (res, msg)
        if self.posedit is None:
            return (res, msg)
        (pe_res, pe_msg) = self.posedit.validate()

# Path: hgvs/enums.py

# 
# Path: hgvs/utils/validation.py
# def validate_type_ac_pair(type, ac):
#     """validate that accession is correct for variant type AND that
#     accession is fully specified.
# 
#     """
# 
#     assert type in valid_pairs, "Unknown variant type " + type
#     if valid_pairs[type].match(ac):
#         return (ValidationLevel.VALID,
#                 "Accession ({ac}) is compatible with variant type {type}".format(ac=ac, type=type))
#     elif invalid_pairs[type].match(ac):
#         return (ValidationLevel.ERROR,
#                 "Accession ({ac}) is not compatible with variant type {type}".format(
#                     ac=ac, type=type))
#     else:
#         return (ValidationLevel.WARNING,
#                 "Accession ({ac}) is not known to be compatible with variant type {type}".format(
#                     ac=ac, type=type))


# Path: hgvs/sequencevariant.py
import attr
import re
import hgvs.variantmapper
from hgvs.enums import ValidationLevel
from hgvs.utils.validation import validate_type_ac_pair

    def __repr__(self):
        return "{0}({1})".format(
            self.__class__.__name__, ", ".join(
                (a.name + "=" + str(getattr(self, a.name))) for a in self.__attrs_attrs__))

    def fill_ref(self, hdp):
        # TODO: Refactor. SVs should not operate on themselves when
        # external resources are required
        # replace_reference should be moved outside function
        vm = hgvs.variantmapper.VariantMapper(hdp)
        type = None
        if isinstance(self.posedit, hgvs.posedit.PosEdit) and isinstance(
                self.posedit.edit, hgvs.edit.Edit):
            type = self.posedit.edit.type
        if type in ["del", "delins", "identity", "dup", "repeat"
                    ] and self.posedit.edit.ref_s is None:
            vm._replace_reference(self)
        if type == "identity" and isinstance(self.posedit.edit, hgvs.edit.NARefAlt):
            self.posedit.edit.alt = self.posedit.edit.ref
        return self

    def validate(self):
        (res, msg) = (ValidationLevel.VALID, None)
        if self.ac and self.type:
            (res, msg) = validate_type_ac_pair(self.type, self.ac)
            if res == ValidationLevel.ERROR:
                return (res, msg)
        if self.posedit is None:
            return (res, msg)
        (pe_res, pe_msg) = self.posedit.validate()

        if pe_res == ValidationLevel.VALID: