drugflow-molstar 0.3.77 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/build/drugflow-molstar-0.4.1.css +1 -0
  2. package/build/drugflow-molstar-component-0.4.1.js +25 -0
  3. package/build/drugflow-molstar-plugin-0.4.1.js +2 -0
  4. package/build/drugflow-molstar-plugin-0.4.1.js.LICENSE.txt +64 -0
  5. package/lib/alphafold-transparency.js +58 -125
  6. package/lib/contact.d.ts +15 -6
  7. package/lib/contact.js +71 -66
  8. package/lib/custom-events.js +16 -16
  9. package/lib/domain-annotations/behavior.js +20 -24
  10. package/lib/domain-annotations/color.d.ts +1 -1
  11. package/lib/domain-annotations/color.js +23 -22
  12. package/lib/domain-annotations/prop.d.ts +3 -3
  13. package/lib/domain-annotations/prop.js +54 -76
  14. package/lib/drugflow-molstar-component-build-0.3.78.js +2 -0
  15. package/lib/drugflow-molstar-component-build-0.4.1.js +2 -0
  16. package/lib/helpers.d.ts +4 -4
  17. package/lib/helpers.js +94 -99
  18. package/lib/index.js +1785 -2608
  19. package/lib/labels.d.ts +1 -1
  20. package/lib/labels.js +20 -23
  21. package/lib/loci-details.d.ts +2 -2
  22. package/lib/loci-details.js +26 -29
  23. package/lib/sifts-mapping.js +30 -34
  24. package/lib/sifts-mappings-behaviour.js +26 -30
  25. package/lib/spec.d.ts +1 -1
  26. package/lib/spec.js +50 -38
  27. package/lib/structure_contact3d.d.ts +13 -4
  28. package/lib/structure_contact3d.js +25 -46
  29. package/lib/subscribe-events.js +17 -17
  30. package/lib/superposition-export.js +100 -144
  31. package/lib/superposition-focus-representation.d.ts +1 -1
  32. package/lib/superposition-focus-representation.js +74 -112
  33. package/lib/superposition-sifts-mapping.d.ts +1 -1
  34. package/lib/superposition-sifts-mapping.js +56 -62
  35. package/lib/superposition.d.ts +2 -2
  36. package/lib/superposition.js +490 -726
  37. package/lib/ui/alphafold-superposition.d.ts +8 -9
  38. package/lib/ui/alphafold-superposition.js +96 -120
  39. package/lib/ui/alphafold-tranparency.d.ts +1 -2
  40. package/lib/ui/alphafold-tranparency.js +27 -43
  41. package/lib/ui/annotation-controls.d.ts +2 -3
  42. package/lib/ui/annotation-controls.js +81 -87
  43. package/lib/ui/export-superposition.js +33 -51
  44. package/lib/ui/pdbe-left-panel.d.ts +3 -3
  45. package/lib/ui/pdbe-left-panel.js +82 -106
  46. package/lib/ui/pdbe-screenshot-controls.d.ts +1 -1
  47. package/lib/ui/pdbe-screenshot-controls.js +54 -83
  48. package/lib/ui/pdbe-structure-controls.d.ts +4 -5
  49. package/lib/ui/pdbe-structure-controls.js +34 -57
  50. package/lib/ui/pdbe-viewport-controls.d.ts +1 -2
  51. package/lib/ui/pdbe-viewport-controls.js +23 -29
  52. package/lib/ui/segment-tree.d.ts +1 -2
  53. package/lib/ui/segment-tree.js +438 -590
  54. package/lib/ui/superposition-components.d.ts +1 -2
  55. package/lib/ui/superposition-components.js +196 -266
  56. package/lib/ui/superposition-viewport.d.ts +1 -2
  57. package/lib/ui/superposition-viewport.js +11 -18
  58. package/package.json +7 -4
  59. package/build/drugflow-molstar-0.3.62.css +0 -1
  60. package/build/drugflow-molstar-0.3.77.css +0 -1
  61. package/build/drugflow-molstar-component-0.3.62.js +0 -25
  62. package/build/drugflow-molstar-component-0.3.77.js +0 -25
  63. package/build/drugflow-molstar-light.css +0 -1
  64. package/build/drugflow-molstar-plugin-0.3.62.js +0 -2
  65. package/build/drugflow-molstar-plugin-0.3.62.js.LICENSE.txt +0 -39
  66. package/build/drugflow-molstar-plugin-0.3.77.js +0 -2
  67. package/build/drugflow-molstar-plugin-0.3.77.js.LICENSE.txt +0 -39
  68. package/lib/drugflow-molstar-component-build-0.1.2.js +0 -4268
  69. package/lib/drugflow-molstar-component-build-0.1.2.js.map +0 -1
  70. package/lib/drugflow-molstar-component-build-0.1.3.js +0 -2
  71. package/lib/drugflow-molstar-component-build-0.1.4.js +0 -2
  72. package/lib/drugflow-molstar-component-build-0.1.4.js.LICENSE.txt +0 -24
  73. package/lib/drugflow-molstar-component-build-0.1.5.js +0 -2
  74. package/lib/drugflow-molstar-component-build-0.1.5.js.LICENSE.txt +0 -24
  75. package/lib/drugflow-molstar-component-build-0.1.6.js +0 -2
  76. package/lib/drugflow-molstar-component-build-0.1.6.js.LICENSE.txt +0 -24
  77. package/lib/drugflow-molstar-component-build-0.2.10.js +0 -2
  78. package/lib/drugflow-molstar-component-build-0.2.10.js.LICENSE.txt +0 -24
  79. package/lib/drugflow-molstar-component-build-0.2.2.js +0 -2
  80. package/lib/drugflow-molstar-component-build-0.2.2.js.LICENSE.txt +0 -24
  81. package/lib/drugflow-molstar-component-build-0.2.3.js +0 -2
  82. package/lib/drugflow-molstar-component-build-0.2.3.js.LICENSE.txt +0 -24
  83. package/lib/drugflow-molstar-component-build-0.2.4.js +0 -2
  84. package/lib/drugflow-molstar-component-build-0.2.4.js.LICENSE.txt +0 -24
  85. package/lib/drugflow-molstar-component-build-0.2.5.js +0 -2
  86. package/lib/drugflow-molstar-component-build-0.2.5.js.LICENSE.txt +0 -24
  87. package/lib/drugflow-molstar-component-build-0.2.6.js +0 -2
  88. package/lib/drugflow-molstar-component-build-0.2.6.js.LICENSE.txt +0 -24
  89. package/lib/drugflow-molstar-component-build-0.2.7.js +0 -2
  90. package/lib/drugflow-molstar-component-build-0.2.7.js.LICENSE.txt +0 -24
  91. package/lib/drugflow-molstar-component-build-0.2.9.js +0 -2
  92. package/lib/drugflow-molstar-component-build-0.2.9.js.LICENSE.txt +0 -24
  93. package/lib/drugflow-molstar-component-build-0.3.1.js +0 -2
  94. package/lib/drugflow-molstar-component-build-0.3.1.js.LICENSE.txt +0 -24
  95. package/lib/drugflow-molstar-component-build-0.3.10.js +0 -2
  96. package/lib/drugflow-molstar-component-build-0.3.10.js.LICENSE.txt +0 -24
  97. package/lib/drugflow-molstar-component-build-0.3.11.js +0 -2
  98. package/lib/drugflow-molstar-component-build-0.3.11.js.LICENSE.txt +0 -24
  99. package/lib/drugflow-molstar-component-build-0.3.12.js +0 -2
  100. package/lib/drugflow-molstar-component-build-0.3.12.js.LICENSE.txt +0 -24
  101. package/lib/drugflow-molstar-component-build-0.3.13.js +0 -2
  102. package/lib/drugflow-molstar-component-build-0.3.13.js.LICENSE.txt +0 -24
  103. package/lib/drugflow-molstar-component-build-0.3.14.js +0 -2
  104. package/lib/drugflow-molstar-component-build-0.3.14.js.LICENSE.txt +0 -24
  105. package/lib/drugflow-molstar-component-build-0.3.15.js +0 -2
  106. package/lib/drugflow-molstar-component-build-0.3.15.js.LICENSE.txt +0 -24
  107. package/lib/drugflow-molstar-component-build-0.3.16.js +0 -2
  108. package/lib/drugflow-molstar-component-build-0.3.16.js.LICENSE.txt +0 -24
  109. package/lib/drugflow-molstar-component-build-0.3.17.js +0 -2
  110. package/lib/drugflow-molstar-component-build-0.3.17.js.LICENSE.txt +0 -24
  111. package/lib/drugflow-molstar-component-build-0.3.18.js +0 -2
  112. package/lib/drugflow-molstar-component-build-0.3.18.js.LICENSE.txt +0 -24
  113. package/lib/drugflow-molstar-component-build-0.3.19.js +0 -2
  114. package/lib/drugflow-molstar-component-build-0.3.19.js.LICENSE.txt +0 -24
  115. package/lib/drugflow-molstar-component-build-0.3.2.js +0 -2
  116. package/lib/drugflow-molstar-component-build-0.3.2.js.LICENSE.txt +0 -24
  117. package/lib/drugflow-molstar-component-build-0.3.20.js +0 -2
  118. package/lib/drugflow-molstar-component-build-0.3.20.js.LICENSE.txt +0 -24
  119. package/lib/drugflow-molstar-component-build-0.3.21.js +0 -2
  120. package/lib/drugflow-molstar-component-build-0.3.21.js.LICENSE.txt +0 -24
  121. package/lib/drugflow-molstar-component-build-0.3.22.js +0 -2
  122. package/lib/drugflow-molstar-component-build-0.3.22.js.LICENSE.txt +0 -24
  123. package/lib/drugflow-molstar-component-build-0.3.23.js +0 -2
  124. package/lib/drugflow-molstar-component-build-0.3.23.js.LICENSE.txt +0 -24
  125. package/lib/drugflow-molstar-component-build-0.3.24.js +0 -2
  126. package/lib/drugflow-molstar-component-build-0.3.24.js.LICENSE.txt +0 -24
  127. package/lib/drugflow-molstar-component-build-0.3.25.js +0 -2
  128. package/lib/drugflow-molstar-component-build-0.3.25.js.LICENSE.txt +0 -24
  129. package/lib/drugflow-molstar-component-build-0.3.26.js +0 -2
  130. package/lib/drugflow-molstar-component-build-0.3.26.js.LICENSE.txt +0 -24
  131. package/lib/drugflow-molstar-component-build-0.3.27.js +0 -2
  132. package/lib/drugflow-molstar-component-build-0.3.27.js.LICENSE.txt +0 -24
  133. package/lib/drugflow-molstar-component-build-0.3.28.js +0 -2
  134. package/lib/drugflow-molstar-component-build-0.3.28.js.LICENSE.txt +0 -24
  135. package/lib/drugflow-molstar-component-build-0.3.29.js +0 -2
  136. package/lib/drugflow-molstar-component-build-0.3.29.js.LICENSE.txt +0 -24
  137. package/lib/drugflow-molstar-component-build-0.3.3.js +0 -2
  138. package/lib/drugflow-molstar-component-build-0.3.3.js.LICENSE.txt +0 -24
  139. package/lib/drugflow-molstar-component-build-0.3.30.js +0 -2
  140. package/lib/drugflow-molstar-component-build-0.3.30.js.LICENSE.txt +0 -24
  141. package/lib/drugflow-molstar-component-build-0.3.31.js +0 -2
  142. package/lib/drugflow-molstar-component-build-0.3.31.js.LICENSE.txt +0 -24
  143. package/lib/drugflow-molstar-component-build-0.3.32.js +0 -2
  144. package/lib/drugflow-molstar-component-build-0.3.32.js.LICENSE.txt +0 -24
  145. package/lib/drugflow-molstar-component-build-0.3.33.js +0 -2
  146. package/lib/drugflow-molstar-component-build-0.3.33.js.LICENSE.txt +0 -24
  147. package/lib/drugflow-molstar-component-build-0.3.34.js +0 -2
  148. package/lib/drugflow-molstar-component-build-0.3.34.js.LICENSE.txt +0 -24
  149. package/lib/drugflow-molstar-component-build-0.3.35.js +0 -2
  150. package/lib/drugflow-molstar-component-build-0.3.35.js.LICENSE.txt +0 -24
  151. package/lib/drugflow-molstar-component-build-0.3.36.js +0 -2
  152. package/lib/drugflow-molstar-component-build-0.3.36.js.LICENSE.txt +0 -24
  153. package/lib/drugflow-molstar-component-build-0.3.37.js +0 -2
  154. package/lib/drugflow-molstar-component-build-0.3.37.js.LICENSE.txt +0 -24
  155. package/lib/drugflow-molstar-component-build-0.3.38.js +0 -2
  156. package/lib/drugflow-molstar-component-build-0.3.38.js.LICENSE.txt +0 -24
  157. package/lib/drugflow-molstar-component-build-0.3.39.js +0 -2
  158. package/lib/drugflow-molstar-component-build-0.3.39.js.LICENSE.txt +0 -24
  159. package/lib/drugflow-molstar-component-build-0.3.4.js +0 -2
  160. package/lib/drugflow-molstar-component-build-0.3.4.js.LICENSE.txt +0 -24
  161. package/lib/drugflow-molstar-component-build-0.3.40.js +0 -2
  162. package/lib/drugflow-molstar-component-build-0.3.40.js.LICENSE.txt +0 -24
  163. package/lib/drugflow-molstar-component-build-0.3.41.js +0 -2
  164. package/lib/drugflow-molstar-component-build-0.3.41.js.LICENSE.txt +0 -24
  165. package/lib/drugflow-molstar-component-build-0.3.42.js +0 -2
  166. package/lib/drugflow-molstar-component-build-0.3.42.js.LICENSE.txt +0 -24
  167. package/lib/drugflow-molstar-component-build-0.3.43.js +0 -2
  168. package/lib/drugflow-molstar-component-build-0.3.43.js.LICENSE.txt +0 -24
  169. package/lib/drugflow-molstar-component-build-0.3.44.js +0 -2
  170. package/lib/drugflow-molstar-component-build-0.3.44.js.LICENSE.txt +0 -24
  171. package/lib/drugflow-molstar-component-build-0.3.46.js +0 -2
  172. package/lib/drugflow-molstar-component-build-0.3.46.js.LICENSE.txt +0 -24
  173. package/lib/drugflow-molstar-component-build-0.3.47.js +0 -2
  174. package/lib/drugflow-molstar-component-build-0.3.47.js.LICENSE.txt +0 -24
  175. package/lib/drugflow-molstar-component-build-0.3.48.js +0 -2
  176. package/lib/drugflow-molstar-component-build-0.3.48.js.LICENSE.txt +0 -24
  177. package/lib/drugflow-molstar-component-build-0.3.49.js +0 -2
  178. package/lib/drugflow-molstar-component-build-0.3.49.js.LICENSE.txt +0 -24
  179. package/lib/drugflow-molstar-component-build-0.3.5.js +0 -2
  180. package/lib/drugflow-molstar-component-build-0.3.5.js.LICENSE.txt +0 -24
  181. package/lib/drugflow-molstar-component-build-0.3.50.js +0 -2
  182. package/lib/drugflow-molstar-component-build-0.3.50.js.LICENSE.txt +0 -24
  183. package/lib/drugflow-molstar-component-build-0.3.51.js +0 -2
  184. package/lib/drugflow-molstar-component-build-0.3.51.js.LICENSE.txt +0 -24
  185. package/lib/drugflow-molstar-component-build-0.3.52.js +0 -2
  186. package/lib/drugflow-molstar-component-build-0.3.52.js.LICENSE.txt +0 -24
  187. package/lib/drugflow-molstar-component-build-0.3.53.js +0 -2
  188. package/lib/drugflow-molstar-component-build-0.3.53.js.LICENSE.txt +0 -24
  189. package/lib/drugflow-molstar-component-build-0.3.54.js +0 -2
  190. package/lib/drugflow-molstar-component-build-0.3.54.js.LICENSE.txt +0 -24
  191. package/lib/drugflow-molstar-component-build-0.3.55.js +0 -2
  192. package/lib/drugflow-molstar-component-build-0.3.55.js.LICENSE.txt +0 -24
  193. package/lib/drugflow-molstar-component-build-0.3.56.js +0 -2
  194. package/lib/drugflow-molstar-component-build-0.3.56.js.LICENSE.txt +0 -24
  195. package/lib/drugflow-molstar-component-build-0.3.57.js +0 -2
  196. package/lib/drugflow-molstar-component-build-0.3.57.js.LICENSE.txt +0 -24
  197. package/lib/drugflow-molstar-component-build-0.3.58.js +0 -2
  198. package/lib/drugflow-molstar-component-build-0.3.58.js.LICENSE.txt +0 -24
  199. package/lib/drugflow-molstar-component-build-0.3.59.js +0 -2
  200. package/lib/drugflow-molstar-component-build-0.3.59.js.LICENSE.txt +0 -24
  201. package/lib/drugflow-molstar-component-build-0.3.6.js +0 -2
  202. package/lib/drugflow-molstar-component-build-0.3.6.js.LICENSE.txt +0 -24
  203. package/lib/drugflow-molstar-component-build-0.3.60.js +0 -2
  204. package/lib/drugflow-molstar-component-build-0.3.60.js.LICENSE.txt +0 -24
  205. package/lib/drugflow-molstar-component-build-0.3.61.js +0 -2
  206. package/lib/drugflow-molstar-component-build-0.3.61.js.LICENSE.txt +0 -24
  207. package/lib/drugflow-molstar-component-build-0.3.62.js +0 -2
  208. package/lib/drugflow-molstar-component-build-0.3.62.js.LICENSE.txt +0 -24
  209. package/lib/drugflow-molstar-component-build-0.3.63.js +0 -2
  210. package/lib/drugflow-molstar-component-build-0.3.63.js.LICENSE.txt +0 -24
  211. package/lib/drugflow-molstar-component-build-0.3.64.js +0 -2
  212. package/lib/drugflow-molstar-component-build-0.3.64.js.LICENSE.txt +0 -24
  213. package/lib/drugflow-molstar-component-build-0.3.65.js +0 -2
  214. package/lib/drugflow-molstar-component-build-0.3.65.js.LICENSE.txt +0 -24
  215. package/lib/drugflow-molstar-component-build-0.3.66.js +0 -2
  216. package/lib/drugflow-molstar-component-build-0.3.66.js.LICENSE.txt +0 -24
  217. package/lib/drugflow-molstar-component-build-0.3.67.js +0 -2
  218. package/lib/drugflow-molstar-component-build-0.3.67.js.LICENSE.txt +0 -24
  219. package/lib/drugflow-molstar-component-build-0.3.68.js +0 -2
  220. package/lib/drugflow-molstar-component-build-0.3.68.js.LICENSE.txt +0 -24
  221. package/lib/drugflow-molstar-component-build-0.3.69.js +0 -2
  222. package/lib/drugflow-molstar-component-build-0.3.69.js.LICENSE.txt +0 -24
  223. package/lib/drugflow-molstar-component-build-0.3.7.js +0 -2
  224. package/lib/drugflow-molstar-component-build-0.3.7.js.LICENSE.txt +0 -24
  225. package/lib/drugflow-molstar-component-build-0.3.70.js +0 -2
  226. package/lib/drugflow-molstar-component-build-0.3.70.js.LICENSE.txt +0 -24
  227. package/lib/drugflow-molstar-component-build-0.3.71.js +0 -2
  228. package/lib/drugflow-molstar-component-build-0.3.71.js.LICENSE.txt +0 -24
  229. package/lib/drugflow-molstar-component-build-0.3.72.js +0 -2
  230. package/lib/drugflow-molstar-component-build-0.3.72.js.LICENSE.txt +0 -24
  231. package/lib/drugflow-molstar-component-build-0.3.73.js +0 -2
  232. package/lib/drugflow-molstar-component-build-0.3.73.js.LICENSE.txt +0 -24
  233. package/lib/drugflow-molstar-component-build-0.3.74.js +0 -2
  234. package/lib/drugflow-molstar-component-build-0.3.74.js.LICENSE.txt +0 -24
  235. package/lib/drugflow-molstar-component-build-0.3.75.js +0 -2
  236. package/lib/drugflow-molstar-component-build-0.3.75.js.LICENSE.txt +0 -24
  237. package/lib/drugflow-molstar-component-build-0.3.76.js +0 -2
  238. package/lib/drugflow-molstar-component-build-0.3.76.js.LICENSE.txt +0 -24
  239. package/lib/drugflow-molstar-component-build-0.3.77.js +0 -2
  240. package/lib/drugflow-molstar-component-build-0.3.77.js.LICENSE.txt +0 -24
  241. package/lib/drugflow-molstar-component-build-0.3.8.js +0 -2
  242. package/lib/drugflow-molstar-component-build-0.3.8.js.LICENSE.txt +0 -24
  243. package/lib/drugflow-molstar-component-build-0.3.9.js +0 -2
  244. package/lib/drugflow-molstar-component-build-0.3.9.js.LICENSE.txt +0 -24
  245. package/lib/index2.d.ts +0 -1
  246. package/lib/index2.js +0 -1369
  247. package/lib/pdbe-molstar-component-build-3.1.2.js +0 -2
  248. package/lib/pdbe-molstar-component-build-3.1.2.js.LICENSE.txt +0 -24
  249. /package/lib/{drugflow-molstar-component-build-0.1.2.js.LICENSE.txt → drugflow-molstar-component-build-0.3.78.js.LICENSE.txt} +0 -0
  250. /package/lib/{drugflow-molstar-component-build-0.1.3.js.LICENSE.txt → drugflow-molstar-component-build-0.4.1.js.LICENSE.txt} +0 -0
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderSuperposition = exports.superposeAf = exports.loadAfStructure = exports.initSuperposition = void 0;
4
- var tslib_1 = require("tslib");
5
- var linear_algebra_1 = require("Molstar/mol-math/linear-algebra");
6
- var builder_1 = require("Molstar/mol-script/language/builder");
7
- var mol_state_1 = require("Molstar/mol-state");
8
- var transforms_1 = require("Molstar/mol-plugin-state/transforms");
9
- var assets_1 = require("Molstar/mol-util/assets");
10
- var helpers_1 = require("./helpers");
11
- var lists_1 = require("Molstar/mol-util/color/lists");
12
- var color_1 = require("Molstar/mol-util/color/color");
13
- var script_1 = require("Molstar/mol-script/script");
14
- var mol_task_1 = require("Molstar/mol-task");
15
- var superposition_sifts_mapping_1 = require("./superposition-sifts-mapping");
16
- var alphafold_transparency_1 = require("./alphafold-transparency");
17
- var structure_1 = require("Molstar/mol-model/structure");
4
+ const linear_algebra_1 = require("Molstar/mol-math/linear-algebra");
5
+ const builder_1 = require("Molstar/mol-script/language/builder");
6
+ const mol_state_1 = require("Molstar/mol-state");
7
+ const transforms_1 = require("Molstar/mol-plugin-state/transforms");
8
+ const assets_1 = require("Molstar/mol-util/assets");
9
+ const helpers_1 = require("./helpers");
10
+ const lists_1 = require("Molstar/mol-util/color/lists");
11
+ const color_1 = require("Molstar/mol-util/color/color");
12
+ const script_1 = require("Molstar/mol-script/script");
13
+ const mol_task_1 = require("Molstar/mol-task");
14
+ const superposition_sifts_mapping_1 = require("./superposition-sifts-mapping");
15
+ const alphafold_transparency_1 = require("./alphafold-transparency");
16
+ const structure_1 = require("Molstar/mol-model/structure");
18
17
  function getRandomColor(plugin, segmentIndex) {
19
- var clList = lists_1.ColorLists;
20
- var spState = plugin.customState.superpositionState;
21
- var palleteIndex = spState.colorState[segmentIndex].palleteIndex;
22
- var colorIndex = spState.colorState[segmentIndex].colorIndex;
18
+ const clList = lists_1.ColorLists;
19
+ const spState = plugin.customState.superpositionState;
20
+ let palleteIndex = spState.colorState[segmentIndex].palleteIndex;
21
+ let colorIndex = spState.colorState[segmentIndex].colorIndex;
23
22
  if (clList[spState.colorPalette[palleteIndex]].list[colorIndex + 1]) {
24
23
  colorIndex += 1;
25
24
  }
@@ -27,598 +26,418 @@ function getRandomColor(plugin, segmentIndex) {
27
26
  colorIndex = 0;
28
27
  palleteIndex = spState.colorPalette[palleteIndex + 1] ? palleteIndex + 1 : 0;
29
28
  }
30
- var palleteName = spState.colorPalette[palleteIndex];
29
+ const palleteName = spState.colorPalette[palleteIndex];
31
30
  plugin.customState.superpositionState.colorState[segmentIndex].palleteIndex = palleteIndex;
32
31
  plugin.customState.superpositionState.colorState[segmentIndex].colorIndex = colorIndex;
33
32
  return clList[palleteName].list[colorIndex];
34
33
  }
35
- function initSuperposition(plugin) {
36
- return tslib_1.__awaiter(this, void 0, void 0, function () {
37
- var customState, superpositionParams, segmentData, afStrUrls, segmentIndex, clusterIndexs, entryList, clusters;
38
- return tslib_1.__generator(this, function (_a) {
39
- switch (_a.label) {
40
- case 0: return [4 /*yield*/, plugin.clear()];
41
- case 1:
42
- _a.sent();
43
- customState = plugin.customState;
44
- superpositionParams = customState.initParams.superpositionParams;
45
- plugin.customState.superpositionState = {
46
- models: {},
47
- entries: {},
48
- refMaps: {},
49
- segmentData: void 0,
50
- matrixData: {},
51
- activeSegment: 0,
52
- loadedStructs: [],
53
- visibleRefs: [],
54
- invalidStruct: [],
55
- noMatrixStruct: [],
56
- hets: {},
57
- colorPalette: ['dark-2', 'red-yellow-green', 'paired', 'set-1', 'accent', 'set-2', 'rainbow'],
58
- colorState: [],
59
- alphafold: {
60
- apiData: {
61
- cif: '',
62
- pae: '',
63
- length: 0
64
- },
65
- length: 0,
66
- ref: '',
67
- traceOnly: true,
68
- visibility: [],
69
- transforms: [],
70
- rmsds: [],
71
- coordinateSystems: []
72
- }
73
- };
74
- // Get segment and cluster information for the given uniprot accession
75
- return [4 /*yield*/, getSegmentData(plugin)];
76
- case 2:
77
- // Get segment and cluster information for the given uniprot accession
78
- _a.sent();
79
- segmentData = plugin.customState.superpositionState.segmentData;
80
- if (!segmentData)
81
- return [2 /*return*/];
82
- // Load Matrix Data
83
- return [4 /*yield*/, getMatrixData(plugin)];
84
- case 3:
85
- // Load Matrix Data
86
- _a.sent();
87
- if (!plugin.customState.superpositionState.segmentData)
88
- return [2 /*return*/];
89
- return [4 /*yield*/, getAfUrl(plugin, customState.initParams.moleculeId)];
90
- case 4:
91
- afStrUrls = _a.sent();
92
- if (afStrUrls)
93
- customState.superpositionState.alphafold.apiData = afStrUrls;
94
- segmentData.forEach(function () {
95
- plugin.customState.superpositionState.loadedStructs.push([]);
96
- plugin.customState.superpositionState.visibleRefs.push([]);
97
- plugin.customState.superpositionState.colorState.push({ palleteIndex: 0, colorIndex: -1 });
98
- });
99
- segmentIndex = (superpositionParams && superpositionParams.segment) ? superpositionParams.segment - 1 : 0;
100
- plugin.customState.superpositionState.activeSegment = segmentIndex + 1;
101
- clusterIndexs = (superpositionParams && superpositionParams.cluster) ? superpositionParams.cluster : void 0;
102
- // Emit segment API data load event
103
- plugin.customState.events.superpositionInit.next(true);
104
- entryList = [];
105
- clusters = segmentData[segmentIndex].clusters;
106
- clusters.forEach(function (cluster, clusterIndex) {
107
- // Validate for cluster index if provided in superPositionParams
108
- if (clusterIndexs && clusterIndexs.indexOf(clusterIndex) === -1)
109
- return;
110
- // Add respresentative structure to the list
111
- if (superpositionParams && superpositionParams.superposeAll) {
112
- entryList = entryList.concat(cluster);
113
- }
114
- else {
115
- entryList.push(cluster[0]);
116
- }
117
- });
118
- return [4 /*yield*/, renderSuperposition(plugin, segmentIndex, entryList)];
119
- case 5:
120
- _a.sent();
121
- return [2 /*return*/];
122
- }
123
- });
34
+ async function initSuperposition(plugin) {
35
+ await plugin.clear();
36
+ const customState = plugin.customState;
37
+ const superpositionParams = customState.initParams.superpositionParams;
38
+ plugin.customState.superpositionState = {
39
+ models: {},
40
+ entries: {},
41
+ refMaps: {},
42
+ segmentData: void 0,
43
+ matrixData: {},
44
+ activeSegment: 0,
45
+ loadedStructs: [],
46
+ visibleRefs: [],
47
+ invalidStruct: [],
48
+ noMatrixStruct: [],
49
+ hets: {},
50
+ colorPalette: ['dark-2', 'red-yellow-green', 'paired', 'set-1', 'accent', 'set-2', 'rainbow'],
51
+ colorState: [],
52
+ alphafold: {
53
+ apiData: {
54
+ cif: '',
55
+ pae: '',
56
+ length: 0
57
+ },
58
+ length: 0,
59
+ ref: '',
60
+ traceOnly: true,
61
+ visibility: [],
62
+ transforms: [],
63
+ rmsds: [],
64
+ coordinateSystems: []
65
+ }
66
+ };
67
+ // Get segment and cluster information for the given uniprot accession
68
+ await getSegmentData(plugin);
69
+ const segmentData = plugin.customState.superpositionState.segmentData;
70
+ if (!segmentData)
71
+ return;
72
+ // Load Matrix Data
73
+ await getMatrixData(plugin);
74
+ if (!plugin.customState.superpositionState.segmentData)
75
+ return;
76
+ const afStrUrls = await getAfUrl(plugin, customState.initParams.moleculeId);
77
+ if (afStrUrls)
78
+ customState.superpositionState.alphafold.apiData = afStrUrls;
79
+ segmentData.forEach(() => {
80
+ plugin.customState.superpositionState.loadedStructs.push([]);
81
+ plugin.customState.superpositionState.visibleRefs.push([]);
82
+ plugin.customState.superpositionState.colorState.push({ palleteIndex: 0, colorIndex: -1 });
83
+ });
84
+ // Set segment and cluster details from superPositionParams
85
+ const segmentIndex = (superpositionParams && superpositionParams.segment) ? superpositionParams.segment - 1 : 0;
86
+ plugin.customState.superpositionState.activeSegment = segmentIndex + 1;
87
+ const clusterIndexs = (superpositionParams && superpositionParams.cluster) ? superpositionParams.cluster : void 0;
88
+ // Emit segment API data load event
89
+ plugin.customState.events.superpositionInit.next(true);
90
+ // Get entry list to load matrix data
91
+ let entryList = [];
92
+ const clusters = segmentData[segmentIndex].clusters;
93
+ clusters.forEach((cluster, clusterIndex) => {
94
+ // Validate for cluster index if provided in superPositionParams
95
+ if (clusterIndexs && clusterIndexs.indexOf(clusterIndex) === -1)
96
+ return;
97
+ // Add respresentative structure to the list
98
+ if (superpositionParams && superpositionParams.superposeAll) {
99
+ entryList = entryList.concat(cluster);
100
+ }
101
+ else {
102
+ entryList.push(cluster[0]);
103
+ }
124
104
  });
105
+ await renderSuperposition(plugin, segmentIndex, entryList);
125
106
  }
126
107
  exports.initSuperposition = initSuperposition;
127
108
  function createCarbVisLabel(carbLigNamesAndCount) {
128
- var compList = [];
129
- for (var carbCompId in carbLigNamesAndCount) {
130
- compList.push("".concat(carbCompId, " (").concat(carbLigNamesAndCount[carbCompId], ")"));
109
+ const compList = [];
110
+ for (const carbCompId in carbLigNamesAndCount) {
111
+ compList.push(`${carbCompId} (${carbLigNamesAndCount[carbCompId]})`);
131
112
  }
132
113
  return compList.join(', ');
133
114
  }
134
- function getAfUrl(plugin, accession) {
135
- return tslib_1.__awaiter(this, void 0, void 0, function () {
136
- var apiResponse, apiData;
137
- var _this = this;
138
- return tslib_1.__generator(this, function (_a) {
139
- switch (_a.label) {
140
- case 0: return [4 /*yield*/, plugin.runTask(mol_task_1.Task.create('Get AlphaFold URL', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
141
- var e_1;
142
- return tslib_1.__generator(this, function (_a) {
143
- switch (_a.label) {
144
- case 0:
145
- _a.trys.push([0, 2, , 3]);
146
- return [4 /*yield*/, plugin.fetch({ url: "https://alphafold.ebi.ac.uk/api/prediction/".concat(accession), type: 'json' }).runInContext(ctx)];
147
- case 1:
148
- apiResponse = _a.sent();
149
- if (apiResponse && (apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse[0].bcifUrl)) {
150
- apiData = {
151
- cif: apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse[0].cifUrl,
152
- pae: apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse[0].paeImageUrl,
153
- length: apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse[0].uniprotEnd
154
- };
155
- }
156
- return [3 /*break*/, 3];
157
- case 2:
158
- e_1 = _a.sent();
159
- return [3 /*break*/, 3];
160
- case 3: return [2 /*return*/];
161
- }
162
- });
163
- }); }))];
164
- case 1:
165
- _a.sent();
166
- return [2 /*return*/, apiData];
115
+ async function getAfUrl(plugin, accession) {
116
+ let apiResponse;
117
+ let apiData;
118
+ await plugin.runTask(mol_task_1.Task.create('Get AlphaFold URL', async (ctx) => {
119
+ try {
120
+ apiResponse = await plugin.fetch({ url: `https://alphafold.ebi.ac.uk/api/prediction/${accession}`, type: 'json' }).runInContext(ctx);
121
+ if (apiResponse && apiResponse?.[0].bcifUrl) {
122
+ apiData = {
123
+ cif: apiResponse?.[0].cifUrl,
124
+ pae: apiResponse?.[0].paeImageUrl,
125
+ length: apiResponse?.[0].uniprotEnd
126
+ };
167
127
  }
168
- });
169
- });
128
+ }
129
+ catch (e) {
130
+ // console.warn(e);
131
+ }
132
+ }));
133
+ return apiData;
170
134
  }
171
- function loadAfStructure(plugin) {
172
- return tslib_1.__awaiter(this, void 0, void 0, function () {
173
- var customState, structure, strInstance, spState, chainSel;
174
- return tslib_1.__generator(this, function (_a) {
175
- switch (_a.label) {
176
- case 0:
177
- customState = plugin.customState;
178
- return [4 /*yield*/, loadStructure(plugin, customState.superpositionState.alphafold.apiData.cif, 'mmcif', false)];
179
- case 1:
180
- structure = (_a.sent()).structure;
181
- strInstance = structure;
182
- if (!strInstance)
183
- return [2 /*return*/, false];
184
- spState = plugin.customState.superpositionState;
185
- spState.alphafold.ref = strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref;
186
- spState.models["AF-".concat(customState.initParams.moleculeId)] = strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref;
187
- return [4 /*yield*/, plugin.builders.structure.tryCreateComponentStatic(strInstance, 'polymer', { label: "AlphaFold Structure", tags: ["alphafold-chain", "superposition-sel"] })];
188
- case 2:
189
- chainSel = _a.sent();
190
- if (!chainSel) return [3 /*break*/, 4];
191
- return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'plddt-confidence', size: 'uniform', sizeParams: { value: 1.5 } }, { tag: "af-superposition-visual" })];
192
- case 3:
193
- _a.sent();
194
- return [2 /*return*/, strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref];
195
- case 4: return [2 /*return*/, false];
196
- }
197
- });
198
- });
135
+ async function loadAfStructure(plugin) {
136
+ const customState = plugin.customState;
137
+ const { structure } = await loadStructure(plugin, customState.superpositionState.alphafold.apiData.cif, 'mmcif', false);
138
+ const strInstance = structure;
139
+ if (!strInstance)
140
+ return false;
141
+ // Store Refs in state
142
+ const spState = plugin.customState.superpositionState;
143
+ spState.alphafold.ref = strInstance?.ref;
144
+ spState.models[`AF-${customState.initParams.moleculeId}`] = strInstance?.ref;
145
+ const chainSel = await plugin.builders.structure.tryCreateComponentStatic(strInstance, 'polymer', { label: `AlphaFold Structure`, tags: [`alphafold-chain`, `superposition-sel`] });
146
+ if (chainSel) {
147
+ await plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'plddt-confidence', size: 'uniform', sizeParams: { value: 1.5 } }, { tag: `af-superposition-visual` });
148
+ return strInstance?.ref;
149
+ }
150
+ return false;
199
151
  }
200
152
  exports.loadAfStructure = loadAfStructure;
201
- function superposeAf(plugin, traceOnly, segmentIndex) {
202
- return tslib_1.__awaiter(this, void 0, void 0, function () {
203
- var customState, spState, afStrRef, _a, afStr, segmentNum, mappingResult_1, coordinateSystems_1, failedPairsResult_1, zeroOverlapPairsResult_1, minRmsd_1, minIndex_1, rmsdList_1, segmentClusters;
204
- return tslib_1.__generator(this, function (_b) {
205
- switch (_b.label) {
206
- case 0:
207
- customState = plugin.customState;
208
- if (!customState.superpositionState || !customState.superpositionState.segmentData)
209
- return [2 /*return*/];
210
- spState = customState.superpositionState;
211
- _a = spState.alphafold.ref;
212
- if (_a) return [3 /*break*/, 2];
213
- return [4 /*yield*/, loadAfStructure(plugin)];
214
- case 1:
215
- _a = (_b.sent());
216
- _b.label = 2;
217
- case 2:
218
- afStrRef = _a;
219
- if (!afStrRef)
220
- return [2 /*return*/];
221
- afStr = plugin.managers.structure.hierarchy.current.refs.get(afStrRef);
222
- segmentNum = segmentIndex ? segmentIndex : spState.activeSegment - 1;
223
- if (!spState.alphafold.transforms[segmentNum]) {
224
- mappingResult_1 = [];
225
- coordinateSystems_1 = [];
226
- failedPairsResult_1 = [];
227
- zeroOverlapPairsResult_1 = [];
228
- minRmsd_1 = 0;
229
- minIndex_1 = 0;
230
- rmsdList_1 = [];
231
- segmentClusters = spState.segmentData[segmentNum].clusters;
232
- segmentClusters.forEach(function (cluster) {
233
- var _a, _b, _c;
234
- var modelRef = spState.models["".concat(cluster[0].pdb_id, "_").concat(cluster[0].struct_asym_id)];
235
- if (modelRef) {
236
- var structHierarchy = plugin.managers.structure.hierarchy.current.refs.get(modelRef);
237
- if (structHierarchy) {
238
- var input = [structHierarchy.components[0], afStr];
239
- var structures = input.map(function (s) { var _a; return (_a = s.cell.obj) === null || _a === void 0 ? void 0 : _a.data; });
240
- var _d = (0, superposition_sifts_mapping_1.alignAndSuperposeWithSIFTSMapping)(structures, { traceOnly: traceOnly, includeResidueTest: function (loc) { return structure_1.StructureProperties.atom.B_iso_or_equiv(loc) > 70; },
241
- applyTestIndex: [1] }), entries = _d.entries, failedPairs = _d.failedPairs, zeroOverlapPairs = _d.zeroOverlapPairs;
242
- if (entries.length === 0 || (entries && entries[0] && entries[0].transform.rmsd.toFixed(1) === '0.0')) {
243
- var alignWithoutPlddt = (0, superposition_sifts_mapping_1.alignAndSuperposeWithSIFTSMapping)(structures, { traceOnly: traceOnly });
244
- entries = alignWithoutPlddt.entries;
245
- }
246
- if (entries && entries[0]) {
247
- mappingResult_1.push(entries[0]);
248
- coordinateSystems_1.push((_c = (_b = (_a = input[0]) === null || _a === void 0 ? void 0 : _a.transform) === null || _b === void 0 ? void 0 : _b.cell.obj) === null || _c === void 0 ? void 0 : _c.data.coordinateSystem);
249
- var totalMappings = mappingResult_1.length;
250
- if (totalMappings === 1 || entries[0].transform.rmsd < minRmsd_1) {
251
- minRmsd_1 = entries[0].transform.rmsd;
252
- minIndex_1 = totalMappings === 1 ? 0 : mappingResult_1.length - 1;
253
- }
254
- rmsdList_1.push("".concat(cluster[0].pdb_id, " chain ").concat(cluster[0].struct_asym_id, ":").concat(entries[0].transform.rmsd.toFixed(2)));
255
- }
256
- else {
257
- if (failedPairs.length > 0)
258
- failedPairsResult_1.push(failedPairs);
259
- if (zeroOverlapPairs.length > 0)
260
- zeroOverlapPairsResult_1.push(zeroOverlapPairs);
261
- // rmsdList.push(`${cluster[0].pdb_id} ${cluster[0].struct_asym_id}:-`)
262
- }
263
- }
264
- }
265
- });
266
- // console.log(failedPairsResult);
267
- // console.log(zeroOverlapPairsResult);
268
- if (mappingResult_1.length > 0) {
269
- spState.alphafold.visibility[segmentNum] = true;
270
- spState.alphafold.transforms[segmentNum] = mappingResult_1[minIndex_1].transform.bTransform;
271
- spState.alphafold.coordinateSystems[segmentNum] = coordinateSystems_1[minIndex_1];
272
- spState.alphafold.rmsds[segmentNum] = rmsdList_1.sort(function (a, b) { return parseFloat(a.split(':')[1]) - parseFloat(b.split(':')[1]); });
153
+ async function superposeAf(plugin, traceOnly, segmentIndex) {
154
+ const customState = plugin.customState;
155
+ if (!customState.superpositionState || !customState.superpositionState.segmentData)
156
+ return;
157
+ const spState = customState.superpositionState;
158
+ // Load AF structure
159
+ const afStrRef = spState.alphafold.ref || await loadAfStructure(plugin);
160
+ if (!afStrRef)
161
+ return;
162
+ const afStr = plugin.managers.structure.hierarchy.current.refs.get(afStrRef);
163
+ const segmentNum = segmentIndex ? segmentIndex : spState.activeSegment - 1;
164
+ if (!spState.alphafold.transforms[segmentNum]) {
165
+ // Create representative list
166
+ const mappingResult = [];
167
+ const coordinateSystems = [];
168
+ const failedPairsResult = [];
169
+ const zeroOverlapPairsResult = [];
170
+ let minRmsd = 0;
171
+ let minIndex = 0;
172
+ let rmsdList = [];
173
+ const segmentClusters = spState.segmentData[segmentNum].clusters;
174
+ segmentClusters.forEach((cluster) => {
175
+ const modelRef = spState.models[`${cluster[0].pdb_id}_${cluster[0].struct_asym_id}`];
176
+ if (modelRef) {
177
+ const structHierarchy = plugin.managers.structure.hierarchy.current.refs.get(modelRef);
178
+ if (structHierarchy) {
179
+ const input = [structHierarchy.components[0], afStr];
180
+ const structures = input.map(s => s.cell.obj?.data);
181
+ let { entries, failedPairs, zeroOverlapPairs } = (0, superposition_sifts_mapping_1.alignAndSuperposeWithSIFTSMapping)(structures, { traceOnly,
182
+ includeResidueTest: loc => structure_1.StructureProperties.atom.B_iso_or_equiv(loc) > 70,
183
+ applyTestIndex: [1]
184
+ });
185
+ if (entries.length === 0 || (entries && entries[0] && entries[0].transform.rmsd.toFixed(1) === '0.0')) {
186
+ const alignWithoutPlddt = (0, superposition_sifts_mapping_1.alignAndSuperposeWithSIFTSMapping)(structures, { traceOnly });
187
+ entries = alignWithoutPlddt.entries;
188
+ }
189
+ if (entries && entries[0]) {
190
+ mappingResult.push(entries[0]);
191
+ coordinateSystems.push(input[0]?.transform?.cell.obj?.data.coordinateSystem);
192
+ const totalMappings = mappingResult.length;
193
+ if (totalMappings === 1 || entries[0].transform.rmsd < minRmsd) {
194
+ minRmsd = entries[0].transform.rmsd;
195
+ minIndex = totalMappings === 1 ? 0 : mappingResult.length - 1;
273
196
  }
197
+ rmsdList.push(`${cluster[0].pdb_id} chain ${cluster[0].struct_asym_id}:${entries[0].transform.rmsd.toFixed(2)}`);
274
198
  }
275
- return [4 /*yield*/, afTransform(plugin, afStr.cell, spState.alphafold.transforms[segmentNum], spState.alphafold.coordinateSystems[segmentNum])];
276
- case 3:
277
- _b.sent();
278
- (0, alphafold_transparency_1.applyAFTransparency)(plugin, afStr, 0.8, 70);
279
- return [2 /*return*/, true];
199
+ else {
200
+ if (failedPairs.length > 0)
201
+ failedPairsResult.push(failedPairs);
202
+ if (zeroOverlapPairs.length > 0)
203
+ zeroOverlapPairsResult.push(zeroOverlapPairs);
204
+ // rmsdList.push(`${cluster[0].pdb_id} ${cluster[0].struct_asym_id}:-`)
205
+ }
206
+ }
280
207
  }
281
208
  });
282
- });
209
+ // console.log(failedPairsResult);
210
+ // console.log(zeroOverlapPairsResult);
211
+ if (mappingResult.length > 0) {
212
+ spState.alphafold.visibility[segmentNum] = true;
213
+ spState.alphafold.transforms[segmentNum] = mappingResult[minIndex].transform.bTransform;
214
+ spState.alphafold.coordinateSystems[segmentNum] = coordinateSystems[minIndex];
215
+ spState.alphafold.rmsds[segmentNum] = rmsdList.sort((a, b) => parseFloat(a.split(':')[1]) - parseFloat(b.split(':')[1]));
216
+ }
217
+ }
218
+ await afTransform(plugin, afStr.cell, spState.alphafold.transforms[segmentNum], spState.alphafold.coordinateSystems[segmentNum]);
219
+ (0, alphafold_transparency_1.applyAFTransparency)(plugin, afStr, 0.8, 70);
220
+ return true;
283
221
  }
284
222
  exports.superposeAf = superposeAf;
285
- function renderSuperposition(plugin, segmentIndex, entryList) {
286
- return tslib_1.__awaiter(this, void 0, void 0, function () {
287
- var customState, superpositionParams, busyFlagOn;
288
- var _this = this;
289
- return tslib_1.__generator(this, function (_a) {
290
- customState = plugin.customState;
291
- superpositionParams = customState.initParams.superpositionParams;
292
- busyFlagOn = false;
293
- if (entryList.length > 1) {
294
- busyFlagOn = true;
295
- customState.events.isBusy.next(true);
223
+ async function renderSuperposition(plugin, segmentIndex, entryList) {
224
+ const customState = plugin.customState;
225
+ const superpositionParams = customState.initParams.superpositionParams;
226
+ let busyFlagOn = false;
227
+ if (entryList.length > 1) {
228
+ busyFlagOn = true;
229
+ customState.events.isBusy.next(true);
230
+ }
231
+ // Load Coordinates and render respresentations
232
+ return plugin.dataTransaction(async () => {
233
+ const spState = plugin.customState.superpositionState;
234
+ for await (const s of entryList) {
235
+ // validate matrix availability
236
+ if (!spState.matrixData[`${s.pdb_id}_${s.auth_asym_id}`]) {
237
+ spState.noMatrixStruct.push(`${s.pdb_id}_${s.struct_asym_id}`);
238
+ spState.invalidStruct.push(`${s.pdb_id}_${s.struct_asym_id}`);
239
+ continue;
296
240
  }
297
- // Load Coordinates and render respresentations
298
- return [2 /*return*/, plugin.dataTransaction(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
299
- var spState, entryList_1, entryList_1_1, s, strUrl, strInstance, modelRef, clearOnFail, polymerInstance, modelInstance, isBinary, _a, model, structure, matrix, chainSel, uniformColor1, uniformColor2, invalidStruct, state, hetInfo, hets, hets_1, hets_1_1, het, ligand, labelTagParams, hetColor, _b, r, g, b, ligandExp, e_2_1, carbEntityCount, allCarbPolymers, polymerChainWithSurroundings, i, _i, _c, carbEntityChainId, carbEntityChain, carbEntityChainInVicinity, data, carbChainSel, carbLigands, carbLigNamesAndCount, carbLigList, _d, _e, carbLigs, ligResDetails, carbVisLabel, branchedEntity, labelTagParams, ligandExp, loadedStructIndex, e_3_1;
300
- var e_3, _f, e_2, _g;
301
- return tslib_1.__generator(this, function (_h) {
302
- switch (_h.label) {
303
- case 0:
304
- spState = plugin.customState.superpositionState;
305
- _h.label = 1;
306
- case 1:
307
- _h.trys.push([1, 41, 42, 47]);
308
- entryList_1 = tslib_1.__asyncValues(entryList);
309
- _h.label = 2;
310
- case 2: return [4 /*yield*/, entryList_1.next()];
311
- case 3:
312
- if (!(entryList_1_1 = _h.sent(), !entryList_1_1.done)) return [3 /*break*/, 40];
313
- s = entryList_1_1.value;
314
- // validate matrix availability
315
- if (!spState.matrixData["".concat(s.pdb_id, "_").concat(s.auth_asym_id)]) {
316
- spState.noMatrixStruct.push("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
317
- spState.invalidStruct.push("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
318
- return [3 /*break*/, 39];
319
- }
320
- spState.loadedStructs[segmentIndex].push("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
321
- strUrl = "".concat(customState.initParams.pdbeUrl, "model-server/v1/").concat(s.pdb_id, "/atoms?auth_asym_id=").concat(s.auth_asym_id, "&encoding=").concat(customState.initParams.encoding);
322
- if (superpositionParams && superpositionParams.ligandView)
323
- strUrl = "https://www.ebi.ac.uk/pdbe/entry-files/download/".concat(s.pdb_id, ".bcif");
324
- strInstance = void 0;
325
- modelRef = void 0;
326
- clearOnFail = true;
327
- if (!(superpositionParams && superpositionParams.ligandView && spState.entries[s.pdb_id])) return [3 /*break*/, 5];
328
- polymerInstance = plugin.state.data.select(spState.entries[s.pdb_id])[0];
329
- modelRef = polymerInstance.transform.parent;
330
- modelInstance = plugin.state.data.select(modelRef)[0];
331
- return [4 /*yield*/, plugin.builders.structure.createStructure(modelInstance, { name: 'model', params: {} })];
332
- case 4:
333
- strInstance = _h.sent();
334
- clearOnFail = false;
335
- return [3 /*break*/, 7];
336
- case 5:
337
- isBinary = customState.initParams.encoding === 'bcif' ? true : false;
338
- return [4 /*yield*/, loadStructure(plugin, strUrl, 'mmcif', isBinary)];
339
- case 6:
340
- _a = _h.sent(), model = _a.model, structure = _a.structure;
341
- strInstance = structure;
342
- modelRef = model.ref;
343
- _h.label = 7;
344
- case 7:
345
- if (!strInstance)
346
- return [3 /*break*/, 39];
347
- // Store Refs in state
348
- if (!spState.models["".concat(s.pdb_id, "_").concat(s.struct_asym_id)])
349
- spState.models["".concat(s.pdb_id, "_").concat(s.struct_asym_id)] = strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref;
350
- if (superpositionParams && superpositionParams.ligandView && !spState.entries[s.pdb_id])
351
- spState.entries[s.pdb_id] = strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref;
352
- matrix = linear_algebra_1.Mat4.ofRows(plugin.customState.superpositionState.matrixData["".concat(s.pdb_id, "_").concat(s.auth_asym_id)].matrix);
353
- return [4 /*yield*/, transform(plugin, strInstance, matrix)];
354
- case 8:
355
- _h.sent();
356
- chainSel = void 0;
357
- if (!((superpositionParams && superpositionParams.ligandView) && s.is_representative)) return [3 /*break*/, 12];
358
- uniformColor1 = getRandomColor(plugin, segmentIndex);
359
- return [4 /*yield*/, plugin.builders.structure.tryCreateComponentFromExpression(strInstance, chainSelection(s.struct_asym_id), "Chain-".concat(segmentIndex), { label: "Chain", tags: ["superposition-sel"] })];
360
- case 9:
361
- chainSel = _h.sent();
362
- if (!chainSel) return [3 /*break*/, 11];
363
- return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'uniform', colorParams: { value: uniformColor1 }, size: 'uniform' }, { tag: "superposition-visual" })];
364
- case 10:
365
- _h.sent();
366
- spState.refMaps[chainSel.ref] = "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
367
- _h.label = 11;
368
- case 11: return [3 /*break*/, 16];
369
- case 12:
370
- if (!((superpositionParams && superpositionParams.ligandView) && !s.is_representative)) return [3 /*break*/, 13];
371
- return [3 /*break*/, 16];
372
- case 13:
373
- uniformColor2 = getRandomColor(plugin, segmentIndex);
374
- return [4 /*yield*/, plugin.builders.structure.tryCreateComponentStatic(strInstance, 'polymer', { label: "Chain", tags: ["Chain-".concat(segmentIndex), "superposition-sel"] })];
375
- case 14:
376
- chainSel = _h.sent();
377
- if (!chainSel) return [3 /*break*/, 16];
378
- return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'uniform', colorParams: { value: uniformColor2 }, size: 'uniform' }, { tag: "superposition-visual" })];
379
- case 15:
380
- _h.sent();
381
- spState.refMaps[chainSel.ref] = "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
382
- _h.label = 16;
383
- case 16:
384
- invalidStruct = chainSel ? false : true;
385
- if (!(superpositionParams && superpositionParams.ligandView)) return [3 /*break*/, 39];
386
- state = plugin.state.data;
387
- return [4 /*yield*/, getLigandNamesFromModelData(plugin, state, modelRef)];
388
- case 17:
389
- hetInfo = _h.sent();
390
- hets = hetInfo ? hetInfo.hetNames : [];
391
- if (!(hets && hets.length > 0)) return [3 /*break*/, 31];
392
- _h.label = 18;
393
- case 18:
394
- _h.trys.push([18, 25, 26, 31]);
395
- hets_1 = (e_2 = void 0, tslib_1.__asyncValues(hets));
396
- _h.label = 19;
397
- case 19: return [4 /*yield*/, hets_1.next()];
398
- case 20:
399
- if (!(hets_1_1 = _h.sent(), !hets_1_1.done)) return [3 /*break*/, 24];
400
- het = hets_1_1.value;
401
- ligand = builder_1.MolScriptBuilder.struct.generator.atomGroups({
402
- 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), s.auth_asym_id]),
403
- 'residue-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.label_comp_id(), het]),
404
- 'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
405
- });
406
- labelTagParams = { label: "".concat(het), tags: ["superposition-ligand-sel"] };
407
- hetColor = color_1.Color.fromRgb(253, 3, 253);
408
- if (superpositionParams && superpositionParams.ligandColor) {
409
- _b = superpositionParams.ligandColor, r = _b.r, g = _b.g, b = _b.b;
410
- hetColor = color_1.Color.fromRgb(r, g, b);
411
- }
412
- return [4 /*yield*/, plugin.builders.structure.tryCreateComponentFromExpression(strInstance, ligand, "".concat(het, "-").concat(segmentIndex), labelTagParams)];
413
- case 21:
414
- ligandExp = _h.sent();
415
- if (!ligandExp) return [3 /*break*/, 23];
416
- return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(ligandExp, { type: 'ball-and-stick', color: 'uniform', colorParams: { value: hetColor } }, { tag: "superposition-ligand-visual" })];
417
- case 22:
418
- _h.sent();
419
- spState.refMaps[ligandExp.ref] = "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
420
- invalidStruct = false;
421
- _h.label = 23;
422
- case 23: return [3 /*break*/, 19];
423
- case 24: return [3 /*break*/, 31];
424
- case 25:
425
- e_2_1 = _h.sent();
426
- e_2 = { error: e_2_1 };
427
- return [3 /*break*/, 31];
428
- case 26:
429
- _h.trys.push([26, , 29, 30]);
430
- if (!(hets_1_1 && !hets_1_1.done && (_g = hets_1.return))) return [3 /*break*/, 28];
431
- return [4 /*yield*/, _g.call(hets_1)];
432
- case 27:
433
- _h.sent();
434
- _h.label = 28;
435
- case 28: return [3 /*break*/, 30];
436
- case 29:
437
- if (e_2) throw e_2.error;
438
- return [7 /*endfinally*/];
439
- case 30: return [7 /*endfinally*/];
440
- case 31:
441
- carbEntityCount = hetInfo ? hetInfo.carbEntityCount : 0;
442
- if (!(carbEntityCount > 0)) return [3 /*break*/, 38];
443
- return [4 /*yield*/, getCarbPolymerDetailsFromApi(plugin, s.pdb_id)];
444
- case 32:
445
- allCarbPolymers = _h.sent();
446
- polymerChainWithSurroundings = builder_1.MolScriptBuilder.struct.modifier.includeSurroundings({
447
- 0: builder_1.MolScriptBuilder.struct.generator.atomGroups({
448
- 'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'polymer']),
449
- 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), s.auth_asym_id]),
450
- 'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
451
- }),
452
- radius: 5,
453
- 'as-whole-residues': true
454
- });
455
- i = 0;
456
- _i = 0, _c = allCarbPolymers.branchedChains;
457
- _h.label = 33;
458
- case 33:
459
- if (!(_i < _c.length)) return [3 /*break*/, 38];
460
- carbEntityChainId = _c[_i];
461
- carbEntityChain = builder_1.MolScriptBuilder.struct.generator.atomGroups({
462
- 'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'branched']),
463
- 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), carbEntityChainId]),
464
- 'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
465
- });
466
- carbEntityChainInVicinity = builder_1.MolScriptBuilder.struct.filter.intersectedBy({
467
- 0: polymerChainWithSurroundings,
468
- by: carbEntityChain
469
- });
470
- data = (plugin.state.data.select(strInstance.ref)[0].obj).data;
471
- carbChainSel = script_1.Script.getStructureSelection(carbEntityChainInVicinity, data);
472
- if (!(carbChainSel && carbChainSel.kind === 'sequence')) return [3 /*break*/, 36];
473
- carbLigands = [];
474
- carbLigNamesAndCount = {};
475
- carbLigList = [];
476
- for (_d = 0, _e = allCarbPolymers.branchedLigands[i]; _d < _e.length; _d++) {
477
- carbLigs = _e[_d];
478
- ligResDetails = carbLigs.split('-');
479
- carbLigands.push(builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_seq_id(), +ligResDetails[1]]));
480
- if (carbLigNamesAndCount[ligResDetails[0]]) {
481
- carbLigNamesAndCount[ligResDetails[0]]++;
482
- }
483
- else {
484
- carbLigNamesAndCount[ligResDetails[0]] = 1;
485
- }
486
- carbLigList.push(ligResDetails[0]);
487
- }
488
- carbVisLabel = createCarbVisLabel(carbLigNamesAndCount);
489
- branchedEntity = builder_1.MolScriptBuilder.struct.generator.atomGroups({
490
- 'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'branched']),
491
- 'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()]),
492
- 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), carbEntityChainId]),
493
- 'residue-test': builder_1.MolScriptBuilder.core.logic.or(carbLigands)
494
- });
495
- labelTagParams = { label: "".concat(carbVisLabel), tags: ["superposition-carb-sel"] };
496
- return [4 /*yield*/, plugin.builders.structure.tryCreateComponentFromExpression(strInstance, branchedEntity, "".concat(carbLigList.join('-'), "-").concat(segmentIndex), labelTagParams)];
497
- case 34:
498
- ligandExp = _h.sent();
499
- if (!ligandExp) return [3 /*break*/, 36];
500
- return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(ligandExp, { type: 'carbohydrate' }, { tag: "superposition-carb-visual" })];
501
- case 35:
502
- _h.sent();
503
- spState.refMaps[ligandExp.ref] = "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
504
- invalidStruct = false;
505
- _h.label = 36;
506
- case 36:
507
- i++;
508
- _h.label = 37;
509
- case 37:
510
- _i++;
511
- return [3 /*break*/, 33];
512
- case 38:
513
- if (invalidStruct) {
514
- spState.invalidStruct.push("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
515
- loadedStructIndex = spState.loadedStructs[segmentIndex].indexOf("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
516
- if (loadedStructIndex > -1)
517
- spState.loadedStructs[segmentIndex].splice(loadedStructIndex, 1);
518
- // remove downloaded data
519
- if (clearOnFail) {
520
- // const m = plugin.state.data.select(modelRef)[0];
521
- // const t = plugin.state.data.select(m.transform.parent)[0];
522
- // const d = plugin.state.data.select(t.transform.parent)[0];
523
- // PluginCommands.State.RemoveObject(plugin, { state: d.parent!, ref: d.transform.parent, removeParentGhosts: true });
524
- }
241
+ spState.loadedStructs[segmentIndex].push(`${s.pdb_id}_${s.struct_asym_id}`);
242
+ // Set Coordinate server url
243
+ let strUrl = `${customState.initParams.pdbeUrl}model-server/v1/${s.pdb_id}/atoms?auth_asym_id=${s.auth_asym_id}&encoding=${customState.initParams.encoding}`;
244
+ if (superpositionParams && superpositionParams.ligandView)
245
+ strUrl = `https://www.ebi.ac.uk/pdbe/entry-files/download/${s.pdb_id}.bcif`;
246
+ // Load Data
247
+ let strInstance;
248
+ let modelRef;
249
+ let clearOnFail = true;
250
+ if (superpositionParams && superpositionParams.ligandView && spState.entries[s.pdb_id]) {
251
+ const polymerInstance = plugin.state.data.select(spState.entries[s.pdb_id])[0];
252
+ modelRef = polymerInstance.transform.parent;
253
+ const modelInstance = plugin.state.data.select(modelRef)[0];
254
+ strInstance = await plugin.builders.structure.createStructure(modelInstance, { name: 'model', params: {} });
255
+ clearOnFail = false;
256
+ }
257
+ else {
258
+ const isBinary = customState.initParams.encoding === 'bcif' ? true : false;
259
+ const { model, structure } = await loadStructure(plugin, strUrl, 'mmcif', isBinary);
260
+ strInstance = structure;
261
+ modelRef = model.ref;
262
+ }
263
+ if (!strInstance)
264
+ continue;
265
+ // Store Refs in state
266
+ if (!spState.models[`${s.pdb_id}_${s.struct_asym_id}`])
267
+ spState.models[`${s.pdb_id}_${s.struct_asym_id}`] = strInstance?.ref;
268
+ if (superpositionParams && superpositionParams.ligandView && !spState.entries[s.pdb_id])
269
+ spState.entries[s.pdb_id] = strInstance?.ref;
270
+ // Apply tranform matrix
271
+ const matrix = linear_algebra_1.Mat4.ofRows(plugin.customState.superpositionState.matrixData[`${s.pdb_id}_${s.auth_asym_id}`].matrix);
272
+ await transform(plugin, strInstance, matrix);
273
+ // Create representations
274
+ let chainSel;
275
+ if ((superpositionParams && superpositionParams.ligandView) && s.is_representative) {
276
+ const uniformColor1 = getRandomColor(plugin, segmentIndex); // random color
277
+ chainSel = await plugin.builders.structure.tryCreateComponentFromExpression(strInstance, chainSelection(s.struct_asym_id), `Chain-${segmentIndex}`, { label: `Chain`, tags: [`superposition-sel`] });
278
+ if (chainSel) {
279
+ await plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'uniform', colorParams: { value: uniformColor1 }, size: 'uniform' }, { tag: `superposition-visual` });
280
+ spState.refMaps[chainSel.ref] = `${s.pdb_id}_${s.struct_asym_id}`;
281
+ }
282
+ }
283
+ else if ((superpositionParams && superpositionParams.ligandView) && !s.is_representative) {
284
+ // Do nothing
285
+ }
286
+ else {
287
+ const uniformColor2 = getRandomColor(plugin, segmentIndex); // random color
288
+ chainSel = await plugin.builders.structure.tryCreateComponentStatic(strInstance, 'polymer', { label: `Chain`, tags: [`Chain-${segmentIndex}`, `superposition-sel`] });
289
+ if (chainSel) {
290
+ await plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'uniform', colorParams: { value: uniformColor2 }, size: 'uniform' }, { tag: `superposition-visual` });
291
+ spState.refMaps[chainSel.ref] = `${s.pdb_id}_${s.struct_asym_id}`;
292
+ }
293
+ // // const addTooltipUpdate = plugin.state.behaviors.build().to(BestDatabaseSequenceMapping.id).update(BestDatabaseSequenceMapping, (old: any) => { old.showTooltip = true; });
294
+ // // await plugin.runTask(plugin.state.behaviors.updateTree(addTooltipUpdate));
295
+ // BestDatabaseSequenceMapping
296
+ // console.log(plugin.state.data.select(modelRef)[0])
297
+ }
298
+ let invalidStruct = chainSel ? false : true;
299
+ if (superpositionParams && superpositionParams.ligandView) {
300
+ const state = plugin.state.data;
301
+ const hetInfo = await getLigandNamesFromModelData(plugin, state, modelRef);
302
+ const hets = hetInfo ? hetInfo.hetNames : [];
303
+ // const interactingHets = [];
304
+ if (hets && hets.length > 0) {
305
+ for await (const het of hets) {
306
+ const ligand = builder_1.MolScriptBuilder.struct.generator.atomGroups({
307
+ 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), s.auth_asym_id]),
308
+ 'residue-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.label_comp_id(), het]),
309
+ 'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
310
+ });
311
+ let labelTagParams = { label: `${het}`, tags: [`superposition-ligand-sel`] };
312
+ let hetColor = color_1.Color.fromRgb(253, 3, 253);
313
+ if (superpositionParams && superpositionParams.ligandColor) {
314
+ const { r, g, b } = superpositionParams.ligandColor;
315
+ hetColor = color_1.Color.fromRgb(r, g, b);
316
+ }
317
+ const ligandExp = await plugin.builders.structure.tryCreateComponentFromExpression(strInstance, ligand, `${het}-${segmentIndex}`, labelTagParams);
318
+ if (ligandExp) {
319
+ await plugin.builders.structure.representation.addRepresentation(ligandExp, { type: 'ball-and-stick', color: 'uniform', colorParams: { value: hetColor } }, { tag: `superposition-ligand-visual` });
320
+ spState.refMaps[ligandExp.ref] = `${s.pdb_id}_${s.struct_asym_id}`;
321
+ invalidStruct = false;
322
+ // interactingHets.push(het);
323
+ }
324
+ }
325
+ }
326
+ const carbEntityCount = hetInfo ? hetInfo.carbEntityCount : 0;
327
+ if (carbEntityCount > 0) {
328
+ // Get Carbohydrate Polymers details from PDBe API
329
+ const allCarbPolymers = await getCarbPolymerDetailsFromApi(plugin, s.pdb_id);
330
+ // Polymer chain + surroundings query
331
+ const polymerChainWithSurroundings = builder_1.MolScriptBuilder.struct.modifier.includeSurroundings({
332
+ 0: builder_1.MolScriptBuilder.struct.generator.atomGroups({
333
+ 'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'polymer']),
334
+ 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), s.auth_asym_id]),
335
+ 'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
336
+ }),
337
+ radius: 5,
338
+ 'as-whole-residues': true
339
+ });
340
+ let i = 0;
341
+ for (const carbEntityChainId of allCarbPolymers.branchedChains) {
342
+ const carbEntityChain = builder_1.MolScriptBuilder.struct.generator.atomGroups({
343
+ 'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'branched']),
344
+ 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), carbEntityChainId]),
345
+ 'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
346
+ });
347
+ const carbEntityChainInVicinity = builder_1.MolScriptBuilder.struct.filter.intersectedBy({
348
+ 0: polymerChainWithSurroundings,
349
+ by: carbEntityChain
350
+ });
351
+ const data = (plugin.state.data.select(strInstance.ref)[0].obj).data;
352
+ const carbChainSel = script_1.Script.getStructureSelection(carbEntityChainInVicinity, data);
353
+ if (carbChainSel && carbChainSel.kind === 'sequence') {
354
+ // console.log(carbEntityChainId + ' chain present in 5 A radius');
355
+ const carbLigands = [];
356
+ const carbLigNamesAndCount = {};
357
+ const carbLigList = [];
358
+ for (const carbLigs of allCarbPolymers.branchedLigands[i]) {
359
+ const ligResDetails = carbLigs.split('-');
360
+ carbLigands.push(builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_seq_id(), +ligResDetails[1]]));
361
+ if (carbLigNamesAndCount[ligResDetails[0]]) {
362
+ carbLigNamesAndCount[ligResDetails[0]]++;
525
363
  }
526
364
  else {
527
- // if(interactingHets.length > 0) spState.hets[`${s.pdb_id}_${s.struct_asym_id}`] = interactingHets;
365
+ carbLigNamesAndCount[ligResDetails[0]] = 1;
528
366
  }
529
- _h.label = 39;
530
- case 39: return [3 /*break*/, 2];
531
- case 40: return [3 /*break*/, 47];
532
- case 41:
533
- e_3_1 = _h.sent();
534
- e_3 = { error: e_3_1 };
535
- return [3 /*break*/, 47];
536
- case 42:
537
- _h.trys.push([42, , 45, 46]);
538
- if (!(entryList_1_1 && !entryList_1_1.done && (_f = entryList_1.return))) return [3 /*break*/, 44];
539
- return [4 /*yield*/, _f.call(entryList_1)];
540
- case 43:
541
- _h.sent();
542
- _h.label = 44;
543
- case 44: return [3 /*break*/, 46];
544
- case 45:
545
- if (e_3) throw e_3.error;
546
- return [7 /*endfinally*/];
547
- case 46: return [7 /*endfinally*/];
548
- case 47:
549
- if (busyFlagOn) {
550
- busyFlagOn = false;
551
- customState.events.isBusy.next(false);
552
- }
553
- return [2 /*return*/];
367
+ carbLigList.push(ligResDetails[0]);
368
+ }
369
+ const carbVisLabel = createCarbVisLabel(carbLigNamesAndCount);
370
+ const branchedEntity = builder_1.MolScriptBuilder.struct.generator.atomGroups({
371
+ 'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'branched']),
372
+ 'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()]),
373
+ 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), carbEntityChainId]),
374
+ 'residue-test': builder_1.MolScriptBuilder.core.logic.or(carbLigands)
375
+ });
376
+ let labelTagParams = { label: `${carbVisLabel}`, tags: [`superposition-carb-sel`] };
377
+ const ligandExp = await plugin.builders.structure.tryCreateComponentFromExpression(strInstance, branchedEntity, `${carbLigList.join('-')}-${segmentIndex}`, labelTagParams);
378
+ if (ligandExp) {
379
+ await plugin.builders.structure.representation.addRepresentation(ligandExp, { type: 'carbohydrate' }, { tag: `superposition-carb-visual` });
380
+ spState.refMaps[ligandExp.ref] = `${s.pdb_id}_${s.struct_asym_id}`;
381
+ invalidStruct = false;
382
+ }
554
383
  }
555
- });
556
- }); })];
557
- });
558
- });
559
- }
560
- exports.renderSuperposition = renderSuperposition;
561
- function getLigandNamesFromModelData(plugin, state, modelRef) {
562
- var _a;
563
- return tslib_1.__awaiter(this, void 0, void 0, function () {
564
- var cell, model, structures, _i, _b, s, structure, info;
565
- return tslib_1.__generator(this, function (_c) {
566
- switch (_c.label) {
567
- case 0:
568
- cell = state.select(modelRef)[0];
569
- if (!cell || !cell.obj)
570
- return [2 /*return*/, void 0];
571
- model = cell.obj.data;
572
- if (!model)
573
- return [2 /*return*/];
574
- structures = [];
575
- for (_i = 0, _b = plugin.managers.structure.hierarchy.selection.structures; _i < _b.length; _i++) {
576
- s = _b[_i];
577
- structure = (_a = s.cell.obj) === null || _a === void 0 ? void 0 : _a.data;
578
- if (structure)
579
- structures.push(structure);
384
+ i++;
385
+ }
386
+ }
387
+ if (invalidStruct) {
388
+ spState.invalidStruct.push(`${s.pdb_id}_${s.struct_asym_id}`);
389
+ const loadedStructIndex = spState.loadedStructs[segmentIndex].indexOf(`${s.pdb_id}_${s.struct_asym_id}`);
390
+ if (loadedStructIndex > -1)
391
+ spState.loadedStructs[segmentIndex].splice(loadedStructIndex, 1);
392
+ // remove downloaded data
393
+ if (clearOnFail) {
394
+ // const m = plugin.state.data.select(modelRef)[0];
395
+ // const t = plugin.state.data.select(m.transform.parent)[0];
396
+ // const d = plugin.state.data.select(t.transform.parent)[0];
397
+ // PluginCommands.State.RemoveObject(plugin, { state: d.parent!, ref: d.transform.parent, removeParentGhosts: true });
580
398
  }
581
- return [4 /*yield*/, helpers_1.ModelInfo.get(model, structures)];
582
- case 1:
583
- info = _c.sent();
584
- return [2 /*return*/, info];
399
+ }
400
+ else {
401
+ // if(interactingHets.length > 0) spState.hets[`${s.pdb_id}_${s.struct_asym_id}`] = interactingHets;
402
+ }
585
403
  }
586
- });
404
+ }
405
+ if (busyFlagOn) {
406
+ busyFlagOn = false;
407
+ customState.events.isBusy.next(false);
408
+ }
587
409
  });
588
410
  }
589
- function loadStructure(plugin, url, format, isBinary) {
590
- return tslib_1.__awaiter(this, void 0, void 0, function () {
591
- var data, trajectory, model, modelProperties, structure, e_4;
592
- return tslib_1.__generator(this, function (_a) {
593
- switch (_a.label) {
594
- case 0:
595
- _a.trys.push([0, 7, , 8]);
596
- return [4 /*yield*/, plugin.builders.data.download({ url: assets_1.Asset.Url(url), isBinary: isBinary })];
597
- case 1:
598
- data = _a.sent();
599
- return [4 /*yield*/, plugin.builders.structure.parseTrajectory(data, format)];
600
- case 2:
601
- trajectory = _a.sent();
602
- return [4 /*yield*/, plugin.builders.structure.createModel(trajectory)];
603
- case 3:
604
- model = _a.sent();
605
- return [4 /*yield*/, plugin.builders.structure.insertModelProperties(model)];
606
- case 4:
607
- modelProperties = _a.sent();
608
- return [4 /*yield*/, plugin.builders.structure.createStructure(modelProperties || model, { name: 'model', params: {} })];
609
- case 5:
610
- structure = _a.sent();
611
- return [4 /*yield*/, plugin.builders.structure.insertStructureProperties(structure)];
612
- case 6:
613
- _a.sent();
614
- return [2 /*return*/, { data: data, trajectory: trajectory, model: model, structure: structure }];
615
- case 7:
616
- e_4 = _a.sent();
617
- return [2 /*return*/, { structure: void 0 }];
618
- case 8: return [2 /*return*/];
619
- }
620
- });
621
- });
411
+ exports.renderSuperposition = renderSuperposition;
412
+ async function getLigandNamesFromModelData(plugin, state, modelRef) {
413
+ const cell = state.select(modelRef)[0];
414
+ if (!cell || !cell.obj)
415
+ return void 0;
416
+ const model = cell.obj.data;
417
+ if (!model)
418
+ return;
419
+ const structures = [];
420
+ for (const s of plugin.managers.structure.hierarchy.selection.structures) {
421
+ const structure = s.cell.obj?.data;
422
+ if (structure)
423
+ structures.push(structure);
424
+ }
425
+ const info = await helpers_1.ModelInfo.get(model, structures);
426
+ return info;
427
+ }
428
+ async function loadStructure(plugin, url, format, isBinary) {
429
+ try {
430
+ const data = await plugin.builders.data.download({ url: assets_1.Asset.Url(url), isBinary: isBinary });
431
+ const trajectory = await plugin.builders.structure.parseTrajectory(data, format);
432
+ const model = await plugin.builders.structure.createModel(trajectory);
433
+ const modelProperties = await plugin.builders.structure.insertModelProperties(model);
434
+ const structure = await plugin.builders.structure.createStructure(modelProperties || model, { name: 'model', params: {} });
435
+ await plugin.builders.structure.insertStructureProperties(structure);
436
+ return { data, trajectory, model, structure };
437
+ }
438
+ catch (e) {
439
+ return { structure: void 0 };
440
+ }
622
441
  }
623
442
  function chainSelection(struct_asym_id) {
624
443
  return builder_1.MolScriptBuilder.struct.generator.atomGroups({
@@ -626,169 +445,114 @@ function chainSelection(struct_asym_id) {
626
445
  });
627
446
  }
628
447
  function transform(plugin, s, matrix) {
629
- var b = plugin.state.data.build().to(s)
448
+ const b = plugin.state.data.build().to(s)
630
449
  .insert(transforms_1.StateTransforms.Model.TransformStructureConformation, { transform: { name: 'matrix', params: { data: matrix, transpose: false } } });
631
450
  return plugin.runTask(plugin.state.data.updateTree(b));
632
451
  }
633
- function afTransform(plugin, s, matrix, coordinateSystem) {
634
- return tslib_1.__awaiter(this, void 0, void 0, function () {
635
- var r, o, transform, params, b;
636
- return tslib_1.__generator(this, function (_a) {
637
- switch (_a.label) {
638
- case 0:
639
- r = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, s);
640
- if (!r)
641
- return [2 /*return*/];
642
- o = plugin.state.data.selectQ(function (q) { return q.byRef(r.transform.ref).subtree().withTransformer(transforms_1.StateTransforms.Model.TransformStructureConformation); })[0];
643
- transform = coordinateSystem && !linear_algebra_1.Mat4.isIdentity(coordinateSystem.matrix)
644
- ? linear_algebra_1.Mat4.mul((0, linear_algebra_1.Mat4)(), coordinateSystem.matrix, matrix)
645
- : matrix;
646
- params = {
647
- transform: {
648
- name: 'matrix',
649
- params: { data: transform, transpose: false }
650
- }
651
- };
652
- b = o
653
- ? plugin.state.data.build().to(o).update(params)
654
- : plugin.state.data.build().to(s)
655
- .insert(transforms_1.StateTransforms.Model.TransformStructureConformation, params, { tags: 'SuperpositionTransform' });
656
- return [4 /*yield*/, plugin.runTask(plugin.state.data.updateTree(b))];
657
- case 1:
658
- _a.sent();
659
- return [2 /*return*/];
660
- }
661
- });
662
- });
452
+ async function afTransform(plugin, s, matrix, coordinateSystem) {
453
+ const r = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, s);
454
+ if (!r)
455
+ return;
456
+ const o = plugin.state.data.selectQ(q => q.byRef(r.transform.ref).subtree().withTransformer(transforms_1.StateTransforms.Model.TransformStructureConformation))[0];
457
+ const transform = coordinateSystem && !linear_algebra_1.Mat4.isIdentity(coordinateSystem.matrix)
458
+ ? linear_algebra_1.Mat4.mul((0, linear_algebra_1.Mat4)(), coordinateSystem.matrix, matrix)
459
+ : matrix;
460
+ const params = {
461
+ transform: {
462
+ name: 'matrix',
463
+ params: { data: transform, transpose: false }
464
+ }
465
+ };
466
+ const b = o
467
+ ? plugin.state.data.build().to(o).update(params)
468
+ : plugin.state.data.build().to(s)
469
+ .insert(transforms_1.StateTransforms.Model.TransformStructureConformation, params, { tags: 'SuperpositionTransform' });
470
+ await plugin.runTask(plugin.state.data.updateTree(b));
663
471
  }
664
- function getMatrixData(plugin) {
665
- return tslib_1.__awaiter(this, void 0, void 0, function () {
666
- var customState, matrixAccession, clusterRecUrlStr, assetManager, clusterRecUrl, clusterRecData, e_5;
667
- return tslib_1.__generator(this, function (_a) {
668
- switch (_a.label) {
669
- case 0:
670
- customState = plugin.customState;
671
- matrixAccession = customState.initParams.superpositionParams.matrixAccession ? customState.initParams.superpositionParams.matrixAccession : customState.initParams.moleculeId;
672
- clusterRecUrlStr = "".concat(customState.initParams.pdbeUrl, "static/superpose/matrices/").concat(matrixAccession);
673
- assetManager = plugin.managers.asset;
674
- clusterRecUrl = assets_1.Asset.getUrlAsset(assetManager, clusterRecUrlStr);
675
- _a.label = 1;
676
- case 1:
677
- _a.trys.push([1, 3, , 4]);
678
- return [4 /*yield*/, plugin.runTask(assetManager.resolve(clusterRecUrl, 'json', false))];
679
- case 2:
680
- clusterRecData = _a.sent();
681
- if (clusterRecData && clusterRecData.data) {
682
- plugin.customState.superpositionState.matrixData = clusterRecData.data;
683
- }
684
- return [3 /*break*/, 4];
685
- case 3:
686
- e_5 = _a.sent();
687
- customState['superpositionError'] = "Matrix data not available for ".concat(matrixAccession);
688
- plugin.customState.events.superpositionInit.next(true); // Emit segment API data load event
689
- return [3 /*break*/, 4];
690
- case 4: return [2 /*return*/];
691
- }
692
- });
693
- });
472
+ async function getMatrixData(plugin) {
473
+ const customState = plugin.customState;
474
+ const matrixAccession = customState.initParams.superpositionParams.matrixAccession ? customState.initParams.superpositionParams.matrixAccession : customState.initParams.moleculeId;
475
+ const clusterRecUrlStr = `${customState.initParams.pdbeUrl}static/superpose/matrices/${matrixAccession}`;
476
+ const assetManager = plugin.managers.asset;
477
+ const clusterRecUrl = assets_1.Asset.getUrlAsset(assetManager, clusterRecUrlStr);
478
+ try {
479
+ const clusterRecData = await plugin.runTask(assetManager.resolve(clusterRecUrl, 'json', false));
480
+ if (clusterRecData && clusterRecData.data) {
481
+ plugin.customState.superpositionState.matrixData = clusterRecData.data;
482
+ }
483
+ }
484
+ catch (e) {
485
+ customState['superpositionError'] = `Matrix data not available for ${matrixAccession}`;
486
+ plugin.customState.events.superpositionInit.next(true); // Emit segment API data load event
487
+ }
694
488
  }
695
- function getSegmentData(plugin) {
696
- return tslib_1.__awaiter(this, void 0, void 0, function () {
697
- var customState, segmentsUrl, assetManager, url, result, e_6;
698
- return tslib_1.__generator(this, function (_a) {
699
- switch (_a.label) {
700
- case 0:
701
- customState = plugin.customState;
702
- segmentsUrl = "".concat(customState.initParams.pdbeUrl, "graph-api/uniprot/superposition/").concat(customState.initParams.moleculeId);
703
- assetManager = plugin.managers.asset;
704
- url = assets_1.Asset.getUrlAsset(assetManager, segmentsUrl);
705
- _a.label = 1;
706
- case 1:
707
- _a.trys.push([1, 3, , 4]);
708
- return [4 /*yield*/, plugin.runTask(assetManager.resolve(url, 'json', false))];
709
- case 2:
710
- result = _a.sent();
711
- if (result && result.data) {
712
- customState.superpositionState.segmentData = result.data[customState.initParams.moleculeId];
713
- }
714
- return [3 /*break*/, 4];
715
- case 3:
716
- e_6 = _a.sent();
717
- customState['superpositionError'] = "Superposition data not available for ".concat(customState.initParams.moleculeId);
718
- plugin.customState.events.superpositionInit.next(true); // Emit segment API data load event
719
- return [3 /*break*/, 4];
720
- case 4: return [2 /*return*/];
721
- }
722
- });
723
- });
489
+ async function getSegmentData(plugin) {
490
+ const customState = plugin.customState;
491
+ // Get Data
492
+ const segmentsUrl = `${customState.initParams.pdbeUrl}graph-api/uniprot/superposition/${customState.initParams.moleculeId}`;
493
+ const assetManager = plugin.managers.asset;
494
+ const url = assets_1.Asset.getUrlAsset(assetManager, segmentsUrl);
495
+ try {
496
+ const result = await plugin.runTask(assetManager.resolve(url, 'json', false));
497
+ if (result && result.data) {
498
+ customState.superpositionState.segmentData = result.data[customState.initParams.moleculeId];
499
+ }
500
+ }
501
+ catch (e) {
502
+ customState['superpositionError'] = `Superposition data not available for ${customState.initParams.moleculeId}`;
503
+ plugin.customState.events.superpositionInit.next(true); // Emit segment API data load event
504
+ }
724
505
  }
725
506
  function getChainLigands(carbEntity) {
726
- var ligandChain = [];
727
- var ligandLabels = [];
728
- var ligands = [];
729
- var labelValueArr = [];
730
- var ligNameStr = '';
731
- for (var _i = 0, _a = carbEntity.chem_comp_list; _i < _a.length; _i++) {
732
- var chemComp = _a[_i];
733
- labelValueArr.push("".concat(chemComp.chem_comp_id, " (").concat(chemComp.count, ")"));
507
+ const ligandChain = [];
508
+ const ligandLabels = [];
509
+ const ligands = [];
510
+ const labelValueArr = [];
511
+ let ligNameStr = '';
512
+ for (const chemComp of carbEntity.chem_comp_list) {
513
+ labelValueArr.push(`${chemComp.chem_comp_id} (${chemComp.count})`);
734
514
  }
735
515
  ligNameStr = labelValueArr.join(', ');
736
- for (var _b = 0, _c = carbEntity.chains; _b < _c.length; _b++) {
737
- var chain = _c[_b];
516
+ for (const chain of carbEntity.chains) {
738
517
  ligandChain.push(chain.chain_id);
739
518
  ligandLabels.push(ligNameStr);
740
- var chainLigands = [];
741
- for (var _d = 0, _e = chain.residues; _d < _e.length; _d++) {
742
- var residue = _e[_d];
519
+ const chainLigands = [];
520
+ for (const residue of chain.residues) {
743
521
  chainLigands.push(residue.chem_comp_id + '-' + residue.residue_number);
744
522
  }
745
523
  ligands.push(chainLigands);
746
524
  }
747
525
  return {
748
- ligands: ligands,
749
- ligandChain: ligandChain,
750
- ligandLabels: ligandLabels
526
+ ligands,
527
+ ligandChain,
528
+ ligandLabels
751
529
  };
752
530
  }
753
- function getCarbPolymerDetailsFromApi(plugin, pdb_id) {
754
- return tslib_1.__awaiter(this, void 0, void 0, function () {
755
- var customState, apiUrl, assetManager, url, branchedLigands, branchedChains, branchedlabels, result, carbEntities, _i, carbEntities_1, carbEntity, carbLigData, e_7;
756
- return tslib_1.__generator(this, function (_a) {
757
- switch (_a.label) {
758
- case 0:
759
- customState = plugin.customState;
760
- apiUrl = "".concat(customState.initParams.pdbeUrl, "api/pdb/entry/carbohydrate_polymer/").concat(pdb_id);
761
- assetManager = plugin.managers.asset;
762
- url = assets_1.Asset.getUrlAsset(assetManager, apiUrl);
763
- branchedLigands = [];
764
- branchedChains = [];
765
- branchedlabels = [];
766
- _a.label = 1;
767
- case 1:
768
- _a.trys.push([1, 3, , 4]);
769
- return [4 /*yield*/, plugin.runTask(assetManager.resolve(url, 'json', false))];
770
- case 2:
771
- result = _a.sent();
772
- if (result && result.data) {
773
- carbEntities = result.data[pdb_id];
774
- for (_i = 0, carbEntities_1 = carbEntities; _i < carbEntities_1.length; _i++) {
775
- carbEntity = carbEntities_1[_i];
776
- carbLigData = getChainLigands(carbEntity);
777
- branchedLigands = branchedLigands.concat(carbLigData.ligands);
778
- branchedChains = branchedChains.concat(carbLigData.ligandChain);
779
- branchedlabels = branchedlabels.concat(carbLigData.ligandLabels);
780
- }
781
- }
782
- return [3 /*break*/, 4];
783
- case 3:
784
- e_7 = _a.sent();
785
- return [3 /*break*/, 4];
786
- case 4: return [2 /*return*/, {
787
- branchedChains: branchedChains,
788
- branchedLigands: branchedLigands,
789
- branchedlabels: branchedlabels
790
- }];
531
+ async function getCarbPolymerDetailsFromApi(plugin, pdb_id) {
532
+ const customState = plugin.customState;
533
+ // Get Data
534
+ const apiUrl = `${customState.initParams.pdbeUrl}api/pdb/entry/carbohydrate_polymer/${pdb_id}`;
535
+ const assetManager = plugin.managers.asset;
536
+ const url = assets_1.Asset.getUrlAsset(assetManager, apiUrl);
537
+ let branchedLigands = [];
538
+ let branchedChains = [];
539
+ let branchedlabels = [];
540
+ try {
541
+ const result = await plugin.runTask(assetManager.resolve(url, 'json', false));
542
+ if (result && result.data) {
543
+ const carbEntities = result.data[pdb_id];
544
+ for (const carbEntity of carbEntities) {
545
+ const carbLigData = getChainLigands(carbEntity);
546
+ branchedLigands = branchedLigands.concat(carbLigData.ligands);
547
+ branchedChains = branchedChains.concat(carbLigData.ligandChain);
548
+ branchedlabels = branchedlabels.concat(carbLigData.ligandLabels);
791
549
  }
792
- });
793
- });
550
+ }
551
+ }
552
+ catch (e) { }
553
+ return {
554
+ branchedChains,
555
+ branchedLigands,
556
+ branchedlabels
557
+ };
794
558
  }