molstar 3.0.0-dev.8 → 3.0.0-dev.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/build/viewer/molstar.js +1 -1
  2. package/lib/apps/viewer/app.d.ts +230 -0
  3. package/lib/apps/viewer/app.js +515 -0
  4. package/lib/apps/viewer/index.d.ts +2 -225
  5. package/lib/apps/viewer/index.js +2 -509
  6. package/lib/commonjs/apps/viewer/app.d.ts +230 -0
  7. package/lib/commonjs/apps/viewer/app.js +521 -0
  8. package/lib/commonjs/apps/viewer/index.d.ts +2 -225
  9. package/lib/commonjs/apps/viewer/index.js +2 -512
  10. package/lib/commonjs/mol-canvas3d/canvas3d.js +1 -1
  11. package/lib/commonjs/mol-io/reader/mol2/parser.d.ts +1 -1
  12. package/lib/commonjs/mol-io/reader/mol2/parser.js +33 -3
  13. package/lib/commonjs/mol-io/reader/mol2/schema.d.ts +12 -1
  14. package/lib/commonjs/mol-io/reader/mol2/schema.js +1 -1
  15. package/lib/commonjs/mol-model/structure/structure/element/stats.js +8 -0
  16. package/lib/commonjs/mol-model/structure/structure/unit/bonds/common.d.ts +2 -1
  17. package/lib/commonjs/mol-model/structure/structure/unit/bonds/common.js +11 -2
  18. package/lib/commonjs/mol-model/structure/structure/unit/bonds/inter-compute.d.ts +1 -1
  19. package/lib/commonjs/mol-model/structure/structure/unit/bonds/inter-compute.js +20 -10
  20. package/lib/commonjs/mol-model/structure/structure/unit/bonds/intra-compute.d.ts +1 -1
  21. package/lib/commonjs/mol-model/structure/structure/unit/bonds/intra-compute.js +21 -11
  22. package/lib/commonjs/mol-model-formats/structure/mol2.d.ts +1 -1
  23. package/lib/commonjs/mol-model-formats/structure/mol2.js +37 -7
  24. package/lib/commonjs/mol-model-formats/structure/property/bonds/index-pair.d.ts +18 -1
  25. package/lib/commonjs/mol-model-formats/structure/property/bonds/index-pair.js +18 -5
  26. package/lib/commonjs/mol-plugin/config.d.ts +1 -1
  27. package/lib/commonjs/mol-plugin-state/actions/structure.d.ts +1 -0
  28. package/lib/commonjs/mol-plugin-state/actions/structure.js +41 -8
  29. package/lib/mol-canvas3d/canvas3d.js +1 -1
  30. package/lib/mol-io/reader/mol2/parser.d.ts +1 -1
  31. package/lib/mol-io/reader/mol2/parser.js +33 -3
  32. package/lib/mol-io/reader/mol2/schema.d.ts +12 -1
  33. package/lib/mol-io/reader/mol2/schema.js +1 -1
  34. package/lib/mol-model/structure/structure/element/stats.js +8 -0
  35. package/lib/mol-model/structure/structure/unit/bonds/common.d.ts +2 -1
  36. package/lib/mol-model/structure/structure/unit/bonds/common.js +9 -1
  37. package/lib/mol-model/structure/structure/unit/bonds/inter-compute.d.ts +1 -1
  38. package/lib/mol-model/structure/structure/unit/bonds/inter-compute.js +21 -11
  39. package/lib/mol-model/structure/structure/unit/bonds/intra-compute.d.ts +1 -1
  40. package/lib/mol-model/structure/structure/unit/bonds/intra-compute.js +22 -12
  41. package/lib/mol-model-formats/structure/mol2.d.ts +1 -1
  42. package/lib/mol-model-formats/structure/mol2.js +37 -7
  43. package/lib/mol-model-formats/structure/property/bonds/index-pair.d.ts +18 -1
  44. package/lib/mol-model-formats/structure/property/bonds/index-pair.js +18 -5
  45. package/lib/mol-plugin/config.d.ts +1 -1
  46. package/lib/mol-plugin/version.js +2 -2
  47. package/lib/mol-plugin-state/actions/structure.d.ts +1 -0
  48. package/lib/mol-plugin-state/actions/structure.js +41 -8
  49. package/package.json +1 -1
@@ -1,519 +1,12 @@
1
1
  /**
2
- * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author David Sehnal <david.sehnal@gmail.com>
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
6
6
  */
7
- import { __assign, __awaiter, __generator, __spreadArray } from "tslib";
8
- import { ANVILMembraneOrientation } from '../../extensions/anvil/behavior';
9
- import { CellPack } from '../../extensions/cellpack';
10
- import { DnatcoConfalPyramids } from '../../extensions/dnatco';
11
- import { G3DFormat, G3dProvider } from '../../extensions/g3d/format';
12
- import { GeometryExport } from '../../extensions/geo-export';
13
- import { MAQualityAssessment } from '../../extensions/model-archive/quality-assessment/behavior';
14
- import { QualityAssessmentPLDDTPreset, QualityAssessmentQmeanPreset } from '../../extensions/model-archive/quality-assessment/behavior';
15
- import { QualityAssessment } from '../../extensions/model-archive/quality-assessment/prop';
16
- import { Mp4Export } from '../../extensions/mp4-export';
17
- import { PDBeStructureQualityReport } from '../../extensions/pdbe';
18
- import { RCSBAssemblySymmetry, RCSBValidationReport } from '../../extensions/rcsb';
19
- import { DownloadStructure, PdbDownloadProvider } from '../../mol-plugin-state/actions/structure';
20
- import { DownloadDensity } from '../../mol-plugin-state/actions/volume';
21
- import { PresetStructureRepresentations, StructureRepresentationPresetProvider } from '../../mol-plugin-state/builder/structure/representation-preset';
22
- import { createVolumeRepresentationParams } from '../../mol-plugin-state/helpers/volume-representation-params';
23
- import { StateTransforms } from '../../mol-plugin-state/transforms';
24
- import { TrajectoryFromModelAndCoordinates } from '../../mol-plugin-state/transforms/model';
25
- import { createPluginUI } from '../../mol-plugin-ui';
26
- import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
27
- import { PluginCommands } from '../../mol-plugin/commands';
28
- import { PluginConfig } from '../../mol-plugin/config';
29
- import { PluginSpec } from '../../mol-plugin/spec';
30
- import { StateObjectRef } from '../../mol-state';
31
- import { Asset } from '../../mol-util/assets';
32
- import '../../mol-util/polyfill';
33
- import { ObjectKeys } from '../../mol-util/type-helpers';
34
7
  import './embedded.html';
35
8
  import './favicon.ico';
36
9
  import './index.html';
37
10
  require('mol-plugin-ui/skin/light.scss');
38
- export { PLUGIN_VERSION as version } from '../../mol-plugin/version';
39
- export { setDebugMode, setProductionMode } from '../../mol-util/debug';
40
- var CustomFormats = [
41
- ['g3d', G3dProvider]
42
- ];
43
- var Extensions = {
44
- 'cellpack': PluginSpec.Behavior(CellPack),
45
- 'dnatco-confal-pyramids': PluginSpec.Behavior(DnatcoConfalPyramids),
46
- 'pdbe-structure-quality-report': PluginSpec.Behavior(PDBeStructureQualityReport),
47
- 'rcsb-assembly-symmetry': PluginSpec.Behavior(RCSBAssemblySymmetry),
48
- 'rcsb-validation-report': PluginSpec.Behavior(RCSBValidationReport),
49
- 'anvil-membrane-orientation': PluginSpec.Behavior(ANVILMembraneOrientation),
50
- 'g3d': PluginSpec.Behavior(G3DFormat),
51
- 'mp4-export': PluginSpec.Behavior(Mp4Export),
52
- 'geo-export': PluginSpec.Behavior(GeometryExport),
53
- 'ma-quality-assessment': PluginSpec.Behavior(MAQualityAssessment),
54
- };
55
- var DefaultViewerOptions = {
56
- customFormats: CustomFormats,
57
- extensions: ObjectKeys(Extensions),
58
- layoutIsExpanded: true,
59
- layoutShowControls: true,
60
- layoutShowRemoteState: true,
61
- layoutControlsDisplay: 'reactive',
62
- layoutShowSequence: true,
63
- layoutShowLog: true,
64
- layoutShowLeftPanel: true,
65
- collapseLeftPanel: false,
66
- collapseRightPanel: false,
67
- disableAntialiasing: PluginConfig.General.DisableAntialiasing.defaultValue,
68
- pixelScale: PluginConfig.General.PixelScale.defaultValue,
69
- pickScale: PluginConfig.General.PickScale.defaultValue,
70
- pickPadding: PluginConfig.General.PickPadding.defaultValue,
71
- enableWboit: PluginConfig.General.EnableWboit.defaultValue,
72
- preferWebgl1: PluginConfig.General.PreferWebGl1.defaultValue,
73
- viewportShowExpand: PluginConfig.Viewport.ShowExpand.defaultValue,
74
- viewportShowControls: PluginConfig.Viewport.ShowControls.defaultValue,
75
- viewportShowSettings: PluginConfig.Viewport.ShowSettings.defaultValue,
76
- viewportShowSelectionMode: PluginConfig.Viewport.ShowSelectionMode.defaultValue,
77
- viewportShowAnimation: PluginConfig.Viewport.ShowAnimation.defaultValue,
78
- pluginStateServer: PluginConfig.State.DefaultServer.defaultValue,
79
- volumeStreamingServer: PluginConfig.VolumeStreaming.DefaultServer.defaultValue,
80
- volumeStreamingDisabled: !PluginConfig.VolumeStreaming.Enabled.defaultValue,
81
- pdbProvider: PluginConfig.Download.DefaultPdbProvider.defaultValue,
82
- emdbProvider: PluginConfig.Download.DefaultEmdbProvider.defaultValue,
83
- };
84
- var Viewer = /** @class */ (function () {
85
- function Viewer(plugin) {
86
- this.plugin = plugin;
87
- }
88
- Viewer.create = function (elementOrId, options) {
89
- var _a;
90
- if (options === void 0) { options = {}; }
91
- return __awaiter(this, void 0, void 0, function () {
92
- var o, defaultSpec, spec, element, plugin;
93
- return __generator(this, function (_b) {
94
- switch (_b.label) {
95
- case 0:
96
- o = __assign(__assign({}, DefaultViewerOptions), options);
97
- defaultSpec = DefaultPluginUISpec();
98
- spec = {
99
- actions: defaultSpec.actions,
100
- behaviors: __spreadArray(__spreadArray([], defaultSpec.behaviors, true), o.extensions.map(function (e) { return Extensions[e]; }), true),
101
- animations: __spreadArray([], defaultSpec.animations || [], true),
102
- customParamEditors: defaultSpec.customParamEditors,
103
- customFormats: o === null || o === void 0 ? void 0 : o.customFormats,
104
- layout: {
105
- initial: {
106
- isExpanded: o.layoutIsExpanded,
107
- showControls: o.layoutShowControls,
108
- controlsDisplay: o.layoutControlsDisplay,
109
- regionState: {
110
- bottom: 'full',
111
- left: o.collapseLeftPanel ? 'collapsed' : 'full',
112
- right: o.collapseRightPanel ? 'hidden' : 'full',
113
- top: 'full',
114
- }
115
- },
116
- },
117
- components: __assign(__assign({}, defaultSpec.components), { controls: __assign(__assign({}, (_a = defaultSpec.components) === null || _a === void 0 ? void 0 : _a.controls), { top: o.layoutShowSequence ? undefined : 'none', bottom: o.layoutShowLog ? undefined : 'none', left: o.layoutShowLeftPanel ? undefined : 'none' }), remoteState: o.layoutShowRemoteState ? 'default' : 'none' }),
118
- config: [
119
- [PluginConfig.General.DisableAntialiasing, o.disableAntialiasing],
120
- [PluginConfig.General.PixelScale, o.pixelScale],
121
- [PluginConfig.General.PickScale, o.pickScale],
122
- [PluginConfig.General.PickPadding, o.pickPadding],
123
- [PluginConfig.General.EnableWboit, o.enableWboit],
124
- [PluginConfig.General.PreferWebGl1, o.preferWebgl1],
125
- [PluginConfig.Viewport.ShowExpand, o.viewportShowExpand],
126
- [PluginConfig.Viewport.ShowControls, o.viewportShowControls],
127
- [PluginConfig.Viewport.ShowSettings, o.viewportShowSettings],
128
- [PluginConfig.Viewport.ShowSelectionMode, o.viewportShowSelectionMode],
129
- [PluginConfig.Viewport.ShowAnimation, o.viewportShowAnimation],
130
- [PluginConfig.State.DefaultServer, o.pluginStateServer],
131
- [PluginConfig.State.CurrentServer, o.pluginStateServer],
132
- [PluginConfig.VolumeStreaming.DefaultServer, o.volumeStreamingServer],
133
- [PluginConfig.VolumeStreaming.Enabled, !o.volumeStreamingDisabled],
134
- [PluginConfig.Download.DefaultPdbProvider, o.pdbProvider],
135
- [PluginConfig.Download.DefaultEmdbProvider, o.emdbProvider],
136
- [PluginConfig.Structure.DefaultRepresentationPreset, ViewerAutoPreset.id],
137
- ]
138
- };
139
- element = typeof elementOrId === 'string'
140
- ? document.getElementById(elementOrId)
141
- : elementOrId;
142
- if (!element)
143
- throw new Error("Could not get element with id '".concat(elementOrId, "'"));
144
- return [4 /*yield*/, createPluginUI(element, spec, {
145
- onBeforeUIRender: function (plugin) {
146
- // the preset needs to be added before the UI renders otherwise
147
- // "Download Structure" wont be able to pick it up
148
- plugin.builders.structure.representation.registerPreset(ViewerAutoPreset);
149
- }
150
- })];
151
- case 1:
152
- plugin = _b.sent();
153
- return [2 /*return*/, new Viewer(plugin)];
154
- }
155
- });
156
- });
157
- };
158
- Viewer.prototype.setRemoteSnapshot = function (id) {
159
- var url = "".concat(this.plugin.config.get(PluginConfig.State.CurrentServer), "/get/").concat(id);
160
- return PluginCommands.State.Snapshots.Fetch(this.plugin, { url: url });
161
- };
162
- Viewer.prototype.loadSnapshotFromUrl = function (url, type) {
163
- return PluginCommands.State.Snapshots.OpenUrl(this.plugin, { url: url, type: type });
164
- };
165
- Viewer.prototype.loadStructureFromUrl = function (url, format, isBinary, options) {
166
- if (format === void 0) { format = 'mmcif'; }
167
- if (isBinary === void 0) { isBinary = false; }
168
- var params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj, this.plugin);
169
- return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
170
- source: {
171
- name: 'url',
172
- params: {
173
- url: Asset.Url(url),
174
- format: format,
175
- isBinary: isBinary,
176
- options: __assign(__assign({}, params.source.params.options), { representationParams: options === null || options === void 0 ? void 0 : options.representationParams }),
177
- }
178
- }
179
- }));
180
- };
181
- Viewer.prototype.loadAllModelsOrAssemblyFromUrl = function (url, format, isBinary, options) {
182
- if (format === void 0) { format = 'mmcif'; }
183
- if (isBinary === void 0) { isBinary = false; }
184
- return __awaiter(this, void 0, void 0, function () {
185
- var plugin, data, trajectory;
186
- return __generator(this, function (_a) {
187
- switch (_a.label) {
188
- case 0:
189
- plugin = this.plugin;
190
- return [4 /*yield*/, plugin.builders.data.download({ url: url, isBinary: isBinary }, { state: { isGhost: true } })];
191
- case 1:
192
- data = _a.sent();
193
- return [4 /*yield*/, plugin.builders.structure.parseTrajectory(data, format)];
194
- case 2:
195
- trajectory = _a.sent();
196
- return [4 /*yield*/, this.plugin.builders.structure.hierarchy.applyPreset(trajectory, 'all-models', { useDefaultIfSingleModel: true, representationPresetParams: options === null || options === void 0 ? void 0 : options.representationParams })];
197
- case 3:
198
- _a.sent();
199
- return [2 /*return*/];
200
- }
201
- });
202
- });
203
- };
204
- Viewer.prototype.loadStructureFromData = function (data, format, options) {
205
- return __awaiter(this, void 0, void 0, function () {
206
- var _data, trajectory;
207
- return __generator(this, function (_a) {
208
- switch (_a.label) {
209
- case 0: return [4 /*yield*/, this.plugin.builders.data.rawData({ data: data, label: options === null || options === void 0 ? void 0 : options.dataLabel })];
210
- case 1:
211
- _data = _a.sent();
212
- return [4 /*yield*/, this.plugin.builders.structure.parseTrajectory(_data, format)];
213
- case 2:
214
- trajectory = _a.sent();
215
- return [4 /*yield*/, this.plugin.builders.structure.hierarchy.applyPreset(trajectory, 'default')];
216
- case 3:
217
- _a.sent();
218
- return [2 /*return*/];
219
- }
220
- });
221
- });
222
- };
223
- Viewer.prototype.loadPdb = function (pdb, options) {
224
- var params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj, this.plugin);
225
- var provider = this.plugin.config.get(PluginConfig.Download.DefaultPdbProvider);
226
- return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
227
- source: {
228
- name: 'pdb',
229
- params: {
230
- provider: {
231
- id: pdb,
232
- server: {
233
- name: provider,
234
- params: PdbDownloadProvider[provider].defaultValue
235
- }
236
- },
237
- options: __assign(__assign({}, params.source.params.options), { representationParams: options === null || options === void 0 ? void 0 : options.representationParams }),
238
- }
239
- }
240
- }));
241
- };
242
- Viewer.prototype.loadPdbDev = function (pdbDev) {
243
- var params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj, this.plugin);
244
- return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
245
- source: {
246
- name: 'pdb-dev',
247
- params: {
248
- provider: {
249
- id: pdbDev,
250
- encoding: 'bcif',
251
- },
252
- options: params.source.params.options,
253
- }
254
- }
255
- }));
256
- };
257
- Viewer.prototype.loadEmdb = function (emdb, options) {
258
- var _a;
259
- var provider = this.plugin.config.get(PluginConfig.Download.DefaultEmdbProvider);
260
- return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadDensity, {
261
- source: {
262
- name: 'pdb-emd-ds',
263
- params: {
264
- provider: {
265
- id: emdb,
266
- server: provider,
267
- },
268
- detail: (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : 3,
269
- }
270
- }
271
- }));
272
- };
273
- Viewer.prototype.loadAlphaFoldDb = function (afdb) {
274
- var params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj, this.plugin);
275
- return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
276
- source: {
277
- name: 'alphafolddb',
278
- params: {
279
- id: afdb,
280
- options: __assign(__assign({}, params.source.params.options), { representation: 'preset-structure-representation-ma-quality-assessment-plddt' }),
281
- }
282
- }
283
- }));
284
- };
285
- Viewer.prototype.loadModelArchive = function (id) {
286
- var params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj, this.plugin);
287
- return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
288
- source: {
289
- name: 'modelarchive',
290
- params: {
291
- id: id,
292
- options: params.source.params.options,
293
- }
294
- }
295
- }));
296
- };
297
- /**
298
- * @example Load X-ray density from volume server
299
- viewer.loadVolumeFromUrl({
300
- url: 'https://www.ebi.ac.uk/pdbe/densities/x-ray/1tqn/cell?detail=3',
301
- format: 'dscif',
302
- isBinary: true
303
- }, [{
304
- type: 'relative',
305
- value: 1.5,
306
- color: 0x3362B2
307
- }, {
308
- type: 'relative',
309
- value: 3,
310
- color: 0x33BB33,
311
- volumeIndex: 1
312
- }, {
313
- type: 'relative',
314
- value: -3,
315
- color: 0xBB3333,
316
- volumeIndex: 1
317
- }], {
318
- entryId: ['2FO-FC', 'FO-FC'],
319
- isLazy: true
320
- });
321
- * *********************
322
- * @example Load EM density from volume server
323
- viewer.loadVolumeFromUrl({
324
- url: 'https://maps.rcsb.org/em/emd-30210/cell?detail=6',
325
- format: 'dscif',
326
- isBinary: true
327
- }, [{
328
- type: 'relative',
329
- value: 1,
330
- color: 0x3377aa
331
- }], {
332
- entryId: 'EMD-30210',
333
- isLazy: true
334
- });
335
- */
336
- Viewer.prototype.loadVolumeFromUrl = function (_a, isovalues, options) {
337
- var url = _a.url, format = _a.format, isBinary = _a.isBinary;
338
- return __awaiter(this, void 0, void 0, function () {
339
- var plugin, update;
340
- var _this = this;
341
- return __generator(this, function (_b) {
342
- plugin = this.plugin;
343
- if (!plugin.dataFormats.get(format)) {
344
- throw new Error("Unknown density format: ".concat(format));
345
- }
346
- if (options === null || options === void 0 ? void 0 : options.isLazy) {
347
- update = this.plugin.build();
348
- update.toRoot().apply(StateTransforms.Data.LazyVolume, {
349
- url: url,
350
- format: format,
351
- entryId: options === null || options === void 0 ? void 0 : options.entryId,
352
- isBinary: isBinary,
353
- isovalues: isovalues.map(function (v) { return (__assign({ alpha: 1, volumeIndex: 0 }, v)); })
354
- });
355
- return [2 /*return*/, update.commit()];
356
- }
357
- return [2 /*return*/, plugin.dataTransaction(function () { return __awaiter(_this, void 0, void 0, function () {
358
- var data, parsed, firstVolume, repr, _i, isovalues_1, iso;
359
- var _a, _b, _c, _d;
360
- return __generator(this, function (_e) {
361
- switch (_e.label) {
362
- case 0: return [4 /*yield*/, plugin.builders.data.download({ url: url, isBinary: isBinary }, { state: { isGhost: true } })];
363
- case 1:
364
- data = _e.sent();
365
- return [4 /*yield*/, plugin.dataFormats.get(format).parse(plugin, data, { entryId: options === null || options === void 0 ? void 0 : options.entryId })];
366
- case 2:
367
- parsed = _e.sent();
368
- firstVolume = (parsed.volume || parsed.volumes[0]);
369
- if (!(firstVolume === null || firstVolume === void 0 ? void 0 : firstVolume.isOk))
370
- throw new Error('Failed to parse any volume.');
371
- repr = plugin.build();
372
- for (_i = 0, isovalues_1 = isovalues; _i < isovalues_1.length; _i++) {
373
- iso = isovalues_1[_i];
374
- repr
375
- .to((_c = (_a = parsed.volumes) === null || _a === void 0 ? void 0 : _a[(_b = iso.volumeIndex) !== null && _b !== void 0 ? _b : 0]) !== null && _c !== void 0 ? _c : parsed.volume)
376
- .apply(StateTransforms.Representation.VolumeRepresentation3D, createVolumeRepresentationParams(this.plugin, firstVolume.data, {
377
- type: 'isosurface',
378
- typeParams: { alpha: (_d = iso.alpha) !== null && _d !== void 0 ? _d : 1, isoValue: iso.type === 'absolute' ? { kind: 'absolute', absoluteValue: iso.value } : { kind: 'relative', relativeValue: iso.value } },
379
- color: 'uniform',
380
- colorParams: { value: iso.color }
381
- }));
382
- }
383
- return [4 /*yield*/, repr.commit()];
384
- case 3:
385
- _e.sent();
386
- return [2 /*return*/];
387
- }
388
- });
389
- }); })];
390
- });
391
- });
392
- };
393
- /**
394
- * @example
395
- * viewer.loadTrajectory({
396
- * model: { kind: 'model-url', url: 'villin.gro', format: 'gro' },
397
- * coordinates: { kind: 'coordinates-url', url: 'villin.xtc', format: 'xtc', isBinary: true },
398
- * preset: 'all-models' // or 'default'
399
- * });
400
- */
401
- Viewer.prototype.loadTrajectory = function (params) {
402
- var _a, _b;
403
- return __awaiter(this, void 0, void 0, function () {
404
- var plugin, model, coords, data, _c, trajectory_1, data, _d, provider, data, _e, provider, trajectory, preset;
405
- return __generator(this, function (_f) {
406
- switch (_f.label) {
407
- case 0:
408
- plugin = this.plugin;
409
- if (!(params.model.kind === 'model-data' || params.model.kind === 'model-url')) return [3 /*break*/, 7];
410
- if (!(params.model.kind === 'model-data')) return [3 /*break*/, 2];
411
- return [4 /*yield*/, plugin.builders.data.rawData({ data: params.model.data, label: params.modelLabel })];
412
- case 1:
413
- _c = _f.sent();
414
- return [3 /*break*/, 4];
415
- case 2: return [4 /*yield*/, plugin.builders.data.download({ url: params.model.url, isBinary: params.model.isBinary, label: params.modelLabel })];
416
- case 3:
417
- _c = _f.sent();
418
- _f.label = 4;
419
- case 4:
420
- data = _c;
421
- return [4 /*yield*/, plugin.builders.structure.parseTrajectory(data, (_a = params.model.format) !== null && _a !== void 0 ? _a : 'mmcif')];
422
- case 5:
423
- trajectory_1 = _f.sent();
424
- return [4 /*yield*/, plugin.builders.structure.createModel(trajectory_1)];
425
- case 6:
426
- model = _f.sent();
427
- return [3 /*break*/, 13];
428
- case 7:
429
- if (!(params.model.kind === 'topology-data')) return [3 /*break*/, 9];
430
- return [4 /*yield*/, plugin.builders.data.rawData({ data: params.model.data, label: params.modelLabel })];
431
- case 8:
432
- _d = _f.sent();
433
- return [3 /*break*/, 11];
434
- case 9: return [4 /*yield*/, plugin.builders.data.download({ url: params.model.url, isBinary: params.model.isBinary, label: params.modelLabel })];
435
- case 10:
436
- _d = _f.sent();
437
- _f.label = 11;
438
- case 11:
439
- data = _d;
440
- provider = plugin.dataFormats.get(params.model.format);
441
- return [4 /*yield*/, provider.parse(plugin, data)];
442
- case 12:
443
- model = _f.sent();
444
- _f.label = 13;
445
- case 13:
446
- if (!(params.coordinates.kind === 'coordinates-data')) return [3 /*break*/, 15];
447
- return [4 /*yield*/, plugin.builders.data.rawData({ data: params.coordinates.data, label: params.coordinatesLabel })];
448
- case 14:
449
- _e = _f.sent();
450
- return [3 /*break*/, 17];
451
- case 15: return [4 /*yield*/, plugin.builders.data.download({ url: params.coordinates.url, isBinary: params.coordinates.isBinary, label: params.coordinatesLabel })];
452
- case 16:
453
- _e = _f.sent();
454
- _f.label = 17;
455
- case 17:
456
- data = _e;
457
- provider = plugin.dataFormats.get(params.coordinates.format);
458
- return [4 /*yield*/, provider.parse(plugin, data)];
459
- case 18:
460
- coords = _f.sent();
461
- return [4 /*yield*/, plugin.build().toRoot()
462
- .apply(TrajectoryFromModelAndCoordinates, {
463
- modelRef: model.ref,
464
- coordinatesRef: coords.ref
465
- }, { dependsOn: [model.ref, coords.ref] })
466
- .commit()];
467
- case 19:
468
- trajectory = _f.sent();
469
- return [4 /*yield*/, plugin.builders.structure.hierarchy.applyPreset(trajectory, (_b = params.preset) !== null && _b !== void 0 ? _b : 'default')];
470
- case 20:
471
- preset = _f.sent();
472
- return [2 /*return*/, { model: model, coords: coords, preset: preset }];
473
- }
474
- });
475
- });
476
- };
477
- Viewer.prototype.handleResize = function () {
478
- this.plugin.layout.events.updated.next(void 0);
479
- };
480
- return Viewer;
481
- }());
482
- export { Viewer };
483
- export var ViewerAutoPreset = StructureRepresentationPresetProvider({
484
- id: 'preset-structure-representation-viewer-auto',
485
- display: {
486
- name: 'Automatic (w/ Annotation)', group: 'Annotation',
487
- description: 'Show standard automatic representation but colored by quality assessment (if available in the model).'
488
- },
489
- isApplicable: function (a) {
490
- return (!!a.data.models.some(function (m) { return QualityAssessment.isApplicable(m, 'pLDDT'); }) ||
491
- !!a.data.models.some(function (m) { return QualityAssessment.isApplicable(m, 'qmean'); }));
492
- },
493
- params: function () { return StructureRepresentationPresetProvider.CommonParams; },
494
- apply: function (ref, params, plugin) {
495
- var _a;
496
- return __awaiter(this, void 0, void 0, function () {
497
- var structureCell, structure;
498
- return __generator(this, function (_b) {
499
- switch (_b.label) {
500
- case 0:
501
- structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref);
502
- structure = (_a = structureCell === null || structureCell === void 0 ? void 0 : structureCell.obj) === null || _a === void 0 ? void 0 : _a.data;
503
- if (!structureCell || !structure)
504
- return [2 /*return*/, {}];
505
- if (!!!structure.models.some(function (m) { return QualityAssessment.isApplicable(m, 'pLDDT'); })) return [3 /*break*/, 2];
506
- return [4 /*yield*/, QualityAssessmentPLDDTPreset.apply(ref, params, plugin)];
507
- case 1: return [2 /*return*/, _b.sent()];
508
- case 2:
509
- if (!!!structure.models.some(function (m) { return QualityAssessment.isApplicable(m, 'qmean'); })) return [3 /*break*/, 4];
510
- return [4 /*yield*/, QualityAssessmentQmeanPreset.apply(ref, params, plugin)];
511
- case 3: return [2 /*return*/, _b.sent()];
512
- case 4: return [4 /*yield*/, PresetStructureRepresentations.auto.apply(ref, params, plugin)];
513
- case 5: return [2 /*return*/, _b.sent()];
514
- }
515
- });
516
- });
517
- }
518
- });
11
+ export * from './app';
519
12
  //# sourceMappingURL=index.js.map