"""
Auto-generated residue definitions.

DO NOT EDIT MANUALLY - Generated by ciffy/src/codegen/generate.py

To modify residues, edit ciffy/biochemistry/definitions.py and run:
    python ciffy/src/codegen/generate.py
"""

from ..utils import IndexEnum
from ..types import Molecule


class Residue(IndexEnum):
    """
    Residue types with unique integer indices.
    
    Includes nucleotides (RNA and DNA), amino acids, water, and ions.
    """

    ADE = 0  # Adenosine
    CYT = 1  # Cytosine
    GUA = 2  # Guanosine
    URA = 3  # Uridine
    DA = 4  # Deoxyadenosine
    DC = 5  # Deoxycytidine
    DG = 6  # Deoxyguanosine
    DT = 7  # Thymidine
    ALA = 8  # Alanine
    CYS = 9  # Cysteine
    ASP = 10  # AsparticAcid
    GLU = 11  # GlutamicAcid
    PHE = 12  # Phenylalanine
    GLY = 13  # Glycine
    HIS = 14  # Histidine
    ILE = 15  # Isoleucine
    LYS = 16  # Lysine
    LEU = 17  # Leucine
    MET = 18  # Methionine
    ASN = 19  # Asparagine
    PRO = 20  # Proline
    GLN = 21  # Glutamine
    ARG = 22  # Arginine
    SER = 23  # Serine
    THR = 24  # Threonine
    VAL = 25  # Valine
    TRP = 26  # Tryptophan
    TYR = 27  # Tyrosine
    HOH = 28  # Water
    MG = 29  # Magnesium
    CS = 30  # Cesium
    GTP = 31  # GuanosineTriphosphate
    CCC = 32  # CytidineTriphosphate
    GNG = 33  # Deoxyguanosine2Prime


# Mapping from residue index to molecule type
RESIDUE_MOLECULE_TYPE: dict[int, Molecule] = {
    0: Molecule.RNA,  # ADE
    1: Molecule.RNA,  # CYT
    2: Molecule.RNA,  # GUA
    3: Molecule.RNA,  # URA
    4: Molecule.DNA,  # DA
    5: Molecule.DNA,  # DC
    6: Molecule.DNA,  # DG
    7: Molecule.DNA,  # DT
    8: Molecule.PROTEIN,  # ALA
    9: Molecule.PROTEIN,  # CYS
    10: Molecule.PROTEIN,  # ASP
    11: Molecule.PROTEIN,  # GLU
    12: Molecule.PROTEIN,  # PHE
    13: Molecule.PROTEIN,  # GLY
    14: Molecule.PROTEIN,  # HIS
    15: Molecule.PROTEIN,  # ILE
    16: Molecule.PROTEIN,  # LYS
    17: Molecule.PROTEIN,  # LEU
    18: Molecule.PROTEIN,  # MET
    19: Molecule.PROTEIN,  # ASN
    20: Molecule.PROTEIN,  # PRO
    21: Molecule.PROTEIN,  # GLN
    22: Molecule.PROTEIN,  # ARG
    23: Molecule.PROTEIN,  # SER
    24: Molecule.PROTEIN,  # THR
    25: Molecule.PROTEIN,  # VAL
    26: Molecule.PROTEIN,  # TRP
    27: Molecule.PROTEIN,  # TYR
    28: Molecule.WATER,  # HOH
    29: Molecule.ION,  # MG
    30: Molecule.ION,  # CS
    31: Molecule.RNA,  # GTP
    32: Molecule.RNA,  # CCC
    33: Molecule.DNA,  # GNG
}

# CIF residue names -> Residue index (for parsing)
CIF_RESIDUE_NAMES: dict[str, int] = {
    "A": 0,  # ADE
    "C": 1,  # CYT
    "G": 2,  # GUA
    "U": 3,  # URA
    "DA": 4,  # DA
    "DC": 5,  # DC
    "DG": 6,  # DG
    "DT": 7,  # DT
    "T": 7,  # DT
    "ALA": 8,  # ALA
    "CYS": 9,  # CYS
    "ASP": 10,  # ASP
    "GLU": 11,  # GLU
    "PHE": 12,  # PHE
    "GLY": 13,  # GLY
    "HIS": 14,  # HIS
    "ILE": 15,  # ILE
    "LYS": 16,  # LYS
    "LEU": 17,  # LEU
    "MET": 18,  # MET
    "ASN": 19,  # ASN
    "PRO": 20,  # PRO
    "GLN": 21,  # GLN
    "ARG": 22,  # ARG
    "SER": 23,  # SER
    "THR": 24,  # THR
    "VAL": 25,  # VAL
    "TRP": 26,  # TRP
    "TYR": 27,  # TYR
    "HOH": 28,  # HOH
    "MG": 29,  # MG
    "CS": 30,  # CS
    "GTP": 31,  # GTP
    "CCC": 32,  # CCC
    "GNG": 33,  # GNG
}

# Residue index -> CIF output name (for writing)
RESIDUE_CIF_NAMES: dict[int, str] = {
    0: "A",  # ADE
    1: "C",  # CYT
    2: "G",  # GUA
    3: "U",  # URA
    4: "DA",  # DA
    5: "DC",  # DC
    6: "DG",  # DG
    7: "DT",  # DT
    8: "ALA",  # ALA
    9: "CYS",  # CYS
    10: "ASP",  # ASP
    11: "GLU",  # GLU
    12: "PHE",  # PHE
    13: "GLY",  # GLY
    14: "HIS",  # HIS
    15: "ILE",  # ILE
    16: "LYS",  # LYS
    17: "LEU",  # LEU
    18: "MET",  # MET
    19: "ASN",  # ASN
    20: "PRO",  # PRO
    21: "GLN",  # GLN
    22: "ARG",  # ARG
    23: "SER",  # SER
    24: "THR",  # THR
    25: "VAL",  # VAL
    26: "TRP",  # TRP
    27: "TYR",  # TYR
    28: "HOH",  # HOH
    29: "MG",  # MG
    30: "CS",  # CS
    31: "GTP",  # GTP
    32: "CCC",  # CCC
    33: "GNG",  # GNG
}

# Residue index -> single-letter abbreviation
RESIDUE_ABBREV: dict[int, str] = {
    0: "a",  # ADE
    1: "c",  # CYT
    2: "g",  # GUA
    3: "u",  # URA
    4: "a",  # DA
    5: "c",  # DC
    6: "g",  # DG
    7: "t",  # DT
    8: "A",  # ALA
    9: "C",  # CYS
    10: "D",  # ASP
    11: "E",  # GLU
    12: "F",  # PHE
    13: "G",  # GLY
    14: "H",  # HIS
    15: "I",  # ILE
    16: "K",  # LYS
    17: "L",  # LEU
    18: "M",  # MET
    19: "N",  # ASN
    20: "P",  # PRO
    21: "Q",  # GLN
    22: "R",  # ARG
    23: "S",  # SER
    24: "T",  # THR
    25: "V",  # VAL
    26: "W",  # TRP
    27: "Y",  # TYR
    28: "~",  # HOH
    29: "~",  # MG
    30: "~",  # CS
    31: "g",  # GTP
    32: "c",  # CCC
    33: "g",  # GNG
}
