drugflow-molstar 0.4.7 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/build/drugflow-molstar-0.4.8.css +1 -0
  2. package/build/drugflow-molstar-component-0.4.8.js +25 -0
  3. package/build/drugflow-molstar-plugin-0.4.8.js +2 -0
  4. package/build/drugflow-molstar-plugin-0.4.8.js.LICENSE.txt +39 -0
  5. package/lib/alphafold-transparency.js +157 -62
  6. package/lib/contact.d.ts +7 -14
  7. package/lib/contact.js +68 -72
  8. package/lib/custom-events.js +15 -15
  9. package/lib/domain-annotations/behavior.d.ts +1 -1
  10. package/lib/domain-annotations/behavior.js +24 -20
  11. package/lib/domain-annotations/color.js +22 -22
  12. package/lib/domain-annotations/prop.js +111 -62
  13. package/lib/drugflow-molstar-component-build-0.4.8.js +2 -0
  14. package/lib/drugflow-molstar-component-build-0.4.8.js.LICENSE.txt +24 -0
  15. package/lib/helpers.d.ts +3 -3
  16. package/lib/helpers.js +94 -89
  17. package/lib/index.d.ts +902 -1
  18. package/lib/index.js +2814 -1875
  19. package/lib/labels.d.ts +1 -1
  20. package/lib/labels.js +34 -20
  21. package/lib/loci-details.js +46 -34
  22. package/lib/sifts-mapping.js +32 -28
  23. package/lib/sifts-mappings-behaviour.d.ts +1 -1
  24. package/lib/sifts-mappings-behaviour.js +30 -26
  25. package/lib/spec.js +40 -52
  26. package/lib/structure_contact3d.d.ts +14 -21
  27. package/lib/structure_contact3d.js +46 -25
  28. package/lib/subscribe-events.js +18 -19
  29. package/lib/superposition-export.js +178 -102
  30. package/lib/superposition-focus-representation.d.ts +2 -2
  31. package/lib/superposition-focus-representation.js +131 -73
  32. package/lib/superposition-sifts-mapping.js +150 -105
  33. package/lib/superposition.js +810 -495
  34. package/lib/ui/alphafold-superposition.d.ts +1 -1
  35. package/lib/ui/alphafold-superposition.js +118 -94
  36. package/lib/ui/alphafold-tranparency.js +43 -27
  37. package/lib/ui/annotation-controls.js +89 -83
  38. package/lib/ui/export-superposition.d.ts +0 -1
  39. package/lib/ui/export-superposition.js +50 -32
  40. package/lib/ui/pdbe-left-panel.d.ts +0 -1
  41. package/lib/ui/pdbe-left-panel.js +105 -82
  42. package/lib/ui/pdbe-screenshot-controls.js +83 -54
  43. package/lib/ui/pdbe-structure-controls.js +57 -34
  44. package/lib/ui/pdbe-viewport-controls.js +29 -23
  45. package/lib/ui/segment-tree.js +663 -440
  46. package/lib/ui/superposition-components.js +312 -208
  47. package/lib/ui/superposition-viewport.js +18 -11
  48. package/package.json +3 -3
  49. package/build/drugflow-molstar-0.4.7.css +0 -1
  50. package/build/drugflow-molstar-component-0.4.7.js +0 -25
  51. package/build/drugflow-molstar-plugin-0.4.7.js +0 -2
  52. package/build/drugflow-molstar-plugin-0.4.7.js.LICENSE.txt +0 -64
@@ -2,64 +2,57 @@ import { StateTransformer } from 'molstar/lib/mol-state';
2
2
  import { PluginStateObject as SO } from 'molstar/lib/mol-plugin-state/objects';
3
3
  export { StructureSelectionsContact3D };
4
4
  type StructureSelectionsContact3D = typeof StructureSelectionsContact3D;
5
- declare const StructureSelectionsContact3D: StateTransformer<SO.Molecule.Structure.Selections, SO.Shape.Representation3D, import("molstar/lib/mol-util/param-definition").ParamDefinition.Normalize<{
5
+ declare const StructureSelectionsContact3D: StateTransformer<SO.Molecule.Structure.Selections, SO.Shape.Representation3D, import("Molstar/mol-util/param-definition").ParamDefinition.Normalize<{
6
6
  visuals: ("text" | "cylinder")[];
7
7
  unitLabel: string;
8
8
  borderWidth: number;
9
9
  customText: string;
10
- textColor: import("molstar/lib/mol-util/color").Color;
10
+ textColor: import("Molstar/mol-util/color").Color;
11
11
  textSize: number;
12
12
  sizeFactor: number;
13
- borderColor: import("molstar/lib/mol-util/color").Color;
13
+ borderColor: import("Molstar/mol-util/color").Color;
14
14
  offsetX: number;
15
15
  offsetY: number;
16
16
  offsetZ: number;
17
17
  background: boolean;
18
18
  backgroundMargin: number;
19
- backgroundColor: import("molstar/lib/mol-util/color").Color;
19
+ backgroundColor: import("Molstar/mol-util/color").Color;
20
20
  backgroundOpacity: number;
21
21
  tether: boolean;
22
22
  tetherLength: number;
23
23
  tetherBaseWidth: number;
24
- attachment: "middle-center" | "bottom-left" | "bottom-center" | "bottom-right" | "middle-left" | "middle-right" | "top-left" | "top-center" | "top-right";
25
- fontFamily: import("molstar/lib/mol-geo/geometry/text/font-atlas").FontFamily;
24
+ attachment: "bottom-left" | "bottom-center" | "bottom-right" | "middle-left" | "middle-center" | "middle-right" | "top-left" | "top-center" | "top-right";
25
+ fontFamily: import("Molstar/mol-geo/geometry/text/font-atlas").FontFamily;
26
26
  fontQuality: number;
27
- fontStyle: import("molstar/lib/mol-geo/geometry/text/font-atlas").FontStyle;
28
- fontVariant: import("molstar/lib/mol-geo/geometry/text/font-atlas").FontVariant;
29
- fontWeight: import("molstar/lib/mol-geo/geometry/text/font-atlas").FontWeight;
27
+ fontStyle: import("Molstar/mol-geo/geometry/text/font-atlas").FontStyle;
28
+ fontVariant: import("Molstar/mol-geo/geometry/text/font-atlas").FontVariant;
29
+ fontWeight: import("Molstar/mol-geo/geometry/text/font-atlas").FontWeight;
30
30
  alpha: number;
31
31
  quality: "auto" | "medium" | "high" | "low" | "custom" | "highest" | "higher" | "lower" | "lowest";
32
- material: import("molstar/lib/mol-util/param-definition").ParamDefinition.Normalize<{
32
+ material: import("Molstar/mol-util/param-definition").ParamDefinition.Normalize<{
33
33
  metalness: number;
34
34
  roughness: number;
35
35
  bumpiness: number;
36
36
  }>;
37
- clip: import("molstar/lib/mol-util/param-definition").ParamDefinition.Normalize<{
38
- variant: import("molstar/lib/mol-util/clip").Clip.Variant;
39
- objects: import("molstar/lib/mol-util/param-definition").ParamDefinition.Normalize<{
37
+ clip: import("Molstar/mol-util/param-definition").ParamDefinition.Normalize<{
38
+ variant: import("Molstar/mol-util/clip").Clip.Variant;
39
+ objects: import("Molstar/mol-util/param-definition").ParamDefinition.Normalize<{
40
40
  type: any;
41
41
  invert: any;
42
42
  position: any;
43
43
  rotation: any;
44
44
  scale: any;
45
- transform: any;
46
45
  }>[];
47
46
  }>;
48
- emissive: number;
49
- density: number;
50
47
  instanceGranularity: boolean;
51
- lod: import("molstar/lib/mol-math/linear-algebra").Vec3;
52
- cellSize: number;
53
- batchSize: number;
54
48
  lineSizeAttenuation: boolean;
55
49
  linesSize: number;
56
50
  dashLength: number;
57
51
  interactionType: string;
58
- cylinderColor: import("molstar/lib/mol-util/color").Color;
52
+ cylinderColor: import("Molstar/mol-util/color").Color;
59
53
  sizeAspectRatio: number;
60
54
  doubleSided: boolean;
61
55
  ignoreLight: boolean;
62
- celShaded: boolean;
63
56
  xrayShaded: boolean | "inverted";
64
57
  transparentBackfaces: "off" | "on" | "opaque";
65
58
  solidInterior: boolean;
@@ -1,39 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StructureSelectionsContact3D = void 0;
4
- const mol_state_1 = require("molstar/lib/mol-state");
5
- const mol_task_1 = require("molstar/lib/mol-task");
6
- const objects_1 = require("molstar/lib/mol-plugin-state/objects");
7
- const helpers_1 = require("molstar/lib/mol-plugin-state/transforms/helpers");
8
- const contact_1 = require("./contact");
9
- const StructureSelectionsContact3D = objects_1.PluginStateTransform.BuiltIn({
4
+ var tslib_1 = require("tslib");
5
+ var mol_state_1 = require("molstar/lib/mol-state");
6
+ var mol_task_1 = require("molstar/lib/mol-task");
7
+ var objects_1 = require("molstar/lib/mol-plugin-state/objects");
8
+ var helpers_1 = require("molstar/lib/mol-plugin-state/transforms/helpers");
9
+ var contact_1 = require("./contact");
10
+ var StructureSelectionsContact3D = objects_1.PluginStateTransform.BuiltIn({
10
11
  name: 'structure-selections-contact-3d',
11
12
  display: '3D Contact',
12
13
  from: objects_1.PluginStateObject.Molecule.Structure.Selections,
13
14
  to: objects_1.PluginStateObject.Shape.Representation3D,
14
- params: () => ({
15
- ...contact_1.ContactParams,
16
- })
15
+ params: function () { return (tslib_1.__assign({}, contact_1.ContactParams)); }
17
16
  })({
18
- canAutoUpdate({ oldParams, newParams }) {
17
+ canAutoUpdate: function (_a) {
18
+ var oldParams = _a.oldParams, newParams = _a.newParams;
19
19
  return true;
20
20
  },
21
- apply({ a, params }, plugin) {
22
- return mol_task_1.Task.create('Structure Contact', async (ctx) => {
23
- const data = (0, helpers_1.getDistanceDataFromStructureSelections)(a.data);
24
- const repr = (0, contact_1.ContactRepresentation)({ webgl: plugin.canvas3d?.webgl, ...plugin.representation.structure.themes }, () => contact_1.ContactParams);
25
- await repr.createOrUpdate(params, data).runInContext(ctx);
26
- return new objects_1.PluginStateObject.Shape.Representation3D({ repr, sourceData: data }, { label: `Contact` });
27
- });
21
+ apply: function (_a, plugin) {
22
+ var _this = this;
23
+ var a = _a.a, params = _a.params;
24
+ return mol_task_1.Task.create('Structure Contact', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
25
+ var data, repr;
26
+ var _a;
27
+ return tslib_1.__generator(this, function (_b) {
28
+ switch (_b.label) {
29
+ case 0:
30
+ data = (0, helpers_1.getDistanceDataFromStructureSelections)(a.data);
31
+ repr = (0, contact_1.ContactRepresentation)(tslib_1.__assign({ webgl: (_a = plugin.canvas3d) === null || _a === void 0 ? void 0 : _a.webgl }, plugin.representation.structure.themes), function () { return contact_1.ContactParams; });
32
+ return [4 /*yield*/, repr.createOrUpdate(params, data).runInContext(ctx)];
33
+ case 1:
34
+ _b.sent();
35
+ return [2 /*return*/, new objects_1.PluginStateObject.Shape.Representation3D({ repr: repr, sourceData: data }, { label: "Contact" })];
36
+ }
37
+ });
38
+ }); });
28
39
  },
29
- update({ a, b, oldParams, newParams }, plugin) {
30
- return mol_task_1.Task.create('Structure Contact', async (ctx) => {
31
- const props = { ...b.data.repr.props, ...newParams };
32
- const data = (0, helpers_1.getDistanceDataFromStructureSelections)(a.data);
33
- await b.data.repr.createOrUpdate(props, data).runInContext(ctx);
34
- b.data.sourceData = data;
35
- return mol_state_1.StateTransformer.UpdateResult.Updated;
36
- });
40
+ update: function (_a, plugin) {
41
+ var _this = this;
42
+ var a = _a.a, b = _a.b, oldParams = _a.oldParams, newParams = _a.newParams;
43
+ return mol_task_1.Task.create('Structure Contact', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
44
+ var props, data;
45
+ return tslib_1.__generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0:
48
+ props = tslib_1.__assign(tslib_1.__assign({}, b.data.repr.props), newParams);
49
+ data = (0, helpers_1.getDistanceDataFromStructureSelections)(a.data);
50
+ return [4 /*yield*/, b.data.repr.createOrUpdate(props, data).runInContext(ctx)];
51
+ case 1:
52
+ _a.sent();
53
+ b.data.sourceData = data;
54
+ return [2 /*return*/, mol_state_1.StateTransformer.UpdateResult.Updated];
55
+ }
56
+ });
57
+ }); });
37
58
  },
38
59
  });
39
60
  exports.StructureSelectionsContact3D = StructureSelectionsContact3D;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.subscribeToComponentEvents = void 0;
3
+ exports.subscribeToComponentEvents = subscribeToComponentEvents;
4
4
  function subscribeToComponentEvents(wrapperCtx) {
5
5
  document.addEventListener('PDB.interactions.click', function (e) {
6
6
  if (typeof e.detail !== 'undefined') {
7
- const data = e.detail.interacting_nodes ? { data: e.detail.interacting_nodes } : { data: [e.detail.selected_node] };
7
+ var data = e.detail.interacting_nodes ? { data: e.detail.interacting_nodes } : { data: [e.detail.selected_node] };
8
8
  data.data[0]['focus'] = true;
9
9
  wrapperCtx.visual.select(data);
10
10
  }
11
11
  });
12
12
  document.addEventListener('PDB.interactions.mouseover', function (e) {
13
13
  if (typeof e.detail !== 'undefined') {
14
- const data = e.detail.interacting_nodes ? { data: e.detail.interacting_nodes } : { data: [e.detail.selected_node] };
14
+ var data = e.detail.interacting_nodes ? { data: e.detail.interacting_nodes } : { data: [e.detail.selected_node] };
15
15
  wrapperCtx.visual.highlight(data);
16
16
  }
17
17
  });
@@ -21,7 +21,7 @@ function subscribeToComponentEvents(wrapperCtx) {
21
21
  document.addEventListener('PDB.topologyViewer.click', function (e) {
22
22
  if (typeof e.eventData !== 'undefined') {
23
23
  // Create query object from event data
24
- let highlightQuery = {
24
+ var highlightQuery = {
25
25
  entity_id: e.eventData.entityId,
26
26
  struct_asym_id: e.eventData.structAsymId,
27
27
  start_residue_number: e.eventData.residueNumber,
@@ -38,7 +38,7 @@ function subscribeToComponentEvents(wrapperCtx) {
38
38
  // Abort if entryid do not match or viewer type is unipdb
39
39
  // if(e.eventData.entryId != scope.pdbId) return;
40
40
  // Create query object from event data
41
- let highlightQuery = {
41
+ var highlightQuery = {
42
42
  entity_id: e.eventData.entityId,
43
43
  struct_asym_id: e.eventData.structAsymId,
44
44
  start_residue_number: e.eventData.residueNumber,
@@ -53,7 +53,7 @@ function subscribeToComponentEvents(wrapperCtx) {
53
53
  });
54
54
  document.addEventListener('protvista-mouseover', function (e) {
55
55
  if (typeof e.detail !== 'undefined') {
56
- let highlightQuery = undefined;
56
+ var highlightQuery = undefined;
57
57
  // Create query object from event data
58
58
  if (e.detail.start && e.detail.end) {
59
59
  highlightQuery = {
@@ -76,8 +76,8 @@ function subscribeToComponentEvents(wrapperCtx) {
76
76
  });
77
77
  document.addEventListener('protvista-click', function (e) {
78
78
  if (typeof e.detail !== 'undefined') {
79
- let showInteraction = false;
80
- let highlightQuery = undefined;
79
+ var showInteraction = false;
80
+ var highlightQuery = undefined;
81
81
  // Create query object from event data
82
82
  if (e.detail.start && e.detail.end) {
83
83
  highlightQuery = {
@@ -101,7 +101,7 @@ function subscribeToComponentEvents(wrapperCtx) {
101
101
  highlightQuery['sideChain'] = true;
102
102
  }
103
103
  else {
104
- let selColor = undefined;
104
+ var selColor = undefined;
105
105
  if (e.detail.trackIndex > -1 && e.detail.feature.locations && e.detail.feature.locations[0].fragments[e.detail.trackIndex].color)
106
106
  selColor = e.detail.feature.locations[0].fragments[e.detail.trackIndex].color;
107
107
  if (typeof selColor == 'undefined' && e.detail.feature.color)
@@ -112,9 +112,9 @@ function subscribeToComponentEvents(wrapperCtx) {
112
112
  selColor = { r: 65, g: 96, b: 91 };
113
113
  }
114
114
  else {
115
- let isRgb = /rgb/g;
115
+ var isRgb = /rgb/g;
116
116
  if (isRgb.test(selColor)) {
117
- let rgbArr = selColor.substring(4, selColor.length - 1).split(',');
117
+ var rgbArr = selColor.substring(4, selColor.length - 1).split(',');
118
118
  selColor = { r: rgbArr[0], g: rgbArr[1], b: rgbArr[2] };
119
119
  }
120
120
  }
@@ -125,15 +125,15 @@ function subscribeToComponentEvents(wrapperCtx) {
125
125
  }
126
126
  }
127
127
  });
128
- const elementTypeArrForRange = ['uniprot', 'pfam', 'cath', 'scop', 'strand', 'helice'];
129
- const elementTypeArrForSingle = ['chain', 'quality', 'quality_outlier', 'binding site', 'alternate conformer'];
128
+ var elementTypeArrForRange = ['uniprot', 'pfam', 'cath', 'scop', 'strand', 'helice'];
129
+ var elementTypeArrForSingle = ['chain', 'quality', 'quality_outlier', 'binding site', 'alternate conformer'];
130
130
  document.addEventListener('PDB.seqViewer.click', function (e) {
131
131
  if (typeof e.eventData !== 'undefined') {
132
132
  // Abort if entryid and entityid do not match or viewer type is unipdb
133
133
  // if(e.eventData.entryId != scope.pdbId) return;
134
134
  if (typeof e.eventData.elementData !== 'undefined' && elementTypeArrForSingle.indexOf(e.eventData.elementData.elementType) > -1) {
135
135
  // Create query object from event data
136
- const highlightQuery = {
136
+ var highlightQuery = {
137
137
  entity_id: e.eventData.entityId,
138
138
  struct_asym_id: e.eventData.elementData.pathData.struct_asym_id,
139
139
  start_residue_number: e.eventData.residueNumber,
@@ -145,9 +145,9 @@ function subscribeToComponentEvents(wrapperCtx) {
145
145
  wrapperCtx.visual.select({ data: [highlightQuery] });
146
146
  }
147
147
  else if (typeof e.eventData.elementData !== 'undefined' && elementTypeArrForRange.indexOf(e.eventData.elementData.elementType) > -1) {
148
- const seqColorArray = e.eventData.elementData.color;
148
+ var seqColorArray = e.eventData.elementData.color;
149
149
  // Create query object from event data
150
- const highlightQuery = {
150
+ var highlightQuery = {
151
151
  entity_id: e.eventData.entityId,
152
152
  struct_asym_id: e.eventData.elementData.pathData.struct_asym_id,
153
153
  start_residue_number: e.eventData.elementData.pathData.start.residue_number,
@@ -165,7 +165,7 @@ function subscribeToComponentEvents(wrapperCtx) {
165
165
  // if(e.eventData.entryId != scope.pdbId) return;
166
166
  if (typeof e.eventData.elementData !== 'undefined' && elementTypeArrForSingle.indexOf(e.eventData.elementData.elementType) > -1) {
167
167
  // Create query object from event data
168
- let highlightQuery = {
168
+ var highlightQuery = {
169
169
  entity_id: e.eventData.entityId,
170
170
  struct_asym_id: e.eventData.elementData.pathData.struct_asym_id,
171
171
  start_residue_number: e.eventData.residueNumber,
@@ -176,7 +176,7 @@ function subscribeToComponentEvents(wrapperCtx) {
176
176
  }
177
177
  else if (typeof e.eventData.elementData !== 'undefined' && elementTypeArrForRange.indexOf(e.eventData.elementData.elementType) > -1) {
178
178
  // Create query object from event data
179
- let highlightQuery = {
179
+ var highlightQuery = {
180
180
  entity_id: e.eventData.entityId,
181
181
  struct_asym_id: e.eventData.elementData.pathData.struct_asym_id,
182
182
  start_residue_number: e.eventData.elementData.pathData.start.residue_number,
@@ -191,4 +191,3 @@ function subscribeToComponentEvents(wrapperCtx) {
191
191
  wrapperCtx.visual.clearHighlight();
192
192
  });
193
193
  }
194
- exports.subscribeToComponentEvents = subscribeToComponentEvents;
@@ -1,108 +1,184 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.superpositionExportHierarchy = void 0;
4
- const utf8_1 = require("Molstar/mol-io/common/utf8");
5
- const structure_1 = require("Molstar/mol-model/structure");
6
- const mol_task_1 = require("Molstar/mol-task");
7
- const date_1 = require("Molstar/mol-util/date");
8
- const download_1 = require("Molstar/mol-util/download");
9
- const zip_1 = require("Molstar/mol-util/zip/zip");
10
- const commands_1 = require("Molstar/mol-plugin/commands");
11
- async function superpositionExportHierarchy(plugin, options) {
12
- try {
13
- await plugin.runTask(_superpositionExportHierarchy(plugin, options), { useOverlay: true });
14
- }
15
- catch (e) {
16
- console.error(e);
17
- plugin.log.error(`Model export failed. See console for details.`);
18
- }
19
- }
20
3
  exports.superpositionExportHierarchy = superpositionExportHierarchy;
21
- function _superpositionExportHierarchy(plugin, options) {
22
- return mol_task_1.Task.create('Export', async (ctx) => {
23
- await ctx.update({ message: 'Exporting...', isIndeterminate: true, canAbort: false });
24
- const format = options?.format ?? 'cif';
25
- // const { structures } = plugin.managers.structure.hierarchy.current;
26
- const customState = plugin.customState;
27
- const superpositionState = customState.superpositionState;
28
- const segmentIndex = superpositionState.activeSegment - 1;
29
- const files = [];
30
- const entryMap = new Map();
31
- const structures = superpositionState.loadedStructs[segmentIndex].slice();
32
- if (superpositionState.alphafold.ref)
33
- structures.push(`AF-${customState.initParams.moleculeId}`);
34
- for (const molId of structures) {
35
- const modelRef = superpositionState.models[molId];
36
- if (!modelRef)
37
- continue;
38
- let isStrHidden = false;
39
- const _s = plugin.managers.structure.hierarchy.current.refs.get(modelRef);
40
- if (_s.cell.state.isHidden)
41
- isStrHidden = true;
42
- for (const strComp of _s.components) {
43
- if (strComp.cell.state.isHidden)
44
- isStrHidden = true;
45
- }
46
- if (isStrHidden)
47
- continue;
48
- const s = _s.transform?.cell.obj?.data ?? _s.cell.obj?.data;
49
- if (!s)
50
- continue;
51
- if (s.models.length > 1) {
52
- plugin.log.warn(`[Export] Skipping ${_s.cell.obj?.label}: Multimodel exports not supported.`);
53
- continue;
54
- }
55
- if (s.units.some((u) => !structure_1.Unit.isAtomic(u))) {
56
- plugin.log.warn(`[Export] Skipping ${_s.cell.obj?.label}: Non-atomic model exports not supported.`);
57
- continue;
58
- }
59
- const name = entryMap.has(s.model.entryId)
60
- ? `${s.model.entryId}_${entryMap.get(s.model.entryId) + 1}.${format}`
61
- : `${s.model.entryId}.${format}`;
62
- entryMap.set(s.model.entryId, (entryMap.get(s.model.entryId) ?? 0) + 1);
63
- await ctx.update({ message: `Exporting ${s.model.entryId}...`, isIndeterminate: true, canAbort: false });
64
- if (s.elementCount > 100000) {
65
- // Give UI chance to update, only needed for larger structures.
66
- await new Promise(res => setTimeout(res, 50));
67
- }
68
- try {
69
- files.push([name, (0, structure_1.to_mmCIF)(s.model.entryId, s, format === 'bcif', { copyAllCategories: true })]);
4
+ var tslib_1 = require("tslib");
5
+ var utf8_1 = require("Molstar/mol-io/common/utf8");
6
+ var structure_1 = require("Molstar/mol-model/structure");
7
+ var mol_task_1 = require("Molstar/mol-task");
8
+ var date_1 = require("Molstar/mol-util/date");
9
+ var download_1 = require("Molstar/mol-util/download");
10
+ var zip_1 = require("Molstar/mol-util/zip/zip");
11
+ var commands_1 = require("Molstar/mol-plugin/commands");
12
+ function superpositionExportHierarchy(plugin, options) {
13
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
14
+ var e_1;
15
+ return tslib_1.__generator(this, function (_a) {
16
+ switch (_a.label) {
17
+ case 0:
18
+ _a.trys.push([0, 2, , 3]);
19
+ return [4 /*yield*/, plugin.runTask(_superpositionExportHierarchy(plugin, options), { useOverlay: true })];
20
+ case 1:
21
+ _a.sent();
22
+ return [3 /*break*/, 3];
23
+ case 2:
24
+ e_1 = _a.sent();
25
+ console.error(e_1);
26
+ plugin.log.error("Model export failed. See console for details.");
27
+ return [3 /*break*/, 3];
28
+ case 3: return [2 /*return*/];
70
29
  }
71
- catch (e) {
72
- if (format === 'cif' && s.elementCount > 2000000) {
73
- plugin.log.warn(`[Export] The structure might be too big to be exported as Text CIF, consider using the BinaryCIF format instead.`);
74
- }
75
- throw e;
76
- }
77
- }
78
- if (files.length === 0) {
79
- commands_1.PluginCommands.Toast.Show(plugin, {
80
- title: 'Export Models',
81
- message: 'No visible structure in the 3D view to export!',
82
- key: 'superposition-toast-1',
83
- timeoutMs: 7000
84
- });
85
- return;
86
- }
87
- if (files.length === 1) {
88
- (0, download_1.download)(new Blob([files[0][1]]), files[0][0]);
89
- }
90
- else if (files.length > 1) {
91
- const zipData = {};
92
- for (const [fn, data] of files) {
93
- if (data instanceof Uint8Array) {
94
- zipData[fn] = data;
95
- }
96
- else {
97
- const bytes = new Uint8Array((0, utf8_1.utf8ByteCount)(data));
98
- (0, utf8_1.utf8Write)(bytes, 0, data);
99
- zipData[fn] = bytes;
100
- }
101
- }
102
- await ctx.update({ message: `Compressing Data...`, isIndeterminate: true, canAbort: false });
103
- const buffer = await (0, zip_1.zip)(ctx, zipData);
104
- (0, download_1.download)(new Blob([new Uint8Array(buffer, 0, buffer.byteLength)]), `structures_${(0, date_1.getFormattedTime)()}.zip`);
105
- }
106
- plugin.log.info(`[Export] Done.`);
30
+ });
107
31
  });
108
32
  }
33
+ function _superpositionExportHierarchy(plugin, options) {
34
+ var _this = this;
35
+ return mol_task_1.Task.create('Export', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
36
+ var format, customState, superpositionState, segmentIndex, files, entryMap, structures, structures_1, structures_1_1, molId, modelRef, isStrHidden, _s, _a, _b, strComp, s, name_1, e_2_1, zipData, files_1, files_1_1, _c, fn, data, bytes, buffer;
37
+ var e_2, _d, e_3, _e, e_4, _f;
38
+ var _g, _h, _j, _k, _l, _m, _o, _p;
39
+ return tslib_1.__generator(this, function (_q) {
40
+ switch (_q.label) {
41
+ case 0: return [4 /*yield*/, ctx.update({ message: 'Exporting...', isIndeterminate: true, canAbort: false })];
42
+ case 1:
43
+ _q.sent();
44
+ format = (_g = options === null || options === void 0 ? void 0 : options.format) !== null && _g !== void 0 ? _g : 'cif';
45
+ customState = plugin.customState;
46
+ superpositionState = customState.superpositionState;
47
+ segmentIndex = superpositionState.activeSegment - 1;
48
+ files = [];
49
+ entryMap = new Map();
50
+ structures = superpositionState.loadedStructs[segmentIndex].slice();
51
+ if (superpositionState.alphafold.ref)
52
+ structures.push("AF-".concat(customState.initParams.moleculeId));
53
+ _q.label = 2;
54
+ case 2:
55
+ _q.trys.push([2, 9, 10, 11]);
56
+ structures_1 = tslib_1.__values(structures), structures_1_1 = structures_1.next();
57
+ _q.label = 3;
58
+ case 3:
59
+ if (!!structures_1_1.done) return [3 /*break*/, 8];
60
+ molId = structures_1_1.value;
61
+ modelRef = superpositionState.models[molId];
62
+ if (!modelRef)
63
+ return [3 /*break*/, 7];
64
+ isStrHidden = false;
65
+ _s = plugin.managers.structure.hierarchy.current.refs.get(modelRef);
66
+ if (_s.cell.state.isHidden)
67
+ isStrHidden = true;
68
+ try {
69
+ for (_a = (e_3 = void 0, tslib_1.__values(_s.components)), _b = _a.next(); !_b.done; _b = _a.next()) {
70
+ strComp = _b.value;
71
+ if (strComp.cell.state.isHidden)
72
+ isStrHidden = true;
73
+ }
74
+ }
75
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
76
+ finally {
77
+ try {
78
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
79
+ }
80
+ finally { if (e_3) throw e_3.error; }
81
+ }
82
+ if (isStrHidden)
83
+ return [3 /*break*/, 7];
84
+ s = (_k = (_j = (_h = _s.transform) === null || _h === void 0 ? void 0 : _h.cell.obj) === null || _j === void 0 ? void 0 : _j.data) !== null && _k !== void 0 ? _k : (_l = _s.cell.obj) === null || _l === void 0 ? void 0 : _l.data;
85
+ if (!s)
86
+ return [3 /*break*/, 7];
87
+ if (s.models.length > 1) {
88
+ plugin.log.warn("[Export] Skipping ".concat((_m = _s.cell.obj) === null || _m === void 0 ? void 0 : _m.label, ": Multimodel exports not supported."));
89
+ return [3 /*break*/, 7];
90
+ }
91
+ if (s.units.some(function (u) { return !structure_1.Unit.isAtomic(u); })) {
92
+ plugin.log.warn("[Export] Skipping ".concat((_o = _s.cell.obj) === null || _o === void 0 ? void 0 : _o.label, ": Non-atomic model exports not supported."));
93
+ return [3 /*break*/, 7];
94
+ }
95
+ name_1 = entryMap.has(s.model.entryId)
96
+ ? "".concat(s.model.entryId, "_").concat(entryMap.get(s.model.entryId) + 1, ".").concat(format)
97
+ : "".concat(s.model.entryId, ".").concat(format);
98
+ entryMap.set(s.model.entryId, ((_p = entryMap.get(s.model.entryId)) !== null && _p !== void 0 ? _p : 0) + 1);
99
+ return [4 /*yield*/, ctx.update({ message: "Exporting ".concat(s.model.entryId, "..."), isIndeterminate: true, canAbort: false })];
100
+ case 4:
101
+ _q.sent();
102
+ if (!(s.elementCount > 100000)) return [3 /*break*/, 6];
103
+ // Give UI chance to update, only needed for larger structures.
104
+ return [4 /*yield*/, new Promise(function (res) { return setTimeout(res, 50); })];
105
+ case 5:
106
+ // Give UI chance to update, only needed for larger structures.
107
+ _q.sent();
108
+ _q.label = 6;
109
+ case 6:
110
+ try {
111
+ files.push([name_1, (0, structure_1.to_mmCIF)(s.model.entryId, s, format === 'bcif', { copyAllCategories: true })]);
112
+ }
113
+ catch (e) {
114
+ if (format === 'cif' && s.elementCount > 2000000) {
115
+ plugin.log.warn("[Export] The structure might be too big to be exported as Text CIF, consider using the BinaryCIF format instead.");
116
+ }
117
+ throw e;
118
+ }
119
+ _q.label = 7;
120
+ case 7:
121
+ structures_1_1 = structures_1.next();
122
+ return [3 /*break*/, 3];
123
+ case 8: return [3 /*break*/, 11];
124
+ case 9:
125
+ e_2_1 = _q.sent();
126
+ e_2 = { error: e_2_1 };
127
+ return [3 /*break*/, 11];
128
+ case 10:
129
+ try {
130
+ if (structures_1_1 && !structures_1_1.done && (_d = structures_1.return)) _d.call(structures_1);
131
+ }
132
+ finally { if (e_2) throw e_2.error; }
133
+ return [7 /*endfinally*/];
134
+ case 11:
135
+ if (files.length === 0) {
136
+ commands_1.PluginCommands.Toast.Show(plugin, {
137
+ title: 'Export Models',
138
+ message: 'No visible structure in the 3D view to export!',
139
+ key: 'superposition-toast-1',
140
+ timeoutMs: 7000
141
+ });
142
+ return [2 /*return*/];
143
+ }
144
+ if (!(files.length === 1)) return [3 /*break*/, 12];
145
+ (0, download_1.download)(new Blob([files[0][1]]), files[0][0]);
146
+ return [3 /*break*/, 15];
147
+ case 12:
148
+ if (!(files.length > 1)) return [3 /*break*/, 15];
149
+ zipData = {};
150
+ try {
151
+ for (files_1 = tslib_1.__values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
152
+ _c = tslib_1.__read(files_1_1.value, 2), fn = _c[0], data = _c[1];
153
+ if (data instanceof Uint8Array) {
154
+ zipData[fn] = data;
155
+ }
156
+ else {
157
+ bytes = new Uint8Array((0, utf8_1.utf8ByteCount)(data));
158
+ (0, utf8_1.utf8Write)(bytes, 0, data);
159
+ zipData[fn] = bytes;
160
+ }
161
+ }
162
+ }
163
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
164
+ finally {
165
+ try {
166
+ if (files_1_1 && !files_1_1.done && (_f = files_1.return)) _f.call(files_1);
167
+ }
168
+ finally { if (e_4) throw e_4.error; }
169
+ }
170
+ return [4 /*yield*/, ctx.update({ message: "Compressing Data...", isIndeterminate: true, canAbort: false })];
171
+ case 13:
172
+ _q.sent();
173
+ return [4 /*yield*/, (0, zip_1.zip)(ctx, zipData)];
174
+ case 14:
175
+ buffer = _q.sent();
176
+ (0, download_1.download)(new Blob([new Uint8Array(buffer, 0, buffer.byteLength)]), "structures_".concat((0, date_1.getFormattedTime)(), ".zip"));
177
+ _q.label = 15;
178
+ case 15:
179
+ plugin.log.info("[Export] Done.");
180
+ return [2 /*return*/];
181
+ }
182
+ });
183
+ }); });
184
+ }
@@ -4,7 +4,7 @@ import { PluginContext } from 'Molstar/mol-plugin/context';
4
4
  declare const SuperpositionFocusRepresentationParams: (plugin: PluginContext) => {
5
5
  expandRadius: PD.Numeric;
6
6
  surroundingsParams: PD.Group<PD.Normalize<{
7
- [x: string]: any;
7
+ [x: string]: /*elided*/ any;
8
8
  }>>;
9
9
  };
10
10
  type SuperpositionFocusRepresentationProps = PD.ValuesFor<ReturnType<typeof SuperpositionFocusRepresentationParams>>;
@@ -12,5 +12,5 @@ export declare enum SuperpositionFocusRepresentationTags {
12
12
  SurrSel = "superposition-focus-surr-sel",
13
13
  SurrRepr = "superposition-focus-surr-repr"
14
14
  }
15
- export declare const SuperpositionFocusRepresentation: import("molstar/lib/mol-state/transformer").StateTransformer<PluginBehavior.Category, PluginBehavior.Behavior, SuperpositionFocusRepresentationProps>;
15
+ export declare const SuperpositionFocusRepresentation: import("Molstar/mol-state").StateTransformer<PluginBehavior.Category, PluginBehavior.Behavior, SuperpositionFocusRepresentationProps>;
16
16
  export {};