drugflow-molstar 0.2.1 → 0.2.2

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 (113) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +15 -15
  3. package/build/{drugflow-molstar-component-0.2.1.js → drugflow-molstar-component-0.2.2.js} +4 -4
  4. package/build/drugflow-molstar-light.css +1 -1
  5. package/build/{drugflow-molstar-plugin-0.2.1.js → drugflow-molstar-plugin-0.2.2.js} +2 -2
  6. package/lib/alphafold-transparency.d.ts +6 -6
  7. package/lib/alphafold-transparency.js +153 -153
  8. package/lib/app/molstar/lib/apps/docking-viewer/index.html +37 -0
  9. package/lib/app/molstar/lib/apps/viewer/embedded.html +44 -0
  10. package/lib/app/molstar/lib/apps/viewer/favicon.ico +0 -0
  11. package/lib/app/molstar/lib/apps/viewer/index.html +110 -0
  12. package/lib/app/molstar/lib/examples/alpha-orbitals/index.html +73 -0
  13. package/lib/app/molstar/lib/examples/basic-wrapper/index.html +138 -0
  14. package/lib/app/molstar/lib/examples/lighting/index.html +89 -0
  15. package/lib/app/molstar/lib/examples/proteopedia-wrapper/index.html +237 -0
  16. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/base.scss +33 -0
  17. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/controls-base.scss +334 -0
  18. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/controls.scss +419 -0
  19. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/help.scss +27 -0
  20. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/line-graph.scss +68 -0
  21. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/log.scss +100 -0
  22. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/misc.scss +644 -0
  23. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/sequence.scss +126 -0
  24. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/slider.scss +166 -0
  25. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/tasks.scss +99 -0
  26. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/toast.scss +84 -0
  27. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/transformer.scss +164 -0
  28. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/components/viewport.scss +128 -0
  29. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout/common.scss +72 -0
  30. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout/controls-landscape.scss +90 -0
  31. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout/controls-outside.scss +99 -0
  32. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout/controls-portrait.scss +109 -0
  33. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/layout.scss +41 -0
  34. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/logo.scss +13 -0
  35. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/normalize.scss +210 -0
  36. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/ui.scss +41 -0
  37. package/lib/app/molstar/lib/mol-plugin-ui/skin/base/variables.scss +86 -0
  38. package/lib/app/molstar/lib/mol-plugin-ui/skin/blue.scss +2 -0
  39. package/lib/app/molstar/lib/mol-plugin-ui/skin/colors/blue.scss +24 -0
  40. package/lib/app/molstar/lib/mol-plugin-ui/skin/colors/dark.scss +24 -0
  41. package/lib/app/molstar/lib/mol-plugin-ui/skin/colors/light.scss +30 -0
  42. package/lib/app/molstar/lib/mol-plugin-ui/skin/dark.scss +2 -0
  43. package/lib/app/molstar/lib/mol-plugin-ui/skin/light.scss +2 -0
  44. package/lib/custom-events.d.ts +4 -4
  45. package/lib/custom-events.js +56 -56
  46. package/lib/domain-annotations/behavior.d.ts +5 -5
  47. package/lib/domain-annotations/behavior.js +49 -49
  48. package/lib/domain-annotations/color.d.ts +10 -10
  49. package/lib/domain-annotations/color.js +78 -78
  50. package/lib/domain-annotations/prop.d.ts +35 -35
  51. package/lib/domain-annotations/prop.js +160 -160
  52. package/lib/drugflow-molstar-component-build-0.1.2.js +4268 -0
  53. package/lib/drugflow-molstar-component-build-0.1.2.js.LICENSE.txt +24 -0
  54. package/lib/drugflow-molstar-component-build-0.1.2.js.map +1 -0
  55. package/lib/drugflow-molstar-component-build-0.1.3.js +2 -0
  56. package/lib/drugflow-molstar-component-build-0.1.3.js.LICENSE.txt +24 -0
  57. package/lib/drugflow-molstar-component-build-0.1.4.js +2 -0
  58. package/lib/drugflow-molstar-component-build-0.1.4.js.LICENSE.txt +24 -0
  59. package/lib/drugflow-molstar-component-build-0.1.6.js +2 -0
  60. package/lib/drugflow-molstar-component-build-0.1.6.js.LICENSE.txt +24 -0
  61. package/lib/drugflow-molstar-component-build-0.2.2.js +2 -0
  62. package/lib/drugflow-molstar-component-build-0.2.2.js.LICENSE.txt +24 -0
  63. package/lib/helpers.d.ts +82 -81
  64. package/lib/helpers.js +278 -278
  65. package/lib/index.d.ts +1 -1
  66. package/lib/index.js +1274 -1239
  67. package/lib/labels.d.ts +2 -2
  68. package/lib/labels.js +42 -42
  69. package/lib/loci-details.d.ts +27 -27
  70. package/lib/loci-details.js +128 -128
  71. package/lib/pdbe-molstar-component-build-3.1.2.js +2 -0
  72. package/lib/pdbe-molstar-component-build-3.1.2.js.LICENSE.txt +24 -0
  73. package/lib/sifts-mapping.d.ts +16 -16
  74. package/lib/sifts-mapping.js +83 -83
  75. package/lib/sifts-mappings-behaviour.d.ts +5 -5
  76. package/lib/sifts-mappings-behaviour.js +64 -64
  77. package/lib/spec.d.ts +76 -76
  78. package/lib/spec.js +105 -105
  79. package/lib/subscribe-events.d.ts +1 -1
  80. package/lib/subscribe-events.js +194 -194
  81. package/lib/superposition-export.d.ts +4 -4
  82. package/lib/superposition-export.js +152 -152
  83. package/lib/superposition-focus-representation.d.ts +16 -16
  84. package/lib/superposition-focus-representation.js +153 -153
  85. package/lib/superposition-sifts-mapping.d.ts +22 -22
  86. package/lib/superposition-sifts-mapping.js +159 -159
  87. package/lib/superposition.d.ts +18 -18
  88. package/lib/superposition.js +794 -794
  89. package/lib/ui/alphafold-superposition.d.ts +56 -56
  90. package/lib/ui/alphafold-superposition.js +178 -178
  91. package/lib/ui/alphafold-tranparency.d.ts +22 -22
  92. package/lib/ui/alphafold-tranparency.js +65 -65
  93. package/lib/ui/annotation-controls.d.ts +24 -24
  94. package/lib/ui/annotation-controls.js +166 -166
  95. package/lib/ui/export-superposition.d.ts +6 -6
  96. package/lib/ui/export-superposition.js +71 -71
  97. package/lib/ui/pdbe-left-panel.d.ts +18 -18
  98. package/lib/ui/pdbe-left-panel.js +167 -167
  99. package/lib/ui/pdbe-screenshot-controls.d.ts +20 -20
  100. package/lib/ui/pdbe-screenshot-controls.js +101 -101
  101. package/lib/ui/pdbe-structure-controls.d.ts +17 -17
  102. package/lib/ui/pdbe-structure-controls.js +70 -70
  103. package/lib/ui/pdbe-viewport-controls.d.ts +6 -6
  104. package/lib/ui/pdbe-viewport-controls.js +56 -56
  105. package/lib/ui/segment-tree.d.ts +18 -18
  106. package/lib/ui/segment-tree.js +804 -804
  107. package/lib/ui/superposition-components.d.ts +10 -10
  108. package/lib/ui/superposition-components.js +435 -435
  109. package/lib/ui/superposition-viewport.d.ts +5 -5
  110. package/lib/ui/superposition-viewport.js +23 -23
  111. package/package.json +79 -79
  112. /package/build/{drugflow-molstar-0.2.1.css → drugflow-molstar-0.2.2.css} +0 -0
  113. /package/build/{drugflow-molstar-plugin-0.2.1.js.LICENSE.txt → drugflow-molstar-plugin-0.2.2.js.LICENSE.txt} +0 -0
@@ -1,804 +1,804 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SegmentTree = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsx_runtime_1 = require("react/jsx-runtime");
6
- var operators_1 = require("rxjs/operators");
7
- var commands_1 = require("Molstar/mol-plugin/commands");
8
- var mol_state_1 = require("Molstar/mol-state");
9
- var base_1 = require("Molstar/mol-plugin-ui/base");
10
- var common_1 = require("Molstar/mol-plugin-ui/controls/common");
11
- var param_definition_1 = require("Molstar/mol-util/param-definition");
12
- var parameters_1 = require("Molstar/mol-plugin-ui/controls/parameters");
13
- var mol_state_2 = require("Molstar/mol-state");
14
- var superposition_1 = require("../superposition");
15
- var update_transform_1 = require("Molstar/mol-plugin-ui/state/update-transform");
16
- var icons_1 = require("Molstar/mol-plugin-ui/controls/icons");
17
- var lists_1 = require("Molstar/mol-util/color/lists");
18
- var color_1 = require("Molstar/mol-util/color");
19
- var builder_1 = require("Molstar/mol-script/language/builder");
20
- var rxjs_1 = require("rxjs");
21
- var transforms_1 = require("Molstar/mol-plugin-state/transforms");
22
- var superposition_2 = require("../superposition");
23
- var SuperpositionTag = 'SuperpositionTransform';
24
- var SegmentTree = /** @class */ (function (_super) {
25
- tslib_1.__extends(SegmentTree, _super);
26
- function SegmentTree() {
27
- var _this = _super !== null && _super.apply(this, arguments) || this;
28
- _this.getSegmentParams = function () {
29
- var customState = _this.customState;
30
- if (!customState.superpositionState || !customState.superpositionState.segmentData)
31
- return;
32
- var segmentData = customState.superpositionState.segmentData;
33
- var segmentArr = segmentData.map(function (segment, i) {
34
- var segmentLabel = "".concat(i + 1, " ( ").concat(segment.segment_start, " - ").concat(segment.segment_end, " )");
35
- return [segmentLabel, segmentLabel];
36
- });
37
- var segmentOptions = {
38
- segment: param_definition_1.ParamDefinition.Select('', segmentArr, { label: 'Select Segment', description: 'Select segment to view its clusters below' })
39
- };
40
- var segmentIndex = customState.superpositionState.activeSegment - 1;
41
- _this.setState({ segment: {
42
- params: segmentOptions,
43
- value: { segment: segmentArr[segmentIndex][0] }
44
- } });
45
- _this.setState({ isBusy: false });
46
- };
47
- _this.updateSegment = function (val) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
48
- var customState, updatedParams;
49
- var _this = this;
50
- return tslib_1.__generator(this, function (_a) {
51
- if (!this.state.segment)
52
- return [2 /*return*/];
53
- customState = this.customState;
54
- customState.events.isBusy.next(true);
55
- // Hide pervious segement structures
56
- this.hideStructures(customState.superpositionState.activeSegment - 1);
57
- updatedParams = tslib_1.__assign({}, this.state.segment);
58
- updatedParams.value = val;
59
- this.setState({ segment: updatedParams });
60
- setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
61
- var updatedSegmentIndex;
62
- return tslib_1.__generator(this, function (_a) {
63
- switch (_a.label) {
64
- case 0:
65
- updatedSegmentIndex = parseInt(val.segment.split(' ')[0]);
66
- customState.superpositionState.activeSegment = updatedSegmentIndex;
67
- // Display current segment visible structures
68
- return [4 /*yield*/, this.displayStructures(customState.superpositionState.activeSegment - 1)];
69
- case 1:
70
- // Display current segment visible structures
71
- _a.sent();
72
- customState.events.isBusy.next(false);
73
- this.plugin.customState.events.segmentUpdate.next(true);
74
- return [2 /*return*/];
75
- }
76
- });
77
- }); }, 100);
78
- return [2 /*return*/, false];
79
- });
80
- }); };
81
- _this.hideStructures = function (segmentIndex) {
82
- // clear selections
83
- _this.plugin.managers.interactivity.lociSelects.deselectAll();
84
- // clear Focus
85
- _this.plugin.managers.structure.focus.clear();
86
- // remove measurements
87
- var measurements = _this.plugin.managers.structure.measurement.state;
88
- var measureTypes = ['labels', 'distances', 'angles', 'dihedrals'];
89
- var measurementCell = void 0;
90
- measureTypes.forEach(function (type) {
91
- if (measurementCell)
92
- return;
93
- if (measurements[type][0]) {
94
- measurementCell = _this.plugin.state.data.cells.get(measurements[type][0].transform.parent);
95
- }
96
- });
97
- if (measurementCell) {
98
- commands_1.PluginCommands.State.RemoveObject(_this.plugin, { state: measurementCell.parent, ref: measurementCell.transform.parent, removeParentGhosts: true });
99
- }
100
- // hide structures
101
- var customState = _this.customState;
102
- customState.superpositionState.visibleRefs[segmentIndex] = [];
103
- for (var _i = 0, _a = customState.superpositionState.loadedStructs[segmentIndex]; _i < _a.length; _i++) {
104
- var struct = _a[_i];
105
- var structRef = _this.customState.superpositionState.models[struct];
106
- if (structRef) {
107
- var structHierarchy = _this.plugin.managers.structure.hierarchy.current.refs.get(structRef);
108
- if (structHierarchy && structHierarchy.components) {
109
- for (var _b = 0, _c = structHierarchy.components; _b < _c.length; _b++) {
110
- var c = _c[_b];
111
- if (c && c.cell && !c.cell.state.isHidden) {
112
- customState.superpositionState.visibleRefs[segmentIndex].push(c.cell.transform.ref);
113
- commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: c.cell.parent, ref: c.cell.transform.ref });
114
- }
115
- }
116
- }
117
- }
118
- }
119
- if (customState.superpositionState.alphafold.ref) {
120
- var afStr = _this.plugin.managers.structure.hierarchy.current.refs.get(customState.superpositionState.alphafold.ref);
121
- if (afStr && afStr.components) {
122
- for (var _d = 0, _e = afStr.components; _d < _e.length; _d++) {
123
- var c = _e[_d];
124
- if (c && c.cell && !c.cell.state.isHidden) {
125
- commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: c.cell.parent, ref: c.cell.transform.ref });
126
- }
127
- }
128
- }
129
- }
130
- };
131
- _this.displayStructures = function (segmentIndex) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
132
- var customState, spState, loadStrs_1, _i, _a, ref, cell, afStr, _b, _c, c;
133
- var _this = this;
134
- return tslib_1.__generator(this, function (_d) {
135
- switch (_d.label) {
136
- case 0:
137
- customState = this.customState;
138
- spState = customState.superpositionState;
139
- if (!(customState.superpositionState.visibleRefs[segmentIndex].length === 0)) return [3 /*break*/, 3];
140
- loadStrs_1 = [];
141
- customState.superpositionState.segmentData[segmentIndex].clusters.forEach(function (cluster) {
142
- var entryList = [cluster[0]];
143
- if (customState.initParams.superpositionParams && customState.initParams.superpositionParams.superposeAll) {
144
- entryList = cluster;
145
- }
146
- entryList.forEach(function (str) {
147
- var structStateId = "".concat(str.pdb_id, "_").concat(str.struct_asym_id);
148
- var structRef = customState.superpositionState.models[structStateId];
149
- if (structRef) {
150
- var cell = _this.plugin.state.data.cells.get(structRef);
151
- var isHidden = cell.state.isHidden ? true : false;
152
- if (isHidden) {
153
- commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: cell.parent, ref: structRef });
154
- // PluginCommands.State.ToggleVisibility(this.plugin, { state: cell.parent!, ref: cell.transform.parent });
155
- }
156
- }
157
- else {
158
- loadStrs_1.push(str);
159
- }
160
- });
161
- });
162
- commands_1.PluginCommands.Camera.Reset(this.plugin);
163
- if (!(loadStrs_1.length > 0)) return [3 /*break*/, 2];
164
- return [4 /*yield*/, (0, superposition_1.renderSuperposition)(this.plugin, segmentIndex, loadStrs_1)];
165
- case 1:
166
- _d.sent();
167
- commands_1.PluginCommands.Camera.Reset(this.plugin);
168
- _d.label = 2;
169
- case 2: return [3 /*break*/, 4];
170
- case 3:
171
- for (_i = 0, _a = customState.superpositionState.visibleRefs[segmentIndex]; _i < _a.length; _i++) {
172
- ref = _a[_i];
173
- cell = this.plugin.state.data.cells.get(ref);
174
- if (cell && cell.state.isHidden) {
175
- commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: cell.parent, ref: ref });
176
- }
177
- }
178
- commands_1.PluginCommands.Camera.Reset(this.plugin);
179
- _d.label = 4;
180
- case 4:
181
- if (spState.alphafold.ref) {
182
- (0, superposition_2.superposeAf)(this.plugin, spState.alphafold.traceOnly);
183
- commands_1.PluginCommands.Camera.Reset(this.plugin);
184
- }
185
- if (spState.alphafold.ref && spState.alphafold.visibility[segmentIndex]) {
186
- afStr = this.plugin.managers.structure.hierarchy.current.refs.get(customState.superpositionState.alphafold.ref);
187
- if (afStr && afStr.components) {
188
- for (_b = 0, _c = afStr.components; _b < _c.length; _b++) {
189
- c = _c[_b];
190
- if (c && c.cell && c.cell.state.isHidden) {
191
- commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: c.cell.parent, ref: c.cell.transform.ref });
192
- }
193
- }
194
- }
195
- }
196
- return [2 /*return*/];
197
- }
198
- });
199
- }); };
200
- return _this;
201
- }
202
- SegmentTree.prototype.componentDidMount = function () {
203
- var _this = this;
204
- this.subscribe(this.plugin.customState.events.superpositionInit, function () {
205
- var customState = _this.customState;
206
- if (customState && !customState.superpositionError) {
207
- _this.getSegmentParams();
208
- }
209
- _this.forceUpdate();
210
- });
211
- this.subscribe(this.plugin.customState.events.isBusy, function (e) {
212
- _this.setState({ isBusy: e });
213
- if (e) {
214
- commands_1.PluginCommands.Toast.Show(_this.plugin, {
215
- title: 'Process',
216
- message: 'Loading / computing large dataset!',
217
- key: 'is-busy-toast'
218
- });
219
- }
220
- else {
221
- commands_1.PluginCommands.Toast.Hide(_this.plugin, { key: 'is-busy-toast' });
222
- }
223
- });
224
- this.subscribe(this.plugin.behaviors.layout.leftPanelTabName, function (e) {
225
- if (e !== 'segments')
226
- return;
227
- _this.getSegmentParams();
228
- _this.forceUpdate();
229
- });
230
- };
231
- Object.defineProperty(SegmentTree.prototype, "customState", {
232
- get: function () {
233
- return this.plugin.customState;
234
- },
235
- enumerable: false,
236
- configurable: true
237
- });
238
- SegmentTree.prototype.transform = function (s, matrix) {
239
- return tslib_1.__awaiter(this, void 0, void 0, function () {
240
- var r, o, params, b;
241
- return tslib_1.__generator(this, function (_a) {
242
- switch (_a.label) {
243
- case 0:
244
- r = mol_state_2.StateObjectRef.resolveAndCheck(this.plugin.state.data, s);
245
- if (!r)
246
- return [2 /*return*/];
247
- o = mol_state_2.StateSelection.findTagInSubtree(this.plugin.state.data.tree, r.transform.ref, SuperpositionTag);
248
- params = {
249
- transform: {
250
- name: 'matrix',
251
- params: { data: matrix, transpose: false }
252
- }
253
- };
254
- b = o
255
- ? this.plugin.state.data.build().to(o).update(params)
256
- : this.plugin.state.data.build().to(s)
257
- .insert(transforms_1.StateTransforms.Model.TransformStructureConformation, params, { tags: SuperpositionTag });
258
- return [4 /*yield*/, this.plugin.runTask(this.plugin.state.data.updateTree(b))];
259
- case 1:
260
- _a.sent();
261
- return [2 /*return*/];
262
- }
263
- });
264
- });
265
- };
266
- SegmentTree.prototype.render = function () {
267
- var sectionHeader = (0, jsx_runtime_1.jsx)(common_1.SectionHeader, { title: "Structure clusters" });
268
- var customState = this.customState;
269
- if (customState && customState.initParams && !customState.initParams.superposition) {
270
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sectionHeader, (0, jsx_runtime_1.jsx)("div", { children: "Functionality unavailable!" })] });
271
- }
272
- else {
273
- if (customState && customState.initParams && customState.initParams.superposition) {
274
- sectionHeader = (0, jsx_runtime_1.jsx)(common_1.SectionHeader, { title: "Structure clusters - ".concat(customState.initParams.moleculeId) });
275
- if (customState.superpositionError) {
276
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sectionHeader, (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { textAlign: 'center' } }, { children: customState.superpositionError }))] });
277
- }
278
- else if (!customState.superpositionState || !customState.superpositionState.segmentData) {
279
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sectionHeader, (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { textAlign: 'center' } }, { children: "Loading Segment Data!" }))] });
280
- }
281
- }
282
- }
283
- if (this.state) {
284
- var segmentIndex_1 = parseInt(this.state.segment.value.segment.split(' ')[0]) - 1;
285
- var segmentData_1 = customState.superpositionState.segmentData;
286
- var fullSegmentRange = "( ".concat(segmentData_1[0].segment_start, " - ").concat(segmentData_1[segmentData_1.length - 1].segment_end, " )");
287
- sectionHeader = (0, jsx_runtime_1.jsx)(common_1.SectionHeader, { title: "Structure clusters ".concat(customState.initParams.moleculeId), desc: fullSegmentRange });
288
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sectionHeader, (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: this.state.segment.params, values: this.state.segment.value, onChangeValues: this.updateSegment, isDisabled: this.state.isBusy }), segmentData_1[segmentIndex_1].clusters.map(function (c, i) { return (0, jsx_runtime_1.jsx)(ClusterNode, { cluster: c, totalClusters: segmentData_1[segmentIndex_1].clusters.length, segmentIndex: segmentIndex_1, clusterIndex: i }, "cluster-".concat(segmentIndex_1, "-").concat(i)); })] });
289
- }
290
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
291
- };
292
- return SegmentTree;
293
- }(base_1.PurePluginUIComponent));
294
- exports.SegmentTree = SegmentTree;
295
- var ClusterNode = /** @class */ (function (_super) {
296
- tslib_1.__extends(ClusterNode, _super);
297
- function ClusterNode() {
298
- var _this = _super !== null && _super.apply(this, arguments) || this;
299
- _this.state = {
300
- isCollapsed: false,
301
- showAll: false,
302
- showNone: false,
303
- showSearch: false,
304
- isBusy: false,
305
- cluster: _this.props.cluster,
306
- searchText: ''
307
- };
308
- _this.inputStream = new rxjs_1.Subject();
309
- _this.handleInputStream = function (inputStr) {
310
- _this.setState({ searchText: inputStr });
311
- var filteredRes = _this.props.cluster.filter(function (item) {
312
- return item.pdb_id.toLowerCase().indexOf(inputStr.toLowerCase()) >= 0;
313
- });
314
- _this.setState({ cluster: filteredRes });
315
- };
316
- _this.toggleExpanded = function (e) {
317
- e.preventDefault();
318
- _this.setState({ isCollapsed: !_this.state.isCollapsed });
319
- e.currentTarget.blur();
320
- };
321
- _this.selectAll = function (e) {
322
- e.preventDefault();
323
- _this.setState({ showAll: !_this.state.showAll, showNone: false });
324
- e.currentTarget.blur();
325
- };
326
- _this.selectNone = function (e) {
327
- e.preventDefault();
328
- _this.setState({ showAll: false, showNone: !_this.state.showNone });
329
- e.currentTarget.blur();
330
- };
331
- _this.applyAction = function (e) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
332
- var customState, currentState;
333
- var _this = this;
334
- return tslib_1.__generator(this, function (_a) {
335
- e.preventDefault();
336
- e.currentTarget.blur();
337
- customState = this.customState;
338
- customState.events.isBusy.next(true);
339
- currentState = tslib_1.__assign({}, this.state);
340
- this.setState({ showAll: false, showNone: false });
341
- setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
342
- var loadStrs, _a, _b, str, structStateId, structRef, cell, isHidden, e_1_1;
343
- var e_1, _c;
344
- return tslib_1.__generator(this, function (_d) {
345
- switch (_d.label) {
346
- case 0:
347
- loadStrs = [];
348
- _d.label = 1;
349
- case 1:
350
- _d.trys.push([1, 9, 10, 15]);
351
- _a = tslib_1.__asyncValues(this.state.cluster);
352
- _d.label = 2;
353
- case 2: return [4 /*yield*/, _a.next()];
354
- case 3:
355
- if (!(_b = _d.sent(), !_b.done)) return [3 /*break*/, 8];
356
- str = _b.value;
357
- structStateId = "".concat(str.pdb_id, "_").concat(str.struct_asym_id);
358
- structRef = undefined;
359
- if (customState && customState.superpositionState && customState.superpositionState.models[structStateId]) {
360
- structRef = this.customState.superpositionState.models[structStateId];
361
- }
362
- if (!structRef) return [3 /*break*/, 6];
363
- cell = this.plugin.state.data.cells.get(structRef);
364
- if (!cell) return [3 /*break*/, 5];
365
- isHidden = cell.state.isHidden ? true : false;
366
- if (!((isHidden && currentState.showAll) || (!isHidden && currentState.showNone))) return [3 /*break*/, 5];
367
- return [4 /*yield*/, commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: cell.parent, ref: structRef })];
368
- case 4:
369
- _d.sent();
370
- _d.label = 5;
371
- case 5: return [3 /*break*/, 7];
372
- case 6:
373
- if (currentState.showAll)
374
- loadStrs.push(str);
375
- _d.label = 7;
376
- case 7: return [3 /*break*/, 2];
377
- case 8: return [3 /*break*/, 15];
378
- case 9:
379
- e_1_1 = _d.sent();
380
- e_1 = { error: e_1_1 };
381
- return [3 /*break*/, 15];
382
- case 10:
383
- _d.trys.push([10, , 13, 14]);
384
- if (!(_b && !_b.done && (_c = _a.return))) return [3 /*break*/, 12];
385
- return [4 /*yield*/, _c.call(_a)];
386
- case 11:
387
- _d.sent();
388
- _d.label = 12;
389
- case 12: return [3 /*break*/, 14];
390
- case 13:
391
- if (e_1) throw e_1.error;
392
- return [7 /*endfinally*/];
393
- case 14: return [7 /*endfinally*/];
394
- case 15:
395
- ;
396
- commands_1.PluginCommands.Camera.Reset(this.plugin);
397
- if (!(loadStrs.length > 0)) return [3 /*break*/, 17];
398
- return [4 /*yield*/, (0, superposition_1.renderSuperposition)(this.plugin, this.props.segmentIndex, loadStrs)];
399
- case 16:
400
- _d.sent();
401
- _d.label = 17;
402
- case 17:
403
- customState.events.isBusy.next(false);
404
- return [2 /*return*/];
405
- }
406
- });
407
- }); });
408
- return [2 /*return*/];
409
- });
410
- }); };
411
- _this.cancelAction = function (e) {
412
- e.preventDefault();
413
- _this.setState({ showAll: false, showNone: false });
414
- e.currentTarget.blur();
415
- };
416
- _this.clearSearch = function (e) {
417
- e.preventDefault();
418
- _this.setState({ searchText: '' });
419
- _this.inputStream.next('');
420
- e.currentTarget.blur();
421
- };
422
- return _this;
423
- }
424
- ClusterNode.prototype.componentDidMount = function () {
425
- var _this = this;
426
- this.subscribe(this.plugin.customState.events.isBusy, function (e) {
427
- _this.setState({ isBusy: e, showAll: false, showNone: false });
428
- });
429
- this.subscribe(this.inputStream.pipe((0, operators_1.debounceTime)(1000 / 24)), function (e) { return _this.handleInputStream(e); });
430
- };
431
- Object.defineProperty(ClusterNode.prototype, "customState", {
432
- get: function () {
433
- return this.plugin.customState;
434
- },
435
- enumerable: false,
436
- configurable: true
437
- });
438
- ClusterNode.prototype.render = function () {
439
- var _this = this;
440
- var customState = this.customState;
441
- if (!customState.superpositionState || !customState.superpositionState.segmentData)
442
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
443
- var expand = (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: this.state.isCollapsed ? icons_1.ArrowRightSvg : icons_1.ArrowDropDownSvg, flex: '20px', onClick: this.toggleExpanded, transparent: true, disabled: this.state.isBusy, className: 'msp-no-hover-outline' });
444
- var title = "Segment ".concat(customState.superpositionState.activeSegment, " Cluster ").concat(this.props.clusterIndex + 1);
445
- var label = (0, jsx_runtime_1.jsxs)(common_1.Button, tslib_1.__assign({ className: "msp-btn-tree-label", noOverflow: true, title: title, disabled: this.state.isBusy }, { children: [(0, jsx_runtime_1.jsxs)("span", { children: ["Cluster ", this.props.clusterIndex + 1] }), " ", (0, jsx_runtime_1.jsxs)("small", { children: [this.state.cluster.length < this.props.cluster.length ? "".concat(this.state.cluster.length, " / ") : '', this.props.cluster.length, " chain", this.props.cluster.length > 1 ? 's' : ''] })] }));
446
- var selectionControls = (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CheckSvg, flex: true, onClick: this.selectAll, style: { flex: '0 0 50px', textAlign: 'center', fontSize: '80%', color: '#9cacc3', padding: 0 }, disabled: this.state.isBusy, title: "Show all chains" }, { children: "All" })), (0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CloseSvg, flex: true, onClick: this.selectNone, style: { flex: '0 0 50px', textAlign: 'center', fontSize: '80%', color: '#9cacc3', padding: 0 }, disabled: this.state.isBusy, title: "Hide all chains" }, { children: "None" }))] });
447
- var mainRow = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "msp-flex-row msp-tree-row", style: { marginTop: '10px' } }, { children: [expand, label, this.props.cluster.length > 1 && selectionControls] }));
448
- var searchControls = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-mapped-parameter-group', style: { fontSize: '90%' } }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-control-row msp-transform-header-brand-gray', style: { height: '33px', marginLeft: '30px' } }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: 'msp-control-row-label' }, { children: "Search PDB ID" })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-row-ctrl' }, { children: (0, jsx_runtime_1.jsx)("input", { type: 'text', placeholder: 'Enter PDB ID..', disabled: this.state.isBusy, onChange: function (e) { return _this.inputStream.next(e.target.value); }, value: this.state.searchText, maxLength: 4 }) }))] })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: icons_1.CloseSvg, flex: true, onClick: this.clearSearch, style: { flex: '0 0 24px', padding: 0 }, disabled: this.state.isBusy || this.state.searchText === '', toggleState: this.state.searchText !== '', title: 'Clear search input' })] }));
449
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [mainRow, (this.state.showAll || this.state.showNone) && (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "msp-control-row msp-transform-header-brand-".concat(this.state.showAll ? 'green' : 'red'), style: { display: 'flex', marginLeft: '20px', height: '35px' } }, { children: [(0, jsx_runtime_1.jsxs)("span", tslib_1.__assign({ className: 'msp-control-row-label', style: { flex: '1 1 auto', textAlign: 'left', fontSize: '85%' } }, { children: [this.state.showAll ? 'Display' : 'Hide', " ", this.state.cluster.length < this.props.cluster.length ? "".concat(this.state.cluster.length, " / ") : 'all ', this.props.cluster.length, " chains"] })), (0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CheckSvg, flex: true, onClick: this.applyAction, style: { flex: '0 0 60px', textAlign: 'center', fontSize: '78%', color: '#9cacc3', padding: 0, margin: '0 1px' }, title: "Apply action" }, { children: "Apply" })), (0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CloseSvg, flex: true, onClick: this.cancelAction, style: { flex: '0 0 60px', textAlign: 'center', fontSize: '78%', color: '#9cacc3', padding: 0, margin: '0 1px' }, title: "Cancel action" }, { children: "Cancel" }))] })) }), (!this.state.isCollapsed && this.props.cluster.length > 5) && searchControls, !this.state.isCollapsed && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-tree-updates-wrapper', style: { maxHeight: (this.props.totalClusters > 1) ? '330px' : '87%', overflowY: 'auto' } }, { children: this.state.cluster.map(function (s, i) { return (0, jsx_runtime_1.jsx)(StructureNode, { segmentIndex: _this.props.segmentIndex, structure: s, isRep: i === 0 ? true : false }, "str-".concat(s.pdb_id).concat(s.struct_asym_id).concat(i)); }) }))] });
450
- };
451
- return ClusterNode;
452
- }(base_1.PluginUIComponent));
453
- var StructureNode = /** @class */ (function (_super) {
454
- tslib_1.__extends(StructureNode, _super);
455
- function StructureNode() {
456
- var _this = _super !== null && _super.apply(this, arguments) || this;
457
- _this.state = {
458
- showControls: false,
459
- isBusy: false,
460
- isProcessing: false,
461
- isHidden: true,
462
- };
463
- _this.toggleVisible = function (e) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
464
- var structHierarchy, _i, _a, c, currentHiddenState;
465
- return tslib_1.__generator(this, function (_b) {
466
- switch (_b.label) {
467
- case 0:
468
- e.preventDefault();
469
- e.currentTarget.blur();
470
- this.setState({ isProcessing: true, showControls: false });
471
- if (!this.ref) return [3 /*break*/, 1];
472
- structHierarchy = this.plugin.managers.structure.hierarchy.current.refs.get(this.ref);
473
- if (structHierarchy && structHierarchy.components) {
474
- for (_i = 0, _a = structHierarchy.components; _i < _a.length; _i++) {
475
- c = _a[_i];
476
- currentHiddenState = c.cell.state.isHidden ? true : false;
477
- if (currentHiddenState === this.state.isHidden) {
478
- commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: c.cell.parent, ref: c.cell.transform.ref });
479
- }
480
- }
481
- this.setState({ isHidden: !this.state.isHidden });
482
- }
483
- return [3 /*break*/, 3];
484
- case 1: return [4 /*yield*/, (0, superposition_1.renderSuperposition)(this.plugin, this.props.segmentIndex, [this.props.structure])];
485
- case 2:
486
- _b.sent();
487
- _b.label = 3;
488
- case 3:
489
- this.setState({ isProcessing: false });
490
- commands_1.PluginCommands.Camera.Reset(this.plugin);
491
- return [2 /*return*/];
492
- }
493
- });
494
- }); };
495
- _this.selectAction = function (item) {
496
- if (!item)
497
- return;
498
- _this.setState({ showControls: false });
499
- (item === null || item === void 0 ? void 0 : item.value)();
500
- };
501
- _this.highlight = function (e) {
502
- e.preventDefault();
503
- if (_this.ref) {
504
- var cell = _this.plugin.state.data.cells.get(_this.ref);
505
- commands_1.PluginCommands.Interactivity.Object.Highlight(_this.plugin, { state: cell.parent, ref: _this.ref });
506
- }
507
- e.currentTarget.blur();
508
- };
509
- _this.clearHighlight = function (e) {
510
- e.preventDefault();
511
- commands_1.PluginCommands.Interactivity.ClearHighlights(_this.plugin);
512
- e.currentTarget.blur();
513
- };
514
- _this.toggleControls = function (e) {
515
- e.preventDefault();
516
- _this.setState({ showControls: !_this.state.showControls });
517
- e.currentTarget.blur();
518
- };
519
- return _this;
520
- }
521
- Object.defineProperty(StructureNode.prototype, "customState", {
522
- get: function () {
523
- return this.plugin.customState;
524
- },
525
- enumerable: false,
526
- configurable: true
527
- });
528
- Object.defineProperty(StructureNode.prototype, "ref", {
529
- get: function () {
530
- if (this.customState && this.customState.superpositionState && this.customState.superpositionState.models["".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id)]) {
531
- return this.customState.superpositionState.models["".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id)];
532
- }
533
- else {
534
- return undefined;
535
- }
536
- },
537
- enumerable: false,
538
- configurable: true
539
- });
540
- Object.defineProperty(StructureNode.prototype, "modelCell", {
541
- get: function () {
542
- if (this.ref) {
543
- return this.plugin.state.data.cells.get(this.ref);
544
- }
545
- else {
546
- return undefined;
547
- }
548
- },
549
- enumerable: false,
550
- configurable: true
551
- });
552
- Object.defineProperty(StructureNode.prototype, "isAllHidden", {
553
- get: function () {
554
- var isHidden = true;
555
- if (this.ref) {
556
- var structHierarchy = this.plugin.managers.structure.hierarchy.current.refs.get(this.ref);
557
- if (structHierarchy && structHierarchy.components) {
558
- for (var _i = 0, _a = structHierarchy.components; _i < _a.length; _i++) {
559
- var c = _a[_i];
560
- if (c && c.cell && !c.cell.state.isHidden) {
561
- isHidden = false;
562
- break;
563
- }
564
- }
565
- }
566
- else {
567
- isHidden = false;
568
- }
569
- }
570
- return isHidden;
571
- },
572
- enumerable: false,
573
- configurable: true
574
- });
575
- StructureNode.prototype.checkRelation = function (ref) {
576
- var isRelated = false;
577
- var cell = this.plugin.state.data.cells.get(ref);
578
- if (cell && cell.transform.parent) {
579
- if (cell && cell.transform.parent === this.ref) {
580
- isRelated = true;
581
- }
582
- else {
583
- var pcell = this.plugin.state.data.cells.get(cell.transform.parent);
584
- if (pcell && pcell.transform.parent === this.ref)
585
- isRelated = true;
586
- }
587
- }
588
- else {
589
- var currentNodeCell = this.plugin.state.data.cells.get(this.ref);
590
- if (currentNodeCell && currentNodeCell.transform.parent === cell.transform.parent) {
591
- isRelated = true;
592
- }
593
- }
594
- return isRelated;
595
- };
596
- StructureNode.prototype.is = function (e) {
597
- if (!this.ref)
598
- return false;
599
- var isRelated = false;
600
- if (this.ref && e.ref !== this.ref) {
601
- isRelated = this.checkRelation(e.ref);
602
- }
603
- if (e.ref === this.ref || isRelated) {
604
- return true;
605
- }
606
- else {
607
- var invalidStruct = (this.customState.superpositionState.invalidStruct.indexOf("".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id)) > -1) ? true : false;
608
- return invalidStruct ? true : false;
609
- }
610
- };
611
- StructureNode.prototype.componentDidMount = function () {
612
- var _this = this;
613
- this.setState({ isHidden: this.isAllHidden });
614
- this.subscribe(this.plugin.customState.events.isBusy, function (e) {
615
- _this.setState({ isBusy: e, showControls: false });
616
- });
617
- this.subscribe(this.plugin.state.events.cell.stateUpdated.pipe((0, operators_1.filter)(function (e) { return _this.is(e); }), (0, operators_1.debounceTime)(33)), function (e) {
618
- _this.setState({ isHidden: _this.isAllHidden });
619
- // this.forceUpdate();
620
- });
621
- };
622
- StructureNode.prototype.getTagRefs = function (tags) {
623
- var TagSet = new Set(tags);
624
- var tree = this.plugin.state.data.tree;
625
- return mol_state_2.StateSelection.findUniqueTagsInSubtree(tree, this.modelCell.transform.ref, TagSet);
626
- };
627
- StructureNode.prototype.getRandomColor = function () {
628
- var clList = lists_1.ColorLists;
629
- var spState = this.plugin.customState.superpositionState;
630
- var palleteIndex = spState.colorState[this.props.segmentIndex].palleteIndex;
631
- var colorIndex = spState.colorState[this.props.segmentIndex].colorIndex;
632
- if (clList[spState.colorPalette[palleteIndex]].list[colorIndex + 1]) {
633
- colorIndex += 1;
634
- }
635
- else {
636
- colorIndex = 0;
637
- palleteIndex = spState.colorPalette[palleteIndex + 1] ? palleteIndex + 1 : 0;
638
- }
639
- var palleteName = spState.colorPalette[palleteIndex];
640
- this.plugin.customState.superpositionState.colorState[this.props.segmentIndex].palleteIndex = palleteIndex;
641
- this.plugin.customState.superpositionState.colorState[this.props.segmentIndex].colorIndex = colorIndex;
642
- return clList[palleteName].list[colorIndex];
643
- };
644
- StructureNode.prototype.addChainRepr = function () {
645
- return tslib_1.__awaiter(this, void 0, void 0, function () {
646
- var uniformColor1, strInstance, query, chainSel;
647
- return tslib_1.__generator(this, function (_a) {
648
- switch (_a.label) {
649
- case 0:
650
- uniformColor1 = this.getRandomColor();
651
- strInstance = this.plugin.state.data.select(this.ref)[0];
652
- query = builder_1.MolScriptBuilder.struct.generator.atomGroups({
653
- 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.label_asym_id(), this.props.structure.struct_asym_id])
654
- });
655
- return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentFromExpression(strInstance, query, "Chain-".concat(this.props.segmentIndex), { label: "Chain", tags: ["superposition-sel"] })];
656
- case 1:
657
- chainSel = _a.sent();
658
- if (!chainSel) return [3 /*break*/, 3];
659
- return [4 /*yield*/, this.plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'cartoon', color: 'uniform', colorParams: { value: uniformColor1 } }, { tag: "superposition-visual" })];
660
- case 2:
661
- _a.sent();
662
- _a.label = 3;
663
- case 3: return [2 /*return*/];
664
- }
665
- });
666
- });
667
- };
668
- StructureNode.prototype.updates = function () {
669
- var _this = this;
670
- var structHierarchy = this.plugin.managers.structure.hierarchy.current.refs.get(this.ref);
671
- if (structHierarchy && structHierarchy.components) {
672
- var representations_1 = [];
673
- var showAddChainBtn_1 = true;
674
- structHierarchy.components.forEach(function (comps) {
675
- var gKeys = comps.key.split(',');
676
- var cId1Arr = gKeys[0].split('-');
677
- if (cId1Arr[2] === 'Chain')
678
- showAddChainBtn_1 = false;
679
- if (comps.representations) {
680
- comps.representations.forEach(function (repr) {
681
- representations_1.push(repr);
682
- });
683
- }
684
- });
685
- var customState = this.plugin.customState;
686
- if (customState.initParams && customState.initParams.superpositionParams && !customState.initParams.superpositionParams.ligandView) {
687
- showAddChainBtn_1 = false;
688
- }
689
- if (representations_1.length > 0) {
690
- return (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-accent-offset', style: { marginLeft: '40px' } }, { children: [representations_1.length > 0 && representations_1.map(function (r, i) { return (0, jsx_runtime_1.jsx)(StructureRepresentationEntry, { group: [structHierarchy], representation: r }, "".concat(r.cell.transform.ref, "-").concat(i)); }), showAddChainBtn_1 && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-group-header', style: { marginTop: '1px' } }, { children: (0, jsx_runtime_1.jsxs)(common_1.Button, tslib_1.__assign({ noOverflow: true, className: 'msp-control-button-label', title: "Click to add chain representaion", onClick: function () { return _this.addChainRepr(); } }, { children: ["\u00A0\u00A0Add Chain ", this.props.structure.struct_asym_id, " Representation"] })) }))] }));
691
- }
692
- }
693
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
694
- };
695
- StructureNode.prototype.getSubtitle = function () {
696
- var customState = this.plugin.customState;
697
- var hetList = customState.superpositionState.hets["".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id)];
698
- var subtitle;
699
- if (hetList) {
700
- var hetLimit = this.props.structure.is_representative ? 1 : 4;
701
- var totalHets = hetList.length;
702
- var hetStr = hetList.join(', ');
703
- if (totalHets > hetLimit) {
704
- hetStr = hetList.slice(0, hetLimit).join(', ');
705
- hetStr += " + ".concat(totalHets - hetLimit);
706
- }
707
- subtitle = " ( ".concat(hetStr, " )");
708
- if (this.props.structure.is_representative)
709
- subtitle = " ".concat(subtitle, " ( Representative )");
710
- }
711
- else if (this.props.structure.is_representative) {
712
- subtitle = ' ( Representative )';
713
- }
714
- return subtitle;
715
- };
716
- Object.defineProperty(StructureNode.prototype, "panelColor", {
717
- get: function () {
718
- var panelColor = '#808080';
719
- if (!this.state.isHidden) {
720
- if (this.modelCell) {
721
- var refs = this.getTagRefs(["superposition-visual", "superposition-ligand-visual"]);
722
- var visualRef = refs["superposition-ligand-visual"] ? refs["superposition-ligand-visual"] : refs["superposition-visual"] ? refs["superposition-visual"] : undefined;
723
- if (visualRef) {
724
- var visualCell = this.plugin.state.data.cells.get(visualRef);
725
- if (visualCell.params && visualCell.params.values && visualCell.params.values.colorTheme) {
726
- var colorTheme = visualCell.params.values.colorTheme;
727
- if (colorTheme.params && colorTheme.params.value) {
728
- panelColor = "".concat(color_1.Color.toStyle(colorTheme.params.value));
729
- }
730
- else if (colorTheme.params && colorTheme.params.palette) {
731
- var colorList1 = colorTheme.params.palette.params.list.colors;
732
- panelColor = "".concat(color_1.Color.toStyle(colorList1[0]));
733
- }
734
- else if (colorTheme.params && colorTheme.params.list) {
735
- var colorList2 = colorTheme.params.list.colors;
736
- panelColor = "".concat(color_1.Color.toStyle(colorList2[0]));
737
- }
738
- }
739
- }
740
- }
741
- }
742
- return panelColor;
743
- },
744
- enumerable: false,
745
- configurable: true
746
- });
747
- StructureNode.prototype.render = function () {
748
- var superpositionParams = this.customState.initParams.superpositionParams;
749
- var strutStateId = "".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id);
750
- var invalidStruct = (this.customState.superpositionState.invalidStruct.indexOf(strutStateId) > -1) ? true : false;
751
- var noMatrixStruct = (this.customState.superpositionState.noMatrixStruct.indexOf(strutStateId) > -1) ? true : false;
752
- var subTitle = invalidStruct ? noMatrixStruct ? " Matrix not available!" : " No Ligand found!" : this.getSubtitle();
753
- var strTitle = "".concat(this.props.structure.pdb_id, " chain ").concat(this.props.structure.auth_asym_id);
754
- if (superpositionParams && superpositionParams.ligandView) {
755
- strTitle = "".concat(this.props.structure.pdb_id, " ").concat(this.props.structure.struct_asym_id);
756
- }
757
- var label = (0, jsx_runtime_1.jsxs)(common_1.Button, tslib_1.__assign({ className: "msp-btn-tree-label", style: { borderLeftColor: this.panelColor }, noOverflow: true, title: strTitle, disabled: (invalidStruct || this.state.isBusy || this.state.isProcessing) ? true : false, onMouseEnter: this.highlight, onMouseLeave: this.clearHighlight }, { children: [(0, jsx_runtime_1.jsx)("span", { children: strTitle }), subTitle && (0, jsx_runtime_1.jsx)("small", { children: subTitle })] }));
758
- var expand = (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: !this.state.showControls ? icons_1.ArrowRightSvg : icons_1.ArrowDropDownSvg, flex: '20px', onClick: this.toggleControls, transparent: true, className: 'msp-no-hover-outline', disabled: (invalidStruct || this.state.isBusy || this.state.isProcessing) ? true : false });
759
- var visibility = (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: this.state.isHidden ? icons_1.VisibilityOffOutlinedSvg : icons_1.VisibilityOutlinedSvg, toggleState: false, small: true, onClick: this.toggleVisible, disabled: (invalidStruct || this.state.isBusy || this.state.isProcessing) ? true : false, title: this.state.isHidden ? "Show chain" : "Hide chain" });
760
- var row = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "msp-flex-row msp-tree-row", style: { marginLeft: !this.state.isHidden ? '10px' : '31px' } }, { children: [!this.state.isHidden && expand, label, visibility] }));
761
- return (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ style: { marginBottom: '1px' } }, { children: [row, this.state.showControls && this.updates()] }));
762
- };
763
- return StructureNode;
764
- }(base_1.PluginUIComponent));
765
- var StructureRepresentationEntry = /** @class */ (function (_super) {
766
- tslib_1.__extends(StructureRepresentationEntry, _super);
767
- function StructureRepresentationEntry() {
768
- var _this = _super !== null && _super.apply(this, arguments) || this;
769
- _this.toggleVisible = function (e) {
770
- e.preventDefault();
771
- e.currentTarget.blur();
772
- var cell = _this.props.representation.cell;
773
- commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: cell.parent, ref: cell.transform.parent });
774
- };
775
- return _this;
776
- }
777
- StructureRepresentationEntry.prototype.componentDidMount = function () {
778
- var _this = this;
779
- this.subscribe(this.plugin.state.events.cell.stateUpdated, function (e) {
780
- if (mol_state_1.State.ObjectEvent.isCell(e, _this.props.representation.cell))
781
- _this.forceUpdate();
782
- });
783
- };
784
- StructureRepresentationEntry.prototype.render = function () {
785
- var _a, _b, _c, _d, _e, _f, _g;
786
- var repr = this.props.representation.cell;
787
- var label = (_a = repr.obj) === null || _a === void 0 ? void 0 : _a.label;
788
- if (((_b = repr.obj) === null || _b === void 0 ? void 0 : _b.data.repr) && ((_c = repr.obj) === null || _c === void 0 ? void 0 : _c.data.repr.label)) {
789
- var sourceLabel = (((_d = repr.obj) === null || _d === void 0 ? void 0 : _d.data.repr.label.indexOf('[Focus]')) >= 0) ? '[Focus]' : (_e = repr.obj) === null || _e === void 0 ? void 0 : _e.data.repr.label;
790
- var isLargeLabel = sourceLabel.length > 10 ? true : false;
791
- sourceLabel = "".concat(isLargeLabel ? "".concat(sourceLabel.substring(0, 28), "...") : sourceLabel);
792
- if (isLargeLabel) {
793
- label = sourceLabel;
794
- }
795
- else {
796
- label = "".concat(sourceLabel, " ").concat((label && label.length < 21) ? ' - ' + label : '');
797
- }
798
- }
799
- if (((_f = repr.obj) === null || _f === void 0 ? void 0 : _f.data.repr) && ((_g = repr.obj) === null || _g === void 0 ? void 0 : _g.data.repr.label) === 'Custom Selection')
800
- label = 'Custom Selection';
801
- return (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: [repr.parent && (0, jsx_runtime_1.jsx)(common_1.ExpandGroup, tslib_1.__assign({ header: "".concat(label || 'Representation'), noOffset: true, headerStyle: { overflow: 'hidden' } }, { children: (0, jsx_runtime_1.jsx)(update_transform_1.UpdateTransformControl, { state: repr.parent, transform: repr.transform, customHeader: 'none', noMargin: true }) })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: this.props.representation.cell.state.isHidden ? icons_1.VisibilityOffOutlinedSvg : icons_1.VisibilityOutlinedSvg, toggleState: false, onClick: this.toggleVisible, title: this.props.representation.cell.state.isHidden ? "Show representation" : "Hide representation", small: true, className: 'msp-default-bg', style: { position: 'absolute', top: 0, right: 0, lineHeight: '24px', height: '24px', textAlign: 'right', width: '32px', paddingRight: '6px', background: 'none' } })] }));
802
- };
803
- return StructureRepresentationEntry;
804
- }(base_1.PurePluginUIComponent));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SegmentTree = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var jsx_runtime_1 = require("react/jsx-runtime");
6
+ var operators_1 = require("rxjs/operators");
7
+ var commands_1 = require("Molstar/mol-plugin/commands");
8
+ var mol_state_1 = require("Molstar/mol-state");
9
+ var base_1 = require("Molstar/mol-plugin-ui/base");
10
+ var common_1 = require("Molstar/mol-plugin-ui/controls/common");
11
+ var param_definition_1 = require("Molstar/mol-util/param-definition");
12
+ var parameters_1 = require("Molstar/mol-plugin-ui/controls/parameters");
13
+ var mol_state_2 = require("Molstar/mol-state");
14
+ var superposition_1 = require("../superposition");
15
+ var update_transform_1 = require("Molstar/mol-plugin-ui/state/update-transform");
16
+ var icons_1 = require("Molstar/mol-plugin-ui/controls/icons");
17
+ var lists_1 = require("Molstar/mol-util/color/lists");
18
+ var color_1 = require("Molstar/mol-util/color");
19
+ var builder_1 = require("Molstar/mol-script/language/builder");
20
+ var rxjs_1 = require("rxjs");
21
+ var transforms_1 = require("Molstar/mol-plugin-state/transforms");
22
+ var superposition_2 = require("../superposition");
23
+ var SuperpositionTag = 'SuperpositionTransform';
24
+ var SegmentTree = /** @class */ (function (_super) {
25
+ tslib_1.__extends(SegmentTree, _super);
26
+ function SegmentTree() {
27
+ var _this = _super !== null && _super.apply(this, arguments) || this;
28
+ _this.getSegmentParams = function () {
29
+ var customState = _this.customState;
30
+ if (!customState.superpositionState || !customState.superpositionState.segmentData)
31
+ return;
32
+ var segmentData = customState.superpositionState.segmentData;
33
+ var segmentArr = segmentData.map(function (segment, i) {
34
+ var segmentLabel = "".concat(i + 1, " ( ").concat(segment.segment_start, " - ").concat(segment.segment_end, " )");
35
+ return [segmentLabel, segmentLabel];
36
+ });
37
+ var segmentOptions = {
38
+ segment: param_definition_1.ParamDefinition.Select('', segmentArr, { label: 'Select Segment', description: 'Select segment to view its clusters below' })
39
+ };
40
+ var segmentIndex = customState.superpositionState.activeSegment - 1;
41
+ _this.setState({ segment: {
42
+ params: segmentOptions,
43
+ value: { segment: segmentArr[segmentIndex][0] }
44
+ } });
45
+ _this.setState({ isBusy: false });
46
+ };
47
+ _this.updateSegment = function (val) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
48
+ var customState, updatedParams;
49
+ var _this = this;
50
+ return tslib_1.__generator(this, function (_a) {
51
+ if (!this.state.segment)
52
+ return [2 /*return*/];
53
+ customState = this.customState;
54
+ customState.events.isBusy.next(true);
55
+ // Hide pervious segement structures
56
+ this.hideStructures(customState.superpositionState.activeSegment - 1);
57
+ updatedParams = tslib_1.__assign({}, this.state.segment);
58
+ updatedParams.value = val;
59
+ this.setState({ segment: updatedParams });
60
+ setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
61
+ var updatedSegmentIndex;
62
+ return tslib_1.__generator(this, function (_a) {
63
+ switch (_a.label) {
64
+ case 0:
65
+ updatedSegmentIndex = parseInt(val.segment.split(' ')[0]);
66
+ customState.superpositionState.activeSegment = updatedSegmentIndex;
67
+ // Display current segment visible structures
68
+ return [4 /*yield*/, this.displayStructures(customState.superpositionState.activeSegment - 1)];
69
+ case 1:
70
+ // Display current segment visible structures
71
+ _a.sent();
72
+ customState.events.isBusy.next(false);
73
+ this.plugin.customState.events.segmentUpdate.next(true);
74
+ return [2 /*return*/];
75
+ }
76
+ });
77
+ }); }, 100);
78
+ return [2 /*return*/, false];
79
+ });
80
+ }); };
81
+ _this.hideStructures = function (segmentIndex) {
82
+ // clear selections
83
+ _this.plugin.managers.interactivity.lociSelects.deselectAll();
84
+ // clear Focus
85
+ _this.plugin.managers.structure.focus.clear();
86
+ // remove measurements
87
+ var measurements = _this.plugin.managers.structure.measurement.state;
88
+ var measureTypes = ['labels', 'distances', 'angles', 'dihedrals'];
89
+ var measurementCell = void 0;
90
+ measureTypes.forEach(function (type) {
91
+ if (measurementCell)
92
+ return;
93
+ if (measurements[type][0]) {
94
+ measurementCell = _this.plugin.state.data.cells.get(measurements[type][0].transform.parent);
95
+ }
96
+ });
97
+ if (measurementCell) {
98
+ commands_1.PluginCommands.State.RemoveObject(_this.plugin, { state: measurementCell.parent, ref: measurementCell.transform.parent, removeParentGhosts: true });
99
+ }
100
+ // hide structures
101
+ var customState = _this.customState;
102
+ customState.superpositionState.visibleRefs[segmentIndex] = [];
103
+ for (var _i = 0, _a = customState.superpositionState.loadedStructs[segmentIndex]; _i < _a.length; _i++) {
104
+ var struct = _a[_i];
105
+ var structRef = _this.customState.superpositionState.models[struct];
106
+ if (structRef) {
107
+ var structHierarchy = _this.plugin.managers.structure.hierarchy.current.refs.get(structRef);
108
+ if (structHierarchy && structHierarchy.components) {
109
+ for (var _b = 0, _c = structHierarchy.components; _b < _c.length; _b++) {
110
+ var c = _c[_b];
111
+ if (c && c.cell && !c.cell.state.isHidden) {
112
+ customState.superpositionState.visibleRefs[segmentIndex].push(c.cell.transform.ref);
113
+ commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: c.cell.parent, ref: c.cell.transform.ref });
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ if (customState.superpositionState.alphafold.ref) {
120
+ var afStr = _this.plugin.managers.structure.hierarchy.current.refs.get(customState.superpositionState.alphafold.ref);
121
+ if (afStr && afStr.components) {
122
+ for (var _d = 0, _e = afStr.components; _d < _e.length; _d++) {
123
+ var c = _e[_d];
124
+ if (c && c.cell && !c.cell.state.isHidden) {
125
+ commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: c.cell.parent, ref: c.cell.transform.ref });
126
+ }
127
+ }
128
+ }
129
+ }
130
+ };
131
+ _this.displayStructures = function (segmentIndex) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
132
+ var customState, spState, loadStrs_1, _i, _a, ref, cell, afStr, _b, _c, c;
133
+ var _this = this;
134
+ return tslib_1.__generator(this, function (_d) {
135
+ switch (_d.label) {
136
+ case 0:
137
+ customState = this.customState;
138
+ spState = customState.superpositionState;
139
+ if (!(customState.superpositionState.visibleRefs[segmentIndex].length === 0)) return [3 /*break*/, 3];
140
+ loadStrs_1 = [];
141
+ customState.superpositionState.segmentData[segmentIndex].clusters.forEach(function (cluster) {
142
+ var entryList = [cluster[0]];
143
+ if (customState.initParams.superpositionParams && customState.initParams.superpositionParams.superposeAll) {
144
+ entryList = cluster;
145
+ }
146
+ entryList.forEach(function (str) {
147
+ var structStateId = "".concat(str.pdb_id, "_").concat(str.struct_asym_id);
148
+ var structRef = customState.superpositionState.models[structStateId];
149
+ if (structRef) {
150
+ var cell = _this.plugin.state.data.cells.get(structRef);
151
+ var isHidden = cell.state.isHidden ? true : false;
152
+ if (isHidden) {
153
+ commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: cell.parent, ref: structRef });
154
+ // PluginCommands.State.ToggleVisibility(this.plugin, { state: cell.parent!, ref: cell.transform.parent });
155
+ }
156
+ }
157
+ else {
158
+ loadStrs_1.push(str);
159
+ }
160
+ });
161
+ });
162
+ commands_1.PluginCommands.Camera.Reset(this.plugin);
163
+ if (!(loadStrs_1.length > 0)) return [3 /*break*/, 2];
164
+ return [4 /*yield*/, (0, superposition_1.renderSuperposition)(this.plugin, segmentIndex, loadStrs_1)];
165
+ case 1:
166
+ _d.sent();
167
+ commands_1.PluginCommands.Camera.Reset(this.plugin);
168
+ _d.label = 2;
169
+ case 2: return [3 /*break*/, 4];
170
+ case 3:
171
+ for (_i = 0, _a = customState.superpositionState.visibleRefs[segmentIndex]; _i < _a.length; _i++) {
172
+ ref = _a[_i];
173
+ cell = this.plugin.state.data.cells.get(ref);
174
+ if (cell && cell.state.isHidden) {
175
+ commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: cell.parent, ref: ref });
176
+ }
177
+ }
178
+ commands_1.PluginCommands.Camera.Reset(this.plugin);
179
+ _d.label = 4;
180
+ case 4:
181
+ if (spState.alphafold.ref) {
182
+ (0, superposition_2.superposeAf)(this.plugin, spState.alphafold.traceOnly);
183
+ commands_1.PluginCommands.Camera.Reset(this.plugin);
184
+ }
185
+ if (spState.alphafold.ref && spState.alphafold.visibility[segmentIndex]) {
186
+ afStr = this.plugin.managers.structure.hierarchy.current.refs.get(customState.superpositionState.alphafold.ref);
187
+ if (afStr && afStr.components) {
188
+ for (_b = 0, _c = afStr.components; _b < _c.length; _b++) {
189
+ c = _c[_b];
190
+ if (c && c.cell && c.cell.state.isHidden) {
191
+ commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: c.cell.parent, ref: c.cell.transform.ref });
192
+ }
193
+ }
194
+ }
195
+ }
196
+ return [2 /*return*/];
197
+ }
198
+ });
199
+ }); };
200
+ return _this;
201
+ }
202
+ SegmentTree.prototype.componentDidMount = function () {
203
+ var _this = this;
204
+ this.subscribe(this.plugin.customState.events.superpositionInit, function () {
205
+ var customState = _this.customState;
206
+ if (customState && !customState.superpositionError) {
207
+ _this.getSegmentParams();
208
+ }
209
+ _this.forceUpdate();
210
+ });
211
+ this.subscribe(this.plugin.customState.events.isBusy, function (e) {
212
+ _this.setState({ isBusy: e });
213
+ if (e) {
214
+ commands_1.PluginCommands.Toast.Show(_this.plugin, {
215
+ title: 'Process',
216
+ message: 'Loading / computing large dataset!',
217
+ key: 'is-busy-toast'
218
+ });
219
+ }
220
+ else {
221
+ commands_1.PluginCommands.Toast.Hide(_this.plugin, { key: 'is-busy-toast' });
222
+ }
223
+ });
224
+ this.subscribe(this.plugin.behaviors.layout.leftPanelTabName, function (e) {
225
+ if (e !== 'segments')
226
+ return;
227
+ _this.getSegmentParams();
228
+ _this.forceUpdate();
229
+ });
230
+ };
231
+ Object.defineProperty(SegmentTree.prototype, "customState", {
232
+ get: function () {
233
+ return this.plugin.customState;
234
+ },
235
+ enumerable: false,
236
+ configurable: true
237
+ });
238
+ SegmentTree.prototype.transform = function (s, matrix) {
239
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
240
+ var r, o, params, b;
241
+ return tslib_1.__generator(this, function (_a) {
242
+ switch (_a.label) {
243
+ case 0:
244
+ r = mol_state_2.StateObjectRef.resolveAndCheck(this.plugin.state.data, s);
245
+ if (!r)
246
+ return [2 /*return*/];
247
+ o = mol_state_2.StateSelection.findTagInSubtree(this.plugin.state.data.tree, r.transform.ref, SuperpositionTag);
248
+ params = {
249
+ transform: {
250
+ name: 'matrix',
251
+ params: { data: matrix, transpose: false }
252
+ }
253
+ };
254
+ b = o
255
+ ? this.plugin.state.data.build().to(o).update(params)
256
+ : this.plugin.state.data.build().to(s)
257
+ .insert(transforms_1.StateTransforms.Model.TransformStructureConformation, params, { tags: SuperpositionTag });
258
+ return [4 /*yield*/, this.plugin.runTask(this.plugin.state.data.updateTree(b))];
259
+ case 1:
260
+ _a.sent();
261
+ return [2 /*return*/];
262
+ }
263
+ });
264
+ });
265
+ };
266
+ SegmentTree.prototype.render = function () {
267
+ var sectionHeader = (0, jsx_runtime_1.jsx)(common_1.SectionHeader, { title: "Structure clusters" });
268
+ var customState = this.customState;
269
+ if (customState && customState.initParams && !customState.initParams.superposition) {
270
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sectionHeader, (0, jsx_runtime_1.jsx)("div", { children: "Functionality unavailable!" })] });
271
+ }
272
+ else {
273
+ if (customState && customState.initParams && customState.initParams.superposition) {
274
+ sectionHeader = (0, jsx_runtime_1.jsx)(common_1.SectionHeader, { title: "Structure clusters - ".concat(customState.initParams.moleculeId) });
275
+ if (customState.superpositionError) {
276
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sectionHeader, (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { textAlign: 'center' } }, { children: customState.superpositionError }))] });
277
+ }
278
+ else if (!customState.superpositionState || !customState.superpositionState.segmentData) {
279
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sectionHeader, (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { textAlign: 'center' } }, { children: "Loading Segment Data!" }))] });
280
+ }
281
+ }
282
+ }
283
+ if (this.state) {
284
+ var segmentIndex_1 = parseInt(this.state.segment.value.segment.split(' ')[0]) - 1;
285
+ var segmentData_1 = customState.superpositionState.segmentData;
286
+ var fullSegmentRange = "( ".concat(segmentData_1[0].segment_start, " - ").concat(segmentData_1[segmentData_1.length - 1].segment_end, " )");
287
+ sectionHeader = (0, jsx_runtime_1.jsx)(common_1.SectionHeader, { title: "Structure clusters ".concat(customState.initParams.moleculeId), desc: fullSegmentRange });
288
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sectionHeader, (0, jsx_runtime_1.jsx)(parameters_1.ParameterControls, { params: this.state.segment.params, values: this.state.segment.value, onChangeValues: this.updateSegment, isDisabled: this.state.isBusy }), segmentData_1[segmentIndex_1].clusters.map(function (c, i) { return (0, jsx_runtime_1.jsx)(ClusterNode, { cluster: c, totalClusters: segmentData_1[segmentIndex_1].clusters.length, segmentIndex: segmentIndex_1, clusterIndex: i }, "cluster-".concat(segmentIndex_1, "-").concat(i)); })] });
289
+ }
290
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
291
+ };
292
+ return SegmentTree;
293
+ }(base_1.PurePluginUIComponent));
294
+ exports.SegmentTree = SegmentTree;
295
+ var ClusterNode = /** @class */ (function (_super) {
296
+ tslib_1.__extends(ClusterNode, _super);
297
+ function ClusterNode() {
298
+ var _this = _super !== null && _super.apply(this, arguments) || this;
299
+ _this.state = {
300
+ isCollapsed: false,
301
+ showAll: false,
302
+ showNone: false,
303
+ showSearch: false,
304
+ isBusy: false,
305
+ cluster: _this.props.cluster,
306
+ searchText: ''
307
+ };
308
+ _this.inputStream = new rxjs_1.Subject();
309
+ _this.handleInputStream = function (inputStr) {
310
+ _this.setState({ searchText: inputStr });
311
+ var filteredRes = _this.props.cluster.filter(function (item) {
312
+ return item.pdb_id.toLowerCase().indexOf(inputStr.toLowerCase()) >= 0;
313
+ });
314
+ _this.setState({ cluster: filteredRes });
315
+ };
316
+ _this.toggleExpanded = function (e) {
317
+ e.preventDefault();
318
+ _this.setState({ isCollapsed: !_this.state.isCollapsed });
319
+ e.currentTarget.blur();
320
+ };
321
+ _this.selectAll = function (e) {
322
+ e.preventDefault();
323
+ _this.setState({ showAll: !_this.state.showAll, showNone: false });
324
+ e.currentTarget.blur();
325
+ };
326
+ _this.selectNone = function (e) {
327
+ e.preventDefault();
328
+ _this.setState({ showAll: false, showNone: !_this.state.showNone });
329
+ e.currentTarget.blur();
330
+ };
331
+ _this.applyAction = function (e) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
332
+ var customState, currentState;
333
+ var _this = this;
334
+ return tslib_1.__generator(this, function (_a) {
335
+ e.preventDefault();
336
+ e.currentTarget.blur();
337
+ customState = this.customState;
338
+ customState.events.isBusy.next(true);
339
+ currentState = tslib_1.__assign({}, this.state);
340
+ this.setState({ showAll: false, showNone: false });
341
+ setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
342
+ var loadStrs, _a, _b, str, structStateId, structRef, cell, isHidden, e_1_1;
343
+ var e_1, _c;
344
+ return tslib_1.__generator(this, function (_d) {
345
+ switch (_d.label) {
346
+ case 0:
347
+ loadStrs = [];
348
+ _d.label = 1;
349
+ case 1:
350
+ _d.trys.push([1, 9, 10, 15]);
351
+ _a = tslib_1.__asyncValues(this.state.cluster);
352
+ _d.label = 2;
353
+ case 2: return [4 /*yield*/, _a.next()];
354
+ case 3:
355
+ if (!(_b = _d.sent(), !_b.done)) return [3 /*break*/, 8];
356
+ str = _b.value;
357
+ structStateId = "".concat(str.pdb_id, "_").concat(str.struct_asym_id);
358
+ structRef = undefined;
359
+ if (customState && customState.superpositionState && customState.superpositionState.models[structStateId]) {
360
+ structRef = this.customState.superpositionState.models[structStateId];
361
+ }
362
+ if (!structRef) return [3 /*break*/, 6];
363
+ cell = this.plugin.state.data.cells.get(structRef);
364
+ if (!cell) return [3 /*break*/, 5];
365
+ isHidden = cell.state.isHidden ? true : false;
366
+ if (!((isHidden && currentState.showAll) || (!isHidden && currentState.showNone))) return [3 /*break*/, 5];
367
+ return [4 /*yield*/, commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: cell.parent, ref: structRef })];
368
+ case 4:
369
+ _d.sent();
370
+ _d.label = 5;
371
+ case 5: return [3 /*break*/, 7];
372
+ case 6:
373
+ if (currentState.showAll)
374
+ loadStrs.push(str);
375
+ _d.label = 7;
376
+ case 7: return [3 /*break*/, 2];
377
+ case 8: return [3 /*break*/, 15];
378
+ case 9:
379
+ e_1_1 = _d.sent();
380
+ e_1 = { error: e_1_1 };
381
+ return [3 /*break*/, 15];
382
+ case 10:
383
+ _d.trys.push([10, , 13, 14]);
384
+ if (!(_b && !_b.done && (_c = _a.return))) return [3 /*break*/, 12];
385
+ return [4 /*yield*/, _c.call(_a)];
386
+ case 11:
387
+ _d.sent();
388
+ _d.label = 12;
389
+ case 12: return [3 /*break*/, 14];
390
+ case 13:
391
+ if (e_1) throw e_1.error;
392
+ return [7 /*endfinally*/];
393
+ case 14: return [7 /*endfinally*/];
394
+ case 15:
395
+ ;
396
+ commands_1.PluginCommands.Camera.Reset(this.plugin);
397
+ if (!(loadStrs.length > 0)) return [3 /*break*/, 17];
398
+ return [4 /*yield*/, (0, superposition_1.renderSuperposition)(this.plugin, this.props.segmentIndex, loadStrs)];
399
+ case 16:
400
+ _d.sent();
401
+ _d.label = 17;
402
+ case 17:
403
+ customState.events.isBusy.next(false);
404
+ return [2 /*return*/];
405
+ }
406
+ });
407
+ }); });
408
+ return [2 /*return*/];
409
+ });
410
+ }); };
411
+ _this.cancelAction = function (e) {
412
+ e.preventDefault();
413
+ _this.setState({ showAll: false, showNone: false });
414
+ e.currentTarget.blur();
415
+ };
416
+ _this.clearSearch = function (e) {
417
+ e.preventDefault();
418
+ _this.setState({ searchText: '' });
419
+ _this.inputStream.next('');
420
+ e.currentTarget.blur();
421
+ };
422
+ return _this;
423
+ }
424
+ ClusterNode.prototype.componentDidMount = function () {
425
+ var _this = this;
426
+ this.subscribe(this.plugin.customState.events.isBusy, function (e) {
427
+ _this.setState({ isBusy: e, showAll: false, showNone: false });
428
+ });
429
+ this.subscribe(this.inputStream.pipe((0, operators_1.debounceTime)(1000 / 24)), function (e) { return _this.handleInputStream(e); });
430
+ };
431
+ Object.defineProperty(ClusterNode.prototype, "customState", {
432
+ get: function () {
433
+ return this.plugin.customState;
434
+ },
435
+ enumerable: false,
436
+ configurable: true
437
+ });
438
+ ClusterNode.prototype.render = function () {
439
+ var _this = this;
440
+ var customState = this.customState;
441
+ if (!customState.superpositionState || !customState.superpositionState.segmentData)
442
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
443
+ var expand = (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: this.state.isCollapsed ? icons_1.ArrowRightSvg : icons_1.ArrowDropDownSvg, flex: '20px', onClick: this.toggleExpanded, transparent: true, disabled: this.state.isBusy, className: 'msp-no-hover-outline' });
444
+ var title = "Segment ".concat(customState.superpositionState.activeSegment, " Cluster ").concat(this.props.clusterIndex + 1);
445
+ var label = (0, jsx_runtime_1.jsxs)(common_1.Button, tslib_1.__assign({ className: "msp-btn-tree-label", noOverflow: true, title: title, disabled: this.state.isBusy }, { children: [(0, jsx_runtime_1.jsxs)("span", { children: ["Cluster ", this.props.clusterIndex + 1] }), " ", (0, jsx_runtime_1.jsxs)("small", { children: [this.state.cluster.length < this.props.cluster.length ? "".concat(this.state.cluster.length, " / ") : '', this.props.cluster.length, " chain", this.props.cluster.length > 1 ? 's' : ''] })] }));
446
+ var selectionControls = (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CheckSvg, flex: true, onClick: this.selectAll, style: { flex: '0 0 50px', textAlign: 'center', fontSize: '80%', color: '#9cacc3', padding: 0 }, disabled: this.state.isBusy, title: "Show all chains" }, { children: "All" })), (0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CloseSvg, flex: true, onClick: this.selectNone, style: { flex: '0 0 50px', textAlign: 'center', fontSize: '80%', color: '#9cacc3', padding: 0 }, disabled: this.state.isBusy, title: "Hide all chains" }, { children: "None" }))] });
447
+ var mainRow = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "msp-flex-row msp-tree-row", style: { marginTop: '10px' } }, { children: [expand, label, this.props.cluster.length > 1 && selectionControls] }));
448
+ var searchControls = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-mapped-parameter-group', style: { fontSize: '90%' } }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-control-row msp-transform-header-brand-gray', style: { height: '33px', marginLeft: '30px' } }, { children: [(0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: 'msp-control-row-label' }, { children: "Search PDB ID" })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-row-ctrl' }, { children: (0, jsx_runtime_1.jsx)("input", { type: 'text', placeholder: 'Enter PDB ID..', disabled: this.state.isBusy, onChange: function (e) { return _this.inputStream.next(e.target.value); }, value: this.state.searchText, maxLength: 4 }) }))] })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: icons_1.CloseSvg, flex: true, onClick: this.clearSearch, style: { flex: '0 0 24px', padding: 0 }, disabled: this.state.isBusy || this.state.searchText === '', toggleState: this.state.searchText !== '', title: 'Clear search input' })] }));
449
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [mainRow, (this.state.showAll || this.state.showNone) && (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "msp-control-row msp-transform-header-brand-".concat(this.state.showAll ? 'green' : 'red'), style: { display: 'flex', marginLeft: '20px', height: '35px' } }, { children: [(0, jsx_runtime_1.jsxs)("span", tslib_1.__assign({ className: 'msp-control-row-label', style: { flex: '1 1 auto', textAlign: 'left', fontSize: '85%' } }, { children: [this.state.showAll ? 'Display' : 'Hide', " ", this.state.cluster.length < this.props.cluster.length ? "".concat(this.state.cluster.length, " / ") : 'all ', this.props.cluster.length, " chains"] })), (0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CheckSvg, flex: true, onClick: this.applyAction, style: { flex: '0 0 60px', textAlign: 'center', fontSize: '78%', color: '#9cacc3', padding: 0, margin: '0 1px' }, title: "Apply action" }, { children: "Apply" })), (0, jsx_runtime_1.jsx)(common_1.Button, tslib_1.__assign({ icon: icons_1.CloseSvg, flex: true, onClick: this.cancelAction, style: { flex: '0 0 60px', textAlign: 'center', fontSize: '78%', color: '#9cacc3', padding: 0, margin: '0 1px' }, title: "Cancel action" }, { children: "Cancel" }))] })) }), (!this.state.isCollapsed && this.props.cluster.length > 5) && searchControls, !this.state.isCollapsed && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-tree-updates-wrapper', style: { maxHeight: (this.props.totalClusters > 1) ? '330px' : '87%', overflowY: 'auto' } }, { children: this.state.cluster.map(function (s, i) { return (0, jsx_runtime_1.jsx)(StructureNode, { segmentIndex: _this.props.segmentIndex, structure: s, isRep: i === 0 ? true : false }, "str-".concat(s.pdb_id).concat(s.struct_asym_id).concat(i)); }) }))] });
450
+ };
451
+ return ClusterNode;
452
+ }(base_1.PluginUIComponent));
453
+ var StructureNode = /** @class */ (function (_super) {
454
+ tslib_1.__extends(StructureNode, _super);
455
+ function StructureNode() {
456
+ var _this = _super !== null && _super.apply(this, arguments) || this;
457
+ _this.state = {
458
+ showControls: false,
459
+ isBusy: false,
460
+ isProcessing: false,
461
+ isHidden: true,
462
+ };
463
+ _this.toggleVisible = function (e) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
464
+ var structHierarchy, _i, _a, c, currentHiddenState;
465
+ return tslib_1.__generator(this, function (_b) {
466
+ switch (_b.label) {
467
+ case 0:
468
+ e.preventDefault();
469
+ e.currentTarget.blur();
470
+ this.setState({ isProcessing: true, showControls: false });
471
+ if (!this.ref) return [3 /*break*/, 1];
472
+ structHierarchy = this.plugin.managers.structure.hierarchy.current.refs.get(this.ref);
473
+ if (structHierarchy && structHierarchy.components) {
474
+ for (_i = 0, _a = structHierarchy.components; _i < _a.length; _i++) {
475
+ c = _a[_i];
476
+ currentHiddenState = c.cell.state.isHidden ? true : false;
477
+ if (currentHiddenState === this.state.isHidden) {
478
+ commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: c.cell.parent, ref: c.cell.transform.ref });
479
+ }
480
+ }
481
+ this.setState({ isHidden: !this.state.isHidden });
482
+ }
483
+ return [3 /*break*/, 3];
484
+ case 1: return [4 /*yield*/, (0, superposition_1.renderSuperposition)(this.plugin, this.props.segmentIndex, [this.props.structure])];
485
+ case 2:
486
+ _b.sent();
487
+ _b.label = 3;
488
+ case 3:
489
+ this.setState({ isProcessing: false });
490
+ commands_1.PluginCommands.Camera.Reset(this.plugin);
491
+ return [2 /*return*/];
492
+ }
493
+ });
494
+ }); };
495
+ _this.selectAction = function (item) {
496
+ if (!item)
497
+ return;
498
+ _this.setState({ showControls: false });
499
+ (item === null || item === void 0 ? void 0 : item.value)();
500
+ };
501
+ _this.highlight = function (e) {
502
+ e.preventDefault();
503
+ if (_this.ref) {
504
+ var cell = _this.plugin.state.data.cells.get(_this.ref);
505
+ commands_1.PluginCommands.Interactivity.Object.Highlight(_this.plugin, { state: cell.parent, ref: _this.ref });
506
+ }
507
+ e.currentTarget.blur();
508
+ };
509
+ _this.clearHighlight = function (e) {
510
+ e.preventDefault();
511
+ commands_1.PluginCommands.Interactivity.ClearHighlights(_this.plugin);
512
+ e.currentTarget.blur();
513
+ };
514
+ _this.toggleControls = function (e) {
515
+ e.preventDefault();
516
+ _this.setState({ showControls: !_this.state.showControls });
517
+ e.currentTarget.blur();
518
+ };
519
+ return _this;
520
+ }
521
+ Object.defineProperty(StructureNode.prototype, "customState", {
522
+ get: function () {
523
+ return this.plugin.customState;
524
+ },
525
+ enumerable: false,
526
+ configurable: true
527
+ });
528
+ Object.defineProperty(StructureNode.prototype, "ref", {
529
+ get: function () {
530
+ if (this.customState && this.customState.superpositionState && this.customState.superpositionState.models["".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id)]) {
531
+ return this.customState.superpositionState.models["".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id)];
532
+ }
533
+ else {
534
+ return undefined;
535
+ }
536
+ },
537
+ enumerable: false,
538
+ configurable: true
539
+ });
540
+ Object.defineProperty(StructureNode.prototype, "modelCell", {
541
+ get: function () {
542
+ if (this.ref) {
543
+ return this.plugin.state.data.cells.get(this.ref);
544
+ }
545
+ else {
546
+ return undefined;
547
+ }
548
+ },
549
+ enumerable: false,
550
+ configurable: true
551
+ });
552
+ Object.defineProperty(StructureNode.prototype, "isAllHidden", {
553
+ get: function () {
554
+ var isHidden = true;
555
+ if (this.ref) {
556
+ var structHierarchy = this.plugin.managers.structure.hierarchy.current.refs.get(this.ref);
557
+ if (structHierarchy && structHierarchy.components) {
558
+ for (var _i = 0, _a = structHierarchy.components; _i < _a.length; _i++) {
559
+ var c = _a[_i];
560
+ if (c && c.cell && !c.cell.state.isHidden) {
561
+ isHidden = false;
562
+ break;
563
+ }
564
+ }
565
+ }
566
+ else {
567
+ isHidden = false;
568
+ }
569
+ }
570
+ return isHidden;
571
+ },
572
+ enumerable: false,
573
+ configurable: true
574
+ });
575
+ StructureNode.prototype.checkRelation = function (ref) {
576
+ var isRelated = false;
577
+ var cell = this.plugin.state.data.cells.get(ref);
578
+ if (cell && cell.transform.parent) {
579
+ if (cell && cell.transform.parent === this.ref) {
580
+ isRelated = true;
581
+ }
582
+ else {
583
+ var pcell = this.plugin.state.data.cells.get(cell.transform.parent);
584
+ if (pcell && pcell.transform.parent === this.ref)
585
+ isRelated = true;
586
+ }
587
+ }
588
+ else {
589
+ var currentNodeCell = this.plugin.state.data.cells.get(this.ref);
590
+ if (currentNodeCell && currentNodeCell.transform.parent === cell.transform.parent) {
591
+ isRelated = true;
592
+ }
593
+ }
594
+ return isRelated;
595
+ };
596
+ StructureNode.prototype.is = function (e) {
597
+ if (!this.ref)
598
+ return false;
599
+ var isRelated = false;
600
+ if (this.ref && e.ref !== this.ref) {
601
+ isRelated = this.checkRelation(e.ref);
602
+ }
603
+ if (e.ref === this.ref || isRelated) {
604
+ return true;
605
+ }
606
+ else {
607
+ var invalidStruct = (this.customState.superpositionState.invalidStruct.indexOf("".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id)) > -1) ? true : false;
608
+ return invalidStruct ? true : false;
609
+ }
610
+ };
611
+ StructureNode.prototype.componentDidMount = function () {
612
+ var _this = this;
613
+ this.setState({ isHidden: this.isAllHidden });
614
+ this.subscribe(this.plugin.customState.events.isBusy, function (e) {
615
+ _this.setState({ isBusy: e, showControls: false });
616
+ });
617
+ this.subscribe(this.plugin.state.events.cell.stateUpdated.pipe((0, operators_1.filter)(function (e) { return _this.is(e); }), (0, operators_1.debounceTime)(33)), function (e) {
618
+ _this.setState({ isHidden: _this.isAllHidden });
619
+ // this.forceUpdate();
620
+ });
621
+ };
622
+ StructureNode.prototype.getTagRefs = function (tags) {
623
+ var TagSet = new Set(tags);
624
+ var tree = this.plugin.state.data.tree;
625
+ return mol_state_2.StateSelection.findUniqueTagsInSubtree(tree, this.modelCell.transform.ref, TagSet);
626
+ };
627
+ StructureNode.prototype.getRandomColor = function () {
628
+ var clList = lists_1.ColorLists;
629
+ var spState = this.plugin.customState.superpositionState;
630
+ var palleteIndex = spState.colorState[this.props.segmentIndex].palleteIndex;
631
+ var colorIndex = spState.colorState[this.props.segmentIndex].colorIndex;
632
+ if (clList[spState.colorPalette[palleteIndex]].list[colorIndex + 1]) {
633
+ colorIndex += 1;
634
+ }
635
+ else {
636
+ colorIndex = 0;
637
+ palleteIndex = spState.colorPalette[palleteIndex + 1] ? palleteIndex + 1 : 0;
638
+ }
639
+ var palleteName = spState.colorPalette[palleteIndex];
640
+ this.plugin.customState.superpositionState.colorState[this.props.segmentIndex].palleteIndex = palleteIndex;
641
+ this.plugin.customState.superpositionState.colorState[this.props.segmentIndex].colorIndex = colorIndex;
642
+ return clList[palleteName].list[colorIndex];
643
+ };
644
+ StructureNode.prototype.addChainRepr = function () {
645
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
646
+ var uniformColor1, strInstance, query, chainSel;
647
+ return tslib_1.__generator(this, function (_a) {
648
+ switch (_a.label) {
649
+ case 0:
650
+ uniformColor1 = this.getRandomColor();
651
+ strInstance = this.plugin.state.data.select(this.ref)[0];
652
+ query = builder_1.MolScriptBuilder.struct.generator.atomGroups({
653
+ 'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.label_asym_id(), this.props.structure.struct_asym_id])
654
+ });
655
+ return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentFromExpression(strInstance, query, "Chain-".concat(this.props.segmentIndex), { label: "Chain", tags: ["superposition-sel"] })];
656
+ case 1:
657
+ chainSel = _a.sent();
658
+ if (!chainSel) return [3 /*break*/, 3];
659
+ return [4 /*yield*/, this.plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'cartoon', color: 'uniform', colorParams: { value: uniformColor1 } }, { tag: "superposition-visual" })];
660
+ case 2:
661
+ _a.sent();
662
+ _a.label = 3;
663
+ case 3: return [2 /*return*/];
664
+ }
665
+ });
666
+ });
667
+ };
668
+ StructureNode.prototype.updates = function () {
669
+ var _this = this;
670
+ var structHierarchy = this.plugin.managers.structure.hierarchy.current.refs.get(this.ref);
671
+ if (structHierarchy && structHierarchy.components) {
672
+ var representations_1 = [];
673
+ var showAddChainBtn_1 = true;
674
+ structHierarchy.components.forEach(function (comps) {
675
+ var gKeys = comps.key.split(',');
676
+ var cId1Arr = gKeys[0].split('-');
677
+ if (cId1Arr[2] === 'Chain')
678
+ showAddChainBtn_1 = false;
679
+ if (comps.representations) {
680
+ comps.representations.forEach(function (repr) {
681
+ representations_1.push(repr);
682
+ });
683
+ }
684
+ });
685
+ var customState = this.plugin.customState;
686
+ if (customState.initParams && customState.initParams.superpositionParams && !customState.initParams.superpositionParams.ligandView) {
687
+ showAddChainBtn_1 = false;
688
+ }
689
+ if (representations_1.length > 0) {
690
+ return (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-accent-offset', style: { marginLeft: '40px' } }, { children: [representations_1.length > 0 && representations_1.map(function (r, i) { return (0, jsx_runtime_1.jsx)(StructureRepresentationEntry, { group: [structHierarchy], representation: r }, "".concat(r.cell.transform.ref, "-").concat(i)); }), showAddChainBtn_1 && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: 'msp-control-group-header', style: { marginTop: '1px' } }, { children: (0, jsx_runtime_1.jsxs)(common_1.Button, tslib_1.__assign({ noOverflow: true, className: 'msp-control-button-label', title: "Click to add chain representaion", onClick: function () { return _this.addChainRepr(); } }, { children: ["\u00A0\u00A0Add Chain ", this.props.structure.struct_asym_id, " Representation"] })) }))] }));
691
+ }
692
+ }
693
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
694
+ };
695
+ StructureNode.prototype.getSubtitle = function () {
696
+ var customState = this.plugin.customState;
697
+ var hetList = customState.superpositionState.hets["".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id)];
698
+ var subtitle;
699
+ if (hetList) {
700
+ var hetLimit = this.props.structure.is_representative ? 1 : 4;
701
+ var totalHets = hetList.length;
702
+ var hetStr = hetList.join(', ');
703
+ if (totalHets > hetLimit) {
704
+ hetStr = hetList.slice(0, hetLimit).join(', ');
705
+ hetStr += " + ".concat(totalHets - hetLimit);
706
+ }
707
+ subtitle = " ( ".concat(hetStr, " )");
708
+ if (this.props.structure.is_representative)
709
+ subtitle = " ".concat(subtitle, " ( Representative )");
710
+ }
711
+ else if (this.props.structure.is_representative) {
712
+ subtitle = ' ( Representative )';
713
+ }
714
+ return subtitle;
715
+ };
716
+ Object.defineProperty(StructureNode.prototype, "panelColor", {
717
+ get: function () {
718
+ var panelColor = '#808080';
719
+ if (!this.state.isHidden) {
720
+ if (this.modelCell) {
721
+ var refs = this.getTagRefs(["superposition-visual", "superposition-ligand-visual"]);
722
+ var visualRef = refs["superposition-ligand-visual"] ? refs["superposition-ligand-visual"] : refs["superposition-visual"] ? refs["superposition-visual"] : undefined;
723
+ if (visualRef) {
724
+ var visualCell = this.plugin.state.data.cells.get(visualRef);
725
+ if (visualCell.params && visualCell.params.values && visualCell.params.values.colorTheme) {
726
+ var colorTheme = visualCell.params.values.colorTheme;
727
+ if (colorTheme.params && colorTheme.params.value) {
728
+ panelColor = "".concat(color_1.Color.toStyle(colorTheme.params.value));
729
+ }
730
+ else if (colorTheme.params && colorTheme.params.palette) {
731
+ var colorList1 = colorTheme.params.palette.params.list.colors;
732
+ panelColor = "".concat(color_1.Color.toStyle(colorList1[0]));
733
+ }
734
+ else if (colorTheme.params && colorTheme.params.list) {
735
+ var colorList2 = colorTheme.params.list.colors;
736
+ panelColor = "".concat(color_1.Color.toStyle(colorList2[0]));
737
+ }
738
+ }
739
+ }
740
+ }
741
+ }
742
+ return panelColor;
743
+ },
744
+ enumerable: false,
745
+ configurable: true
746
+ });
747
+ StructureNode.prototype.render = function () {
748
+ var superpositionParams = this.customState.initParams.superpositionParams;
749
+ var strutStateId = "".concat(this.props.structure.pdb_id, "_").concat(this.props.structure.struct_asym_id);
750
+ var invalidStruct = (this.customState.superpositionState.invalidStruct.indexOf(strutStateId) > -1) ? true : false;
751
+ var noMatrixStruct = (this.customState.superpositionState.noMatrixStruct.indexOf(strutStateId) > -1) ? true : false;
752
+ var subTitle = invalidStruct ? noMatrixStruct ? " Matrix not available!" : " No Ligand found!" : this.getSubtitle();
753
+ var strTitle = "".concat(this.props.structure.pdb_id, " chain ").concat(this.props.structure.auth_asym_id);
754
+ if (superpositionParams && superpositionParams.ligandView) {
755
+ strTitle = "".concat(this.props.structure.pdb_id, " ").concat(this.props.structure.struct_asym_id);
756
+ }
757
+ var label = (0, jsx_runtime_1.jsxs)(common_1.Button, tslib_1.__assign({ className: "msp-btn-tree-label", style: { borderLeftColor: this.panelColor }, noOverflow: true, title: strTitle, disabled: (invalidStruct || this.state.isBusy || this.state.isProcessing) ? true : false, onMouseEnter: this.highlight, onMouseLeave: this.clearHighlight }, { children: [(0, jsx_runtime_1.jsx)("span", { children: strTitle }), subTitle && (0, jsx_runtime_1.jsx)("small", { children: subTitle })] }));
758
+ var expand = (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: !this.state.showControls ? icons_1.ArrowRightSvg : icons_1.ArrowDropDownSvg, flex: '20px', onClick: this.toggleControls, transparent: true, className: 'msp-no-hover-outline', disabled: (invalidStruct || this.state.isBusy || this.state.isProcessing) ? true : false });
759
+ var visibility = (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: this.state.isHidden ? icons_1.VisibilityOffOutlinedSvg : icons_1.VisibilityOutlinedSvg, toggleState: false, small: true, onClick: this.toggleVisible, disabled: (invalidStruct || this.state.isBusy || this.state.isProcessing) ? true : false, title: this.state.isHidden ? "Show chain" : "Hide chain" });
760
+ var row = (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "msp-flex-row msp-tree-row", style: { marginLeft: !this.state.isHidden ? '10px' : '31px' } }, { children: [!this.state.isHidden && expand, label, visibility] }));
761
+ return (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ style: { marginBottom: '1px' } }, { children: [row, this.state.showControls && this.updates()] }));
762
+ };
763
+ return StructureNode;
764
+ }(base_1.PluginUIComponent));
765
+ var StructureRepresentationEntry = /** @class */ (function (_super) {
766
+ tslib_1.__extends(StructureRepresentationEntry, _super);
767
+ function StructureRepresentationEntry() {
768
+ var _this = _super !== null && _super.apply(this, arguments) || this;
769
+ _this.toggleVisible = function (e) {
770
+ e.preventDefault();
771
+ e.currentTarget.blur();
772
+ var cell = _this.props.representation.cell;
773
+ commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: cell.parent, ref: cell.transform.parent });
774
+ };
775
+ return _this;
776
+ }
777
+ StructureRepresentationEntry.prototype.componentDidMount = function () {
778
+ var _this = this;
779
+ this.subscribe(this.plugin.state.events.cell.stateUpdated, function (e) {
780
+ if (mol_state_1.State.ObjectEvent.isCell(e, _this.props.representation.cell))
781
+ _this.forceUpdate();
782
+ });
783
+ };
784
+ StructureRepresentationEntry.prototype.render = function () {
785
+ var _a, _b, _c, _d, _e, _f, _g;
786
+ var repr = this.props.representation.cell;
787
+ var label = (_a = repr.obj) === null || _a === void 0 ? void 0 : _a.label;
788
+ if (((_b = repr.obj) === null || _b === void 0 ? void 0 : _b.data.repr) && ((_c = repr.obj) === null || _c === void 0 ? void 0 : _c.data.repr.label)) {
789
+ var sourceLabel = (((_d = repr.obj) === null || _d === void 0 ? void 0 : _d.data.repr.label.indexOf('[Focus]')) >= 0) ? '[Focus]' : (_e = repr.obj) === null || _e === void 0 ? void 0 : _e.data.repr.label;
790
+ var isLargeLabel = sourceLabel.length > 10 ? true : false;
791
+ sourceLabel = "".concat(isLargeLabel ? "".concat(sourceLabel.substring(0, 28), "...") : sourceLabel);
792
+ if (isLargeLabel) {
793
+ label = sourceLabel;
794
+ }
795
+ else {
796
+ label = "".concat(sourceLabel, " ").concat((label && label.length < 21) ? ' - ' + label : '');
797
+ }
798
+ }
799
+ if (((_f = repr.obj) === null || _f === void 0 ? void 0 : _f.data.repr) && ((_g = repr.obj) === null || _g === void 0 ? void 0 : _g.data.repr.label) === 'Custom Selection')
800
+ label = 'Custom Selection';
801
+ return (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: 'msp-representation-entry' }, { children: [repr.parent && (0, jsx_runtime_1.jsx)(common_1.ExpandGroup, tslib_1.__assign({ header: "".concat(label || 'Representation'), noOffset: true, headerStyle: { overflow: 'hidden' } }, { children: (0, jsx_runtime_1.jsx)(update_transform_1.UpdateTransformControl, { state: repr.parent, transform: repr.transform, customHeader: 'none', noMargin: true }) })), (0, jsx_runtime_1.jsx)(common_1.IconButton, { svg: this.props.representation.cell.state.isHidden ? icons_1.VisibilityOffOutlinedSvg : icons_1.VisibilityOutlinedSvg, toggleState: false, onClick: this.toggleVisible, title: this.props.representation.cell.state.isHidden ? "Show representation" : "Hide representation", small: true, className: 'msp-default-bg', style: { position: 'absolute', top: 0, right: 0, lineHeight: '24px', height: '24px', textAlign: 'right', width: '32px', paddingRight: '6px', background: 'none' } })] }));
802
+ };
803
+ return StructureRepresentationEntry;
804
+ }(base_1.PurePluginUIComponent));