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.
Files changed (65) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +15 -0
  3. package/build/pdbe-molstar-3.1.2.css +1 -0
  4. package/build/pdbe-molstar-component-3.1.2.js +25 -0
  5. package/build/pdbe-molstar-plugin-3.1.2.js +2 -0
  6. package/build/pdbe-molstar-plugin-3.1.2.js.LICENSE.txt +39 -0
  7. package/lib/alphafold-transparency.d.ts +6 -0
  8. package/lib/alphafold-transparency.js +153 -0
  9. package/lib/custom-events.d.ts +4 -0
  10. package/lib/custom-events.js +56 -0
  11. package/lib/domain-annotations/behavior.d.ts +5 -0
  12. package/lib/domain-annotations/behavior.js +49 -0
  13. package/lib/domain-annotations/color.d.ts +10 -0
  14. package/lib/domain-annotations/color.js +78 -0
  15. package/lib/domain-annotations/prop.d.ts +35 -0
  16. package/lib/domain-annotations/prop.js +160 -0
  17. package/lib/helpers.d.ts +80 -0
  18. package/lib/helpers.js +278 -0
  19. package/lib/index.d.ts +1 -0
  20. package/lib/index.js +901 -0
  21. package/lib/labels.d.ts +2 -0
  22. package/lib/labels.js +42 -0
  23. package/lib/loci-details.d.ts +27 -0
  24. package/lib/loci-details.js +128 -0
  25. package/lib/pdbe-molstar-component-build-3.1.2.js +2 -0
  26. package/lib/pdbe-molstar-component-build-3.1.2.js.LICENSE.txt +24 -0
  27. package/lib/sifts-mapping.d.ts +16 -0
  28. package/lib/sifts-mapping.js +83 -0
  29. package/lib/sifts-mappings-behaviour.d.ts +5 -0
  30. package/lib/sifts-mappings-behaviour.js +64 -0
  31. package/lib/spec.d.ts +75 -0
  32. package/lib/spec.js +105 -0
  33. package/lib/subscribe-events.d.ts +1 -0
  34. package/lib/subscribe-events.js +194 -0
  35. package/lib/superposition-export.d.ts +4 -0
  36. package/lib/superposition-export.js +152 -0
  37. package/lib/superposition-focus-representation.d.ts +16 -0
  38. package/lib/superposition-focus-representation.js +153 -0
  39. package/lib/superposition-sifts-mapping.d.ts +22 -0
  40. package/lib/superposition-sifts-mapping.js +159 -0
  41. package/lib/superposition.d.ts +18 -0
  42. package/lib/superposition.js +794 -0
  43. package/lib/ui/alphafold-superposition.d.ts +56 -0
  44. package/lib/ui/alphafold-superposition.js +178 -0
  45. package/lib/ui/alphafold-tranparency.d.ts +22 -0
  46. package/lib/ui/alphafold-tranparency.js +65 -0
  47. package/lib/ui/annotation-controls.d.ts +24 -0
  48. package/lib/ui/annotation-controls.js +166 -0
  49. package/lib/ui/export-superposition.d.ts +6 -0
  50. package/lib/ui/export-superposition.js +71 -0
  51. package/lib/ui/pdbe-left-panel.d.ts +18 -0
  52. package/lib/ui/pdbe-left-panel.js +167 -0
  53. package/lib/ui/pdbe-screenshot-controls.d.ts +20 -0
  54. package/lib/ui/pdbe-screenshot-controls.js +101 -0
  55. package/lib/ui/pdbe-structure-controls.d.ts +17 -0
  56. package/lib/ui/pdbe-structure-controls.js +70 -0
  57. package/lib/ui/pdbe-viewport-controls.d.ts +6 -0
  58. package/lib/ui/pdbe-viewport-controls.js +56 -0
  59. package/lib/ui/segment-tree.d.ts +18 -0
  60. package/lib/ui/segment-tree.js +804 -0
  61. package/lib/ui/superposition-components.d.ts +10 -0
  62. package/lib/ui/superposition-components.js +435 -0
  63. package/lib/ui/superposition-viewport.d.ts +5 -0
  64. package/lib/ui/superposition-viewport.js +23 -0
  65. package/package.json +79 -0
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subscribeToComponentEvents = void 0;
4
+ function subscribeToComponentEvents(wrapperCtx) {
5
+ document.addEventListener('PDB.interactions.click', function (e) {
6
+ if (typeof e.detail !== 'undefined') {
7
+ var data = e.detail.interacting_nodes ? { data: e.detail.interacting_nodes } : { data: [e.detail.selected_node] };
8
+ data.data[0]['focus'] = true;
9
+ wrapperCtx.visual.select(data);
10
+ }
11
+ });
12
+ document.addEventListener('PDB.interactions.mouseover', function (e) {
13
+ if (typeof e.detail !== 'undefined') {
14
+ var data = e.detail.interacting_nodes ? { data: e.detail.interacting_nodes } : { data: [e.detail.selected_node] };
15
+ wrapperCtx.visual.highlight(data);
16
+ }
17
+ });
18
+ document.addEventListener('PDB.interactions.mouseout', function (e) {
19
+ wrapperCtx.visual.clearHighlight();
20
+ });
21
+ document.addEventListener('PDB.topologyViewer.click', function (e) {
22
+ if (typeof e.eventData !== 'undefined') {
23
+ // Create query object from event data
24
+ var highlightQuery = {
25
+ entity_id: e.eventData.entityId,
26
+ struct_asym_id: e.eventData.structAsymId,
27
+ start_residue_number: e.eventData.residueNumber,
28
+ end_residue_number: e.eventData.residueNumber,
29
+ sideChain: true,
30
+ focus: true
31
+ };
32
+ // Call highlightAnnotation
33
+ wrapperCtx.visual.select({ data: [highlightQuery] });
34
+ }
35
+ });
36
+ document.addEventListener('PDB.topologyViewer.mouseover', function (e) {
37
+ if (typeof e.eventData !== 'undefined') {
38
+ // Abort if entryid do not match or viewer type is unipdb
39
+ // if(e.eventData.entryId != scope.pdbId) return;
40
+ // Create query object from event data
41
+ var highlightQuery = {
42
+ entity_id: e.eventData.entityId,
43
+ struct_asym_id: e.eventData.structAsymId,
44
+ start_residue_number: e.eventData.residueNumber,
45
+ end_residue_number: e.eventData.residueNumber
46
+ };
47
+ // Call highlightAnnotation
48
+ wrapperCtx.visual.highlight({ data: [highlightQuery] });
49
+ }
50
+ });
51
+ document.addEventListener('PDB.topologyViewer.mouseout', function (e) {
52
+ wrapperCtx.visual.clearHighlight();
53
+ });
54
+ document.addEventListener('protvista-mouseover', function (e) {
55
+ if (typeof e.detail !== 'undefined') {
56
+ var highlightQuery = undefined;
57
+ // Create query object from event data
58
+ if (e.detail.start && e.detail.end) {
59
+ highlightQuery = {
60
+ start_residue_number: parseInt(e.detail.start),
61
+ end_residue_number: parseInt(e.detail.end)
62
+ };
63
+ }
64
+ if (e.detail.feature && e.detail.feature.entityId)
65
+ highlightQuery['entity_id'] = e.detail.feature.entityId + '';
66
+ if (e.detail.feature && e.detail.feature.bestChainId)
67
+ highlightQuery['struct_asym_id'] = e.detail.feature.bestChainId;
68
+ if (e.detail.feature && e.detail.feature.chainId)
69
+ highlightQuery['struct_asym_id'] = e.detail.feature.chainId;
70
+ if (highlightQuery)
71
+ wrapperCtx.visual.highlight({ data: [highlightQuery] });
72
+ }
73
+ });
74
+ document.addEventListener('protvista-mouseout', function (e) {
75
+ wrapperCtx.visual.clearHighlight();
76
+ });
77
+ document.addEventListener('protvista-click', function (e) {
78
+ if (typeof e.detail !== 'undefined') {
79
+ var showInteraction = false;
80
+ var highlightQuery = undefined;
81
+ // Create query object from event data
82
+ if (e.detail.start && e.detail.end) {
83
+ highlightQuery = {
84
+ start_residue_number: parseInt(e.detail.start),
85
+ end_residue_number: parseInt(e.detail.end)
86
+ };
87
+ }
88
+ if (e.detail.feature && e.detail.feature.entityId)
89
+ highlightQuery['entity_id'] = e.detail.feature.entityId + '';
90
+ if (e.detail.feature && e.detail.feature.bestChainId)
91
+ highlightQuery['struct_asym_id'] = e.detail.feature.bestChainId;
92
+ if (e.detail.feature && e.detail.feature.chainId)
93
+ highlightQuery['struct_asym_id'] = e.detail.feature.chainId;
94
+ if (e.detail.feature && e.detail.feature.accession && e.detail.feature.accession.split(' ')[0] === 'Chain' || e.detail.feature.tooltipContent === 'Ligand binding site') {
95
+ showInteraction = true;
96
+ }
97
+ if (e.detail.start === e.detail.end)
98
+ showInteraction = true;
99
+ if (highlightQuery) {
100
+ if (showInteraction) {
101
+ highlightQuery['sideChain'] = true;
102
+ }
103
+ else {
104
+ var selColor = undefined;
105
+ if (e.detail.trackIndex > -1 && e.detail.feature.locations && e.detail.feature.locations[0].fragments[e.detail.trackIndex].color)
106
+ selColor = e.detail.feature.locations[0].fragments[e.detail.trackIndex].color;
107
+ if (typeof selColor == 'undefined' && e.detail.feature.color)
108
+ selColor = e.detail.feature.color;
109
+ if (typeof selColor == 'undefined' && e.detail.color)
110
+ selColor = e.detail.color;
111
+ if (typeof selColor == 'undefined') {
112
+ selColor = { r: 65, g: 96, b: 91 };
113
+ }
114
+ else {
115
+ var isRgb = /rgb/g;
116
+ if (isRgb.test(selColor)) {
117
+ var rgbArr = selColor.substring(4, selColor.length - 1).split(',');
118
+ selColor = { r: rgbArr[0], g: rgbArr[1], b: rgbArr[2] };
119
+ }
120
+ }
121
+ highlightQuery['color'] = selColor;
122
+ }
123
+ highlightQuery['focus'] = true;
124
+ wrapperCtx.visual.select({ data: [highlightQuery] });
125
+ }
126
+ }
127
+ });
128
+ var elementTypeArrForRange = ['uniprot', 'pfam', 'cath', 'scop', 'strand', 'helice'];
129
+ var elementTypeArrForSingle = ['chain', 'quality', 'quality_outlier', 'binding site', 'alternate conformer'];
130
+ document.addEventListener('PDB.seqViewer.click', function (e) {
131
+ if (typeof e.eventData !== 'undefined') {
132
+ // Abort if entryid and entityid do not match or viewer type is unipdb
133
+ // if(e.eventData.entryId != scope.pdbId) return;
134
+ if (typeof e.eventData.elementData !== 'undefined' && elementTypeArrForSingle.indexOf(e.eventData.elementData.elementType) > -1) {
135
+ // Create query object from event data
136
+ var highlightQuery = {
137
+ entity_id: e.eventData.entityId,
138
+ struct_asym_id: e.eventData.elementData.pathData.struct_asym_id,
139
+ start_residue_number: e.eventData.residueNumber,
140
+ end_residue_number: e.eventData.residueNumber,
141
+ sideChain: true,
142
+ focus: true
143
+ };
144
+ // Call highlightAnnotation
145
+ wrapperCtx.visual.select({ data: [highlightQuery] });
146
+ }
147
+ else if (typeof e.eventData.elementData !== 'undefined' && elementTypeArrForRange.indexOf(e.eventData.elementData.elementType) > -1) {
148
+ var seqColorArray = e.eventData.elementData.color;
149
+ // Create query object from event data
150
+ var highlightQuery = {
151
+ entity_id: e.eventData.entityId,
152
+ struct_asym_id: e.eventData.elementData.pathData.struct_asym_id,
153
+ start_residue_number: e.eventData.elementData.pathData.start.residue_number,
154
+ end_residue_number: e.eventData.elementData.pathData.end.residue_number,
155
+ color: { r: seqColorArray[0], g: seqColorArray[1], b: seqColorArray[2] },
156
+ focus: true
157
+ };
158
+ wrapperCtx.visual.select({ data: [highlightQuery] });
159
+ }
160
+ }
161
+ });
162
+ document.addEventListener('PDB.seqViewer.mouseover', function (e) {
163
+ if (typeof e.eventData !== 'undefined') {
164
+ // Abort if entryid and entityid do not match or viewer type is unipdb
165
+ // if(e.eventData.entryId != scope.pdbId) return;
166
+ if (typeof e.eventData.elementData !== 'undefined' && elementTypeArrForSingle.indexOf(e.eventData.elementData.elementType) > -1) {
167
+ // Create query object from event data
168
+ var highlightQuery = {
169
+ entity_id: e.eventData.entityId,
170
+ struct_asym_id: e.eventData.elementData.pathData.struct_asym_id,
171
+ start_residue_number: e.eventData.residueNumber,
172
+ end_residue_number: e.eventData.residueNumber,
173
+ focus: true
174
+ };
175
+ wrapperCtx.visual.select({ data: [highlightQuery] });
176
+ }
177
+ else if (typeof e.eventData.elementData !== 'undefined' && elementTypeArrForRange.indexOf(e.eventData.elementData.elementType) > -1) {
178
+ // Create query object from event data
179
+ var highlightQuery = {
180
+ entity_id: e.eventData.entityId,
181
+ struct_asym_id: e.eventData.elementData.pathData.struct_asym_id,
182
+ start_residue_number: e.eventData.elementData.pathData.start.residue_number,
183
+ end_residue_number: e.eventData.elementData.pathData.end.residue_number
184
+ };
185
+ // Call highlightAnnotation
186
+ wrapperCtx.visual.highlight({ data: [highlightQuery] });
187
+ }
188
+ }
189
+ });
190
+ document.addEventListener('PDB.seqViewer.mouseout', function (e) {
191
+ wrapperCtx.visual.clearHighlight();
192
+ });
193
+ }
194
+ exports.subscribeToComponentEvents = subscribeToComponentEvents;
@@ -0,0 +1,4 @@
1
+ import { PluginContext } from 'Molstar/mol-plugin/context';
2
+ export declare function superpositionExportHierarchy(plugin: PluginContext, options?: {
3
+ format?: 'cif' | 'bcif';
4
+ }): Promise<void>;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.superpositionExportHierarchy = void 0;
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*/];
29
+ }
30
+ });
31
+ });
32
+ }
33
+ exports.superpositionExportHierarchy = superpositionExportHierarchy;
34
+ function _superpositionExportHierarchy(plugin, options) {
35
+ var _this = this;
36
+ return mol_task_1.Task.create('Export', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
37
+ var format, customState, superpositionState, segmentIndex, files, entryMap, structures, _i, structures_1, molId, modelRef, isStrHidden, _s, _a, _b, strComp, s, name_1, zipData, _c, files_1, _d, fn, data, bytes, buffer;
38
+ var _e, _f, _g, _h, _j, _k, _l, _m;
39
+ return tslib_1.__generator(this, function (_o) {
40
+ switch (_o.label) {
41
+ case 0: return [4 /*yield*/, ctx.update({ message: 'Exporting...', isIndeterminate: true, canAbort: false })];
42
+ case 1:
43
+ _o.sent();
44
+ format = (_e = options === null || options === void 0 ? void 0 : options.format) !== null && _e !== void 0 ? _e : '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
+ _i = 0, structures_1 = structures;
54
+ _o.label = 2;
55
+ case 2:
56
+ if (!(_i < structures_1.length)) return [3 /*break*/, 7];
57
+ molId = structures_1[_i];
58
+ modelRef = superpositionState.models[molId];
59
+ if (!modelRef)
60
+ return [3 /*break*/, 6];
61
+ isStrHidden = false;
62
+ _s = plugin.managers.structure.hierarchy.current.refs.get(modelRef);
63
+ if (_s.cell.state.isHidden)
64
+ isStrHidden = true;
65
+ for (_a = 0, _b = _s.components; _a < _b.length; _a++) {
66
+ strComp = _b[_a];
67
+ if (strComp.cell.state.isHidden)
68
+ isStrHidden = true;
69
+ }
70
+ if (isStrHidden)
71
+ return [3 /*break*/, 6];
72
+ s = (_h = (_g = (_f = _s.transform) === null || _f === void 0 ? void 0 : _f.cell.obj) === null || _g === void 0 ? void 0 : _g.data) !== null && _h !== void 0 ? _h : (_j = _s.cell.obj) === null || _j === void 0 ? void 0 : _j.data;
73
+ if (!s)
74
+ return [3 /*break*/, 6];
75
+ if (s.models.length > 1) {
76
+ plugin.log.warn("[Export] Skipping ".concat((_k = _s.cell.obj) === null || _k === void 0 ? void 0 : _k.label, ": Multimodel exports not supported."));
77
+ return [3 /*break*/, 6];
78
+ }
79
+ if (s.units.some(function (u) { return !structure_1.Unit.isAtomic(u); })) {
80
+ plugin.log.warn("[Export] Skipping ".concat((_l = _s.cell.obj) === null || _l === void 0 ? void 0 : _l.label, ": Non-atomic model exports not supported."));
81
+ return [3 /*break*/, 6];
82
+ }
83
+ name_1 = entryMap.has(s.model.entryId)
84
+ ? "".concat(s.model.entryId, "_").concat(entryMap.get(s.model.entryId) + 1, ".").concat(format)
85
+ : "".concat(s.model.entryId, ".").concat(format);
86
+ entryMap.set(s.model.entryId, ((_m = entryMap.get(s.model.entryId)) !== null && _m !== void 0 ? _m : 0) + 1);
87
+ return [4 /*yield*/, ctx.update({ message: "Exporting ".concat(s.model.entryId, "..."), isIndeterminate: true, canAbort: false })];
88
+ case 3:
89
+ _o.sent();
90
+ if (!(s.elementCount > 100000)) return [3 /*break*/, 5];
91
+ // Give UI chance to update, only needed for larger structures.
92
+ return [4 /*yield*/, new Promise(function (res) { return setTimeout(res, 50); })];
93
+ case 4:
94
+ // Give UI chance to update, only needed for larger structures.
95
+ _o.sent();
96
+ _o.label = 5;
97
+ case 5:
98
+ try {
99
+ files.push([name_1, (0, structure_1.to_mmCIF)(s.model.entryId, s, format === 'bcif', { copyAllCategories: true })]);
100
+ }
101
+ catch (e) {
102
+ if (format === 'cif' && s.elementCount > 2000000) {
103
+ plugin.log.warn("[Export] The structure might be too big to be exported as Text CIF, consider using the BinaryCIF format instead.");
104
+ }
105
+ throw e;
106
+ }
107
+ _o.label = 6;
108
+ case 6:
109
+ _i++;
110
+ return [3 /*break*/, 2];
111
+ case 7:
112
+ if (files.length === 0) {
113
+ commands_1.PluginCommands.Toast.Show(plugin, {
114
+ title: 'Export Models',
115
+ message: 'No visible structure in the 3D view to export!',
116
+ key: 'superposition-toast-1',
117
+ timeoutMs: 7000
118
+ });
119
+ return [2 /*return*/];
120
+ }
121
+ if (!(files.length === 1)) return [3 /*break*/, 8];
122
+ (0, download_1.download)(new Blob([files[0][1]]), files[0][0]);
123
+ return [3 /*break*/, 11];
124
+ case 8:
125
+ if (!(files.length > 1)) return [3 /*break*/, 11];
126
+ zipData = {};
127
+ for (_c = 0, files_1 = files; _c < files_1.length; _c++) {
128
+ _d = files_1[_c], fn = _d[0], data = _d[1];
129
+ if (data instanceof Uint8Array) {
130
+ zipData[fn] = data;
131
+ }
132
+ else {
133
+ bytes = new Uint8Array((0, utf8_1.utf8ByteCount)(data));
134
+ (0, utf8_1.utf8Write)(bytes, 0, data);
135
+ zipData[fn] = bytes;
136
+ }
137
+ }
138
+ return [4 /*yield*/, ctx.update({ message: "Compressing Data...", isIndeterminate: true, canAbort: false })];
139
+ case 9:
140
+ _o.sent();
141
+ return [4 /*yield*/, (0, zip_1.zip)(ctx, zipData)];
142
+ case 10:
143
+ buffer = _o.sent();
144
+ (0, download_1.download)(new Blob([new Uint8Array(buffer, 0, buffer.byteLength)]), "structures_".concat((0, date_1.getFormattedTime)(), ".zip"));
145
+ _o.label = 11;
146
+ case 11:
147
+ plugin.log.info("[Export] Done.");
148
+ return [2 /*return*/];
149
+ }
150
+ });
151
+ }); });
152
+ }
@@ -0,0 +1,16 @@
1
+ import { PluginBehavior } from 'Molstar/mol-plugin/behavior';
2
+ import { ParamDefinition as PD } from 'Molstar/mol-util/param-definition';
3
+ import { PluginContext } from 'Molstar/mol-plugin/context';
4
+ declare const SuperpositionFocusRepresentationParams: (plugin: PluginContext) => {
5
+ expandRadius: PD.Numeric;
6
+ surroundingsParams: PD.Group<PD.Normalize<{
7
+ [x: string]: any;
8
+ }>>;
9
+ };
10
+ declare type SuperpositionFocusRepresentationProps = PD.ValuesFor<ReturnType<typeof SuperpositionFocusRepresentationParams>>;
11
+ export declare enum SuperpositionFocusRepresentationTags {
12
+ SurrSel = "superposition-focus-surr-sel",
13
+ SurrRepr = "superposition-focus-surr-repr"
14
+ }
15
+ export declare const SuperpositionFocusRepresentation: import("molstar/lib/mol-state/transformer").StateTransformer<PluginBehavior.Category, PluginBehavior.Behavior, SuperpositionFocusRepresentationProps>;
16
+ export {};
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SuperpositionFocusRepresentation = exports.SuperpositionFocusRepresentationTags = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var structure_1 = require("Molstar/mol-model/structure");
6
+ var structure_representation_params_1 = require("Molstar/mol-plugin-state/helpers/structure-representation-params");
7
+ var transforms_1 = require("Molstar/mol-plugin-state/transforms");
8
+ var behavior_1 = require("Molstar/mol-plugin/behavior");
9
+ var builder_1 = require("Molstar/mol-script/language/builder");
10
+ var mol_state_1 = require("Molstar/mol-state");
11
+ var param_definition_1 = require("Molstar/mol-util/param-definition");
12
+ var commands_1 = require("Molstar/mol-plugin/commands");
13
+ var loci_details_1 = require("./loci-details");
14
+ var SuperpositionFocusRepresentationParams = function (plugin) {
15
+ var reprParams = transforms_1.StateTransforms.Representation.StructureRepresentation3D.definition.params(void 0, plugin);
16
+ return {
17
+ expandRadius: param_definition_1.ParamDefinition.Numeric(5, { min: 1, max: 10, step: 1 }),
18
+ surroundingsParams: param_definition_1.ParamDefinition.Group(reprParams, {
19
+ label: 'Surroundings',
20
+ customDefault: (0, structure_representation_params_1.createStructureRepresentationParams)(plugin, void 0, { type: 'ball-and-stick', size: 'physical', typeParams: { sizeFactor: 0.16 }, sizeParams: { scale: 0.3 } })
21
+ })
22
+ };
23
+ };
24
+ var SuperpositionFocusRepresentationTags;
25
+ (function (SuperpositionFocusRepresentationTags) {
26
+ SuperpositionFocusRepresentationTags["SurrSel"] = "superposition-focus-surr-sel";
27
+ SuperpositionFocusRepresentationTags["SurrRepr"] = "superposition-focus-surr-repr";
28
+ })(SuperpositionFocusRepresentationTags = exports.SuperpositionFocusRepresentationTags || (exports.SuperpositionFocusRepresentationTags = {}));
29
+ var TagSet = new Set([SuperpositionFocusRepresentationTags.SurrSel, SuperpositionFocusRepresentationTags.SurrRepr]);
30
+ var SuperpositionFocusRepresentationBehavior = /** @class */ (function (_super) {
31
+ tslib_1.__extends(SuperpositionFocusRepresentationBehavior, _super);
32
+ function SuperpositionFocusRepresentationBehavior() {
33
+ return _super !== null && _super.apply(this, arguments) || this;
34
+ }
35
+ Object.defineProperty(SuperpositionFocusRepresentationBehavior.prototype, "surrLabel", {
36
+ get: function () { return "[Focus] Surroundings (".concat(this.params.expandRadius, " \u00C5)"); },
37
+ enumerable: false,
38
+ configurable: true
39
+ });
40
+ SuperpositionFocusRepresentationBehavior.prototype.ensureShape = function (cell) {
41
+ var state = this.plugin.state.data, tree = state.tree;
42
+ var builder = state.build();
43
+ var refs = mol_state_1.StateSelection.findUniqueTagsInSubtree(tree, cell.transform.ref, TagSet);
44
+ // Selections
45
+ if (!refs[SuperpositionFocusRepresentationTags.SurrSel]) {
46
+ refs[SuperpositionFocusRepresentationTags.SurrSel] = builder
47
+ .to(cell)
48
+ .apply(transforms_1.StateTransforms.Model.StructureSelectionFromExpression, { expression: builder_1.MolScriptBuilder.struct.generator.empty(), label: this.surrLabel }, { tags: SuperpositionFocusRepresentationTags.SurrSel }).ref;
49
+ }
50
+ // Representations
51
+ if (!refs[SuperpositionFocusRepresentationTags.SurrRepr]) {
52
+ refs[SuperpositionFocusRepresentationTags.SurrRepr] = builder
53
+ .to(refs[SuperpositionFocusRepresentationTags.SurrSel])
54
+ .apply(transforms_1.StateTransforms.Representation.StructureRepresentation3D, this.params.surroundingsParams, { tags: SuperpositionFocusRepresentationTags.SurrRepr }).ref;
55
+ }
56
+ return { state: state, builder: builder, refs: refs };
57
+ };
58
+ SuperpositionFocusRepresentationBehavior.prototype.clear = function (root) {
59
+ var state = this.plugin.state.data;
60
+ var surrs = state.select(mol_state_1.StateSelection.Generators.byRef(root).subtree().withTag(SuperpositionFocusRepresentationTags.SurrSel));
61
+ if (surrs.length === 0)
62
+ return;
63
+ var update = state.build();
64
+ var expression = builder_1.MolScriptBuilder.struct.generator.empty();
65
+ for (var _i = 0, surrs_1 = surrs; _i < surrs_1.length; _i++) {
66
+ var s = surrs_1[_i];
67
+ update.to(s).update(transforms_1.StateTransforms.Model.StructureSelectionFromExpression, function (old) { return (tslib_1.__assign(tslib_1.__assign({}, old), { expression: expression })); });
68
+ }
69
+ return commands_1.PluginCommands.State.Update(this.plugin, { state: state, tree: update, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
70
+ };
71
+ SuperpositionFocusRepresentationBehavior.prototype.focus = function (sourceLoci) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
73
+ var parent, loci, residueLoci, residueBundle, target, surroundings, lociDeatils, _a, state, builder, refs;
74
+ var _this = this;
75
+ return tslib_1.__generator(this, function (_b) {
76
+ switch (_b.label) {
77
+ case 0:
78
+ parent = this.plugin.helpers.substructureParent.get(sourceLoci.structure);
79
+ if (!parent || !parent.obj)
80
+ return [2 /*return*/];
81
+ loci = structure_1.StructureElement.Loci.remap(sourceLoci, parent.obj.data);
82
+ residueLoci = structure_1.StructureElement.Loci.extendToWholeResidues(loci);
83
+ residueBundle = structure_1.StructureElement.Bundle.fromLoci(residueLoci);
84
+ target = structure_1.StructureElement.Bundle.toExpression(residueBundle);
85
+ surroundings = builder_1.MolScriptBuilder.struct.modifier.includeSurroundings({
86
+ 0: target,
87
+ radius: this.params.expandRadius,
88
+ 'as-whole-residues': true
89
+ });
90
+ lociDeatils = (0, loci_details_1.lociDetails)(sourceLoci);
91
+ if (!lociDeatils) {
92
+ surroundings = builder_1.MolScriptBuilder.struct.modifier.exceptBy({
93
+ 0: surroundings,
94
+ by: target
95
+ });
96
+ }
97
+ _a = this.ensureShape(parent), state = _a.state, builder = _a.builder, refs = _a.refs;
98
+ builder.to(refs[SuperpositionFocusRepresentationTags.SurrSel]).update(transforms_1.StateTransforms.Model.StructureSelectionFromExpression, function (old) { return (tslib_1.__assign(tslib_1.__assign({}, old), { expression: surroundings, label: _this.surrLabel })); });
99
+ return [4 /*yield*/, commands_1.PluginCommands.State.Update(this.plugin, { state: state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } })];
100
+ case 1:
101
+ _b.sent();
102
+ return [2 /*return*/];
103
+ }
104
+ });
105
+ });
106
+ };
107
+ SuperpositionFocusRepresentationBehavior.prototype.register = function (ref) {
108
+ var _this = this;
109
+ this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current, function (entry) {
110
+ // if (entry) this.focus(entry.loci);
111
+ // else this.clear(StateTransform.RootRef);
112
+ _this.clear(mol_state_1.StateTransform.RootRef);
113
+ if (entry)
114
+ _this.focus(entry.loci);
115
+ });
116
+ };
117
+ SuperpositionFocusRepresentationBehavior.prototype.update = function (params) {
118
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
119
+ var old, state, builder, all, _i, _a, repr;
120
+ return tslib_1.__generator(this, function (_b) {
121
+ switch (_b.label) {
122
+ case 0:
123
+ old = this.params;
124
+ this.params = params;
125
+ state = this.plugin.state.data;
126
+ builder = state.build();
127
+ all = mol_state_1.StateSelection.Generators.root.subtree();
128
+ for (_i = 0, _a = state.select(all.withTag(SuperpositionFocusRepresentationTags.SurrRepr)); _i < _a.length; _i++) {
129
+ repr = _a[_i];
130
+ builder.to(repr).update(this.params.surroundingsParams);
131
+ }
132
+ return [4 /*yield*/, commands_1.PluginCommands.State.Update(this.plugin, { state: state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } })];
133
+ case 1:
134
+ _b.sent();
135
+ if (!(params.expandRadius !== old.expandRadius)) return [3 /*break*/, 3];
136
+ return [4 /*yield*/, this.clear(mol_state_1.StateTransform.RootRef)];
137
+ case 2:
138
+ _b.sent();
139
+ _b.label = 3;
140
+ case 3: return [2 /*return*/, true];
141
+ }
142
+ });
143
+ });
144
+ };
145
+ return SuperpositionFocusRepresentationBehavior;
146
+ }(behavior_1.PluginBehavior.WithSubscribers));
147
+ exports.SuperpositionFocusRepresentation = behavior_1.PluginBehavior.create({
148
+ name: 'create-superposition-focus-representation',
149
+ display: { name: 'Superposition Focus Representation' },
150
+ category: 'interaction',
151
+ ctor: SuperpositionFocusRepresentationBehavior,
152
+ params: function (_, plugin) { return SuperpositionFocusRepresentationParams(plugin); }
153
+ });
@@ -0,0 +1,22 @@
1
+ import { MinimizeRmsd } from 'Molstar/mol-math/linear-algebra/3d/minimize-rmsd';
2
+ import { ElementIndex, ResidueIndex } from 'Molstar/mol-model/structure/model/indexing';
3
+ import { StructureElement } from 'Molstar/mol-model/structure/structure/element';
4
+ import { Structure } from 'Molstar/mol-model/structure';
5
+ import { Unit } from 'Molstar/mol-model/structure/structure/unit';
6
+ export interface AlignmentResultEntry {
7
+ transform: MinimizeRmsd.Result;
8
+ pivot: number;
9
+ other: number;
10
+ }
11
+ export interface AlignmentResult {
12
+ entries: AlignmentResultEntry[];
13
+ zeroOverlapPairs: [number, number][];
14
+ failedPairs: [number, number][];
15
+ }
16
+ declare type IncludeResidueTest = (traceElementOrFirstAtom: StructureElement.Location<Unit.Atomic>, residueIndex: ResidueIndex, startIndex: ElementIndex, endIndex: ElementIndex) => boolean;
17
+ export declare function alignAndSuperposeWithSIFTSMapping(structures: Structure[], options?: {
18
+ traceOnly?: boolean;
19
+ includeResidueTest?: IncludeResidueTest;
20
+ applyTestIndex?: number[];
21
+ }): AlignmentResult;
22
+ export {};