bonds.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { AminoAcidNames, BaseNames } from '../../types';
  7. /**
  8. * Map of intra component bond orders in aminoacids and nucleotides assuming standard IUPAC naming.
  9. * The key is constructed as `${compId}|${atomId1}|${atomId2}` with `atomId1 < atomId2`.
  10. */
  11. const IntraBondOrderTable = new Map([
  12. ['HIS|CD2|CG', 2],
  13. ['HIS|CE1|ND1', 2],
  14. ['ARG|CZ|NH2', 2],
  15. ['PHE|CE1|CZ', 2],
  16. ['PHE|CD2|CE2', 2],
  17. ['PHE|CD1|CG', 2],
  18. ['TRP|CD1|CG', 2],
  19. ['TRP|CD2|CE2', 2],
  20. ['TRP|CE3|CZ3', 2],
  21. ['TRP|CH2|CZ2', 2],
  22. ['ASN|CG|OD1', 2],
  23. ['GLN|CD|OE1', 2],
  24. ['TYR|CD1|CG', 2],
  25. ['TYR|CD2|CE2', 2],
  26. ['TYR|CE1|CZ', 2],
  27. ['ASP|CG|OD1', 2],
  28. ['GLU|CD|OE1', 2],
  29. ['G|C8|N7', 2],
  30. ['G|C4|C5', 2],
  31. ['G|C2|N3', 2],
  32. ['G|C6|O6', 2],
  33. ['C|C4|N3', 2],
  34. ['C|C5|C6', 2],
  35. ['C|C2|O2', 2],
  36. ['A|C2|N3', 2],
  37. ['A|C6|N1', 2],
  38. ['A|C4|C5', 2],
  39. ['A|C8|N7', 2],
  40. ['U|C5|C6', 2],
  41. ['U|C2|O2', 2],
  42. ['U|C4|O4', 2],
  43. ['DG|C8|N7', 2],
  44. ['DG|C4|C5', 2],
  45. ['DG|C2|N3', 2],
  46. ['DG|C6|O6', 2],
  47. ['DC|C4|N3', 2],
  48. ['DC|C5|C6', 2],
  49. ['DC|C2|O2', 2],
  50. ['DA|C2|N3', 2],
  51. ['DA|C6|N1', 2],
  52. ['DA|C4|C5', 2],
  53. ['DA|C8|N7', 2],
  54. ['DT|C5|C6', 2],
  55. ['DT|C2|O2', 2],
  56. ['DT|C4|O4', 2]
  57. ]);
  58. /**
  59. * Get order for bonds in aminoacids and nucleotides assuming standard IUPAC naming
  60. */
  61. export function getIntraBondOrderFromTable (compId: string, atomId1: string, atomId2: string) {
  62. [atomId1, atomId2] = atomId1 < atomId2 ? [atomId1, atomId2] : [atomId2, atomId1];
  63. if (AminoAcidNames.has(compId) && atomId1 === 'C' && atomId2 === 'O') return 2;
  64. if (BaseNames.has(compId) && atomId1 === 'OP1' && atomId2 === 'P') return 2;
  65. return IntraBondOrderTable.get(`${compId}|${atomId1}|${atomId2}`) || 1;
  66. }
  67. /**
  68. * Map of inter component bond orders assuming PDBx/mmCIF naming.
  69. * The key is constructed as `${compId1}|${compId2}|${atomId1}|${atomId2}` with `compId1 < compId2`.
  70. */
  71. const InterBondOrderTable = new Map([
  72. ['LYS|NZ|RET|C15', 2] // Schiff base in Rhodopsin and Bacteriorhodopsin
  73. ]);
  74. /**
  75. * Get order for bonds between component assuming PDBx/mmCIF naming.
  76. */
  77. export function getInterBondOrderFromTable (compId1: string, atomId1: string, compId2: string, atomId2: string) {
  78. if (compId1 > compId2) {
  79. [compId1, compId2] = [compId2, compId1];
  80. [atomId1, atomId2] = [atomId2, atomId1];
  81. }
  82. return InterBondOrderTable.get(`${compId1}|${atomId1}|${compId2}|${atomId2}`) || 1;
  83. }