drugflow-molstar 0.4.7 → 0.4.8

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