drugflow-molstar 0.1.0
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/LICENSE +201 -0
- package/README.md +15 -0
- package/build/pdbe-molstar-3.1.2.css +1 -0
- package/build/pdbe-molstar-component-3.1.2.js +25 -0
- package/build/pdbe-molstar-plugin-3.1.2.js +2 -0
- package/build/pdbe-molstar-plugin-3.1.2.js.LICENSE.txt +39 -0
- package/lib/alphafold-transparency.d.ts +6 -0
- package/lib/alphafold-transparency.js +153 -0
- package/lib/custom-events.d.ts +4 -0
- package/lib/custom-events.js +56 -0
- package/lib/domain-annotations/behavior.d.ts +5 -0
- package/lib/domain-annotations/behavior.js +49 -0
- package/lib/domain-annotations/color.d.ts +10 -0
- package/lib/domain-annotations/color.js +78 -0
- package/lib/domain-annotations/prop.d.ts +35 -0
- package/lib/domain-annotations/prop.js +160 -0
- package/lib/helpers.d.ts +80 -0
- package/lib/helpers.js +278 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +901 -0
- package/lib/labels.d.ts +2 -0
- package/lib/labels.js +42 -0
- package/lib/loci-details.d.ts +27 -0
- package/lib/loci-details.js +128 -0
- package/lib/pdbe-molstar-component-build-3.1.2.js +2 -0
- package/lib/pdbe-molstar-component-build-3.1.2.js.LICENSE.txt +24 -0
- package/lib/sifts-mapping.d.ts +16 -0
- package/lib/sifts-mapping.js +83 -0
- package/lib/sifts-mappings-behaviour.d.ts +5 -0
- package/lib/sifts-mappings-behaviour.js +64 -0
- package/lib/spec.d.ts +75 -0
- package/lib/spec.js +105 -0
- package/lib/subscribe-events.d.ts +1 -0
- package/lib/subscribe-events.js +194 -0
- package/lib/superposition-export.d.ts +4 -0
- package/lib/superposition-export.js +152 -0
- package/lib/superposition-focus-representation.d.ts +16 -0
- package/lib/superposition-focus-representation.js +153 -0
- package/lib/superposition-sifts-mapping.d.ts +22 -0
- package/lib/superposition-sifts-mapping.js +159 -0
- package/lib/superposition.d.ts +18 -0
- package/lib/superposition.js +794 -0
- package/lib/ui/alphafold-superposition.d.ts +56 -0
- package/lib/ui/alphafold-superposition.js +178 -0
- package/lib/ui/alphafold-tranparency.d.ts +22 -0
- package/lib/ui/alphafold-tranparency.js +65 -0
- package/lib/ui/annotation-controls.d.ts +24 -0
- package/lib/ui/annotation-controls.js +166 -0
- package/lib/ui/export-superposition.d.ts +6 -0
- package/lib/ui/export-superposition.js +71 -0
- package/lib/ui/pdbe-left-panel.d.ts +18 -0
- package/lib/ui/pdbe-left-panel.js +167 -0
- package/lib/ui/pdbe-screenshot-controls.d.ts +20 -0
- package/lib/ui/pdbe-screenshot-controls.js +101 -0
- package/lib/ui/pdbe-structure-controls.d.ts +17 -0
- package/lib/ui/pdbe-structure-controls.js +70 -0
- package/lib/ui/pdbe-viewport-controls.d.ts +6 -0
- package/lib/ui/pdbe-viewport-controls.js +56 -0
- package/lib/ui/segment-tree.d.ts +18 -0
- package/lib/ui/segment-tree.js +804 -0
- package/lib/ui/superposition-components.d.ts +10 -0
- package/lib/ui/superposition-components.js +435 -0
- package/lib/ui/superposition-viewport.d.ts +5 -0
- package/lib/ui/superposition-viewport.js +23 -0
- package/package.json +79 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,901 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var spec_1 = require("./spec");
|
|
5
|
+
var commands_1 = require("Molstar/mol-plugin/commands");
|
|
6
|
+
var mol_state_1 = require("Molstar/mol-state");
|
|
7
|
+
var loci_1 = require("Molstar/mol-model/loci");
|
|
8
|
+
var rx_event_helper_1 = require("Molstar/mol-util/rx-event-helper");
|
|
9
|
+
var helpers_1 = require("./helpers");
|
|
10
|
+
var pdbe_structure_controls_1 = require("./ui/pdbe-structure-controls");
|
|
11
|
+
var pdbe_viewport_controls_1 = require("./ui/pdbe-viewport-controls");
|
|
12
|
+
var mol_state_2 = require("Molstar/mol-state");
|
|
13
|
+
var structure_focus_representation_1 = require("Molstar/mol-plugin/behavior/dynamic/selection/structure-focus-representation");
|
|
14
|
+
var spec_2 = require("Molstar/mol-plugin/spec");
|
|
15
|
+
var transformers_1 = require("Molstar/mol-plugin/behavior/dynamic/volume-streaming/transformers");
|
|
16
|
+
var structure_representation_params_1 = require("Molstar/mol-plugin-state/helpers/structure-representation-params");
|
|
17
|
+
var subscribe_events_1 = require("./subscribe-events");
|
|
18
|
+
var pdbe_left_panel_1 = require("./ui/pdbe-left-panel");
|
|
19
|
+
var superposition_1 = require("./superposition");
|
|
20
|
+
var custom_events_1 = require("./custom-events");
|
|
21
|
+
var assets_1 = require("Molstar/mol-util/assets");
|
|
22
|
+
var config_1 = require("Molstar/mol-plugin/config");
|
|
23
|
+
var color_1 = require("Molstar/mol-util/color/color");
|
|
24
|
+
var component_1 = require("Molstar/mol-plugin-state/manager/structure/component");
|
|
25
|
+
var param_definition_1 = require("Molstar/mol-util/param-definition");
|
|
26
|
+
var behavior_1 = require("./domain-annotations/behavior");
|
|
27
|
+
var pdbe_1 = require("Molstar/extensions/pdbe");
|
|
28
|
+
var behavior_2 = require("Molstar/extensions/model-archive/quality-assessment/behavior");
|
|
29
|
+
var structure_overpaint_1 = require("Molstar/mol-plugin-state/helpers/structure-overpaint");
|
|
30
|
+
var superposition_focus_representation_1 = require("./superposition-focus-representation");
|
|
31
|
+
var superposition_viewport_1 = require("./ui/superposition-viewport");
|
|
32
|
+
var representation_1 = require("Molstar/mol-plugin/behavior/dynamic/representation");
|
|
33
|
+
var camera_1 = require("molstar/lib/mol-plugin/behavior/dynamic/camera");
|
|
34
|
+
var mp4_export_1 = require("Molstar/extensions/mp4-export");
|
|
35
|
+
var geo_export_1 = require("Molstar/extensions/geo-export");
|
|
36
|
+
var element_symbol_1 = require("Molstar/mol-theme/color/element-symbol");
|
|
37
|
+
var model_index_1 = require("Molstar/mol-plugin-state/animation/built-in/model-index");
|
|
38
|
+
var camera_spin_1 = require("Molstar/mol-plugin-state/animation/built-in/camera-spin");
|
|
39
|
+
var state_snapshots_1 = require("Molstar/mol-plugin-state/animation/built-in/state-snapshots");
|
|
40
|
+
var state_interpolation_1 = require("Molstar/mol-plugin-state/animation/built-in/state-interpolation");
|
|
41
|
+
var spin_structure_1 = require("Molstar/mol-plugin-state/animation/built-in/spin-structure");
|
|
42
|
+
var camera_rock_1 = require("Molstar/mol-plugin-state/animation/built-in/camera-rock");
|
|
43
|
+
var assembly_unwind_1 = require("Molstar/mol-plugin-state/animation/built-in/assembly-unwind");
|
|
44
|
+
require('Molstar/mol-plugin-ui/skin/dark.scss');
|
|
45
|
+
var PDBeMolstarPlugin = /** @class */ (function () {
|
|
46
|
+
function PDBeMolstarPlugin() {
|
|
47
|
+
var _this = this;
|
|
48
|
+
this._ev = rx_event_helper_1.RxEventHelper.create();
|
|
49
|
+
this.events = {
|
|
50
|
+
loadComplete: this._ev()
|
|
51
|
+
};
|
|
52
|
+
this.assemblyRef = '';
|
|
53
|
+
this.isHighlightColorUpdated = false;
|
|
54
|
+
this.isSelectedColorUpdated = false;
|
|
55
|
+
this.applyVisualParams = function () {
|
|
56
|
+
var TagRefs = {
|
|
57
|
+
'structure-component-static-polymer': 'polymer',
|
|
58
|
+
'structure-component-static-ligand': 'het',
|
|
59
|
+
'structure-component-static-branched': 'carbs',
|
|
60
|
+
'structure-component-static-water': 'water',
|
|
61
|
+
'structure-component-static-coarse': 'coarse',
|
|
62
|
+
'non-standard': 'nonStandard'
|
|
63
|
+
};
|
|
64
|
+
var componentGroups = _this.plugin.managers.structure.hierarchy.currentComponentGroups;
|
|
65
|
+
componentGroups.forEach(function (compGrp) {
|
|
66
|
+
var _a;
|
|
67
|
+
var compGrpIndex = compGrp.length - 1;
|
|
68
|
+
var key = compGrp[compGrpIndex].key;
|
|
69
|
+
var rm = false;
|
|
70
|
+
if (key && _this.initParams.hideStructure) {
|
|
71
|
+
var structType = TagRefs[key];
|
|
72
|
+
if (structType && ((_a = _this.initParams.hideStructure) === null || _a === void 0 ? void 0 : _a.indexOf(structType)) > -1)
|
|
73
|
+
rm = true;
|
|
74
|
+
}
|
|
75
|
+
if (rm) {
|
|
76
|
+
_this.plugin.managers.structure.hierarchy.remove([compGrp[compGrpIndex]]);
|
|
77
|
+
}
|
|
78
|
+
if (!rm && _this.initParams.visualStyle) {
|
|
79
|
+
if (compGrp[compGrpIndex] && compGrp[compGrpIndex].representations) {
|
|
80
|
+
compGrp[compGrpIndex].representations.forEach(function (rep) {
|
|
81
|
+
var currentParams = (0, structure_representation_params_1.createStructureRepresentationParams)(_this.plugin, void 0, { type: _this.initParams.visualStyle });
|
|
82
|
+
_this.plugin.managers.structure.component.updateRepresentations([compGrp[compGrpIndex]], rep, currentParams);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
this.canvas = {
|
|
89
|
+
toggleControls: function (isVisible) {
|
|
90
|
+
if (typeof isVisible === 'undefined')
|
|
91
|
+
isVisible = !_this.plugin.layout.state.showControls;
|
|
92
|
+
commands_1.PluginCommands.Layout.Update(_this.plugin, { state: { showControls: isVisible } });
|
|
93
|
+
},
|
|
94
|
+
toggleExpanded: function (isExpanded) {
|
|
95
|
+
if (typeof isExpanded === 'undefined')
|
|
96
|
+
isExpanded = !_this.plugin.layout.state.isExpanded;
|
|
97
|
+
commands_1.PluginCommands.Layout.Update(_this.plugin, { state: { isExpanded: isExpanded } });
|
|
98
|
+
},
|
|
99
|
+
setBgColor: function (color) {
|
|
100
|
+
if (!color)
|
|
101
|
+
return;
|
|
102
|
+
_this.canvas.applySettings({ color: color });
|
|
103
|
+
},
|
|
104
|
+
applySettings: function (settings) {
|
|
105
|
+
if (!settings)
|
|
106
|
+
return;
|
|
107
|
+
var rendererParams = {};
|
|
108
|
+
if (settings.color)
|
|
109
|
+
rendererParams['backgroundColor'] = color_1.Color.fromRgb(settings.color.r, settings.color.g, settings.color.b);
|
|
110
|
+
if (settings.lighting)
|
|
111
|
+
rendererParams['style'] = { name: settings.lighting };
|
|
112
|
+
var renderer = _this.plugin.canvas3d.props.renderer;
|
|
113
|
+
commands_1.PluginCommands.Canvas3D.SetSettings(_this.plugin, { settings: { renderer: tslib_1.__assign(tslib_1.__assign({}, renderer), rendererParams) } });
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
this.visual = {
|
|
117
|
+
highlight: function (params) {
|
|
118
|
+
var loci = _this.getLociForParams(params.data, params.structureNumber);
|
|
119
|
+
if (loci_1.Loci.isEmpty(loci))
|
|
120
|
+
return;
|
|
121
|
+
if (params.color) {
|
|
122
|
+
_this.visual.setColor({ highlight: params.color });
|
|
123
|
+
}
|
|
124
|
+
_this.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: loci });
|
|
125
|
+
if (params.focus)
|
|
126
|
+
_this.plugin.managers.camera.focusLoci(loci);
|
|
127
|
+
},
|
|
128
|
+
clearHighlight: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
129
|
+
return tslib_1.__generator(this, function (_a) {
|
|
130
|
+
this.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: loci_1.EmptyLoci });
|
|
131
|
+
if (this.isHighlightColorUpdated)
|
|
132
|
+
this.visual.reset({ highlightColor: true });
|
|
133
|
+
return [2 /*return*/];
|
|
134
|
+
});
|
|
135
|
+
}); },
|
|
136
|
+
select: function (params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
137
|
+
var structureData, structureData_1, structureData_1_1, s, e_1_1, _a, _b, param, loci, themeParams, colorValue, repr, defaultParams, defaultValues, values, structures, updatedStructureData, comps, lastCompsIndex, recentRepComp, uniformColor, e_2_1;
|
|
138
|
+
var e_1, _c, e_2, _d;
|
|
139
|
+
return tslib_1.__generator(this, function (_e) {
|
|
140
|
+
switch (_e.label) {
|
|
141
|
+
case 0:
|
|
142
|
+
if (!this.selectedParams) return [3 /*break*/, 2];
|
|
143
|
+
return [4 /*yield*/, this.visual.clearSelection(params.structureNumber)];
|
|
144
|
+
case 1:
|
|
145
|
+
_e.sent();
|
|
146
|
+
_e.label = 2;
|
|
147
|
+
case 2:
|
|
148
|
+
structureData = this.plugin.managers.structure.hierarchy.current.structures;
|
|
149
|
+
if (params.structureNumber) {
|
|
150
|
+
structureData = [this.plugin.managers.structure.hierarchy.current.structures[params.structureNumber - 1]];
|
|
151
|
+
}
|
|
152
|
+
if (!params.nonSelectedColor) return [3 /*break*/, 15];
|
|
153
|
+
_e.label = 3;
|
|
154
|
+
case 3:
|
|
155
|
+
_e.trys.push([3, 9, 10, 15]);
|
|
156
|
+
structureData_1 = tslib_1.__asyncValues(structureData);
|
|
157
|
+
_e.label = 4;
|
|
158
|
+
case 4: return [4 /*yield*/, structureData_1.next()];
|
|
159
|
+
case 5:
|
|
160
|
+
if (!(structureData_1_1 = _e.sent(), !structureData_1_1.done)) return [3 /*break*/, 8];
|
|
161
|
+
s = structureData_1_1.value;
|
|
162
|
+
return [4 /*yield*/, this.plugin.managers.structure.component.updateRepresentationsTheme(s.components, { color: 'uniform', colorParams: { value: this.normalizeColor(params.nonSelectedColor) } })];
|
|
163
|
+
case 6:
|
|
164
|
+
_e.sent();
|
|
165
|
+
_e.label = 7;
|
|
166
|
+
case 7: return [3 /*break*/, 4];
|
|
167
|
+
case 8: return [3 /*break*/, 15];
|
|
168
|
+
case 9:
|
|
169
|
+
e_1_1 = _e.sent();
|
|
170
|
+
e_1 = { error: e_1_1 };
|
|
171
|
+
return [3 /*break*/, 15];
|
|
172
|
+
case 10:
|
|
173
|
+
_e.trys.push([10, , 13, 14]);
|
|
174
|
+
if (!(structureData_1_1 && !structureData_1_1.done && (_c = structureData_1.return))) return [3 /*break*/, 12];
|
|
175
|
+
return [4 /*yield*/, _c.call(structureData_1)];
|
|
176
|
+
case 11:
|
|
177
|
+
_e.sent();
|
|
178
|
+
_e.label = 12;
|
|
179
|
+
case 12: return [3 /*break*/, 14];
|
|
180
|
+
case 13:
|
|
181
|
+
if (e_1) throw e_1.error;
|
|
182
|
+
return [7 /*endfinally*/];
|
|
183
|
+
case 14: return [7 /*endfinally*/];
|
|
184
|
+
case 15:
|
|
185
|
+
_e.trys.push([15, 23, 24, 29]);
|
|
186
|
+
_a = tslib_1.__asyncValues(params.data);
|
|
187
|
+
_e.label = 16;
|
|
188
|
+
case 16: return [4 /*yield*/, _a.next()];
|
|
189
|
+
case 17:
|
|
190
|
+
if (!(_b = _e.sent(), !_b.done)) return [3 /*break*/, 22];
|
|
191
|
+
param = _b.value;
|
|
192
|
+
loci = this.getLociForParams([param], params.structureNumber);
|
|
193
|
+
if (loci_1.Loci.isEmpty(loci))
|
|
194
|
+
return [2 /*return*/];
|
|
195
|
+
// set default selection color to minimise change display
|
|
196
|
+
this.visual.setColor({ select: param.color ? param.color : { r: 255, g: 112, b: 3 } });
|
|
197
|
+
// apply selection
|
|
198
|
+
this.plugin.managers.interactivity.lociSelects.selectOnly({ loci: loci });
|
|
199
|
+
themeParams = component_1.StructureComponentManager.getThemeParams(this.plugin, this.plugin.managers.structure.component.pivotStructure);
|
|
200
|
+
colorValue = param_definition_1.ParamDefinition.getDefaultValues(themeParams);
|
|
201
|
+
colorValue.action.params = { color: param.color ? this.normalizeColor(param.color) : color_1.Color.fromRgb(255, 112, 3), opacity: 1 };
|
|
202
|
+
return [4 /*yield*/, this.plugin.managers.structure.component.applyTheme(colorValue, structureData)];
|
|
203
|
+
case 18:
|
|
204
|
+
_e.sent();
|
|
205
|
+
if (!(param.sideChain || param.representation)) return [3 /*break*/, 20];
|
|
206
|
+
repr = 'ball-and-stick';
|
|
207
|
+
if (param.representation)
|
|
208
|
+
repr = param.representation;
|
|
209
|
+
defaultParams = component_1.StructureComponentManager.getAddParams(this.plugin, { allowNone: false, hideSelection: true, checkExisting: true });
|
|
210
|
+
defaultValues = param_definition_1.ParamDefinition.getDefaultValues(defaultParams);
|
|
211
|
+
defaultValues.options = { label: 'selection-by-script', checkExisting: params.structureNumber ? false : true };
|
|
212
|
+
values = tslib_1.__assign(tslib_1.__assign({}, defaultValues), { representation: repr });
|
|
213
|
+
structures = this.plugin.managers.structure.hierarchy.getStructuresWithSelection();
|
|
214
|
+
return [4 /*yield*/, this.plugin.managers.structure.component.add(values, structures)];
|
|
215
|
+
case 19:
|
|
216
|
+
_e.sent();
|
|
217
|
+
// Apply uniform theme
|
|
218
|
+
if (param.representationColor) {
|
|
219
|
+
updatedStructureData = this.plugin.managers.structure.hierarchy.current.structures;
|
|
220
|
+
if (params.structureNumber) {
|
|
221
|
+
updatedStructureData = [this.plugin.managers.structure.hierarchy.current.structures[params.structureNumber - 1]];
|
|
222
|
+
}
|
|
223
|
+
comps = updatedStructureData[0].components;
|
|
224
|
+
lastCompsIndex = comps.length - 1;
|
|
225
|
+
recentRepComp = [comps[lastCompsIndex]];
|
|
226
|
+
uniformColor = param.representationColor ? this.normalizeColor(param.representationColor) : color_1.Color.fromRgb(255, 112, 3);
|
|
227
|
+
this.plugin.managers.structure.component.updateRepresentationsTheme(recentRepComp, { color: 'uniform', colorParams: { value: uniformColor } });
|
|
228
|
+
}
|
|
229
|
+
params.addedRepr = true;
|
|
230
|
+
_e.label = 20;
|
|
231
|
+
case 20:
|
|
232
|
+
// focus loci
|
|
233
|
+
if (param.focus)
|
|
234
|
+
this.plugin.managers.camera.focusLoci(loci);
|
|
235
|
+
// remove selection
|
|
236
|
+
this.plugin.managers.interactivity.lociSelects.deselect({ loci: loci });
|
|
237
|
+
_e.label = 21;
|
|
238
|
+
case 21: return [3 /*break*/, 16];
|
|
239
|
+
case 22: return [3 /*break*/, 29];
|
|
240
|
+
case 23:
|
|
241
|
+
e_2_1 = _e.sent();
|
|
242
|
+
e_2 = { error: e_2_1 };
|
|
243
|
+
return [3 /*break*/, 29];
|
|
244
|
+
case 24:
|
|
245
|
+
_e.trys.push([24, , 27, 28]);
|
|
246
|
+
if (!(_b && !_b.done && (_d = _a.return))) return [3 /*break*/, 26];
|
|
247
|
+
return [4 /*yield*/, _d.call(_a)];
|
|
248
|
+
case 25:
|
|
249
|
+
_e.sent();
|
|
250
|
+
_e.label = 26;
|
|
251
|
+
case 26: return [3 /*break*/, 28];
|
|
252
|
+
case 27:
|
|
253
|
+
if (e_2) throw e_2.error;
|
|
254
|
+
return [7 /*endfinally*/];
|
|
255
|
+
case 28: return [7 /*endfinally*/];
|
|
256
|
+
case 29:
|
|
257
|
+
// reset selection color
|
|
258
|
+
this.visual.reset({ selectColor: true });
|
|
259
|
+
// save selection params to optimise clear
|
|
260
|
+
this.selectedParams = params;
|
|
261
|
+
return [2 /*return*/];
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}); },
|
|
265
|
+
clearSelection: function (structureNumber) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
266
|
+
var structIndex, selReprCells, _i, _a, c, selReprCells_1, selReprCells_1_1, selReprCell, e_3_1;
|
|
267
|
+
var e_3, _b;
|
|
268
|
+
return tslib_1.__generator(this, function (_c) {
|
|
269
|
+
switch (_c.label) {
|
|
270
|
+
case 0:
|
|
271
|
+
structIndex = structureNumber ? structureNumber - 1 : 0;
|
|
272
|
+
this.plugin.managers.interactivity.lociSelects.deselectAll();
|
|
273
|
+
// reset theme to default
|
|
274
|
+
if (this.selectedParams && this.selectedParams.nonSelectedColor) {
|
|
275
|
+
this.visual.reset({ theme: true });
|
|
276
|
+
}
|
|
277
|
+
// remove overpaints
|
|
278
|
+
return [4 /*yield*/, (0, structure_overpaint_1.clearStructureOverpaint)(this.plugin, this.plugin.managers.structure.hierarchy.current.structures[structIndex].components)];
|
|
279
|
+
case 1:
|
|
280
|
+
// remove overpaints
|
|
281
|
+
_c.sent();
|
|
282
|
+
if (!(this.selectedParams && this.selectedParams.addedRepr)) return [3 /*break*/, 15];
|
|
283
|
+
selReprCells = [];
|
|
284
|
+
for (_i = 0, _a = this.plugin.managers.structure.hierarchy.current.structures[structIndex].components; _i < _a.length; _i++) {
|
|
285
|
+
c = _a[_i];
|
|
286
|
+
if (c.cell && c.cell.params && c.cell.params.values && c.cell.params.values.label === 'selection-by-script')
|
|
287
|
+
selReprCells.push(c.cell);
|
|
288
|
+
}
|
|
289
|
+
if (!(selReprCells.length > 0)) return [3 /*break*/, 15];
|
|
290
|
+
_c.label = 2;
|
|
291
|
+
case 2:
|
|
292
|
+
_c.trys.push([2, 8, 9, 14]);
|
|
293
|
+
selReprCells_1 = tslib_1.__asyncValues(selReprCells);
|
|
294
|
+
_c.label = 3;
|
|
295
|
+
case 3: return [4 /*yield*/, selReprCells_1.next()];
|
|
296
|
+
case 4:
|
|
297
|
+
if (!(selReprCells_1_1 = _c.sent(), !selReprCells_1_1.done)) return [3 /*break*/, 7];
|
|
298
|
+
selReprCell = selReprCells_1_1.value;
|
|
299
|
+
return [4 /*yield*/, commands_1.PluginCommands.State.RemoveObject(this.plugin, { state: selReprCell.parent, ref: selReprCell.transform.ref })];
|
|
300
|
+
case 5:
|
|
301
|
+
_c.sent();
|
|
302
|
+
_c.label = 6;
|
|
303
|
+
case 6: return [3 /*break*/, 3];
|
|
304
|
+
case 7: return [3 /*break*/, 14];
|
|
305
|
+
case 8:
|
|
306
|
+
e_3_1 = _c.sent();
|
|
307
|
+
e_3 = { error: e_3_1 };
|
|
308
|
+
return [3 /*break*/, 14];
|
|
309
|
+
case 9:
|
|
310
|
+
_c.trys.push([9, , 12, 13]);
|
|
311
|
+
if (!(selReprCells_1_1 && !selReprCells_1_1.done && (_b = selReprCells_1.return))) return [3 /*break*/, 11];
|
|
312
|
+
return [4 /*yield*/, _b.call(selReprCells_1)];
|
|
313
|
+
case 10:
|
|
314
|
+
_c.sent();
|
|
315
|
+
_c.label = 11;
|
|
316
|
+
case 11: return [3 /*break*/, 13];
|
|
317
|
+
case 12:
|
|
318
|
+
if (e_3) throw e_3.error;
|
|
319
|
+
return [7 /*endfinally*/];
|
|
320
|
+
case 13: return [7 /*endfinally*/];
|
|
321
|
+
case 14:
|
|
322
|
+
;
|
|
323
|
+
_c.label = 15;
|
|
324
|
+
case 15:
|
|
325
|
+
this.selectedParams = undefined;
|
|
326
|
+
return [2 /*return*/];
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}); },
|
|
330
|
+
update: function (options, fullLoad) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
331
|
+
var param, settings, dataSource;
|
|
332
|
+
return tslib_1.__generator(this, function (_a) {
|
|
333
|
+
if (!options)
|
|
334
|
+
return [2 /*return*/];
|
|
335
|
+
// for(let param in this.initParams){
|
|
336
|
+
// if(options[param]) this.initParams[param] = options[param];
|
|
337
|
+
// }
|
|
338
|
+
this.initParams = tslib_1.__assign({}, spec_1.DefaultParams);
|
|
339
|
+
for (param in spec_1.DefaultParams) {
|
|
340
|
+
if (typeof options[param] !== 'undefined')
|
|
341
|
+
this.initParams[param] = options[param];
|
|
342
|
+
}
|
|
343
|
+
if (!this.initParams.moleculeId && !this.initParams.customData)
|
|
344
|
+
return [2 /*return*/, false];
|
|
345
|
+
if (this.initParams.customData && this.initParams.customData.url && !this.initParams.customData.format)
|
|
346
|
+
return [2 /*return*/, false];
|
|
347
|
+
this.plugin.customState.initParams = this.initParams;
|
|
348
|
+
// Set background colour
|
|
349
|
+
if (this.initParams.bgColor || this.initParams.lighting) {
|
|
350
|
+
settings = {};
|
|
351
|
+
if (this.initParams.bgColor)
|
|
352
|
+
settings.color = this.initParams.bgColor;
|
|
353
|
+
if (this.initParams.lighting)
|
|
354
|
+
settings.lighting = this.initParams.lighting;
|
|
355
|
+
this.canvas.applySettings(settings);
|
|
356
|
+
}
|
|
357
|
+
dataSource = this.getMoleculeSrcUrl();
|
|
358
|
+
if (dataSource) {
|
|
359
|
+
this.load({ url: dataSource.url, format: dataSource.format, assemblyId: this.initParams.assemblyId, isBinary: dataSource.isBinary }, fullLoad);
|
|
360
|
+
}
|
|
361
|
+
return [2 /*return*/];
|
|
362
|
+
});
|
|
363
|
+
}); },
|
|
364
|
+
visibility: function (data) {
|
|
365
|
+
if (!data)
|
|
366
|
+
return;
|
|
367
|
+
var refMap = {
|
|
368
|
+
polymer: 'structure-component-static-polymer',
|
|
369
|
+
het: 'structure-component-static-ligand',
|
|
370
|
+
water: 'structure-component-static-water',
|
|
371
|
+
carbs: 'structure-component-static-branched',
|
|
372
|
+
maps: 'volume-streaming-info'
|
|
373
|
+
};
|
|
374
|
+
for (var visual in data) {
|
|
375
|
+
var tagName = refMap[visual];
|
|
376
|
+
var componentRef = mol_state_2.StateSelection.findTagInSubtree(_this.plugin.state.data.tree, mol_state_1.StateTransform.RootRef, tagName);
|
|
377
|
+
if (componentRef) {
|
|
378
|
+
var compVisual = _this.plugin.state.data.select(componentRef)[0];
|
|
379
|
+
if (compVisual && compVisual.obj) {
|
|
380
|
+
var currentlyVisible = (compVisual.state && compVisual.state.isHidden) ? false : true;
|
|
381
|
+
if (data[visual] !== currentlyVisible) {
|
|
382
|
+
commands_1.PluginCommands.State.ToggleVisibility(_this.plugin, { state: _this.state, ref: componentRef });
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
toggleSpin: function (isSpinning, resetCamera) {
|
|
389
|
+
if (!_this.plugin.canvas3d)
|
|
390
|
+
return;
|
|
391
|
+
var trackball = _this.plugin.canvas3d.props.trackball;
|
|
392
|
+
var toggleSpinParam = trackball.animate.name === 'spin' ? { name: 'off', params: {} } : { name: 'spin', params: { speed: 1 } };
|
|
393
|
+
if (typeof isSpinning !== 'undefined') {
|
|
394
|
+
toggleSpinParam = { name: 'off', params: {} };
|
|
395
|
+
if (isSpinning)
|
|
396
|
+
toggleSpinParam = { name: 'spin', params: { speed: 1 } };
|
|
397
|
+
}
|
|
398
|
+
commands_1.PluginCommands.Canvas3D.SetSettings(_this.plugin, { settings: { trackball: tslib_1.__assign(tslib_1.__assign({}, trackball), { animate: toggleSpinParam }) } });
|
|
399
|
+
if (resetCamera)
|
|
400
|
+
commands_1.PluginCommands.Camera.Reset(_this.plugin, {});
|
|
401
|
+
},
|
|
402
|
+
focus: function (params, structureNumber) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
403
|
+
var loci;
|
|
404
|
+
return tslib_1.__generator(this, function (_a) {
|
|
405
|
+
loci = this.getLociForParams(params, structureNumber);
|
|
406
|
+
this.plugin.managers.camera.focusLoci(loci);
|
|
407
|
+
return [2 /*return*/];
|
|
408
|
+
});
|
|
409
|
+
}); },
|
|
410
|
+
setColor: function (param) {
|
|
411
|
+
if (!_this.plugin.canvas3d)
|
|
412
|
+
return;
|
|
413
|
+
var renderer = _this.plugin.canvas3d.props.renderer;
|
|
414
|
+
var rParam = {};
|
|
415
|
+
if (param.highlight)
|
|
416
|
+
rParam['highlightColor'] = _this.normalizeColor(param.highlight);
|
|
417
|
+
if (param.select)
|
|
418
|
+
rParam['selectColor'] = _this.normalizeColor(param.select);
|
|
419
|
+
commands_1.PluginCommands.Canvas3D.SetSettings(_this.plugin, { settings: { renderer: tslib_1.__assign(tslib_1.__assign({}, renderer), rParam) } });
|
|
420
|
+
if (rParam.highlightColor)
|
|
421
|
+
_this.isHighlightColorUpdated = true;
|
|
422
|
+
},
|
|
423
|
+
reset: function (params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
424
|
+
var defaultTheme_1, componentGroups, renderer, rParam;
|
|
425
|
+
var _this = this;
|
|
426
|
+
return tslib_1.__generator(this, function (_a) {
|
|
427
|
+
switch (_a.label) {
|
|
428
|
+
case 0:
|
|
429
|
+
if (!params.camera) return [3 /*break*/, 2];
|
|
430
|
+
return [4 /*yield*/, commands_1.PluginCommands.Camera.Reset(this.plugin, { durationMs: 250 })];
|
|
431
|
+
case 1:
|
|
432
|
+
_a.sent();
|
|
433
|
+
_a.label = 2;
|
|
434
|
+
case 2:
|
|
435
|
+
if (params.theme) {
|
|
436
|
+
defaultTheme_1 = { color: this.initParams.alphafoldView ? 'plddt-confidence' : 'default' };
|
|
437
|
+
componentGroups = this.plugin.managers.structure.hierarchy.currentComponentGroups;
|
|
438
|
+
componentGroups.forEach(function (compGrp) {
|
|
439
|
+
_this.plugin.managers.structure.component.updateRepresentationsTheme(compGrp, defaultTheme_1);
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
if (params.highlightColor || params.selectColor) {
|
|
443
|
+
if (!this.plugin.canvas3d)
|
|
444
|
+
return [2 /*return*/];
|
|
445
|
+
renderer = this.plugin.canvas3d.props.renderer;
|
|
446
|
+
rParam = {};
|
|
447
|
+
if (params.highlightColor)
|
|
448
|
+
rParam['highlightColor'] = this.defaultRendererProps.highlightColor;
|
|
449
|
+
if (params.selectColor)
|
|
450
|
+
rParam['selectColor'] = this.defaultRendererProps.selectColor;
|
|
451
|
+
commands_1.PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { renderer: tslib_1.__assign(tslib_1.__assign({}, renderer), rParam) } });
|
|
452
|
+
if (rParam.highlightColor)
|
|
453
|
+
this.isHighlightColorUpdated = false;
|
|
454
|
+
}
|
|
455
|
+
return [2 /*return*/];
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}); }
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
PDBeMolstarPlugin.prototype.render = function (target, options) {
|
|
462
|
+
var _a;
|
|
463
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
464
|
+
var param, defaultPDBeSpec, pdbePluginSpec, _b, settings, dataSource;
|
|
465
|
+
return tslib_1.__generator(this, function (_c) {
|
|
466
|
+
switch (_c.label) {
|
|
467
|
+
case 0:
|
|
468
|
+
if (!options)
|
|
469
|
+
return [2 /*return*/];
|
|
470
|
+
this.initParams = tslib_1.__assign({}, spec_1.DefaultParams);
|
|
471
|
+
for (param in spec_1.DefaultParams) {
|
|
472
|
+
if (typeof options[param] !== 'undefined')
|
|
473
|
+
this.initParams[param] = options[param];
|
|
474
|
+
}
|
|
475
|
+
if (!this.initParams.moleculeId && !this.initParams.customData)
|
|
476
|
+
return [2 /*return*/, false];
|
|
477
|
+
if (this.initParams.customData && this.initParams.customData.url && !this.initParams.customData.format)
|
|
478
|
+
return [2 /*return*/, false];
|
|
479
|
+
defaultPDBeSpec = (0, spec_1.DefaultPluginUISpec)();
|
|
480
|
+
pdbePluginSpec = {
|
|
481
|
+
actions: tslib_1.__spreadArray([], defaultPDBeSpec.actions || [], true),
|
|
482
|
+
behaviors: tslib_1.__spreadArray([], defaultPDBeSpec.behaviors, true),
|
|
483
|
+
animations: tslib_1.__spreadArray([], defaultPDBeSpec.animations || [], true),
|
|
484
|
+
customParamEditors: defaultPDBeSpec.customParamEditors,
|
|
485
|
+
config: defaultPDBeSpec.config
|
|
486
|
+
};
|
|
487
|
+
if (!this.initParams.ligandView && !this.initParams.superposition && this.initParams.selectInteraction) {
|
|
488
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(structure_focus_representation_1.StructureFocusRepresentation));
|
|
489
|
+
}
|
|
490
|
+
if (this.initParams.superposition) {
|
|
491
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(superposition_focus_representation_1.SuperpositionFocusRepresentation), spec_2.PluginSpec.Behavior(behavior_2.MAQualityAssessment, { autoAttach: true, showTooltip: true }));
|
|
492
|
+
}
|
|
493
|
+
// Add custom properties
|
|
494
|
+
if (this.initParams.domainAnnotation) {
|
|
495
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(behavior_1.PDBeDomainAnnotations, { autoAttach: true, showTooltip: false }));
|
|
496
|
+
}
|
|
497
|
+
if (this.initParams.validationAnnotation) {
|
|
498
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(pdbe_1.PDBeStructureQualityReport, { autoAttach: true, showTooltip: false }));
|
|
499
|
+
}
|
|
500
|
+
pdbePluginSpec.layout = {
|
|
501
|
+
initial: {
|
|
502
|
+
isExpanded: this.initParams.landscape ? false : this.initParams.expanded,
|
|
503
|
+
showControls: !this.initParams.hideControls
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
pdbePluginSpec.components = {
|
|
507
|
+
controls: {
|
|
508
|
+
left: pdbe_left_panel_1.LeftPanelControls,
|
|
509
|
+
// right: DefaultStructureTools,
|
|
510
|
+
top: 'none',
|
|
511
|
+
bottom: 'none'
|
|
512
|
+
},
|
|
513
|
+
viewport: {
|
|
514
|
+
controls: pdbe_viewport_controls_1.PDBeViewportControls,
|
|
515
|
+
view: this.initParams.superposition ? superposition_viewport_1.SuperpostionViewport : void 0
|
|
516
|
+
},
|
|
517
|
+
remoteState: 'none',
|
|
518
|
+
structureTools: this.initParams.superposition ? pdbe_structure_controls_1.PDBeSuperpositionStructureTools : this.initParams.ligandView ? pdbe_structure_controls_1.PDBeLigandViewStructureTools : pdbe_structure_controls_1.PDBeStructureTools
|
|
519
|
+
};
|
|
520
|
+
if (this.initParams.alphafoldView) {
|
|
521
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(behavior_2.MAQualityAssessment, { autoAttach: true, showTooltip: true }));
|
|
522
|
+
}
|
|
523
|
+
if (this.initParams.sequencePanel) {
|
|
524
|
+
if ((_a = pdbePluginSpec.components.controls) === null || _a === void 0 ? void 0 : _a.top)
|
|
525
|
+
delete pdbePluginSpec.components.controls.top;
|
|
526
|
+
}
|
|
527
|
+
pdbePluginSpec.config = [
|
|
528
|
+
[
|
|
529
|
+
config_1.PluginConfig.Structure.DefaultRepresentationPresetParams,
|
|
530
|
+
{
|
|
531
|
+
theme: {
|
|
532
|
+
globalName: (this.initParams.alphafoldView) ? 'plddt-confidence' : undefined,
|
|
533
|
+
carbonColor: { name: 'element-symbol', params: {} },
|
|
534
|
+
focus: {
|
|
535
|
+
name: 'element-symbol',
|
|
536
|
+
params: { carbonColor: { name: 'element-symbol', params: {} } }
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
]
|
|
541
|
+
];
|
|
542
|
+
element_symbol_1.ElementSymbolColorThemeParams.carbonColor.defaultValue = { name: 'element-symbol', params: {} };
|
|
543
|
+
// Add animation props
|
|
544
|
+
if (!this.initParams.ligandView && !this.initParams.superposition) {
|
|
545
|
+
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];
|
|
546
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(mp4_export_1.Mp4Export));
|
|
547
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(geo_export_1.GeometryExport));
|
|
548
|
+
}
|
|
549
|
+
if (this.initParams.hideCanvasControls) {
|
|
550
|
+
if (this.initParams.hideCanvasControls.indexOf('expand') > -1)
|
|
551
|
+
pdbePluginSpec.config.push([config_1.PluginConfig.Viewport.ShowExpand, false]);
|
|
552
|
+
if (this.initParams.hideCanvasControls.indexOf('selection') > -1)
|
|
553
|
+
pdbePluginSpec.config.push([config_1.PluginConfig.Viewport.ShowSelectionMode, false]);
|
|
554
|
+
if (this.initParams.hideCanvasControls.indexOf('animation') > -1)
|
|
555
|
+
pdbePluginSpec.config.push([config_1.PluginConfig.Viewport.ShowAnimation, false]);
|
|
556
|
+
}
|
|
557
|
+
;
|
|
558
|
+
if (this.initParams.landscape && pdbePluginSpec.layout && pdbePluginSpec.layout.initial)
|
|
559
|
+
pdbePluginSpec.layout.initial['controlsDisplay'] = 'landscape';
|
|
560
|
+
if (this.initParams.reactive && pdbePluginSpec.layout && pdbePluginSpec.layout.initial)
|
|
561
|
+
pdbePluginSpec.layout.initial['controlsDisplay'] = 'reactive';
|
|
562
|
+
// override default event bindings
|
|
563
|
+
if (this.initParams.selectBindings) {
|
|
564
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(representation_1.SelectLoci, { bindings: this.initParams.selectBindings }));
|
|
565
|
+
}
|
|
566
|
+
if (this.initParams.focusBindings) {
|
|
567
|
+
pdbePluginSpec.behaviors.push(spec_2.PluginSpec.Behavior(camera_1.FocusLoci, { bindings: this.initParams.focusBindings }));
|
|
568
|
+
}
|
|
569
|
+
this.targetElement = typeof target === 'string' ? document.getElementById(target) : target;
|
|
570
|
+
// Create/ Initialise Plugin
|
|
571
|
+
_b = this;
|
|
572
|
+
return [4 /*yield*/, (0, spec_1.createPluginUI)(this.targetElement, pdbePluginSpec)];
|
|
573
|
+
case 1:
|
|
574
|
+
// Create/ Initialise Plugin
|
|
575
|
+
_b.plugin = _c.sent();
|
|
576
|
+
this.plugin.customState.initParams = tslib_1.__assign({}, this.initParams);
|
|
577
|
+
this.plugin.customState.events = {
|
|
578
|
+
segmentUpdate: this._ev(),
|
|
579
|
+
superpositionInit: this._ev(),
|
|
580
|
+
isBusy: this._ev()
|
|
581
|
+
};
|
|
582
|
+
// Set background colour
|
|
583
|
+
if (this.initParams.bgColor || this.initParams.lighting) {
|
|
584
|
+
settings = {};
|
|
585
|
+
if (this.initParams.bgColor)
|
|
586
|
+
settings.color = this.initParams.bgColor;
|
|
587
|
+
if (this.initParams.lighting)
|
|
588
|
+
settings.lighting = this.initParams.lighting;
|
|
589
|
+
this.canvas.applySettings(settings);
|
|
590
|
+
}
|
|
591
|
+
// Set selection granularity
|
|
592
|
+
if (this.initParams.granularity) {
|
|
593
|
+
this.plugin.managers.interactivity.setProps({ granularity: this.initParams.granularity });
|
|
594
|
+
}
|
|
595
|
+
// Set default highlight and selection colors
|
|
596
|
+
if (this.initParams.highlightColor || this.initParams.selectColor) {
|
|
597
|
+
this.visual.setColor({ highlight: this.initParams.highlightColor, select: this.initParams.selectColor });
|
|
598
|
+
}
|
|
599
|
+
// Save renderer defaults
|
|
600
|
+
this.defaultRendererProps = tslib_1.__assign({}, this.plugin.canvas3d.props.renderer);
|
|
601
|
+
if (this.initParams.superposition) {
|
|
602
|
+
// Set left panel tab
|
|
603
|
+
this.plugin.behaviors.layout.leftPanelTabName.next('segments');
|
|
604
|
+
// Initialise superposition
|
|
605
|
+
(0, superposition_1.initSuperposition)(this.plugin);
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
// Collapse left panel and set left panel tab to none
|
|
609
|
+
commands_1.PluginCommands.Layout.Update(this.plugin, { state: { regionState: tslib_1.__assign(tslib_1.__assign({}, this.plugin.layout.state.regionState), { left: 'collapsed' }) } });
|
|
610
|
+
this.plugin.behaviors.layout.leftPanelTabName.next('none');
|
|
611
|
+
dataSource = this.getMoleculeSrcUrl();
|
|
612
|
+
if (dataSource) {
|
|
613
|
+
this.load({ url: dataSource.url, format: dataSource.format, assemblyId: this.initParams.assemblyId, isBinary: dataSource.isBinary });
|
|
614
|
+
}
|
|
615
|
+
// Binding to other PDB Component events
|
|
616
|
+
if (this.initParams.subscribeEvents) {
|
|
617
|
+
(0, subscribe_events_1.subscribeToComponentEvents)(this);
|
|
618
|
+
}
|
|
619
|
+
// Event handling
|
|
620
|
+
custom_events_1.CustomEvents.add(this.plugin, this.targetElement);
|
|
621
|
+
}
|
|
622
|
+
return [2 /*return*/];
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
PDBeMolstarPlugin.prototype.getMoleculeSrcUrl = function () {
|
|
628
|
+
var supportedFormats = ['mmcif', 'pdb', 'sdf'];
|
|
629
|
+
var id = this.initParams.moleculeId;
|
|
630
|
+
if (!id && !this.initParams.customData) {
|
|
631
|
+
throw new Error("Mandatory parameters missing!");
|
|
632
|
+
}
|
|
633
|
+
var query = 'full';
|
|
634
|
+
var sep = '?';
|
|
635
|
+
if (this.initParams.ligandView) {
|
|
636
|
+
var queryParams = ['data_source=pdb-h'];
|
|
637
|
+
if (!this.initParams.ligandView.label_comp_id_list) {
|
|
638
|
+
if (this.initParams.ligandView.label_comp_id) {
|
|
639
|
+
queryParams.push('label_comp_id=' + this.initParams.ligandView.label_comp_id);
|
|
640
|
+
}
|
|
641
|
+
else if (this.initParams.ligandView.auth_seq_id) {
|
|
642
|
+
queryParams.push('auth_seq_id=' + this.initParams.ligandView.auth_seq_id);
|
|
643
|
+
}
|
|
644
|
+
if (this.initParams.ligandView.auth_asym_id)
|
|
645
|
+
queryParams.push('auth_asym_id=' + this.initParams.ligandView.auth_asym_id);
|
|
646
|
+
}
|
|
647
|
+
query = 'residueSurroundings?' + queryParams.join('&');
|
|
648
|
+
sep = '&';
|
|
649
|
+
}
|
|
650
|
+
var url = "".concat(this.initParams.pdbeUrl, "model-server/v1/").concat(id, "/").concat(query).concat(sep, "encoding=").concat(this.initParams.encoding).concat(this.initParams.lowPrecisionCoords ? '&lowPrecisionCoords=1' : '');
|
|
651
|
+
var isBinary = this.initParams.encoding === 'bcif' ? true : false;
|
|
652
|
+
var format = 'mmcif';
|
|
653
|
+
if (this.initParams.customData) {
|
|
654
|
+
if (!this.initParams.customData.url || !this.initParams.customData.format) {
|
|
655
|
+
throw new Error("Provide all custom data parameters");
|
|
656
|
+
}
|
|
657
|
+
url = this.initParams.customData.url;
|
|
658
|
+
format = this.initParams.customData.format;
|
|
659
|
+
if (format === 'cif' || format === 'bcif')
|
|
660
|
+
format = 'mmcif';
|
|
661
|
+
// Validate supported format
|
|
662
|
+
if (supportedFormats.indexOf(format) === -1) {
|
|
663
|
+
throw new Error("".concat(format, " not supported."));
|
|
664
|
+
}
|
|
665
|
+
isBinary = this.initParams.customData.binary ? this.initParams.customData.binary : false;
|
|
666
|
+
}
|
|
667
|
+
return {
|
|
668
|
+
url: url,
|
|
669
|
+
format: format,
|
|
670
|
+
isBinary: isBinary
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
Object.defineProperty(PDBeMolstarPlugin.prototype, "state", {
|
|
674
|
+
get: function () {
|
|
675
|
+
return this.plugin.state.data;
|
|
676
|
+
},
|
|
677
|
+
enumerable: false,
|
|
678
|
+
configurable: true
|
|
679
|
+
});
|
|
680
|
+
PDBeMolstarPlugin.prototype.createLigandStructure = function (isBranched) {
|
|
681
|
+
var e_4, _a;
|
|
682
|
+
var _b;
|
|
683
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
684
|
+
var _c, _d, comp, e_4_1, structure, ligandQuery, ligandVis, ligandSurr, ligRef, cell, ligLoci;
|
|
685
|
+
var _this = this;
|
|
686
|
+
return tslib_1.__generator(this, function (_e) {
|
|
687
|
+
switch (_e.label) {
|
|
688
|
+
case 0:
|
|
689
|
+
if (this.assemblyRef === '')
|
|
690
|
+
return [2 /*return*/];
|
|
691
|
+
_e.label = 1;
|
|
692
|
+
case 1:
|
|
693
|
+
_e.trys.push([1, 7, 8, 13]);
|
|
694
|
+
_c = tslib_1.__asyncValues(this.plugin.managers.structure.hierarchy.currentComponentGroups);
|
|
695
|
+
_e.label = 2;
|
|
696
|
+
case 2: return [4 /*yield*/, _c.next()];
|
|
697
|
+
case 3:
|
|
698
|
+
if (!(_d = _e.sent(), !_d.done)) return [3 /*break*/, 6];
|
|
699
|
+
comp = _d.value;
|
|
700
|
+
return [4 /*yield*/, commands_1.PluginCommands.State.RemoveObject(this.plugin, { state: comp[0].cell.parent, ref: comp[0].cell.transform.ref, removeParentGhosts: true })];
|
|
701
|
+
case 4:
|
|
702
|
+
_e.sent();
|
|
703
|
+
_e.label = 5;
|
|
704
|
+
case 5: return [3 /*break*/, 2];
|
|
705
|
+
case 6: return [3 /*break*/, 13];
|
|
706
|
+
case 7:
|
|
707
|
+
e_4_1 = _e.sent();
|
|
708
|
+
e_4 = { error: e_4_1 };
|
|
709
|
+
return [3 /*break*/, 13];
|
|
710
|
+
case 8:
|
|
711
|
+
_e.trys.push([8, , 11, 12]);
|
|
712
|
+
if (!(_d && !_d.done && (_a = _c.return))) return [3 /*break*/, 10];
|
|
713
|
+
return [4 /*yield*/, _a.call(_c)];
|
|
714
|
+
case 9:
|
|
715
|
+
_e.sent();
|
|
716
|
+
_e.label = 10;
|
|
717
|
+
case 10: return [3 /*break*/, 12];
|
|
718
|
+
case 11:
|
|
719
|
+
if (e_4) throw e_4.error;
|
|
720
|
+
return [7 /*endfinally*/];
|
|
721
|
+
case 12: return [7 /*endfinally*/];
|
|
722
|
+
case 13:
|
|
723
|
+
structure = this.state.select(this.assemblyRef)[0];
|
|
724
|
+
if (isBranched) {
|
|
725
|
+
ligandQuery = helpers_1.LigandView.branchedQuery((_b = this.initParams.ligandView) === null || _b === void 0 ? void 0 : _b.label_comp_id_list);
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
ligandQuery = helpers_1.LigandView.query(this.initParams.ligandView);
|
|
729
|
+
}
|
|
730
|
+
return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentFromExpression(structure, ligandQuery.core, 'pivot', { label: 'Ligand' })];
|
|
731
|
+
case 14:
|
|
732
|
+
ligandVis = _e.sent();
|
|
733
|
+
if (!ligandVis) return [3 /*break*/, 16];
|
|
734
|
+
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' })];
|
|
735
|
+
case 15:
|
|
736
|
+
_e.sent();
|
|
737
|
+
_e.label = 16;
|
|
738
|
+
case 16: return [4 /*yield*/, this.plugin.builders.structure.tryCreateComponentFromExpression(structure, ligandQuery.surroundings, 'rest', { label: 'Surroundings' })];
|
|
739
|
+
case 17:
|
|
740
|
+
ligandSurr = _e.sent();
|
|
741
|
+
if (!ligandSurr) return [3 /*break*/, 19];
|
|
742
|
+
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 } })];
|
|
743
|
+
case 18:
|
|
744
|
+
_e.sent();
|
|
745
|
+
_e.label = 19;
|
|
746
|
+
case 19:
|
|
747
|
+
ligRef = mol_state_2.StateSelection.findTagInSubtree(this.plugin.state.data.tree, mol_state_1.StateTransform.RootRef, 'ligand-vis');
|
|
748
|
+
if (!ligRef)
|
|
749
|
+
return [2 /*return*/];
|
|
750
|
+
cell = this.plugin.state.data.cells.get(ligRef);
|
|
751
|
+
if (cell) {
|
|
752
|
+
ligLoci = cell.obj.data.repr.getLoci();
|
|
753
|
+
this.plugin.managers.structure.focus.setFromLoci(ligLoci);
|
|
754
|
+
setTimeout(function () {
|
|
755
|
+
var _a;
|
|
756
|
+
// focus-add is not handled in camera behavior, doing it here
|
|
757
|
+
var current = (_a = _this.plugin.managers.structure.focus.current) === null || _a === void 0 ? void 0 : _a.loci;
|
|
758
|
+
if (current)
|
|
759
|
+
_this.plugin.managers.camera.focusLoci(current);
|
|
760
|
+
}, 500);
|
|
761
|
+
}
|
|
762
|
+
return [2 /*return*/];
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
};
|
|
767
|
+
PDBeMolstarPlugin.prototype.load = function (_a, fullLoad) {
|
|
768
|
+
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;
|
|
769
|
+
if (fullLoad === void 0) { fullLoad = true; }
|
|
770
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
771
|
+
var isHetView, downloadOptions, isBranchedView, data, trajectory, model, pivotIndex, pivot, asm, defaultMapParams, pdbeMapParams;
|
|
772
|
+
return tslib_1.__generator(this, function (_e) {
|
|
773
|
+
switch (_e.label) {
|
|
774
|
+
case 0:
|
|
775
|
+
if (fullLoad)
|
|
776
|
+
this.clear();
|
|
777
|
+
isHetView = this.initParams.ligandView ? true : false;
|
|
778
|
+
downloadOptions = void 0;
|
|
779
|
+
isBranchedView = false;
|
|
780
|
+
if (this.initParams.ligandView && this.initParams.ligandView.label_comp_id_list) {
|
|
781
|
+
isBranchedView = true;
|
|
782
|
+
downloadOptions = { body: JSON.stringify(this.initParams.ligandView.label_comp_id_list), headers: [['Content-type', 'application/json']] };
|
|
783
|
+
}
|
|
784
|
+
return [4 /*yield*/, this.plugin.builders.data.download({ url: assets_1.Asset.Url(url, downloadOptions), isBinary: isBinary }, { state: { isGhost: true } })];
|
|
785
|
+
case 1:
|
|
786
|
+
data = _e.sent();
|
|
787
|
+
return [4 /*yield*/, this.plugin.builders.structure.parseTrajectory(data, format)];
|
|
788
|
+
case 2:
|
|
789
|
+
trajectory = _e.sent();
|
|
790
|
+
if (!!isHetView) return [3 /*break*/, 4];
|
|
791
|
+
return [4 /*yield*/, this.plugin.builders.structure.hierarchy.applyPreset(trajectory, this.initParams.defaultPreset, {
|
|
792
|
+
structure: assemblyId ? (assemblyId === 'preferred') ? void 0 : { name: 'assembly', params: { id: assemblyId } } : { name: 'model', params: {} },
|
|
793
|
+
showUnitcell: false,
|
|
794
|
+
representationPreset: 'auto'
|
|
795
|
+
})];
|
|
796
|
+
case 3:
|
|
797
|
+
_e.sent();
|
|
798
|
+
if (this.initParams.hideStructure || this.initParams.visualStyle) {
|
|
799
|
+
this.applyVisualParams();
|
|
800
|
+
}
|
|
801
|
+
return [3 /*break*/, 7];
|
|
802
|
+
case 4: return [4 /*yield*/, this.plugin.builders.structure.createModel(trajectory)];
|
|
803
|
+
case 5:
|
|
804
|
+
model = _e.sent();
|
|
805
|
+
return [4 /*yield*/, this.plugin.builders.structure.createStructure(model, { name: 'model', params: {} })];
|
|
806
|
+
case 6:
|
|
807
|
+
_e.sent();
|
|
808
|
+
_e.label = 7;
|
|
809
|
+
case 7:
|
|
810
|
+
// show selection if param is set
|
|
811
|
+
if (this.initParams.selection) {
|
|
812
|
+
this.visual.select(this.initParams.selection);
|
|
813
|
+
}
|
|
814
|
+
pivotIndex = this.plugin.managers.structure.hierarchy.selection.structures.length - 1;
|
|
815
|
+
pivot = this.plugin.managers.structure.hierarchy.selection.structures[pivotIndex];
|
|
816
|
+
if (pivot && pivot.cell.parent)
|
|
817
|
+
this.assemblyRef = pivot.cell.transform.ref;
|
|
818
|
+
if (!this.initParams.loadMaps) return [3 /*break*/, 9];
|
|
819
|
+
if (this.assemblyRef === '')
|
|
820
|
+
return [2 /*return*/];
|
|
821
|
+
asm = this.state.select(this.assemblyRef)[0].obj;
|
|
822
|
+
defaultMapParams = transformers_1.InitVolumeStreaming.createDefaultParams(asm, this.plugin);
|
|
823
|
+
pdbeMapParams = helpers_1.PDBeVolumes.mapParams(defaultMapParams, this.initParams.mapSettings, '');
|
|
824
|
+
if (!pdbeMapParams) return [3 /*break*/, 9];
|
|
825
|
+
return [4 /*yield*/, this.plugin.runTask(this.state.applyAction(transformers_1.InitVolumeStreaming, pdbeMapParams, this.assemblyRef))];
|
|
826
|
+
case 8:
|
|
827
|
+
_e.sent();
|
|
828
|
+
if (pdbeMapParams.method !== 'em' && !this.initParams.ligandView)
|
|
829
|
+
helpers_1.PDBeVolumes.displayUsibilityMessage(this.plugin);
|
|
830
|
+
_e.label = 9;
|
|
831
|
+
case 9:
|
|
832
|
+
if (!isHetView) return [3 /*break*/, 11];
|
|
833
|
+
return [4 /*yield*/, this.createLigandStructure(isBranchedView)];
|
|
834
|
+
case 10:
|
|
835
|
+
_e.sent();
|
|
836
|
+
_e.label = 11;
|
|
837
|
+
case 11:
|
|
838
|
+
this.events.loadComplete.next(true);
|
|
839
|
+
return [2 /*return*/];
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
};
|
|
844
|
+
PDBeMolstarPlugin.prototype.getLociForParams = function (params, structureNumber) {
|
|
845
|
+
var assemblyRef = this.assemblyRef;
|
|
846
|
+
if (structureNumber) {
|
|
847
|
+
assemblyRef = this.plugin.managers.structure.hierarchy.current.structures[structureNumber - 1].cell.transform.ref;
|
|
848
|
+
}
|
|
849
|
+
if (assemblyRef === '')
|
|
850
|
+
return loci_1.EmptyLoci;
|
|
851
|
+
var data = this.plugin.state.data.select(assemblyRef)[0].obj.data;
|
|
852
|
+
if (!data)
|
|
853
|
+
return loci_1.EmptyLoci;
|
|
854
|
+
return helpers_1.QueryHelper.getInteractivityLoci(params, data);
|
|
855
|
+
};
|
|
856
|
+
PDBeMolstarPlugin.prototype.getLociByPLDDT = function (score, structureNumber) {
|
|
857
|
+
var assemblyRef = this.assemblyRef;
|
|
858
|
+
if (structureNumber) {
|
|
859
|
+
assemblyRef = this.plugin.managers.structure.hierarchy.current.structures[structureNumber - 1].cell.transform.ref;
|
|
860
|
+
}
|
|
861
|
+
if (assemblyRef === '')
|
|
862
|
+
return loci_1.EmptyLoci;
|
|
863
|
+
var data = this.plugin.state.data.select(assemblyRef)[0].obj.data;
|
|
864
|
+
if (!data)
|
|
865
|
+
return loci_1.EmptyLoci;
|
|
866
|
+
return helpers_1.AlphafoldView.getLociByPLDDT(score, data);
|
|
867
|
+
};
|
|
868
|
+
PDBeMolstarPlugin.prototype.normalizeColor = function (colorVal, defaultColor) {
|
|
869
|
+
var color = color_1.Color.fromRgb(170, 170, 170);
|
|
870
|
+
try {
|
|
871
|
+
if (typeof colorVal.r !== 'undefined') {
|
|
872
|
+
color = color_1.Color.fromRgb(colorVal.r, colorVal.g, colorVal.b);
|
|
873
|
+
}
|
|
874
|
+
else if (colorVal[0] === '#') {
|
|
875
|
+
color = (0, color_1.Color)(Number("0x".concat(colorVal.substr(1))));
|
|
876
|
+
}
|
|
877
|
+
else {
|
|
878
|
+
color = (0, color_1.Color)(colorVal);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
catch (e) {
|
|
882
|
+
if (defaultColor)
|
|
883
|
+
color = defaultColor;
|
|
884
|
+
}
|
|
885
|
+
return color;
|
|
886
|
+
};
|
|
887
|
+
PDBeMolstarPlugin.prototype.clear = function () {
|
|
888
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
889
|
+
return tslib_1.__generator(this, function (_a) {
|
|
890
|
+
this.plugin.clear();
|
|
891
|
+
this.assemblyRef = '';
|
|
892
|
+
this.selectedParams = void 0;
|
|
893
|
+
this.isHighlightColorUpdated = false;
|
|
894
|
+
this.isSelectedColorUpdated = false;
|
|
895
|
+
return [2 /*return*/];
|
|
896
|
+
});
|
|
897
|
+
});
|
|
898
|
+
};
|
|
899
|
+
return PDBeMolstarPlugin;
|
|
900
|
+
}());
|
|
901
|
+
window.PDBeMolstarPlugin = PDBeMolstarPlugin;
|