pdbe-molstar 3.2.1-beta.1 → 3.2.1-beta.3
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.
- package/README.md +1 -1
- package/build/pdbe-molstar-component.js +2 -2
- package/build/pdbe-molstar-light.css +2 -2
- package/build/pdbe-molstar-plugin.js +2 -2
- package/build/pdbe-molstar-plugin.js.LICENSE.txt +1 -1
- package/build/pdbe-molstar.css +2 -2
- package/lib/alphafold-transparency.d.ts +3 -3
- package/lib/alphafold-transparency.js +10 -11
- package/lib/custom-events.d.ts +1 -1
- package/lib/custom-events.js +1 -1
- package/lib/domain-annotations/behavior.d.ts +1 -1
- package/lib/domain-annotations/behavior.js +3 -3
- package/lib/domain-annotations/color.d.ts +3 -3
- package/lib/domain-annotations/color.js +4 -4
- package/lib/domain-annotations/prop.d.ts +6 -6
- package/lib/domain-annotations/prop.js +7 -7
- package/lib/extensions/foldseek.d.ts +1 -1
- package/lib/extensions/foldseek.js +2 -2
- package/lib/helpers.d.ts +20 -13
- package/lib/helpers.js +49 -11
- package/lib/index(light).d.ts +4 -179
- package/lib/index(light).js +6 -1234
- package/lib/index.d.ts +4 -179
- package/lib/index.js +6 -1234
- package/lib/labels.d.ts +1 -1
- package/lib/labels.js +3 -3
- package/lib/loci-details.d.ts +2 -2
- package/lib/loci-details.js +3 -3
- package/lib/plugin-custom-state.d.ts +6 -9
- package/lib/sifts-mapping.d.ts +3 -3
- package/lib/sifts-mapping.js +4 -4
- package/lib/sifts-mappings-behaviour.d.ts +1 -1
- package/lib/sifts-mappings-behaviour.js +10 -10
- package/lib/spec.d.ts +36 -11
- package/lib/spec.js +38 -7
- package/lib/{overlay.scss → styles/index.scss} +11 -0
- package/lib/superposition-export.d.ts +1 -1
- package/lib/superposition-export.js +7 -7
- package/lib/superposition-focus-representation.d.ts +3 -3
- package/lib/superposition-focus-representation.js +8 -8
- package/lib/superposition-sifts-mapping.d.ts +5 -5
- package/lib/superposition-sifts-mapping.js +3 -3
- package/lib/superposition.d.ts +7 -4
- package/lib/superposition.js +147 -184
- package/lib/ui/alphafold-superposition.d.ts +4 -4
- package/lib/ui/alphafold-superposition.js +8 -8
- package/lib/ui/alphafold-tranparency.d.ts +2 -2
- package/lib/ui/alphafold-tranparency.js +4 -4
- package/lib/ui/annotation-controls.d.ts +1 -1
- package/lib/ui/annotation-controls.js +7 -7
- package/lib/ui/annotation-row-controls.d.ts +2 -2
- package/lib/ui/annotation-row-controls.js +3 -3
- package/lib/ui/export-superposition.d.ts +1 -1
- package/lib/ui/export-superposition.js +9 -9
- package/lib/ui/pdbe-left-panel.d.ts +8 -8
- package/lib/ui/pdbe-left-panel.js +26 -47
- package/lib/ui/pdbe-screenshot-controls.d.ts +2 -2
- package/lib/ui/pdbe-screenshot-controls.js +7 -7
- package/lib/ui/pdbe-structure-controls.d.ts +1 -1
- package/lib/ui/pdbe-structure-controls.js +8 -8
- package/lib/ui/pdbe-viewport-controls.d.ts +1 -1
- package/lib/ui/pdbe-viewport-controls.js +4 -2
- package/lib/ui/segment-tree.d.ts +4 -4
- package/lib/ui/segment-tree.js +12 -32
- package/lib/ui/superposition-components.d.ts +1 -1
- package/lib/ui/superposition-components.js +8 -8
- package/lib/ui/superposition-viewport.d.ts +1 -1
- package/lib/ui/superposition-viewport.js +5 -5
- package/lib/ui/symmetry-annotation-controls.d.ts +6 -6
- package/lib/ui/symmetry-annotation-controls.js +6 -6
- package/lib/viewer.d.ts +178 -0
- package/lib/viewer.js +1286 -0
- package/package.json +4 -4
package/lib/index(light).js
CHANGED
|
@@ -1,1237 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/** Entrypoint for the bundler. If you want to import PDBeMolstarPlugin without CSS, import from ./viewer instead. */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PDBeMolstarPlugin = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var pdbe_1 = require("Molstar/extensions/pdbe");
|
|
11
|
-
var behavior_3 = require("Molstar/extensions/rcsb/assembly-symmetry/behavior");
|
|
12
|
-
var loci_1 = require("Molstar/mol-model/loci");
|
|
13
|
-
var structure_1 = require("Molstar/mol-model/structure");
|
|
14
|
-
var assembly_unwind_1 = require("Molstar/mol-plugin-state/animation/built-in/assembly-unwind");
|
|
15
|
-
var camera_rock_1 = require("Molstar/mol-plugin-state/animation/built-in/camera-rock");
|
|
16
|
-
var camera_spin_1 = require("Molstar/mol-plugin-state/animation/built-in/camera-spin");
|
|
17
|
-
var model_index_1 = require("Molstar/mol-plugin-state/animation/built-in/model-index");
|
|
18
|
-
var spin_structure_1 = require("Molstar/mol-plugin-state/animation/built-in/spin-structure");
|
|
19
|
-
var state_interpolation_1 = require("Molstar/mol-plugin-state/animation/built-in/state-interpolation");
|
|
20
|
-
var state_snapshots_1 = require("Molstar/mol-plugin-state/animation/built-in/state-snapshots");
|
|
21
|
-
var structure_overpaint_1 = require("Molstar/mol-plugin-state/helpers/structure-overpaint");
|
|
22
|
-
var structure_representation_params_1 = require("Molstar/mol-plugin-state/helpers/structure-representation-params");
|
|
23
|
-
var objects_1 = require("Molstar/mol-plugin-state/objects");
|
|
24
|
-
var transforms_1 = require("Molstar/mol-plugin-state/transforms");
|
|
25
|
-
var model_1 = require("Molstar/mol-plugin-state/transforms/model");
|
|
26
|
-
var representation_1 = require("Molstar/mol-plugin-state/transforms/representation");
|
|
27
|
-
var react18_1 = require("Molstar/mol-plugin-ui/react18");
|
|
28
|
-
var camera_1 = require("Molstar/mol-plugin/behavior/dynamic/camera");
|
|
29
|
-
var representation_2 = require("Molstar/mol-plugin/behavior/dynamic/representation");
|
|
30
|
-
var structure_focus_representation_1 = require("Molstar/mol-plugin/behavior/dynamic/selection/structure-focus-representation");
|
|
31
|
-
var transformers_1 = require("Molstar/mol-plugin/behavior/dynamic/volume-streaming/transformers");
|
|
32
|
-
var commands_1 = require("Molstar/mol-plugin/commands");
|
|
33
|
-
var config_1 = require("Molstar/mol-plugin/config");
|
|
34
|
-
var layout_1 = require("Molstar/mol-plugin/layout");
|
|
35
|
-
var spec_1 = require("Molstar/mol-plugin/spec");
|
|
36
|
-
var mol_state_1 = require("Molstar/mol-state");
|
|
37
|
-
var element_symbol_1 = require("Molstar/mol-theme/color/element-symbol");
|
|
38
|
-
var assets_1 = require("Molstar/mol-util/assets");
|
|
39
|
-
var color_1 = require("Molstar/mol-util/color/color");
|
|
40
|
-
var names_1 = require("Molstar/mol-util/color/names");
|
|
41
|
-
var rx_event_helper_1 = require("Molstar/mol-util/rx-event-helper");
|
|
42
|
-
var custom_events_1 = require("./custom-events");
|
|
43
|
-
var behavior_4 = require("./domain-annotations/behavior");
|
|
44
|
-
var Foldseek = tslib_1.__importStar(require("./extensions/foldseek"));
|
|
45
|
-
var helpers_1 = require("./helpers");
|
|
46
|
-
var overlay_1 = require("./overlay");
|
|
47
|
-
var plugin_custom_state_1 = require("./plugin-custom-state");
|
|
48
|
-
var spec_2 = require("./spec");
|
|
49
|
-
var spec_from_html_1 = require("./spec-from-html");
|
|
50
|
-
var subscribe_events_1 = require("./subscribe-events");
|
|
51
|
-
var superposition_1 = require("./superposition");
|
|
52
|
-
var superposition_focus_representation_1 = require("./superposition-focus-representation");
|
|
53
|
-
var pdbe_left_panel_1 = require("./ui/pdbe-left-panel");
|
|
54
|
-
var pdbe_structure_controls_1 = require("./ui/pdbe-structure-controls");
|
|
55
|
-
var pdbe_viewport_controls_1 = require("./ui/pdbe-viewport-controls");
|
|
56
|
-
var superposition_viewport_1 = require("./ui/superposition-viewport");
|
|
57
|
-
require("Molstar/mol-plugin-ui/skin/light.scss");
|
|
58
|
-
require("./overlay.scss");
|
|
59
|
-
var PDBeMolstarPlugin = /** @class */ (function () {
|
|
60
|
-
function PDBeMolstarPlugin() {
|
|
61
|
-
var _this = this;
|
|
62
|
-
this._ev = rx_event_helper_1.RxEventHelper.create();
|
|
63
|
-
this.events = {
|
|
64
|
-
loadComplete: this._ev()
|
|
65
|
-
};
|
|
66
|
-
this.assemblyRef = '';
|
|
67
|
-
this.isHighlightColorUpdated = false;
|
|
68
|
-
this.isSelectedColorUpdated = false;
|
|
69
|
-
/** Keeps track of representations added by `.visual.select` for each structure. */
|
|
70
|
-
this.addedReprs = {};
|
|
71
|
-
/** Maps structure IDs (assigned when loading) to cell refs. */
|
|
72
|
-
this.structureRefMap = new Map();
|
|
73
|
-
this.applyVisualParams = function () {
|
|
74
|
-
var _a;
|
|
75
|
-
var componentGroups = _this.plugin.managers.structure.hierarchy.currentComponentGroups;
|
|
76
|
-
var _loop_1 = function (compGroup) {
|
|
77
|
-
var compRef = compGroup[compGroup.length - 1];
|
|
78
|
-
var tag = (_a = compRef.key) !== null && _a !== void 0 ? _a : '';
|
|
79
|
-
var remove = _this.initParams.hideStructure.some(function (type) { var _a; return (_a = helpers_1.StructureComponentTags[type]) === null || _a === void 0 ? void 0 : _a.includes(tag); });
|
|
80
|
-
if (remove) {
|
|
81
|
-
_this.plugin.managers.structure.hierarchy.remove([compRef]);
|
|
82
|
-
}
|
|
83
|
-
if (!remove && _this.initParams.visualStyle) {
|
|
84
|
-
if (compRef && compRef.representations) {
|
|
85
|
-
compRef.representations.forEach(function (rep) {
|
|
86
|
-
var currentParams = (0, structure_representation_params_1.createStructureRepresentationParams)(_this.plugin, void 0, { type: _this.initParams.visualStyle });
|
|
87
|
-
_this.plugin.managers.structure.component.updateRepresentations([compRef], rep, currentParams);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
for (var _i = 0, componentGroups_1 = componentGroups; _i < componentGroups_1.length; _i++) {
|
|
93
|
-
var compGroup = componentGroups_1[_i];
|
|
94
|
-
_loop_1(compGroup);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
/** Helper methods related to canvas and layout */
|
|
98
|
-
this.canvas = {
|
|
99
|
-
/** Set canvas background color. */
|
|
100
|
-
setBgColor: function (color) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
101
|
-
return tslib_1.__generator(this, function (_a) {
|
|
102
|
-
switch (_a.label) {
|
|
103
|
-
case 0:
|
|
104
|
-
if (!color)
|
|
105
|
-
return [2 /*return*/];
|
|
106
|
-
return [4 /*yield*/, this.canvas.applySettings({ color: color })];
|
|
107
|
-
case 1:
|
|
108
|
-
_a.sent();
|
|
109
|
-
return [2 /*return*/];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}); },
|
|
113
|
-
/** Set controls panel visibility. Without `isVisible` parameter, toggle controls panel visibility. */
|
|
114
|
-
toggleControls: function (isVisible) {
|
|
115
|
-
if (typeof isVisible === 'undefined')
|
|
116
|
-
isVisible = !_this.plugin.layout.state.showControls;
|
|
117
|
-
commands_1.PluginCommands.Layout.Update(_this.plugin, { state: { showControls: isVisible } });
|
|
118
|
-
},
|
|
119
|
-
/** Set full-screen mode on or off. Without `isExpanded` parameter, toggle full-screen mode. */
|
|
120
|
-
toggleExpanded: function (isExpanded) {
|
|
121
|
-
if (typeof isExpanded === 'undefined')
|
|
122
|
-
isExpanded = !_this.plugin.layout.state.isExpanded;
|
|
123
|
-
commands_1.PluginCommands.Layout.Update(_this.plugin, { state: { isExpanded: isExpanded } });
|
|
124
|
-
},
|
|
125
|
-
applySettings: function (settings) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
126
|
-
var renderer;
|
|
127
|
-
return tslib_1.__generator(this, function (_a) {
|
|
128
|
-
switch (_a.label) {
|
|
129
|
-
case 0:
|
|
130
|
-
if (!settings)
|
|
131
|
-
return [2 /*return*/];
|
|
132
|
-
if (!this.plugin.canvas3d)
|
|
133
|
-
return [2 /*return*/];
|
|
134
|
-
renderer = tslib_1.__assign({}, this.plugin.canvas3d.props.renderer);
|
|
135
|
-
if (settings.color) {
|
|
136
|
-
renderer.backgroundColor = color_1.Color.fromRgb(settings.color.r, settings.color.g, settings.color.b);
|
|
137
|
-
}
|
|
138
|
-
if (settings.lighting) {
|
|
139
|
-
renderer.style = { name: settings.lighting }; // I don't think this does anything and I don't see how it could ever have worked
|
|
140
|
-
}
|
|
141
|
-
return [4 /*yield*/, commands_1.PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { renderer: renderer } })];
|
|
142
|
-
case 1:
|
|
143
|
-
_a.sent();
|
|
144
|
-
return [2 /*return*/];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}); },
|
|
148
|
-
};
|
|
149
|
-
/** Helper methods related to 3D visuals */
|
|
150
|
-
this.visual = {
|
|
151
|
-
/** Change the visibility of individual entity visuals */
|
|
152
|
-
visibility: function (data) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
153
|
-
var _a, _b, _c, _i, visual, requiredVisibility, tags, _d, tags_1, tag, componentRef, compVisual, currentlyVisible;
|
|
154
|
-
var _e;
|
|
155
|
-
return tslib_1.__generator(this, function (_f) {
|
|
156
|
-
switch (_f.label) {
|
|
157
|
-
case 0:
|
|
158
|
-
if (!data)
|
|
159
|
-
return [2 /*return*/];
|
|
160
|
-
_a = data;
|
|
161
|
-
_b = [];
|
|
162
|
-
for (_c in _a)
|
|
163
|
-
_b.push(_c);
|
|
164
|
-
_i = 0;
|
|
165
|
-
_f.label = 1;
|
|
166
|
-
case 1:
|
|
167
|
-
if (!(_i < _b.length)) return [3 /*break*/, 6];
|
|
168
|
-
_c = _b[_i];
|
|
169
|
-
if (!(_c in _a)) return [3 /*break*/, 5];
|
|
170
|
-
visual = _c;
|
|
171
|
-
requiredVisibility = data[visual];
|
|
172
|
-
if (requiredVisibility === undefined)
|
|
173
|
-
return [3 /*break*/, 5];
|
|
174
|
-
tags = (_e = helpers_1.StructureComponentTags[visual]) !== null && _e !== void 0 ? _e : [];
|
|
175
|
-
_d = 0, tags_1 = tags;
|
|
176
|
-
_f.label = 2;
|
|
177
|
-
case 2:
|
|
178
|
-
if (!(_d < tags_1.length)) return [3 /*break*/, 5];
|
|
179
|
-
tag = tags_1[_d];
|
|
180
|
-
componentRef = mol_state_1.StateSelection.findTagInSubtree(this.plugin.state.data.tree, mol_state_1.StateTransform.RootRef, tag);
|
|
181
|
-
if (!componentRef) return [3 /*break*/, 4];
|
|
182
|
-
compVisual = this.plugin.state.data.select(componentRef)[0];
|
|
183
|
-
if (!(compVisual && compVisual.obj)) return [3 /*break*/, 4];
|
|
184
|
-
currentlyVisible = !(compVisual.state && compVisual.state.isHidden);
|
|
185
|
-
if (!(currentlyVisible !== requiredVisibility)) return [3 /*break*/, 4];
|
|
186
|
-
return [4 /*yield*/, commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: this.state, ref: componentRef })];
|
|
187
|
-
case 3:
|
|
188
|
-
_f.sent();
|
|
189
|
-
_f.label = 4;
|
|
190
|
-
case 4:
|
|
191
|
-
_d++;
|
|
192
|
-
return [3 /*break*/, 2];
|
|
193
|
-
case 5:
|
|
194
|
-
_i++;
|
|
195
|
-
return [3 /*break*/, 1];
|
|
196
|
-
case 6: return [2 /*return*/];
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}); },
|
|
200
|
-
/** Change the visibility of a structure.
|
|
201
|
-
* `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure.
|
|
202
|
-
* If `visibility` is undefined, toggle current visibility state. */
|
|
203
|
-
structureVisibility: function (structureNumberOrId, visibility) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
204
|
-
var struct, currentVisibility;
|
|
205
|
-
return tslib_1.__generator(this, function (_a) {
|
|
206
|
-
switch (_a.label) {
|
|
207
|
-
case 0:
|
|
208
|
-
struct = this.getStructure(structureNumberOrId);
|
|
209
|
-
if (!struct) {
|
|
210
|
-
console.error("Cannot change visibility of structure ".concat(structureNumberOrId, ": structure not found."));
|
|
211
|
-
return [2 /*return*/];
|
|
212
|
-
}
|
|
213
|
-
currentVisibility = !struct.cell.state.isHidden;
|
|
214
|
-
if (!(visibility !== currentVisibility)) return [3 /*break*/, 2];
|
|
215
|
-
return [4 /*yield*/, commands_1.PluginCommands.State.ToggleVisibility(this.plugin, { state: this.state, ref: struct.cell.transform.ref })];
|
|
216
|
-
case 1:
|
|
217
|
-
_a.sent();
|
|
218
|
-
_a.label = 2;
|
|
219
|
-
case 2: return [2 /*return*/];
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}); },
|
|
223
|
-
/** With `isSpinning` parameter, switch visual rotation on or off. Without `isSpinning` parameter, toggle rotation. If `resetCamera`, also reset the camera zoom. */
|
|
224
|
-
toggleSpin: function (isSpinning, resetCamera) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
225
|
-
var trackball, toggleSpinParam;
|
|
226
|
-
return tslib_1.__generator(this, function (_a) {
|
|
227
|
-
switch (_a.label) {
|
|
228
|
-
case 0:
|
|
229
|
-
if (!this.plugin.canvas3d)
|
|
230
|
-
return [2 /*return*/];
|
|
231
|
-
trackball = this.plugin.canvas3d.props.trackball;
|
|
232
|
-
toggleSpinParam = trackball.animate.name === 'spin' ? { name: 'off', params: {} } : { name: 'spin', params: { speed: 1 } };
|
|
233
|
-
if (typeof isSpinning !== 'undefined') {
|
|
234
|
-
toggleSpinParam = { name: 'off', params: {} };
|
|
235
|
-
if (isSpinning)
|
|
236
|
-
toggleSpinParam = { name: 'spin', params: { speed: 1 } };
|
|
237
|
-
}
|
|
238
|
-
return [4 /*yield*/, commands_1.PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { trackball: tslib_1.__assign(tslib_1.__assign({}, trackball), { animate: toggleSpinParam }) } })];
|
|
239
|
-
case 1:
|
|
240
|
-
_a.sent();
|
|
241
|
-
if (!resetCamera) return [3 /*break*/, 3];
|
|
242
|
-
return [4 /*yield*/, commands_1.PluginCommands.Camera.Reset(this.plugin, {})];
|
|
243
|
-
case 2:
|
|
244
|
-
_a.sent();
|
|
245
|
-
_a.label = 3;
|
|
246
|
-
case 3: return [2 /*return*/];
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
}); },
|
|
250
|
-
/** Focus (zoom) on the part of the structure defined by `selection`.
|
|
251
|
-
* If `selection` contains more items, focus on the union of those.
|
|
252
|
-
* If `structureNumber` is provided, use the specified structure (numbered from 1!); otherwise use the last added structure. */
|
|
253
|
-
focus: function (selection, structureNumber) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
254
|
-
var loci;
|
|
255
|
-
return tslib_1.__generator(this, function (_a) {
|
|
256
|
-
loci = this.getLociForParams(selection, structureNumber);
|
|
257
|
-
this.plugin.managers.camera.focusLoci(loci);
|
|
258
|
-
return [2 /*return*/];
|
|
259
|
-
});
|
|
260
|
-
}); },
|
|
261
|
-
/** Trigger highlight on the part of the structure defined by `data`
|
|
262
|
-
* (this will look the same as when the user hovers over a part of the structure).
|
|
263
|
-
* If `focus`, also zoom on the highlighted part.
|
|
264
|
-
* If `structureNumber` is provided, use the specified structure (numbered from 1!); otherwise use the last added structure. */
|
|
265
|
-
highlight: function (params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
266
|
-
var loci;
|
|
267
|
-
return tslib_1.__generator(this, function (_a) {
|
|
268
|
-
switch (_a.label) {
|
|
269
|
-
case 0:
|
|
270
|
-
loci = this.getLociForParams(params.data, params.structureNumber);
|
|
271
|
-
if (loci_1.Loci.isEmpty(loci))
|
|
272
|
-
return [2 /*return*/];
|
|
273
|
-
if (!params.color) return [3 /*break*/, 2];
|
|
274
|
-
return [4 /*yield*/, this.visual.setColor({ highlight: params.color })];
|
|
275
|
-
case 1:
|
|
276
|
-
_a.sent();
|
|
277
|
-
_a.label = 2;
|
|
278
|
-
case 2:
|
|
279
|
-
this.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: loci });
|
|
280
|
-
if (params.focus)
|
|
281
|
-
this.plugin.managers.camera.focusLoci(loci);
|
|
282
|
-
return [2 /*return*/];
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
}); },
|
|
286
|
-
/** Remove any current highlight and reset the highlight color to its default value. */
|
|
287
|
-
clearHighlight: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
288
|
-
return tslib_1.__generator(this, function (_a) {
|
|
289
|
-
switch (_a.label) {
|
|
290
|
-
case 0:
|
|
291
|
-
this.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: loci_1.EmptyLoci });
|
|
292
|
-
if (!this.isHighlightColorUpdated) return [3 /*break*/, 2];
|
|
293
|
-
return [4 /*yield*/, this.visual.reset({ highlightColor: true })];
|
|
294
|
-
case 1:
|
|
295
|
-
_a.sent();
|
|
296
|
-
_a.label = 2;
|
|
297
|
-
case 2: return [2 /*return*/];
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
}); },
|
|
301
|
-
/** Color the parts of the structure defined by `data`. Color the rest of the structure in `nonSelectedColor` if provided.
|
|
302
|
-
* If any items in `data` contain `focus`, zoom to the union of these items.
|
|
303
|
-
* If any items in `data` contain `sideChain` or `representation`, add extra representations to them (colored in `representationColor` if provided).
|
|
304
|
-
* If `structureNumber` is provided, apply to the specified structure (numbered from 1!); otherwise apply to all loaded structures.
|
|
305
|
-
* Remove any previously added coloring and extra representations, unless `keepColors` and/or `keepRepresentations` is set. */
|
|
306
|
-
select: function (params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
307
|
-
var structureNumberOrId, structures, addedReprParams, _i, _a, param, repr, DefaultSelectColor, focusLoci, _b, structures_1, struct, selections, _c, selections_1, selection, overpaintLayers, wholeStructBundle, _d, _e, _f, _g, repr, bundle, overpaintLayers_1;
|
|
308
|
-
var _this = this;
|
|
309
|
-
var _h, _j, _k, _l;
|
|
310
|
-
return tslib_1.__generator(this, function (_m) {
|
|
311
|
-
switch (_m.label) {
|
|
312
|
-
case 0:
|
|
313
|
-
structureNumberOrId = (_h = params.structureId) !== null && _h !== void 0 ? _h : params.structureNumber;
|
|
314
|
-
return [4 /*yield*/, this.visual.clearSelection(structureNumberOrId, { keepColors: params.keepColors, keepRepresentations: params.keepRepresentations })];
|
|
315
|
-
case 1:
|
|
316
|
-
_m.sent();
|
|
317
|
-
structures = this.getStructures(structureNumberOrId);
|
|
318
|
-
addedReprParams = {};
|
|
319
|
-
for (_i = 0, _a = params.data; _i < _a.length; _i++) {
|
|
320
|
-
param = _a[_i];
|
|
321
|
-
repr = (_j = param.representation) !== null && _j !== void 0 ? _j : (param.sideChain ? 'ball-and-stick' : undefined);
|
|
322
|
-
if (repr) {
|
|
323
|
-
((_k = addedReprParams[repr]) !== null && _k !== void 0 ? _k : (addedReprParams[repr] = [])).push(param);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
DefaultSelectColor = color_1.Color.fromRgb(255, 112, 3);
|
|
327
|
-
focusLoci = [];
|
|
328
|
-
_b = 0, structures_1 = structures;
|
|
329
|
-
_m.label = 2;
|
|
330
|
-
case 2:
|
|
331
|
-
if (!(_b < structures_1.length)) return [3 /*break*/, 8];
|
|
332
|
-
struct = structures_1[_b];
|
|
333
|
-
selections = this.getSelections(params.data, struct.number);
|
|
334
|
-
for (_c = 0, selections_1 = selections; _c < selections_1.length; _c++) {
|
|
335
|
-
selection = selections_1[_c];
|
|
336
|
-
if (selection.param.focus) {
|
|
337
|
-
focusLoci.push(selection.loci);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
overpaintLayers = selections
|
|
341
|
-
.filter(function (s) { return s.param.color !== null; })
|
|
342
|
-
.map(function (s) { return ({
|
|
343
|
-
bundle: s.bundle,
|
|
344
|
-
color: s.param.color ? _this.normalizeColor(s.param.color) : DefaultSelectColor,
|
|
345
|
-
clear: false,
|
|
346
|
-
}); });
|
|
347
|
-
if (params.nonSelectedColor) {
|
|
348
|
-
wholeStructBundle = this.getBundle([{}], struct.number);
|
|
349
|
-
if (wholeStructBundle) {
|
|
350
|
-
overpaintLayers.unshift({
|
|
351
|
-
bundle: wholeStructBundle,
|
|
352
|
-
color: this.normalizeColor(params.nonSelectedColor),
|
|
353
|
-
clear: false,
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
return [4 /*yield*/, (0, helpers_1.applyOverpaint)(this.plugin, struct.structureRef, overpaintLayers)];
|
|
358
|
-
case 3:
|
|
359
|
-
_m.sent();
|
|
360
|
-
_d = addedReprParams;
|
|
361
|
-
_e = [];
|
|
362
|
-
for (_f in _d)
|
|
363
|
-
_e.push(_f);
|
|
364
|
-
_g = 0;
|
|
365
|
-
_m.label = 4;
|
|
366
|
-
case 4:
|
|
367
|
-
if (!(_g < _e.length)) return [3 /*break*/, 7];
|
|
368
|
-
_f = _e[_g];
|
|
369
|
-
if (!(_f in _d)) return [3 /*break*/, 6];
|
|
370
|
-
repr = _f;
|
|
371
|
-
bundle = this.getBundle(addedReprParams[repr], struct.number);
|
|
372
|
-
if (!bundle)
|
|
373
|
-
return [3 /*break*/, 6];
|
|
374
|
-
overpaintLayers_1 = selections.filter(function (s) { return s.param.representationColor; }).map(function (s) { return ({
|
|
375
|
-
bundle: s.bundle,
|
|
376
|
-
color: _this.normalizeColor(s.param.representationColor),
|
|
377
|
-
clear: false,
|
|
378
|
-
}); });
|
|
379
|
-
return [4 /*yield*/, this.plugin.build()
|
|
380
|
-
.to(struct.structureRef.cell)
|
|
381
|
-
.apply(model_1.StructureComponent, { type: { name: 'bundle', params: bundle }, label: repr }, { tags: helpers_1.Tags.AddedComponent })
|
|
382
|
-
.apply(representation_1.StructureRepresentation3D, (0, structure_representation_params_1.createStructureRepresentationParams)(this.plugin, (_l = struct.structureRef.cell.obj) === null || _l === void 0 ? void 0 : _l.data, { type: repr }))
|
|
383
|
-
.apply(transforms_1.StateTransforms.Representation.OverpaintStructureRepresentation3DFromBundle, { layers: overpaintLayers_1 }, { tags: helpers_1.Tags.Overpaint })
|
|
384
|
-
.commit()];
|
|
385
|
-
case 5:
|
|
386
|
-
_m.sent();
|
|
387
|
-
// Track that reprs have been added (for later clearSelection)
|
|
388
|
-
this.addedReprs[struct.number] = true;
|
|
389
|
-
_m.label = 6;
|
|
390
|
-
case 6:
|
|
391
|
-
_g++;
|
|
392
|
-
return [3 /*break*/, 4];
|
|
393
|
-
case 7:
|
|
394
|
-
_b++;
|
|
395
|
-
return [3 /*break*/, 2];
|
|
396
|
-
case 8:
|
|
397
|
-
// Apply focus
|
|
398
|
-
if (focusLoci.length > 0) {
|
|
399
|
-
this.plugin.managers.camera.focusLoci(focusLoci);
|
|
400
|
-
}
|
|
401
|
-
return [2 /*return*/];
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
}); },
|
|
405
|
-
/** Remove any coloring and extra representations previously added by the `select` method.
|
|
406
|
-
* If `structureNumber` is provided, apply to the specified structure (numbered from 1!); otherwise apply to all loaded structures.
|
|
407
|
-
* If `keepColors`, current residue coloring is preserved. If `keepRepresentations`, current added representations are preserved. */
|
|
408
|
-
clearSelection: function (structureNumberOrId, options) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
409
|
-
var structures, _i, structures_2, struct, componentsToClear, componentsToDelete, update, _a, componentsToDelete_1, comp;
|
|
410
|
-
return tslib_1.__generator(this, function (_b) {
|
|
411
|
-
switch (_b.label) {
|
|
412
|
-
case 0:
|
|
413
|
-
structures = this.getStructures(structureNumberOrId);
|
|
414
|
-
_i = 0, structures_2 = structures;
|
|
415
|
-
_b.label = 1;
|
|
416
|
-
case 1:
|
|
417
|
-
if (!(_i < structures_2.length)) return [3 /*break*/, 6];
|
|
418
|
-
struct = structures_2[_i];
|
|
419
|
-
if (!!(options === null || options === void 0 ? void 0 : options.keepColors)) return [3 /*break*/, 3];
|
|
420
|
-
componentsToClear = struct.structureRef.components.filter(function (c) { var _a; return !((_a = c.cell.transform.tags) === null || _a === void 0 ? void 0 : _a.includes(helpers_1.Tags.AddedComponent)); });
|
|
421
|
-
return [4 /*yield*/, (0, structure_overpaint_1.clearStructureOverpaint)(this.plugin, componentsToClear)];
|
|
422
|
-
case 2:
|
|
423
|
-
_b.sent();
|
|
424
|
-
_b.label = 3;
|
|
425
|
-
case 3:
|
|
426
|
-
if (!!(options === null || options === void 0 ? void 0 : options.keepRepresentations)) return [3 /*break*/, 5];
|
|
427
|
-
if (!this.addedReprs[struct.number]) return [3 /*break*/, 5];
|
|
428
|
-
componentsToDelete = struct.structureRef.components.filter(function (comp) { var _a; return (_a = comp.cell.transform.tags) === null || _a === void 0 ? void 0 : _a.includes(helpers_1.Tags.AddedComponent); });
|
|
429
|
-
update = this.plugin.build();
|
|
430
|
-
for (_a = 0, componentsToDelete_1 = componentsToDelete; _a < componentsToDelete_1.length; _a++) {
|
|
431
|
-
comp = componentsToDelete_1[_a];
|
|
432
|
-
update.delete(comp.cell.transform.ref);
|
|
433
|
-
}
|
|
434
|
-
return [4 /*yield*/, update.commit()];
|
|
435
|
-
case 4:
|
|
436
|
-
_b.sent();
|
|
437
|
-
delete this.addedReprs[struct.number];
|
|
438
|
-
_b.label = 5;
|
|
439
|
-
case 5:
|
|
440
|
-
_i++;
|
|
441
|
-
return [3 /*break*/, 1];
|
|
442
|
-
case 6: return [2 /*return*/];
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
}); },
|
|
446
|
-
/** Add interactive tooltips to parts of the structure. The added tooltips will be shown on a separate line in the tooltip box.
|
|
447
|
-
* Repeated call to this function removes any previously added tooltips.
|
|
448
|
-
* `structureNumber` counts from 1; if not provided, tooltips will be applied to all loaded structures.
|
|
449
|
-
* Example: `await this.visual.tooltips({ data: [{ struct_asym_id: 'A', tooltip: 'Chain A' }, { struct_asym_id: 'B', tooltip: 'Chain B' }] });`. */
|
|
450
|
-
tooltips: function (params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
451
|
-
var structures, _loop_2, this_1, _i, structures_3, struct;
|
|
452
|
-
var _a;
|
|
453
|
-
return tslib_1.__generator(this, function (_b) {
|
|
454
|
-
switch (_b.label) {
|
|
455
|
-
case 0:
|
|
456
|
-
structures = this.getStructures((_a = params.structureId) !== null && _a !== void 0 ? _a : params.structureNumber);
|
|
457
|
-
_loop_2 = function (struct) {
|
|
458
|
-
var selections, customTooltipProps, structRef, customPropsCells;
|
|
459
|
-
return tslib_1.__generator(this, function (_c) {
|
|
460
|
-
switch (_c.label) {
|
|
461
|
-
case 0:
|
|
462
|
-
selections = this_1.getSelections(params.data, struct.number);
|
|
463
|
-
customTooltipProps = {
|
|
464
|
-
tooltips: selections.map(function (s) { var _a; return ({ text: (_a = s.param.tooltip) !== null && _a !== void 0 ? _a : '', selector: { name: 'bundle', params: s.bundle } }); }),
|
|
465
|
-
};
|
|
466
|
-
structRef = struct.structureRef.cell.transform.ref;
|
|
467
|
-
customPropsCells = this_1.plugin.state.data.select(mol_state_1.StateSelection.Generators.ofTransformer(model_1.CustomStructureProperties, structRef));
|
|
468
|
-
if (!(customPropsCells.length === 0)) return [3 /*break*/, 2];
|
|
469
|
-
return [4 /*yield*/, this_1.plugin.build().to(structRef).apply(model_1.CustomStructureProperties).commit()];
|
|
470
|
-
case 1:
|
|
471
|
-
_c.sent();
|
|
472
|
-
customPropsCells = this_1.plugin.state.data.select(mol_state_1.StateSelection.Generators.ofTransformer(model_1.CustomStructureProperties, structRef));
|
|
473
|
-
_c.label = 2;
|
|
474
|
-
case 2: return [4 /*yield*/, this_1.plugin.build().to(customPropsCells[0]).update(function (old) {
|
|
475
|
-
var _a;
|
|
476
|
-
return ({
|
|
477
|
-
properties: tslib_1.__assign(tslib_1.__assign({}, old.properties), (_a = {}, _a[custom_tooltips_prop_1.CustomTooltipsProvider.descriptor.name] = customTooltipProps, _a)),
|
|
478
|
-
autoAttach: old.autoAttach.includes(custom_tooltips_prop_1.CustomTooltipsProvider.descriptor.name) ?
|
|
479
|
-
old.autoAttach
|
|
480
|
-
: tslib_1.__spreadArray(tslib_1.__spreadArray([], old.autoAttach, true), [custom_tooltips_prop_1.CustomTooltipsProvider.descriptor.name], false),
|
|
481
|
-
});
|
|
482
|
-
}).commit()];
|
|
483
|
-
case 3:
|
|
484
|
-
_c.sent();
|
|
485
|
-
return [2 /*return*/];
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
};
|
|
489
|
-
this_1 = this;
|
|
490
|
-
_i = 0, structures_3 = structures;
|
|
491
|
-
_b.label = 1;
|
|
492
|
-
case 1:
|
|
493
|
-
if (!(_i < structures_3.length)) return [3 /*break*/, 4];
|
|
494
|
-
struct = structures_3[_i];
|
|
495
|
-
return [5 /*yield**/, _loop_2(struct)];
|
|
496
|
-
case 2:
|
|
497
|
-
_b.sent();
|
|
498
|
-
_b.label = 3;
|
|
499
|
-
case 3:
|
|
500
|
-
_i++;
|
|
501
|
-
return [3 /*break*/, 1];
|
|
502
|
-
case 4: return [2 /*return*/];
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
}); },
|
|
506
|
-
/** Remove any custom tooltips added by the `tooltips` method. */
|
|
507
|
-
clearTooltips: function (structureNumberOrId) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
508
|
-
return tslib_1.__generator(this, function (_a) {
|
|
509
|
-
switch (_a.label) {
|
|
510
|
-
case 0: return [4 /*yield*/, this.visual.tooltips({ data: [], structureId: structureNumberOrId })];
|
|
511
|
-
case 1:
|
|
512
|
-
_a.sent();
|
|
513
|
-
return [2 /*return*/];
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
}); },
|
|
517
|
-
/** Set highlight and/or selection color.
|
|
518
|
-
* Highlight color is used when the user hovers over a part of the structure or when applying the `highlight` method.
|
|
519
|
-
* Selection color is used when creating selections with Selection Mode (the mouse cursor icon) and is not related to the color used by the `select` method. */
|
|
520
|
-
setColor: function (params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
521
|
-
var renderer, marking;
|
|
522
|
-
return tslib_1.__generator(this, function (_a) {
|
|
523
|
-
switch (_a.label) {
|
|
524
|
-
case 0:
|
|
525
|
-
if (!this.plugin.canvas3d)
|
|
526
|
-
return [2 /*return*/];
|
|
527
|
-
if (!params.highlight && !params.select)
|
|
528
|
-
return [2 /*return*/];
|
|
529
|
-
renderer = tslib_1.__assign({}, this.plugin.canvas3d.props.renderer);
|
|
530
|
-
marking = tslib_1.__assign({}, this.plugin.canvas3d.props.marking);
|
|
531
|
-
if (params.highlight) {
|
|
532
|
-
renderer.highlightColor = this.normalizeColor(params.highlight);
|
|
533
|
-
marking.highlightEdgeColor = color_1.Color.darken(this.normalizeColor(params.highlight), 1);
|
|
534
|
-
this.isHighlightColorUpdated = true;
|
|
535
|
-
}
|
|
536
|
-
if (params.select) {
|
|
537
|
-
renderer.selectColor = this.normalizeColor(params.select);
|
|
538
|
-
marking.selectEdgeColor = color_1.Color.darken(this.normalizeColor(params.select), 1);
|
|
539
|
-
this.isSelectedColorUpdated = true;
|
|
540
|
-
}
|
|
541
|
-
return [4 /*yield*/, commands_1.PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { renderer: renderer, marking: marking } })];
|
|
542
|
-
case 1:
|
|
543
|
-
_a.sent();
|
|
544
|
-
return [2 /*return*/];
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
}); },
|
|
548
|
-
/** Reset various settings to defaults:
|
|
549
|
-
* `camera` resets camera position (i.e. zooms on the whole scene).
|
|
550
|
-
* `theme` resets color theme for visual representations.
|
|
551
|
-
* `highlightColor` and `selectColor` reset colors previously set by the `setColor` method. */
|
|
552
|
-
reset: function (params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
553
|
-
var defaultTheme, componentGroups, _i, componentGroups_2, compGrp, renderer, marking;
|
|
554
|
-
return tslib_1.__generator(this, function (_a) {
|
|
555
|
-
switch (_a.label) {
|
|
556
|
-
case 0:
|
|
557
|
-
if (!params.camera) return [3 /*break*/, 2];
|
|
558
|
-
return [4 /*yield*/, commands_1.PluginCommands.Camera.Reset(this.plugin, { durationMs: 250 })];
|
|
559
|
-
case 1:
|
|
560
|
-
_a.sent();
|
|
561
|
-
_a.label = 2;
|
|
562
|
-
case 2:
|
|
563
|
-
if (!params.theme) return [3 /*break*/, 6];
|
|
564
|
-
defaultTheme = { color: this.initParams.alphafoldView ? 'plddt-confidence' : 'default' };
|
|
565
|
-
componentGroups = this.plugin.managers.structure.hierarchy.currentComponentGroups;
|
|
566
|
-
_i = 0, componentGroups_2 = componentGroups;
|
|
567
|
-
_a.label = 3;
|
|
568
|
-
case 3:
|
|
569
|
-
if (!(_i < componentGroups_2.length)) return [3 /*break*/, 6];
|
|
570
|
-
compGrp = componentGroups_2[_i];
|
|
571
|
-
return [4 /*yield*/, this.plugin.managers.structure.component.updateRepresentationsTheme(compGrp, defaultTheme)];
|
|
572
|
-
case 4:
|
|
573
|
-
_a.sent();
|
|
574
|
-
_a.label = 5;
|
|
575
|
-
case 5:
|
|
576
|
-
_i++;
|
|
577
|
-
return [3 /*break*/, 3];
|
|
578
|
-
case 6:
|
|
579
|
-
if (!(params.highlightColor || params.selectColor)) return [3 /*break*/, 8];
|
|
580
|
-
if (!this.plugin.canvas3d)
|
|
581
|
-
return [2 /*return*/];
|
|
582
|
-
renderer = tslib_1.__assign({}, this.plugin.canvas3d.props.renderer);
|
|
583
|
-
marking = tslib_1.__assign({}, this.plugin.canvas3d.props.marking);
|
|
584
|
-
if (params.highlightColor) {
|
|
585
|
-
renderer.highlightColor = this.defaultRendererProps.highlightColor;
|
|
586
|
-
marking.highlightEdgeColor = this.defaultMarkingProps.highlightEdgeColor;
|
|
587
|
-
this.isHighlightColorUpdated = false;
|
|
588
|
-
}
|
|
589
|
-
if (params.selectColor) {
|
|
590
|
-
renderer.selectColor = this.defaultRendererProps.selectColor;
|
|
591
|
-
marking.selectEdgeColor = this.defaultMarkingProps.selectEdgeColor;
|
|
592
|
-
this.isSelectedColorUpdated = false;
|
|
593
|
-
}
|
|
594
|
-
return [4 /*yield*/, commands_1.PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { renderer: renderer, marking: marking } })];
|
|
595
|
-
case 7:
|
|
596
|
-
_a.sent();
|
|
597
|
-
_a.label = 8;
|
|
598
|
-
case 8: return [2 /*return*/];
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
}); },
|
|
602
|
-
/** Change parameters of the plugin instance.
|
|
603
|
-
* Can be used to load a different structure.
|
|
604
|
-
* If `fullLoad`, remove currently loaded structure before loading the new one;
|
|
605
|
-
* otherwise add the new structure to existing structures. */
|
|
606
|
-
update: function (options, fullLoad) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
607
|
-
var validationIssues, dataSource;
|
|
608
|
-
return tslib_1.__generator(this, function (_a) {
|
|
609
|
-
switch (_a.label) {
|
|
610
|
-
case 0:
|
|
611
|
-
console.debug('Updating PDBeMolstarPlugin instance with options:', options);
|
|
612
|
-
// Validate options
|
|
613
|
-
if (!options) {
|
|
614
|
-
console.error('Missing `options` argument to `PDBeMolstarPlugin.visual.update');
|
|
615
|
-
return [2 /*return*/, false];
|
|
616
|
-
}
|
|
617
|
-
validationIssues = (0, spec_2.validateInitParams)(options);
|
|
618
|
-
if (validationIssues) {
|
|
619
|
-
console.error('Invalid PDBeMolstarPlugin options:', options);
|
|
620
|
-
return [2 /*return*/, false];
|
|
621
|
-
}
|
|
622
|
-
this.initParams = (0, helpers_1.addDefaults)(options, spec_2.DefaultParams);
|
|
623
|
-
if (!this.initParams.moleculeId && !this.initParams.customData)
|
|
624
|
-
return [2 /*return*/, false];
|
|
625
|
-
if (this.initParams.customData && this.initParams.customData.url && !this.initParams.customData.format)
|
|
626
|
-
return [2 /*return*/, false];
|
|
627
|
-
(0, plugin_custom_state_1.PluginCustomState)(this.plugin).initParams = this.initParams;
|
|
628
|
-
// Show/hide buttons in the viewport control panel
|
|
629
|
-
this.plugin.config.set(config_1.PluginConfig.Viewport.ShowExpand, !this.initParams.hideCanvasControls.includes('expand'));
|
|
630
|
-
this.plugin.config.set(config_1.PluginConfig.Viewport.ShowSelectionMode, !this.initParams.hideCanvasControls.includes('selection'));
|
|
631
|
-
this.plugin.config.set(config_1.PluginConfig.Viewport.ShowAnimation, !this.initParams.hideCanvasControls.includes('animation'));
|
|
632
|
-
this.plugin.config.set(config_1.PluginConfig.Viewport.ShowControls, !this.initParams.hideCanvasControls.includes('controlToggle'));
|
|
633
|
-
this.plugin.config.set(config_1.PluginConfig.Viewport.ShowSettings, !this.initParams.hideCanvasControls.includes('controlInfo'));
|
|
634
|
-
if (!(this.initParams.bgColor || this.initParams.lighting)) return [3 /*break*/, 2];
|
|
635
|
-
return [4 /*yield*/, this.canvas.applySettings({ color: this.initParams.bgColor, lighting: this.initParams.lighting })];
|
|
636
|
-
case 1:
|
|
637
|
-
_a.sent();
|
|
638
|
-
_a.label = 2;
|
|
639
|
-
case 2:
|
|
640
|
-
dataSource = this.getMoleculeSrcUrl();
|
|
641
|
-
if (!dataSource) return [3 /*break*/, 4];
|
|
642
|
-
return [4 /*yield*/, this.load({ url: dataSource.url, format: dataSource.format, assemblyId: this.initParams.assemblyId, isBinary: dataSource.isBinary }, fullLoad)];
|
|
643
|
-
case 3:
|
|
644
|
-
_a.sent();
|
|
645
|
-
_a.label = 4;
|
|
646
|
-
case 4: return [2 /*return*/, true];
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
}); },
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
/** Extract InitParams from attributes of an HTML element */
|
|
653
|
-
PDBeMolstarPlugin.initParamsFromHtmlAttributes = function (element) {
|
|
654
|
-
return (0, spec_from_html_1.initParamsFromHtmlAttributes)(element);
|
|
655
|
-
};
|
|
656
|
-
PDBeMolstarPlugin.prototype.render = function (target, options) {
|
|
657
|
-
var _a, _b, _c, _d, _e, _f;
|
|
658
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
659
|
-
var validationIssues, pdbePluginSpec, _g, dataSource;
|
|
660
|
-
return tslib_1.__generator(this, function (_h) {
|
|
661
|
-
switch (_h.label) {
|
|
662
|
-
case 0:
|
|
663
|
-
console.debug('Rendering PDBeMolstarPlugin instance with options:', options);
|
|
664
|
-
// Validate options
|
|
665
|
-
if (!options) {
|
|
666
|
-
console.error('Missing `options` argument to `PDBeMolstarPlugin.render');
|
|
667
|
-
return [2 /*return*/];
|
|
668
|
-
}
|
|
669
|
-
validationIssues = (0, spec_2.validateInitParams)(options);
|
|
670
|
-
if (validationIssues) {
|
|
671
|
-
console.error('Invalid PDBeMolstarPlugin options:', options);
|
|
672
|
-
return [2 /*return*/];
|
|
673
|
-
}
|
|
674
|
-
this.initParams = (0, helpers_1.addDefaults)(options, spec_2.DefaultParams);
|
|
675
|
-
pdbePluginSpec = (0, spec_2.DefaultPluginUISpec)();
|
|
676
|
-
(_a = pdbePluginSpec.config) !== null && _a !== void 0 ? _a : (pdbePluginSpec.config = []);
|
|
677
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(behavior_2.MolViewSpec));
|
|
678
|
-
if (!this.initParams.ligandView && !this.initParams.superposition && this.initParams.selectInteraction) {
|
|
679
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(structure_focus_representation_1.StructureFocusRepresentation));
|
|
680
|
-
}
|
|
681
|
-
if (this.initParams.superposition) {
|
|
682
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(superposition_focus_representation_1.SuperpositionFocusRepresentation), spec_1.PluginSpec.Behavior(behavior_1.MAQualityAssessment, { autoAttach: true, showTooltip: true }));
|
|
683
|
-
}
|
|
684
|
-
// Add custom properties
|
|
685
|
-
if (this.initParams.domainAnnotation) {
|
|
686
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(behavior_4.PDBeDomainAnnotations, { autoAttach: true, showTooltip: false }));
|
|
687
|
-
}
|
|
688
|
-
if (this.initParams.validationAnnotation) {
|
|
689
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(pdbe_1.PDBeStructureQualityReport, { autoAttach: true, showTooltip: false }));
|
|
690
|
-
}
|
|
691
|
-
if (this.initParams.symmetryAnnotation) {
|
|
692
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(behavior_3.RCSBAssemblySymmetry));
|
|
693
|
-
pdbePluginSpec.config.push([behavior_3.RCSBAssemblySymmetryConfig.DefaultServerType, 'pdbe'], [behavior_3.RCSBAssemblySymmetryConfig.DefaultServerUrl, 'https://www.ebi.ac.uk/pdbe/aggregated-api/pdb/symmetry'], [behavior_3.RCSBAssemblySymmetryConfig.ApplyColors, false]);
|
|
694
|
-
}
|
|
695
|
-
pdbePluginSpec.layout = {
|
|
696
|
-
initial: {
|
|
697
|
-
isExpanded: this.initParams.expanded,
|
|
698
|
-
showControls: !this.initParams.hideControls,
|
|
699
|
-
regionState: {
|
|
700
|
-
left: 'full',
|
|
701
|
-
right: 'full',
|
|
702
|
-
top: this.initParams.sequencePanel ? 'full' : 'hidden',
|
|
703
|
-
bottom: 'full',
|
|
704
|
-
},
|
|
705
|
-
controlsDisplay: this.initParams.reactive ? 'reactive' : this.initParams.landscape ? 'landscape' : layout_1.PluginLayoutStateParams.controlsDisplay.defaultValue,
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
pdbePluginSpec.components = {
|
|
709
|
-
controls: {
|
|
710
|
-
left: pdbe_left_panel_1.LeftPanelControls,
|
|
711
|
-
// right: DefaultStructureTools,
|
|
712
|
-
// top: 'none',
|
|
713
|
-
bottom: 'none'
|
|
714
|
-
},
|
|
715
|
-
viewport: {
|
|
716
|
-
controls: pdbe_viewport_controls_1.PDBeViewportControls,
|
|
717
|
-
view: this.initParams.superposition ? superposition_viewport_1.SuperpostionViewport : void 0
|
|
718
|
-
},
|
|
719
|
-
remoteState: 'none',
|
|
720
|
-
structureTools: this.initParams.superposition ? pdbe_structure_controls_1.PDBeSuperpositionStructureTools : this.initParams.ligandView ? pdbe_structure_controls_1.PDBeLigandViewStructureTools : pdbe_structure_controls_1.PDBeStructureTools
|
|
721
|
-
};
|
|
722
|
-
if (this.initParams.alphafoldView) {
|
|
723
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(behavior_1.MAQualityAssessment, { autoAttach: true, showTooltip: true }));
|
|
724
|
-
}
|
|
725
|
-
pdbePluginSpec.config.push([config_1.PluginConfig.Structure.DefaultRepresentationPresetParams, {
|
|
726
|
-
theme: {
|
|
727
|
-
globalName: (this.initParams.alphafoldView) ? 'plddt-confidence' : undefined,
|
|
728
|
-
carbonColor: { name: 'element-symbol', params: {} },
|
|
729
|
-
focus: {
|
|
730
|
-
name: 'element-symbol',
|
|
731
|
-
params: { carbonColor: { name: 'element-symbol', params: {} } }
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
}]);
|
|
735
|
-
element_symbol_1.ElementSymbolColorThemeParams.carbonColor.defaultValue = { name: 'element-symbol', params: {} };
|
|
736
|
-
// Add animation props
|
|
737
|
-
if (!this.initParams.ligandView && !this.initParams.superposition) {
|
|
738
|
-
pdbePluginSpec.animations = [model_index_1.AnimateModelIndex, camera_spin_1.AnimateCameraSpin, camera_rock_1.AnimateCameraRock, state_snapshots_1.AnimateStateSnapshots, assembly_unwind_1.AnimateAssemblyUnwind, spin_structure_1.AnimateStructureSpin, state_interpolation_1.AnimateStateInterpolation];
|
|
739
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(mp4_export_1.Mp4Export));
|
|
740
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(geo_export_1.GeometryExport));
|
|
741
|
-
}
|
|
742
|
-
if (this.initParams.hideCanvasControls.includes('expand'))
|
|
743
|
-
pdbePluginSpec.config.push([config_1.PluginConfig.Viewport.ShowExpand, false]);
|
|
744
|
-
if (this.initParams.hideCanvasControls.includes('selection'))
|
|
745
|
-
pdbePluginSpec.config.push([config_1.PluginConfig.Viewport.ShowSelectionMode, false]);
|
|
746
|
-
if (this.initParams.hideCanvasControls.includes('animation'))
|
|
747
|
-
pdbePluginSpec.config.push([config_1.PluginConfig.Viewport.ShowAnimation, false]);
|
|
748
|
-
if (this.initParams.hideCanvasControls.includes('controlToggle'))
|
|
749
|
-
pdbePluginSpec.config.push([config_1.PluginConfig.Viewport.ShowControls, false]);
|
|
750
|
-
if (this.initParams.hideCanvasControls.includes('controlInfo'))
|
|
751
|
-
pdbePluginSpec.config.push([config_1.PluginConfig.Viewport.ShowSettings, false]);
|
|
752
|
-
// override default event bindings
|
|
753
|
-
if (this.initParams.selectBindings) {
|
|
754
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(representation_2.SelectLoci, { bindings: this.initParams.selectBindings }));
|
|
755
|
-
}
|
|
756
|
-
if (this.initParams.focusBindings) {
|
|
757
|
-
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(camera_1.FocusLoci, { bindings: this.initParams.focusBindings }));
|
|
758
|
-
}
|
|
759
|
-
this.targetElement = typeof target === 'string' ? document.getElementById(target) : target;
|
|
760
|
-
this.targetElement.viewerInstance = this;
|
|
761
|
-
// Create/ Initialise Plugin
|
|
762
|
-
_g = this;
|
|
763
|
-
return [4 /*yield*/, (0, react18_1.createPluginUI)(this.targetElement, pdbePluginSpec)];
|
|
764
|
-
case 1:
|
|
765
|
-
// Create/ Initialise Plugin
|
|
766
|
-
_g.plugin = _h.sent();
|
|
767
|
-
(0, plugin_custom_state_1.PluginCustomState)(this.plugin).initParams = tslib_1.__assign({}, this.initParams);
|
|
768
|
-
(0, plugin_custom_state_1.PluginCustomState)(this.plugin).events = {
|
|
769
|
-
segmentUpdate: this._ev(),
|
|
770
|
-
superpositionInit: this._ev(),
|
|
771
|
-
isBusy: this._ev()
|
|
772
|
-
};
|
|
773
|
-
// Set background colour
|
|
774
|
-
if (this.initParams.bgColor || this.initParams.lighting) {
|
|
775
|
-
this.canvas.applySettings({ color: this.initParams.bgColor, lighting: this.initParams.lighting });
|
|
776
|
-
}
|
|
777
|
-
// Set selection granularity
|
|
778
|
-
if (this.initParams.granularity) {
|
|
779
|
-
this.plugin.managers.interactivity.setProps({ granularity: this.initParams.granularity });
|
|
780
|
-
}
|
|
781
|
-
// Set default highlight and selection colors
|
|
782
|
-
if (this.initParams.highlightColor || this.initParams.selectColor) {
|
|
783
|
-
this.visual.setColor({ highlight: this.initParams.highlightColor, select: this.initParams.selectColor });
|
|
784
|
-
}
|
|
785
|
-
// Save renderer defaults
|
|
786
|
-
this.defaultRendererProps = tslib_1.__assign({}, this.plugin.canvas3d.props.renderer);
|
|
787
|
-
this.defaultMarkingProps = tslib_1.__assign({}, this.plugin.canvas3d.props.marking);
|
|
788
|
-
if (this.initParams.superposition) {
|
|
789
|
-
// Set left panel tab
|
|
790
|
-
this.plugin.behaviors.layout.leftPanelTabName.next('segments');
|
|
791
|
-
// Initialise superposition
|
|
792
|
-
if (this.initParams.loadingOverlay) {
|
|
793
|
-
new overlay_1.LoadingOverlay(this.targetElement, { resize: (_c = (_b = this.plugin) === null || _b === void 0 ? void 0 : _b.canvas3d) === null || _c === void 0 ? void 0 : _c.resized, hide: this.events.loadComplete }).show();
|
|
794
|
-
}
|
|
795
|
-
(0, superposition_1.initSuperposition)(this.plugin, this.events.loadComplete);
|
|
796
|
-
}
|
|
797
|
-
else {
|
|
798
|
-
// Collapse left panel and set left panel tab to none
|
|
799
|
-
commands_1.PluginCommands.Layout.Update(this.plugin, { state: { regionState: tslib_1.__assign(tslib_1.__assign({}, this.plugin.layout.state.regionState), { left: 'collapsed' }) } });
|
|
800
|
-
this.plugin.behaviors.layout.leftPanelTabName.next('none');
|
|
801
|
-
dataSource = this.getMoleculeSrcUrl();
|
|
802
|
-
if (dataSource) {
|
|
803
|
-
if (this.initParams.loadingOverlay) {
|
|
804
|
-
new overlay_1.LoadingOverlay(this.targetElement, { resize: (_e = (_d = this.plugin) === null || _d === void 0 ? void 0 : _d.canvas3d) === null || _e === void 0 ? void 0 : _e.resized, hide: this.events.loadComplete }).show();
|
|
805
|
-
}
|
|
806
|
-
this.load({
|
|
807
|
-
url: dataSource.url,
|
|
808
|
-
format: dataSource.format,
|
|
809
|
-
assemblyId: this.initParams.assemblyId,
|
|
810
|
-
isBinary: dataSource.isBinary,
|
|
811
|
-
progressMessage: "Loading ".concat((_f = this.initParams.moleculeId) !== null && _f !== void 0 ? _f : '', " ..."),
|
|
812
|
-
id: 'main',
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
// Binding to other PDB Component events
|
|
816
|
-
if (this.initParams.subscribeEvents) {
|
|
817
|
-
(0, subscribe_events_1.subscribeToComponentEvents)(this);
|
|
818
|
-
}
|
|
819
|
-
// Event handling
|
|
820
|
-
custom_events_1.CustomEvents.add(this.plugin, this.targetElement);
|
|
821
|
-
}
|
|
822
|
-
return [2 /*return*/];
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
});
|
|
826
|
-
};
|
|
827
|
-
PDBeMolstarPlugin.prototype.getMoleculeSrcUrl = function () {
|
|
828
|
-
if (this.initParams.customData) {
|
|
829
|
-
var _a = this.initParams.customData, url = _a.url, format = _a.format, binary = _a.binary;
|
|
830
|
-
if (!url || !format) {
|
|
831
|
-
throw new Error("Provide all custom data parameters");
|
|
832
|
-
}
|
|
833
|
-
if (format === 'cif' || format === 'bcif')
|
|
834
|
-
format = 'mmcif';
|
|
835
|
-
// Validate supported format
|
|
836
|
-
var supportedFormats = ['mmcif', 'pdb', 'sdf'];
|
|
837
|
-
if (!supportedFormats.includes(format)) {
|
|
838
|
-
throw new Error("".concat(format, " not supported."));
|
|
839
|
-
}
|
|
840
|
-
return {
|
|
841
|
-
url: url,
|
|
842
|
-
format: format,
|
|
843
|
-
isBinary: binary,
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
if (this.initParams.moleculeId) {
|
|
847
|
-
var request = { pdbId: this.initParams.moleculeId, queryType: 'full', queryParams: {} };
|
|
848
|
-
if (this.initParams.ligandView) {
|
|
849
|
-
request.queryType = 'residueSurroundings';
|
|
850
|
-
request.queryParams['data_source'] = 'pdb-h';
|
|
851
|
-
if (!this.initParams.ligandView.label_comp_id_list) {
|
|
852
|
-
request.queryParams['label_comp_id'] = this.initParams.ligandView.label_comp_id;
|
|
853
|
-
request.queryParams['auth_seq_id'] = this.initParams.ligandView.auth_seq_id;
|
|
854
|
-
request.queryParams['auth_asym_id'] = this.initParams.ligandView.auth_asym_id;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
return {
|
|
858
|
-
url: (0, helpers_1.getStructureUrl)(this.initParams, request),
|
|
859
|
-
format: 'mmcif',
|
|
860
|
-
isBinary: this.initParams.encoding === 'bcif',
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
throw new Error("Mandatory parameters missing! (customData or moleculeId must be defined)");
|
|
864
|
-
};
|
|
865
|
-
Object.defineProperty(PDBeMolstarPlugin.prototype, "state", {
|
|
866
|
-
get: function () {
|
|
867
|
-
return this.plugin.state.data;
|
|
868
|
-
},
|
|
869
|
-
enumerable: false,
|
|
870
|
-
configurable: true
|
|
871
|
-
});
|
|
872
|
-
PDBeMolstarPlugin.prototype.createLigandStructure = function (isBranched) {
|
|
873
|
-
var _a, e_1, _b, _c;
|
|
874
|
-
var _d, _e;
|
|
875
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
876
|
-
var _f, _g, _h, comp, e_1_1, structure, ligandQuery, ligandVis, ligandSurr, ligRef, cell, repr, ligLoci, current;
|
|
877
|
-
return tslib_1.__generator(this, function (_j) {
|
|
878
|
-
switch (_j.label) {
|
|
879
|
-
case 0:
|
|
880
|
-
if (this.assemblyRef === '')
|
|
881
|
-
return [2 /*return*/];
|
|
882
|
-
_j.label = 1;
|
|
883
|
-
case 1:
|
|
884
|
-
_j.trys.push([1, 9, 10, 15]);
|
|
885
|
-
_f = true, _g = tslib_1.__asyncValues(this.plugin.managers.structure.hierarchy.currentComponentGroups);
|
|
886
|
-
_j.label = 2;
|
|
887
|
-
case 2: return [4 /*yield*/, _g.next()];
|
|
888
|
-
case 3:
|
|
889
|
-
if (!(_h = _j.sent(), _a = _h.done, !_a)) return [3 /*break*/, 8];
|
|
890
|
-
_c = _h.value;
|
|
891
|
-
_f = false;
|
|
892
|
-
_j.label = 4;
|
|
893
|
-
case 4:
|
|
894
|
-
_j.trys.push([4, , 6, 7]);
|
|
895
|
-
comp = _c;
|
|
896
|
-
return [4 /*yield*/, commands_1.PluginCommands.State.RemoveObject(this.plugin, { state: comp[0].cell.parent, ref: comp[0].cell.transform.ref, removeParentGhosts: true })];
|
|
897
|
-
case 5:
|
|
898
|
-
_j.sent();
|
|
899
|
-
return [3 /*break*/, 7];
|
|
900
|
-
case 6:
|
|
901
|
-
_f = true;
|
|
902
|
-
return [7 /*endfinally*/];
|
|
903
|
-
case 7: return [3 /*break*/, 2];
|
|
904
|
-
case 8: return [3 /*break*/, 15];
|
|
905
|
-
case 9:
|
|
906
|
-
e_1_1 = _j.sent();
|
|
907
|
-
e_1 = { error: e_1_1 };
|
|
908
|
-
return [3 /*break*/, 15];
|
|
909
|
-
case 10:
|
|
910
|
-
_j.trys.push([10, , 13, 14]);
|
|
911
|
-
if (!(!_f && !_a && (_b = _g.return))) return [3 /*break*/, 12];
|
|
912
|
-
return [4 /*yield*/, _b.call(_g)];
|
|
913
|
-
case 11:
|
|
914
|
-
_j.sent();
|
|
915
|
-
_j.label = 12;
|
|
916
|
-
case 12: return [3 /*break*/, 14];
|
|
917
|
-
case 13:
|
|
918
|
-
if (e_1) throw e_1.error;
|
|
919
|
-
return [7 /*endfinally*/];
|
|
920
|
-
case 14: return [7 /*endfinally*/];
|
|
921
|
-
case 15:
|
|
922
|
-
structure = this.state.select(this.assemblyRef)[0];
|
|
923
|
-
if (isBranched) {
|
|
924
|
-
ligandQuery = helpers_1.LigandView.branchedQuery((_d = this.initParams.ligandView) === null || _d === void 0 ? void 0 : _d.label_comp_id_list);
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
ligandQuery = helpers_1.LigandView.query(this.initParams.ligandView);
|
|
928
|
-
}
|
|
929
|
-
return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentFromExpression(structure, ligandQuery.core, 'pivot', { label: 'Ligand' })];
|
|
930
|
-
case 16:
|
|
931
|
-
ligandVis = _j.sent();
|
|
932
|
-
if (!ligandVis) return [3 /*break*/, 18];
|
|
933
|
-
return [4 /*yield*/, this.plugin.builders.structure.representation.addRepresentation(ligandVis, { type: 'ball-and-stick', color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } }, size: 'uniform', sizeParams: { value: 2.5 } }, { tag: 'ligand-vis' })];
|
|
934
|
-
case 17:
|
|
935
|
-
_j.sent();
|
|
936
|
-
_j.label = 18;
|
|
937
|
-
case 18: return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentFromExpression(structure, ligandQuery.surroundings, 'rest', { label: 'Surroundings' })];
|
|
938
|
-
case 19:
|
|
939
|
-
ligandSurr = _j.sent();
|
|
940
|
-
if (!ligandSurr) return [3 /*break*/, 21];
|
|
941
|
-
return [4 /*yield*/, this.plugin.builders.structure.representation.addRepresentation(ligandSurr, { type: 'ball-and-stick', color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } }, size: 'uniform', sizeParams: { value: 0.8 } })];
|
|
942
|
-
case 20:
|
|
943
|
-
_j.sent();
|
|
944
|
-
_j.label = 21;
|
|
945
|
-
case 21:
|
|
946
|
-
ligRef = mol_state_1.StateSelection.findTagInSubtree(this.plugin.state.data.tree, mol_state_1.StateTransform.RootRef, 'ligand-vis');
|
|
947
|
-
if (!ligRef)
|
|
948
|
-
return [2 /*return*/];
|
|
949
|
-
cell = this.plugin.state.data.cells.get(ligRef);
|
|
950
|
-
if (cell === null || cell === void 0 ? void 0 : cell.obj) {
|
|
951
|
-
repr = cell.obj.data.repr;
|
|
952
|
-
ligLoci = repr.getAllLoci()[0];
|
|
953
|
-
this.plugin.managers.structure.focus.setFromLoci(ligLoci);
|
|
954
|
-
current = (_e = this.plugin.managers.structure.focus.current) === null || _e === void 0 ? void 0 : _e.loci;
|
|
955
|
-
if (current)
|
|
956
|
-
this.plugin.managers.camera.focusLoci(current);
|
|
957
|
-
}
|
|
958
|
-
return [2 /*return*/];
|
|
959
|
-
}
|
|
960
|
-
});
|
|
961
|
-
});
|
|
962
|
-
};
|
|
963
|
-
PDBeMolstarPlugin.prototype.load = function (_a, fullLoad) {
|
|
964
|
-
var url = _a.url, _b = _a.format, format = _b === void 0 ? 'mmcif' : _b, _c = _a.isBinary, isBinary = _c === void 0 ? false : _c, _d = _a.assemblyId, assemblyId = _d === void 0 ? '' : _d, progressMessage = _a.progressMessage, id = _a.id;
|
|
965
|
-
if (fullLoad === void 0) { fullLoad = true; }
|
|
966
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
967
|
-
var _this = this;
|
|
968
|
-
return tslib_1.__generator(this, function (_e) {
|
|
969
|
-
switch (_e.label) {
|
|
970
|
-
case 0: return [4 /*yield*/, (0, helpers_1.runWithProgressMessage)(this.plugin, progressMessage, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
971
|
-
var success, isHetView, downloadOptions, isBranchedView, data_1, trajectory, structRef, model, structure, pivotIndex, pivot, asm, defaultMapParams, pdbeMapParams;
|
|
972
|
-
return tslib_1.__generator(this, function (_a) {
|
|
973
|
-
switch (_a.label) {
|
|
974
|
-
case 0:
|
|
975
|
-
success = false;
|
|
976
|
-
_a.label = 1;
|
|
977
|
-
case 1:
|
|
978
|
-
_a.trys.push([1, , 15, 16]);
|
|
979
|
-
if (!fullLoad) return [3 /*break*/, 3];
|
|
980
|
-
return [4 /*yield*/, this.clear()];
|
|
981
|
-
case 2:
|
|
982
|
-
_a.sent();
|
|
983
|
-
_a.label = 3;
|
|
984
|
-
case 3:
|
|
985
|
-
isHetView = this.initParams.ligandView ? true : false;
|
|
986
|
-
downloadOptions = void 0;
|
|
987
|
-
isBranchedView = false;
|
|
988
|
-
if (this.initParams.ligandView && this.initParams.ligandView.label_comp_id_list) {
|
|
989
|
-
isBranchedView = true;
|
|
990
|
-
downloadOptions = { body: JSON.stringify(this.initParams.ligandView.label_comp_id_list), headers: [['Content-type', 'application/json']] };
|
|
991
|
-
}
|
|
992
|
-
return [4 /*yield*/, this.plugin.builders.data.download({ url: assets_1.Asset.Url(url, downloadOptions), isBinary: isBinary }, { state: { isGhost: true } })];
|
|
993
|
-
case 4:
|
|
994
|
-
data_1 = _a.sent();
|
|
995
|
-
return [4 /*yield*/, this.plugin.builders.structure.parseTrajectory(data_1, format)];
|
|
996
|
-
case 5:
|
|
997
|
-
trajectory = _a.sent();
|
|
998
|
-
structRef = void 0;
|
|
999
|
-
if (!!isHetView) return [3 /*break*/, 7];
|
|
1000
|
-
return [4 /*yield*/, this.plugin.builders.structure.hierarchy.applyPreset(trajectory, this.initParams.defaultPreset, {
|
|
1001
|
-
structure: assemblyId ? (assemblyId === 'preferred') ? void 0 : { name: 'assembly', params: { id: assemblyId } } : { name: 'model', params: {} },
|
|
1002
|
-
showUnitcell: false,
|
|
1003
|
-
representationPreset: 'auto'
|
|
1004
|
-
})];
|
|
1005
|
-
case 6:
|
|
1006
|
-
_a.sent();
|
|
1007
|
-
structRef = this.plugin.state.data.selectQ(function (q) { return q.byRef(data_1.ref).subtree().ofType(objects_1.PluginStateObject.Molecule.Structure); })[0].transform.ref;
|
|
1008
|
-
if (this.initParams.hideStructure.length > 0 || this.initParams.visualStyle) {
|
|
1009
|
-
this.applyVisualParams();
|
|
1010
|
-
}
|
|
1011
|
-
return [3 /*break*/, 10];
|
|
1012
|
-
case 7: return [4 /*yield*/, this.plugin.builders.structure.createModel(trajectory)];
|
|
1013
|
-
case 8:
|
|
1014
|
-
model = _a.sent();
|
|
1015
|
-
return [4 /*yield*/, this.plugin.builders.structure.createStructure(model, { name: 'model', params: {} })];
|
|
1016
|
-
case 9:
|
|
1017
|
-
structure = _a.sent();
|
|
1018
|
-
structRef = structure.ref;
|
|
1019
|
-
_a.label = 10;
|
|
1020
|
-
case 10:
|
|
1021
|
-
if (id) {
|
|
1022
|
-
this.structureRefMap.set(id, structRef);
|
|
1023
|
-
}
|
|
1024
|
-
// show selection if param is set
|
|
1025
|
-
if (this.initParams.selection) {
|
|
1026
|
-
this.visual.select(this.initParams.selection);
|
|
1027
|
-
}
|
|
1028
|
-
pivotIndex = this.plugin.managers.structure.hierarchy.selection.structures.length - 1;
|
|
1029
|
-
pivot = this.plugin.managers.structure.hierarchy.selection.structures[pivotIndex];
|
|
1030
|
-
if (pivot && pivot.cell.parent)
|
|
1031
|
-
this.assemblyRef = pivot.cell.transform.ref;
|
|
1032
|
-
if (!this.initParams.loadMaps) return [3 /*break*/, 12];
|
|
1033
|
-
if (this.assemblyRef === '')
|
|
1034
|
-
return [2 /*return*/];
|
|
1035
|
-
asm = this.state.select(this.assemblyRef)[0].obj;
|
|
1036
|
-
defaultMapParams = transformers_1.InitVolumeStreaming.createDefaultParams(asm, this.plugin);
|
|
1037
|
-
pdbeMapParams = helpers_1.PDBeVolumes.mapParams(defaultMapParams, this.initParams.mapSettings, '');
|
|
1038
|
-
if (!pdbeMapParams) return [3 /*break*/, 12];
|
|
1039
|
-
return [4 /*yield*/, this.plugin.runTask(this.state.applyAction(transformers_1.InitVolumeStreaming, pdbeMapParams, this.assemblyRef))];
|
|
1040
|
-
case 11:
|
|
1041
|
-
_a.sent();
|
|
1042
|
-
if (pdbeMapParams.method !== 'em' && !this.initParams.ligandView)
|
|
1043
|
-
helpers_1.PDBeVolumes.displayUsibilityMessage(this.plugin);
|
|
1044
|
-
_a.label = 12;
|
|
1045
|
-
case 12:
|
|
1046
|
-
if (!isHetView) return [3 /*break*/, 14];
|
|
1047
|
-
return [4 /*yield*/, this.createLigandStructure(isBranchedView)];
|
|
1048
|
-
case 13:
|
|
1049
|
-
_a.sent();
|
|
1050
|
-
_a.label = 14;
|
|
1051
|
-
case 14:
|
|
1052
|
-
success = true;
|
|
1053
|
-
return [3 /*break*/, 16];
|
|
1054
|
-
case 15:
|
|
1055
|
-
this.events.loadComplete.next(success);
|
|
1056
|
-
return [7 /*endfinally*/];
|
|
1057
|
-
case 16: return [2 /*return*/];
|
|
1058
|
-
}
|
|
1059
|
-
});
|
|
1060
|
-
}); })];
|
|
1061
|
-
case 1:
|
|
1062
|
-
_e.sent();
|
|
1063
|
-
return [2 /*return*/];
|
|
1064
|
-
}
|
|
1065
|
-
});
|
|
1066
|
-
});
|
|
1067
|
-
};
|
|
1068
|
-
/** Remove loaded structure(s).
|
|
1069
|
-
* `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure.
|
|
1070
|
-
* If `structureNumberOrId` is undefined, remove all structures.
|
|
1071
|
-
* You will likely need to call `await this.visual.reset({ camera: true })` afterwards. */
|
|
1072
|
-
PDBeMolstarPlugin.prototype.deleteStructure = function (structureNumberOrId) {
|
|
1073
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1074
|
-
var structs, _loop_3, this_2, _i, structs_1, struct;
|
|
1075
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1076
|
-
switch (_a.label) {
|
|
1077
|
-
case 0:
|
|
1078
|
-
structs = this.getStructures(structureNumberOrId);
|
|
1079
|
-
if (structureNumberOrId !== undefined && structs.length === 0) {
|
|
1080
|
-
console.error("Cannot delete structure: there is no structure with number or id ".concat(structureNumberOrId, "."));
|
|
1081
|
-
}
|
|
1082
|
-
_loop_3 = function (struct) {
|
|
1083
|
-
var dataNode;
|
|
1084
|
-
return tslib_1.__generator(this, function (_b) {
|
|
1085
|
-
switch (_b.label) {
|
|
1086
|
-
case 0:
|
|
1087
|
-
dataNode = this_2.plugin.state.data.selectQ(function (q) { return q.byRef(struct.structureRef.cell.transform.ref).ancestorOfType([objects_1.PluginStateObject.Data.String, objects_1.PluginStateObject.Data.Binary]); })[0];
|
|
1088
|
-
if (!dataNode) return [3 /*break*/, 2];
|
|
1089
|
-
return [4 /*yield*/, this_2.plugin.build().delete(dataNode).commit()];
|
|
1090
|
-
case 1:
|
|
1091
|
-
_b.sent();
|
|
1092
|
-
_b.label = 2;
|
|
1093
|
-
case 2: return [2 /*return*/];
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
};
|
|
1097
|
-
this_2 = this;
|
|
1098
|
-
_i = 0, structs_1 = structs;
|
|
1099
|
-
_a.label = 1;
|
|
1100
|
-
case 1:
|
|
1101
|
-
if (!(_i < structs_1.length)) return [3 /*break*/, 4];
|
|
1102
|
-
struct = structs_1[_i];
|
|
1103
|
-
return [5 /*yield**/, _loop_3(struct)];
|
|
1104
|
-
case 2:
|
|
1105
|
-
_a.sent();
|
|
1106
|
-
_a.label = 3;
|
|
1107
|
-
case 3:
|
|
1108
|
-
_i++;
|
|
1109
|
-
return [3 /*break*/, 1];
|
|
1110
|
-
case 4: return [2 /*return*/];
|
|
1111
|
-
}
|
|
1112
|
-
});
|
|
1113
|
-
});
|
|
1114
|
-
};
|
|
1115
|
-
/** Get loci corresponding to a selection within a structure.
|
|
1116
|
-
* If `params` contains more items, return loci for the union of the selections.
|
|
1117
|
-
* If `structureNumber` is provided, use the specified structure (numbered from 1!); otherwise use the last added structure. */
|
|
1118
|
-
PDBeMolstarPlugin.prototype.getLociForParams = function (params, structureNumber) {
|
|
1119
|
-
var assemblyRef = this.assemblyRef;
|
|
1120
|
-
if (structureNumber) {
|
|
1121
|
-
assemblyRef = this.plugin.managers.structure.hierarchy.current.structures[structureNumber - 1].cell.transform.ref;
|
|
1122
|
-
}
|
|
1123
|
-
if (assemblyRef === '')
|
|
1124
|
-
return loci_1.EmptyLoci;
|
|
1125
|
-
var data = this.plugin.state.data.select(assemblyRef)[0].obj.data;
|
|
1126
|
-
if (!data)
|
|
1127
|
-
return loci_1.EmptyLoci;
|
|
1128
|
-
return helpers_1.QueryHelper.getInteractivityLoci(params, data);
|
|
1129
|
-
};
|
|
1130
|
-
PDBeMolstarPlugin.prototype.getLociByPLDDT = function (score, structureNumber) {
|
|
1131
|
-
var assemblyRef = this.assemblyRef;
|
|
1132
|
-
if (structureNumber) {
|
|
1133
|
-
assemblyRef = this.plugin.managers.structure.hierarchy.current.structures[structureNumber - 1].cell.transform.ref;
|
|
1134
|
-
}
|
|
1135
|
-
if (assemblyRef === '')
|
|
1136
|
-
return loci_1.EmptyLoci;
|
|
1137
|
-
var data = this.plugin.state.data.select(assemblyRef)[0].obj.data;
|
|
1138
|
-
if (!data)
|
|
1139
|
-
return loci_1.EmptyLoci;
|
|
1140
|
-
return helpers_1.AlphafoldView.getLociByPLDDT(score, data);
|
|
1141
|
-
};
|
|
1142
|
-
/** For each item in params, get loci and bundle */
|
|
1143
|
-
PDBeMolstarPlugin.prototype.getSelections = function (params, structNumber) {
|
|
1144
|
-
var result = [];
|
|
1145
|
-
for (var _i = 0, params_1 = params; _i < params_1.length; _i++) {
|
|
1146
|
-
var param = params_1[_i];
|
|
1147
|
-
var loci = this.getLociForParams([param], structNumber);
|
|
1148
|
-
if (loci_1.Loci.isEmpty(loci) || !structure_1.StructureElement.Loci.is(loci))
|
|
1149
|
-
continue;
|
|
1150
|
-
var bundle = structure_1.StructureElement.Bundle.fromLoci(loci);
|
|
1151
|
-
result.push({ param: param, loci: loci, bundle: bundle });
|
|
1152
|
-
}
|
|
1153
|
-
return result;
|
|
1154
|
-
};
|
|
1155
|
-
PDBeMolstarPlugin.prototype.getBundle = function (params, structNumber) {
|
|
1156
|
-
var loci = this.getLociForParams(params, structNumber);
|
|
1157
|
-
if (loci_1.Loci.isEmpty(loci) || !structure_1.StructureElement.Loci.is(loci))
|
|
1158
|
-
return undefined;
|
|
1159
|
-
return structure_1.StructureElement.Bundle.fromLoci(loci);
|
|
1160
|
-
};
|
|
1161
|
-
PDBeMolstarPlugin.prototype.normalizeColor = function (colorVal, defaultColor) {
|
|
1162
|
-
var _a, _b, _c;
|
|
1163
|
-
if (defaultColor === void 0) { defaultColor = color_1.Color.fromRgb(170, 170, 170); }
|
|
1164
|
-
try {
|
|
1165
|
-
if (colorVal === undefined || colorVal === null)
|
|
1166
|
-
return defaultColor;
|
|
1167
|
-
if (typeof colorVal === 'number')
|
|
1168
|
-
return (0, color_1.Color)(colorVal);
|
|
1169
|
-
if (typeof colorVal === 'string' && colorVal[0] === '#')
|
|
1170
|
-
return (0, color_1.Color)(Number("0x".concat(colorVal.substring(1))));
|
|
1171
|
-
if (typeof colorVal === 'string' && colorVal in names_1.ColorNames)
|
|
1172
|
-
return names_1.ColorNames[colorVal];
|
|
1173
|
-
if (typeof colorVal === 'object')
|
|
1174
|
-
return color_1.Color.fromRgb((_a = colorVal.r) !== null && _a !== void 0 ? _a : 0, (_b = colorVal.g) !== null && _b !== void 0 ? _b : 0, (_c = colorVal.b) !== null && _c !== void 0 ? _c : 0);
|
|
1175
|
-
}
|
|
1176
|
-
catch (_d) {
|
|
1177
|
-
// do nothing
|
|
1178
|
-
}
|
|
1179
|
-
return defaultColor;
|
|
1180
|
-
};
|
|
1181
|
-
/** Get structure ref for a structure with given `structureNumberOrId`.
|
|
1182
|
-
* `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure.
|
|
1183
|
-
* If `structureNumberOrId` is undefined, return refs for all loaded structures. */
|
|
1184
|
-
PDBeMolstarPlugin.prototype.getStructures = function (structureNumberOrId) {
|
|
1185
|
-
var allStructures = this.plugin.managers.structure.hierarchy.current.structures.map(function (structureRef, i) { return ({ structureRef: structureRef, number: i + 1 }); });
|
|
1186
|
-
if (typeof structureNumberOrId === 'number') {
|
|
1187
|
-
var theStructure = allStructures[structureNumberOrId - 1];
|
|
1188
|
-
return theStructure ? [theStructure] : [];
|
|
1189
|
-
}
|
|
1190
|
-
else if (typeof structureNumberOrId === 'string') {
|
|
1191
|
-
var structRef_1 = this.structureRefMap.get(structureNumberOrId);
|
|
1192
|
-
if (structRef_1 === undefined) {
|
|
1193
|
-
return [];
|
|
1194
|
-
}
|
|
1195
|
-
var found = allStructures.find(function (s) { return s.structureRef.cell.transform.ref === structRef_1; });
|
|
1196
|
-
if (found) {
|
|
1197
|
-
return [found];
|
|
1198
|
-
}
|
|
1199
|
-
else {
|
|
1200
|
-
this.structureRefMap.delete(structureNumberOrId); // remove outdated record
|
|
1201
|
-
return [];
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
else {
|
|
1205
|
-
return allStructures;
|
|
1206
|
-
}
|
|
1207
|
-
};
|
|
1208
|
-
/** Get StructureRef for a structure with given `structureNumberOrId`.
|
|
1209
|
-
* `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure. */
|
|
1210
|
-
PDBeMolstarPlugin.prototype.getStructure = function (structureNumberOrId) {
|
|
1211
|
-
var _a;
|
|
1212
|
-
return (_a = this.getStructures(structureNumberOrId)[0]) === null || _a === void 0 ? void 0 : _a.structureRef;
|
|
1213
|
-
};
|
|
1214
|
-
PDBeMolstarPlugin.prototype.clear = function () {
|
|
1215
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1216
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1217
|
-
switch (_a.label) {
|
|
1218
|
-
case 0: return [4 /*yield*/, this.plugin.clear()];
|
|
1219
|
-
case 1:
|
|
1220
|
-
_a.sent();
|
|
1221
|
-
this.assemblyRef = '';
|
|
1222
|
-
this.addedReprs = {};
|
|
1223
|
-
this.isHighlightColorUpdated = false;
|
|
1224
|
-
this.isSelectedColorUpdated = false;
|
|
1225
|
-
return [2 /*return*/];
|
|
1226
|
-
}
|
|
1227
|
-
});
|
|
1228
|
-
});
|
|
1229
|
-
};
|
|
1230
|
-
/** Helper functions related to specific views or use cases */
|
|
1231
|
-
PDBeMolstarPlugin.extensions = {
|
|
1232
|
-
foldseek: Foldseek,
|
|
1233
|
-
};
|
|
1234
|
-
return PDBeMolstarPlugin;
|
|
1235
|
-
}());
|
|
1236
|
-
exports.PDBeMolstarPlugin = PDBeMolstarPlugin;
|
|
1237
|
-
window.PDBeMolstarPlugin = PDBeMolstarPlugin;
|
|
5
|
+
tslib_1.__exportStar(require("./viewer"), exports);
|
|
6
|
+
var viewer_1 = require("./viewer");
|
|
7
|
+
require("molstar/lib/mol-plugin-ui/skin/light.scss");
|
|
8
|
+
require("./styles/index.scss");
|
|
9
|
+
window.PDBeMolstarPlugin = viewer_1.PDBeMolstarPlugin;
|