"use strict";
/**
 * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
 *
 * @author Alexander Rose <alexander.rose@weirdbyte.de>
 * @author David Sehnal <david.sehnal@gmail.com>
 */
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultResidueHydrophobicity = exports.ResidueHydrophobicity = exports.BondType = exports.DefaultMaxAsa = exports.MaxAsa = exports.SecondaryStructureType = exports.isProtein = exports.isNucleic = exports.isPolymer = exports.getEntitySubtype = exports.getEntityType = exports.getDefaultChemicalComponent = exports.getComponentType = exports.getPolymerType = exports.getMoleculeType = exports.PolymerNames = exports.isPyrimidineBase = exports.isPurineBase = exports.BaseNames = exports.PyrimidineBaseNames = exports.PurineBaseNames = exports.PeptideBaseNames = exports.DnaBaseNames = exports.RnaBaseNames = exports.AminoAcidNames = exports.AminoAcidNamesD = exports.AminoAcidNamesL = exports.WaterNames = exports.LipidComponentTypeNames = exports.IonComponentTypeNames = exports.OtherComponentTypeNames = exports.SaccharideComponentTypeNames = exports.RNAComponentTypeNames = exports.DNAComponentTypeNames = exports.ProteinComponentTypeNames = exports.OtherProteinComponentTypeNames = exports.ProteinTerminusComponentTypeNames = exports.BetaProteinComponentTypeNames = exports.GammaProteinComponentTypeNames = exports.LProteinComponentTypeNames = exports.DProteinComponentTypeNames = exports.NucleicBackboneAtoms = exports.ProteinBackboneAtoms = exports.PolymerTypeAtomRoleId = exports.getElementFromAtomicNumber = exports.ElementSymbol = void 0;
var bit_flags_1 = require("../../../mol-util/bit-flags");
var constants_1 = require("../structure/carbohydrates/constants");
var set_1 = require("../../../mol-util/set");
var lipids_1 = require("./types/lipids");
var ions_1 = require("./types/ions");
var _esCache = (function () {
    var cache = Object.create(null);
    var letters = [];
    for (var i = 'A'.charCodeAt(0); i <= 'Z'.charCodeAt(0); i++)
        letters[letters.length] = String.fromCharCode(i);
    for (var i = 'a'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++)
        letters[letters.length] = String.fromCharCode(i);
    for (var i = '0'.charCodeAt(0); i <= '9'.charCodeAt(0); i++)
        letters[letters.length] = String.fromCharCode(i);
    for (var _i = 0, letters_1 = letters; _i < letters_1.length; _i++) {
        var k = letters_1[_i];
        cache[k] = k.toUpperCase();
        for (var _a = 0, letters_2 = letters; _a < letters_2.length; _a++) {
            var l = letters_2[_a];
            cache[k + l] = (k + l).toUpperCase();
            for (var _b = 0, letters_3 = letters; _b < letters_3.length; _b++) {
                var m = letters_3[_b];
                cache[k + l + m] = (k + l + m).toUpperCase();
            }
        }
    }
    return cache;
}());
function ElementSymbol(s) {
    return _esCache[s] || s.toUpperCase();
}
exports.ElementSymbol = ElementSymbol;
var _elementByAtomicNumber = new Map([[1, 'H'], [2, 'He'], [3, 'Li'], [4, 'Be'], [5, 'B'], [6, 'C'], [7, 'N'], [8, 'O'], [9, 'F'], [10, 'Ne'], [11, 'Na'], [12, 'Mg'], [13, 'Al'], [14, 'Si'], [15, 'P'], [16, 'S'], [17, 'Cl'], [18, 'Ar'], [19, 'K'], [20, 'Ca'], [21, 'Sc'], [22, 'Ti'], [23, 'V'], [24, 'Cr'], [25, 'Mn'], [26, 'Fe'], [27, 'Co'], [28, 'Ni'], [29, 'Cu'], [30, 'Zn'], [31, 'Ga'], [32, 'Ge'], [33, 'As'], [34, 'Se'], [35, 'Br'], [36, 'Kr'], [37, 'Rb'], [38, 'Sr'], [39, 'Y'], [40, 'Zr'], [41, 'Nb'], [42, 'Mo'], [43, 'Tc'], [44, 'Ru'], [45, 'Rh'], [46, 'Pd'], [47, 'Ag'], [48, 'Cd'], [49, 'In'], [50, 'Sn'], [51, 'Sb'], [52, 'Te'], [53, 'I'], [54, 'Xe'], [55, 'Cs'], [56, 'Ba'], [57, 'La'], [58, 'Ce'], [59, 'Pr'], [60, 'Nd'], [61, 'Pm'], [62, 'Sm'], [63, 'Eu'], [64, 'Gd'], [65, 'Tb'], [66, 'Dy'], [67, 'Ho'], [68, 'Er'], [69, 'Tm'], [70, 'Yb'], [71, 'Lu'], [72, 'Hf'], [73, 'Ta'], [74, 'W'], [75, 'Re'], [76, 'Os'], [77, 'Ir'], [78, 'Pt'], [79, 'Au'], [80, 'Hg'], [81, 'Tl'], [82, 'Pb'], [83, 'Bi'], [84, 'Po'], [85, 'At'], [86, 'Rn'], [87, 'Fr'], [88, 'Ra'], [89, 'Ac'], [90, 'Th'], [91, 'Pa'], [92, 'U'], [93, 'Np'], [94, 'Pu'], [95, 'Am'], [96, 'Cm'], [97, 'Bk'], [98, 'Cf'], [99, 'Es'], [100, 'Fm'], [101, 'Md'], [102, 'No'], [103, 'Lr'], [104, 'Rf'], [105, 'Db'], [106, 'Sg'], [107, 'Bh'], [108, 'Hs'], [109, 'Mt'], [110, 'Ds'], [111, 'Rg'], [112, 'Cn'], [113, 'Uut'], [114, 'Fl'], [115, 'Uup'], [116, 'Lv'], [117, 'Uus'], [118, 'Uuo']]
    .map(function (e) { return [e[0], ElementSymbol(e[1])]; }));
function getElementFromAtomicNumber(n) {
    if (_elementByAtomicNumber.has(n))
        return _elementByAtomicNumber.get(n);
    return ElementSymbol('H');
}
exports.getElementFromAtomicNumber = getElementFromAtomicNumber;
exports.PolymerTypeAtomRoleId = (_a = {},
    _a[0 /* NA */] = {
        trace: new Set(),
        directionFrom: new Set(),
        directionTo: new Set(),
        backboneStart: new Set(),
        backboneEnd: new Set(),
        coarseBackbone: new Set()
    },
    _a[1 /* Protein */] = {
        trace: new Set(['CA']),
        directionFrom: new Set(['C']),
        directionTo: new Set(['O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1']),
        backboneStart: new Set(['N']),
        backboneEnd: new Set(['C']),
        // CA1 is used e.g. in GFP chromophores
        // BB is often used for coarse grained models
        coarseBackbone: new Set(['CA', 'BB', 'CA1'])
    },
    _a[2 /* GammaProtein */] = {
        trace: new Set(['CA']),
        directionFrom: new Set(['C']),
        directionTo: new Set(['O']),
        backboneStart: new Set(['N']),
        backboneEnd: new Set(['CD']),
        coarseBackbone: new Set(['CA'])
    },
    _a[3 /* BetaProtein */] = {
        trace: new Set(['CA']),
        directionFrom: new Set(['C']),
        directionTo: new Set(['O']),
        backboneStart: new Set(['N']),
        backboneEnd: new Set(['CG']),
        coarseBackbone: new Set(['CA'])
    },
    _a[4 /* RNA */] = {
        trace: new Set(['O3\'', 'O3*']),
        directionFrom: new Set(['C4\'', 'C4*']),
        directionTo: new Set(['C3\'', 'C3*']),
        backboneStart: new Set(['P']),
        backboneEnd: new Set(['O3\'', 'O3*']),
        coarseBackbone: new Set(['P'])
    },
    _a[5 /* DNA */] = {
        trace: new Set(['O3\'', 'O3*']),
        directionFrom: new Set(['C3\'', 'C3*']),
        directionTo: new Set(['C1\'', 'C1*']),
        backboneStart: new Set(['P']),
        backboneEnd: new Set(['O3\'', 'O3*']),
        coarseBackbone: new Set(['P'])
    },
    _a[6 /* PNA */] = {
        trace: new Set(['N4\'', 'N4*']),
        directionFrom: new Set(['N4\'', 'N4*']),
        directionTo: new Set(['C7\'', 'C7*']),
        backboneStart: new Set(['N1\'', 'N1*']),
        backboneEnd: new Set(['C\'', 'C*']),
        coarseBackbone: new Set(['P'])
    },
    _a);
exports.ProteinBackboneAtoms = new Set([
    'CA', 'C', 'N', 'O',
    'O1', 'O2', 'OC1', 'OC2', 'OT1', 'OT2', 'OX1', 'OXT',
    'H', 'H1', 'H2', 'H3', 'HA', 'HN', 'HXT',
    'BB'
]);
exports.NucleicBackboneAtoms = new Set([
    'P', 'OP1', 'OP2', 'HOP2', 'HOP3',
    'O2\'', 'O3\'', 'O4\'', 'O5\'', 'C1\'', 'C2\'', 'C3\'', 'C4\'', 'C5\'',
    'H1\'', 'H2\'', 'H2\'\'', 'HO2\'', 'H3\'', 'H4\'', 'H5\'', 'H5\'\'', 'HO3\'', 'HO5\'',
    'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'
]);
/** Chemical component type names for D-linked protein */
exports.DProteinComponentTypeNames = new Set([
    'D-PEPTIDE LINKING', 'D-PEPTIDE NH3 AMINO TERMINUS',
    'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',
    'D-BETA-PEPTIDE, C-GAMMA LINKING'
]);
/** Chemical component type names for L-linked protein */
exports.LProteinComponentTypeNames = new Set([
    'L-PEPTIDE LINKING', 'L-PEPTIDE NH3 AMINO TERMINUS',
    'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',
    'L-BETA-PEPTIDE, C-GAMMA LINKING'
]);
/** Chemical component type names for gamma protein, overlaps with D/L-linked */
exports.GammaProteinComponentTypeNames = new Set([
    'D-GAMMA-PEPTIDE, C-DELTA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING'
]);
/** Chemical component type names for beta protein, overlaps with D/L-linked */
exports.BetaProteinComponentTypeNames = new Set([
    'D-BETA-PEPTIDE, C-GAMMA LINKING', 'L-BETA-PEPTIDE, C-GAMMA LINKING'
]);
/** Chemical component type names for protein termini, overlaps with D/L-linked */
exports.ProteinTerminusComponentTypeNames = new Set([
    'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE COOH CARBOXY TERMINUS',
    'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE COOH CARBOXY TERMINUS'
]);
/** Chemical component type names for peptide-like protein */
exports.OtherProteinComponentTypeNames = new Set([
    'PEPTIDE LINKING', 'PEPTIDE-LIKE',
]);
/** Chemical component type names for protein */
exports.ProteinComponentTypeNames = set_1.SetUtils.unionMany(exports.DProteinComponentTypeNames, exports.LProteinComponentTypeNames, exports.OtherProteinComponentTypeNames);
/** Chemical component type names for DNA */
exports.DNAComponentTypeNames = new Set([
    'DNA LINKING', 'L-DNA LINKING', 'DNA OH 5 PRIME TERMINUS', 'DNA OH 3 PRIME TERMINUS',
]);
/** Chemical component type names for RNA */
exports.RNAComponentTypeNames = new Set([
    'RNA LINKING', 'L-RNA LINKING', 'RNA OH 5 PRIME TERMINUS', 'RNA OH 3 PRIME TERMINUS',
]);
/** Chemical component type names for saccharide */
exports.SaccharideComponentTypeNames = new Set([
    'D-SACCHARIDE, BETA LINKING', 'L-SACCHARIDE, BETA LINKING',
    'D-SACCHARIDE, ALPHA LINKING', 'L-SACCHARIDE, ALPHA LINKING',
    'L-SACCHARIDE', 'D-SACCHARIDE', 'SACCHARIDE',
    // the following four are marked to be deprecated in the mmCIF dictionary
    'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,4 LINKING',
    'D-SACCHARIDE 1,4 AND 1,6 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',
]);
/** Chemical component type names for other */
exports.OtherComponentTypeNames = new Set([
    'NON-POLYMER', 'OTHER'
]);
/** Chemical component type names for ion (extension to mmcif) */
exports.IonComponentTypeNames = new Set([
    'ION'
]);
/** Chemical component type names for lipid (extension to mmcif) */
exports.LipidComponentTypeNames = new Set([
    'LIPID'
]);
/** Common names for water molecules */
exports.WaterNames = new Set([
    'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP', 'TIP3', 'TIP4', 'SPC'
]);
exports.AminoAcidNamesL = new Set([
    'HIS', 'ARG', 'LYS', 'ILE', 'PHE', 'LEU', 'TRP', 'ALA', 'MET', 'PRO', 'CYS',
    'ASN', 'VAL', 'GLY', 'SER', 'GLN', 'TYR', 'ASP', 'GLU', 'THR', 'SEC', 'PYL',
    'UNK',
    'MSE', 'SEP', 'TPO', 'PTR', 'PCA',
    // charmm ff
    'HSD', 'HSE', 'HSP', 'LSN', 'ASPP', 'GLUP',
    // amber ff
    'HID', 'HIE', 'HIP', 'LYN', 'ASH', 'GLH',
]);
exports.AminoAcidNamesD = new Set([
    'DAL',
    'DAR',
    'DSG',
    'DAS',
    'DCY',
    'DGL',
    'DGN',
    'DHI',
    'DIL',
    'DLE',
    'DLY',
    'MED',
    'DPN',
    'DPR',
    'DSN',
    'DTH',
    'DTR',
    'DTY',
    'DVA',
    'DNE' // D-NORLEUCINE
    // ???  // D-SELENOCYSTEINE
]);
exports.AminoAcidNames = set_1.SetUtils.unionMany(exports.AminoAcidNamesL, exports.AminoAcidNamesD);
exports.RnaBaseNames = new Set([
    'A', 'C', 'T', 'G', 'I', 'U',
    'N' // unknown RNA base from CCD
]);
exports.DnaBaseNames = new Set([
    'DA', 'DC', 'DT', 'DG', 'DI', 'DU',
    'DN' // unknown DNA base from CCD
]);
exports.PeptideBaseNames = new Set(['APN', 'CPN', 'TPN', 'GPN']);
exports.PurineBaseNames = new Set(['A', 'G', 'I', 'DA', 'DG', 'DI', 'APN', 'GPN']);
exports.PyrimidineBaseNames = new Set(['C', 'T', 'U', 'DC', 'DT', 'DU', 'CPN', 'TPN']);
exports.BaseNames = set_1.SetUtils.unionMany(exports.RnaBaseNames, exports.DnaBaseNames, exports.PeptideBaseNames);
var isPurineBase = function (compId) { return exports.PurineBaseNames.has(compId.toUpperCase()); };
exports.isPurineBase = isPurineBase;
var isPyrimidineBase = function (compId) { return exports.PyrimidineBaseNames.has(compId.toUpperCase()); };
exports.isPyrimidineBase = isPyrimidineBase;
exports.PolymerNames = set_1.SetUtils.unionMany(exports.AminoAcidNames, exports.BaseNames);
/** get the molecule type from component type and id */
function getMoleculeType(compType, compId) {
    compType = compType.toUpperCase();
    compId = compId.toUpperCase();
    if (exports.PeptideBaseNames.has(compId)) {
        return 8 /* PNA */;
    }
    else if (exports.ProteinComponentTypeNames.has(compType)) {
        return 5 /* Protein */;
    }
    else if (exports.RNAComponentTypeNames.has(compType)) {
        return 6 /* RNA */;
    }
    else if (exports.DNAComponentTypeNames.has(compType)) {
        return 7 /* DNA */;
    }
    else if (exports.SaccharideComponentTypeNames.has(compType)) {
        return 9 /* Saccharide */;
    }
    else if (exports.WaterNames.has(compId)) {
        return 2 /* Water */;
    }
    else if (ions_1.IonNames.has(compId)) {
        return 3 /* Ion */;
    }
    else if (lipids_1.LipidNames.has(compId)) {
        return 4 /* Lipid */;
    }
    else if (exports.OtherComponentTypeNames.has(compType)) {
        if (constants_1.SaccharideCompIdMap.has(compId)) {
            // trust our saccharide table more than given 'non-polymer' or 'other' component type
            return 9 /* Saccharide */;
        }
        else {
            return 1 /* Other */;
        }
    }
    else {
        return 0 /* Unknown */;
    }
}
exports.getMoleculeType = getMoleculeType;
function getPolymerType(compType, molType) {
    compType = compType.toUpperCase();
    if (molType === 5 /* Protein */) {
        if (exports.GammaProteinComponentTypeNames.has(compType)) {
            return 2 /* GammaProtein */;
        }
        else if (exports.BetaProteinComponentTypeNames.has(compType)) {
            return 3 /* BetaProtein */;
        }
        else if (exports.ProteinTerminusComponentTypeNames.has(compType)) {
            return 0 /* NA */;
        }
        else {
            return 1 /* Protein */;
        }
    }
    else if (molType === 6 /* RNA */) {
        return 4 /* RNA */;
    }
    else if (molType === 7 /* DNA */) {
        return 5 /* DNA */;
    }
    else if (molType === 8 /* PNA */) {
        return 6 /* PNA */;
    }
    else {
        return 0 /* NA */;
    }
}
exports.getPolymerType = getPolymerType;
function getComponentType(compId) {
    compId = compId.toUpperCase();
    if (exports.AminoAcidNames.has(compId)) {
        return 'peptide linking';
    }
    else if (exports.RnaBaseNames.has(compId)) {
        return 'RNA linking';
    }
    else if (exports.DnaBaseNames.has(compId)) {
        return 'DNA linking';
    }
    else if (constants_1.SaccharideCompIdMap.has(compId)) {
        return 'saccharide';
    }
    else {
        return 'other';
    }
}
exports.getComponentType = getComponentType;
function getDefaultChemicalComponent(compId) {
    // TODO: this is to make the chem_comp_type property work if chem_comp category is not present.
    // should we try to set the formula etc better?
    return {
        formula: '',
        formula_weight: 0,
        id: compId,
        name: compId,
        mon_nstd_flag: exports.PolymerNames.has(compId) ? 'y' : 'n',
        pdbx_synonyms: [],
        type: getComponentType(compId)
    };
}
exports.getDefaultChemicalComponent = getDefaultChemicalComponent;
function getEntityType(compId) {
    compId = compId.toUpperCase();
    if (exports.WaterNames.has(compId)) {
        return 'water';
    }
    else if (exports.PolymerNames.has(compId)) {
        return 'polymer';
    }
    else if (constants_1.SaccharideCompIdMap.has(compId)) {
        return 'branched';
    }
    else {
        return 'non-polymer';
    }
}
exports.getEntityType = getEntityType;
function getEntitySubtype(compId, compType) {
    compId = compId.toUpperCase();
    compType = compType.toUpperCase();
    if (exports.LProteinComponentTypeNames.has(compType)) {
        return 'polypeptide(L)';
    }
    else if (exports.DProteinComponentTypeNames.has(compType)) {
        return 'polypeptide(D)';
    }
    else if (exports.RNAComponentTypeNames.has(compType)) {
        return 'polyribonucleotide';
    }
    else if (exports.DNAComponentTypeNames.has(compType)) {
        return 'polydeoxyribonucleotide';
    }
    else if (exports.SaccharideComponentTypeNames.has(compType)) {
        return 'oligosaccharide';
    }
    else if (constants_1.SaccharideCompIdMap.has(compId)) {
        return 'oligosaccharide';
    }
    else if (exports.PeptideBaseNames.has(compId)) {
        return 'peptide nucleic acid';
    }
    else if (exports.AminoAcidNamesL.has(compId)) {
        return 'polypeptide(L)';
    }
    else if (exports.AminoAcidNamesD.has(compId)) {
        return 'polypeptide(D)';
    }
    else if (exports.RnaBaseNames.has(compId)) {
        return 'polyribonucleotide';
    }
    else if (exports.DnaBaseNames.has(compId)) {
        return 'polydeoxyribonucleotide';
    }
    else if (exports.IonComponentTypeNames.has(compType) || ions_1.IonNames.has(compId)) {
        return 'ion';
    }
    else if (exports.LipidComponentTypeNames.has(compType) || lipids_1.LipidNames.has(compId)) {
        return 'lipid';
    }
    else if (exports.OtherProteinComponentTypeNames.has(compType)) {
        return 'peptide-like';
    }
    else {
        return 'other';
    }
}
exports.getEntitySubtype = getEntitySubtype;
function isPolymer(moleculeType) {
    return isNucleic(moleculeType) || isProtein(moleculeType);
}
exports.isPolymer = isPolymer;
function isNucleic(moleculeType) {
    return moleculeType === 7 /* DNA */ || moleculeType === 6 /* RNA */ || moleculeType === 8 /* PNA */;
}
exports.isNucleic = isNucleic;
function isProtein(moleculeType) {
    return moleculeType === 5 /* Protein */;
}
exports.isProtein = isProtein;
var SecondaryStructureType;
(function (SecondaryStructureType) {
    SecondaryStructureType.is = bit_flags_1.BitFlags.has;
    SecondaryStructureType.create = bit_flags_1.BitFlags.create;
    SecondaryStructureType.SecondaryStructureMmcif = {
        HELX_LH_27_P: 2 /* Helix */ | 32 /* LeftHanded */ | 1024 /* Helix27 */,
        HELX_LH_3T_P: 2 /* Helix */ | 32 /* LeftHanded */ | 2048 /* Helix3Ten */,
        HELX_LH_AL_P: 2 /* Helix */ | 32 /* LeftHanded */ | 4096 /* HelixAlpha */,
        HELX_LH_A_N: 1 /* DoubleHelix */ | 32 /* LeftHanded */ | 524288 /* DoubleHelixA */,
        HELX_LH_B_N: 1 /* DoubleHelix */ | 32 /* LeftHanded */ | 1048576 /* DoubleHelixB */,
        HELX_LH_GA_P: 2 /* Helix */ | 32 /* LeftHanded */ | 8192 /* HelixGamma */,
        HELX_LH_N: 1 /* DoubleHelix */ | 32 /* LeftHanded */,
        HELX_LH_OM_P: 2 /* Helix */ | 32 /* LeftHanded */ | 16384 /* HelixOmega */,
        HELX_LH_OT_N: 1 /* DoubleHelix */ | 32 /* LeftHanded */ | 131072 /* DoubleHelixOther */,
        HELX_LH_OT_P: 2 /* Helix */ | 32 /* LeftHanded */ | 512 /* HelixOther */,
        HELX_LH_P: 2 /* Helix */ | 32 /* LeftHanded */,
        HELX_LH_PI_P: 2 /* Helix */ | 32 /* LeftHanded */ | 32768 /* HelixPi */,
        HELX_LH_PP_P: 2 /* Helix */ | 32 /* LeftHanded */ | 65536 /* HelixPolyproline */,
        HELX_LH_Z_N: 1 /* DoubleHelix */ | 32 /* LeftHanded */ | 262144 /* DoubleHelixZ */,
        HELX_N: 1 /* DoubleHelix */,
        HELX_OT_N: 1 /* DoubleHelix */,
        HELX_OT_P: 2 /* Helix */,
        HELX_P: 2 /* Helix */,
        HELX_RH_27_P: 2 /* Helix */ | 64 /* RightHanded */ | 1024 /* Helix27 */,
        HELX_RH_3T_P: 2 /* Helix */ | 64 /* RightHanded */ | 2048 /* Helix3Ten */,
        HELX_RH_AL_P: 2 /* Helix */ | 64 /* RightHanded */ | 4096 /* HelixAlpha */,
        HELX_RH_A_N: 1 /* DoubleHelix */ | 64 /* RightHanded */ | 524288 /* DoubleHelixA */,
        HELX_RH_B_N: 1 /* DoubleHelix */ | 64 /* RightHanded */ | 1048576 /* DoubleHelixB */,
        HELX_RH_GA_P: 2 /* Helix */ | 64 /* RightHanded */ | 8192 /* HelixGamma */,
        HELX_RH_N: 1 /* DoubleHelix */ | 64 /* RightHanded */,
        HELX_RH_OM_P: 2 /* Helix */ | 64 /* RightHanded */ | 16384 /* HelixOmega */,
        HELX_RH_OT_N: 1 /* DoubleHelix */ | 64 /* RightHanded */ | 131072 /* DoubleHelixOther */,
        HELX_RH_OT_P: 2 /* Helix */ | 64 /* RightHanded */ | 512 /* HelixOther */,
        HELX_RH_P: 2 /* Helix */ | 64 /* RightHanded */,
        HELX_RH_PI_P: 2 /* Helix */ | 64 /* RightHanded */ | 32768 /* HelixPi */,
        HELX_RH_PP_P: 2 /* Helix */ | 64 /* RightHanded */ | 65536 /* HelixPolyproline */,
        HELX_RH_Z_N: 1 /* DoubleHelix */ | 64 /* RightHanded */ | 262144 /* DoubleHelixZ */,
        STRN: 4 /* Beta */ | 4194304 /* BetaStrand */,
        TURN_OT_P: 16 /* Turn */ | 33554432 /* TurnOther */,
        TURN_P: 16 /* Turn */,
        TURN_TY1P_P: 16 /* Turn */ | 256 /* InverseTurn */ | 67108864 /* Turn1 */,
        TURN_TY1_P: 16 /* Turn */ | 128 /* ClassicTurn */ | 67108864 /* Turn1 */,
        TURN_TY2P_P: 16 /* Turn */ | 256 /* InverseTurn */ | 134217728 /* Turn2 */,
        TURN_TY2_P: 16 /* Turn */ | 128 /* ClassicTurn */ | 134217728 /* Turn2 */,
        TURN_TY3P_P: 16 /* Turn */ | 256 /* InverseTurn */ | 268435456 /* Turn3 */,
        TURN_TY3_P: 16 /* Turn */ | 128 /* ClassicTurn */ | 268435456 /* Turn3 */, // type III turn (protein)
    };
    SecondaryStructureType.SecondaryStructurePdb = {
        1: 2 /* Helix */ | 64 /* RightHanded */ | 4096 /* HelixAlpha */,
        2: 2 /* Helix */ | 64 /* RightHanded */ | 16384 /* HelixOmega */,
        3: 2 /* Helix */ | 64 /* RightHanded */ | 32768 /* HelixPi */,
        4: 2 /* Helix */ | 64 /* RightHanded */ | 8192 /* HelixGamma */,
        5: 2 /* Helix */ | 64 /* RightHanded */ | 2048 /* Helix3Ten */,
        6: 2 /* Helix */ | 32 /* LeftHanded */ | 4096 /* HelixAlpha */,
        7: 2 /* Helix */ | 32 /* LeftHanded */ | 16384 /* HelixOmega */,
        8: 2 /* Helix */ | 32 /* LeftHanded */ | 8192 /* HelixGamma */,
        9: 2 /* Helix */ | 1024 /* Helix27 */,
        10: 2 /* Helix */ | 65536 /* HelixPolyproline */, // Polyproline
    };
    SecondaryStructureType.SecondaryStructureStride = {
        H: 2 /* Helix */ | 4096 /* HelixAlpha */,
        G: 2 /* Helix */ | 2048 /* Helix3Ten */,
        I: 2 /* Helix */ | 32768 /* HelixPi */,
        E: 4 /* Beta */ | 8388608 /* BetaSheet */,
        B: 4 /* Beta */ | 4194304 /* BetaStrand */,
        T: 16 /* Turn */,
        C: 536870912 /* NA */, // Coil (none of the above)
    };
    SecondaryStructureType.SecondaryStructureDssp = {
        H: 2 /* Helix */ | 4096 /* HelixAlpha */,
        B: 4 /* Beta */ | 4194304 /* BetaStrand */,
        E: 4 /* Beta */ | 8388608 /* BetaSheet */,
        G: 2 /* Helix */ | 2048 /* Helix3Ten */,
        I: 2 /* Helix */ | 32768 /* HelixPi */,
        T: 16 /* Turn */,
        S: 8 /* Bend */, // bend
    };
})(SecondaryStructureType = exports.SecondaryStructureType || (exports.SecondaryStructureType = {}));
/** Maximum accessible surface area observed for amino acids. Taken from: http://dx.doi.org/10.1371/journal.pone.0080635 */
exports.MaxAsa = {
    'ALA': 121.0,
    'ARG': 265.0,
    'ASN': 187.0,
    'ASP': 187.0,
    'CYS': 148.0,
    'GLU': 214.0,
    'GLN': 214.0,
    'GLY': 97.0,
    'HIS': 216.0,
    'ILE': 195.0,
    'LEU': 191.0,
    'LYS': 230.0,
    'MET': 203.0,
    'PHE': 228.0,
    'PRO': 154.0,
    'SER': 143.0,
    'THR': 163.0,
    'TRP': 264.0,
    'TYR': 255.0,
    'VAL': 165.0,
    // charmm ff
    'HSD': 216.0, 'HSE': 216.0, 'HSP': 216.0,
    // amber ff
    'HID': 216.0, 'HIE': 216.0, 'HIP': 216.0, 'ASH': 187.0, 'GLH': 214.0,
};
exports.DefaultMaxAsa = 121.0;
var BondType;
(function (BondType) {
    BondType.is = bit_flags_1.BitFlags.has;
    function create(flags) {
        return bit_flags_1.BitFlags.create(flags);
    }
    BondType.create = create;
    function isCovalent(flags) {
        return (flags & 1 /* Covalent */) !== 0;
    }
    BondType.isCovalent = isCovalent;
    function isAll(flags) {
        return flags === Math.pow(2, 6) - 1;
    }
    BondType.isAll = isAll;
    BondType.Names = {
        'covalent': 1 /* Covalent */,
        'metal-coordination': 2 /* MetallicCoordination */,
        'hydrogen-bond': 4 /* HydrogenBond */,
        'disulfide': 8 /* Disulfide */,
        'aromatic': 16 /* Aromatic */,
        'computed': 32 /* Computed */,
    };
    function isName(name) {
        return name in BondType.Names;
    }
    BondType.isName = isName;
    function fromName(name) {
        switch (name) {
            case 'covalent': return 1 /* Covalent */;
            case 'metal-coordination': return 2 /* MetallicCoordination */;
            case 'hydrogen-bond': return 4 /* HydrogenBond */;
            case 'disulfide': return 8 /* Disulfide */;
            case 'aromatic': return 16 /* Aromatic */;
            case 'computed': return 32 /* Computed */;
        }
    }
    BondType.fromName = fromName;
    function fromNames(names) {
        var f = 0 /* None */;
        for (var i = 0, il = names.length; i < il; ++i) {
            f |= fromName(names[i]);
        }
        return f;
    }
    BondType.fromNames = fromNames;
})(BondType = exports.BondType || (exports.BondType = {}));
/**
 * "Experimentally determined hydrophobicity scale for proteins at membrane interfaces"
 * by Wimely and White (doi:10.1038/nsb1096-842)
 * http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt
 * https://www.nature.com/articles/nsb1096-842
 */
exports.ResidueHydrophobicity = {
    // AA  DGwif   DGwoct  Oct-IF
    'ALA': [0.17, 0.50, 0.33],
    'ARG': [0.81, 1.81, 1.00],
    'ASN': [0.42, 0.85, 0.43],
    'ASP': [1.23, 3.64, 2.41],
    'ASH': [-0.07, 0.43, 0.50],
    'CYS': [-0.24, -0.02, 0.22],
    'GLN': [0.58, 0.77, 0.19],
    'GLU': [2.02, 3.63, 1.61],
    'GLH': [-0.01, 0.11, 0.12],
    'GLY': [0.01, 1.15, 1.14],
    // "His+": [  0.96,  2.33,  1.37 ],
    'HIS': [0.17, 0.11, -0.06],
    'ILE': [-0.31, -1.12, -0.81],
    'LEU': [-0.56, -1.25, -0.69],
    'LYS': [0.99, 2.80, 1.81],
    'MET': [-0.23, -0.67, -0.44],
    'PHE': [-1.13, -1.71, -0.58],
    'PRO': [0.45, 0.14, -0.31],
    'SER': [0.13, 0.46, 0.33],
    'THR': [0.14, 0.25, 0.11],
    'TRP': [-1.85, -2.09, -0.24],
    'TYR': [-0.94, -0.71, 0.23],
    'VAL': [0.07, -0.46, -0.53],
    // charmm ff
    'HSD': [0.17, 0.11, -0.06], 'HSE': [0.17, 0.11, -0.06], 'HSP': [0.96, 2.33, 1.37],
    // amber ff
    'HID': [0.17, 0.11, -0.06], 'HIE': [0.17, 0.11, -0.06], 'HIP': [0.96, 2.33, 1.37],
};
exports.DefaultResidueHydrophobicity = [0.00, 0.00, 0.00];
//# sourceMappingURL=types.js.map