constants.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. export type AminoAlphabet =
  7. | 'H' | 'R' | 'K' | 'I' | 'F' | 'L' | 'W' | 'A' | 'M' | 'P' | 'C' | 'N' | 'V' | 'G' | 'S' | 'Q' | 'Y' | 'D' | 'E' | 'T' | 'U' | 'O'
  8. | 'X' /** = Unknown */
  9. | '-' /** = Gap */
  10. export type NuclecicAlphabet =
  11. | 'A' | 'C' | 'G' | 'T' | 'U'
  12. | 'X' /** = Unknown */
  13. | '-' /** = Gap */
  14. // from NGL
  15. const ProteinOneLetterCodes: { [name: string]: AminoAlphabet } = {
  16. 'HIS': 'H',
  17. 'ARG': 'R',
  18. 'LYS': 'K',
  19. 'ILE': 'I',
  20. 'PHE': 'F',
  21. 'LEU': 'L',
  22. 'TRP': 'W',
  23. 'ALA': 'A',
  24. 'MET': 'M',
  25. 'PRO': 'P',
  26. 'CYS': 'C',
  27. 'ASN': 'N',
  28. 'VAL': 'V',
  29. 'GLY': 'G',
  30. 'SER': 'S',
  31. 'GLN': 'Q',
  32. 'TYR': 'Y',
  33. 'ASP': 'D',
  34. 'GLU': 'E',
  35. 'THR': 'T',
  36. 'SEC': 'U', // as per IUPAC definition
  37. 'PYL': 'O', // as per IUPAC definition
  38. }
  39. const DnaOneLetterCodes: { [name: string]: NuclecicAlphabet } = {
  40. 'DA': 'A',
  41. 'DC': 'C',
  42. 'DG': 'G',
  43. 'DT': 'T',
  44. 'DU': 'U'
  45. }
  46. const RnaOneLetterCodes: { [name: string]: NuclecicAlphabet } = {
  47. 'A': 'A',
  48. 'C': 'C',
  49. 'G': 'G',
  50. 'T': 'T',
  51. 'U': 'U'
  52. }
  53. export function getProteinOneLetterCode(residueName: string): AminoAlphabet {
  54. const code = ProteinOneLetterCodes[residueName];
  55. return code || 'X';
  56. }
  57. export function getRnaOneLetterCode(residueName: string): NuclecicAlphabet {
  58. const code = RnaOneLetterCodes[residueName];
  59. return code || 'X';
  60. }
  61. export function getDnaOneLetterCode(residueName: string): NuclecicAlphabet {
  62. const code = DnaOneLetterCodes[residueName];
  63. return code || 'X';
  64. }