drugflow-molstar 0.4.7 → 0.4.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.
- package/build/drugflow-molstar-0.4.9.css +1 -0
- package/build/drugflow-molstar-component-0.4.9.js +25 -0
- package/build/drugflow-molstar-plugin-0.4.9.js +2 -0
- package/build/drugflow-molstar-plugin-0.4.9.js.LICENSE.txt +39 -0
- package/lib/alphafold-transparency.js +157 -62
- package/lib/contact.d.ts +7 -14
- package/lib/contact.js +68 -72
- package/lib/custom-events.js +15 -15
- package/lib/domain-annotations/behavior.d.ts +1 -1
- package/lib/domain-annotations/behavior.js +24 -20
- package/lib/domain-annotations/color.js +22 -22
- package/lib/domain-annotations/prop.js +111 -62
- package/lib/drugflow-molstar-component-build-0.4.8.js +2 -0
- package/lib/drugflow-molstar-component-build-0.4.8.js.LICENSE.txt +24 -0
- package/lib/drugflow-molstar-component-build-0.4.9.js +2 -0
- package/lib/drugflow-molstar-component-build-0.4.9.js.LICENSE.txt +24 -0
- package/lib/helpers.d.ts +3 -3
- package/lib/helpers.js +94 -89
- package/lib/index.d.ts +902 -1
- package/lib/index.js +2814 -1875
- package/lib/labels.d.ts +1 -1
- package/lib/labels.js +34 -20
- package/lib/loci-details.js +46 -34
- package/lib/sifts-mapping.js +32 -28
- package/lib/sifts-mappings-behaviour.d.ts +1 -1
- package/lib/sifts-mappings-behaviour.js +30 -26
- package/lib/spec.js +40 -52
- package/lib/structure_contact3d.d.ts +14 -21
- package/lib/structure_contact3d.js +46 -25
- package/lib/subscribe-events.js +18 -19
- package/lib/superposition-export.js +178 -102
- package/lib/superposition-focus-representation.d.ts +2 -2
- package/lib/superposition-focus-representation.js +131 -73
- package/lib/superposition-sifts-mapping.js +150 -105
- package/lib/superposition.js +810 -495
- package/lib/ui/alphafold-superposition.d.ts +1 -1
- package/lib/ui/alphafold-superposition.js +118 -94
- package/lib/ui/alphafold-tranparency.js +43 -27
- package/lib/ui/annotation-controls.js +89 -83
- package/lib/ui/export-superposition.d.ts +0 -1
- package/lib/ui/export-superposition.js +50 -32
- package/lib/ui/pdbe-left-panel.d.ts +0 -1
- package/lib/ui/pdbe-left-panel.js +105 -82
- package/lib/ui/pdbe-screenshot-controls.js +83 -54
- package/lib/ui/pdbe-structure-controls.js +57 -34
- package/lib/ui/pdbe-viewport-controls.js +29 -23
- package/lib/ui/segment-tree.js +663 -440
- package/lib/ui/superposition-components.js +312 -208
- package/lib/ui/superposition-viewport.js +18 -11
- package/package.json +3 -3
- package/build/drugflow-molstar-0.4.7.css +0 -1
- package/build/drugflow-molstar-component-0.4.7.js +0 -25
- package/build/drugflow-molstar-plugin-0.4.7.js +0 -2
- package/build/drugflow-molstar-plugin-0.4.7.js.LICENSE.txt +0 -64
package/lib/superposition.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
exports.initSuperposition = initSuperposition;
|
|
4
|
+
exports.loadAfStructure = loadAfStructure;
|
|
5
|
+
exports.superposeAf = superposeAf;
|
|
6
|
+
exports.renderSuperposition = renderSuperposition;
|
|
7
|
+
var tslib_1 = require("tslib");
|
|
8
|
+
var linear_algebra_1 = require("Molstar/mol-math/linear-algebra");
|
|
9
|
+
var builder_1 = require("Molstar/mol-script/language/builder");
|
|
10
|
+
var mol_state_1 = require("Molstar/mol-state");
|
|
11
|
+
var transforms_1 = require("Molstar/mol-plugin-state/transforms");
|
|
12
|
+
var assets_1 = require("Molstar/mol-util/assets");
|
|
13
|
+
var helpers_1 = require("./helpers");
|
|
14
|
+
var lists_1 = require("Molstar/mol-util/color/lists");
|
|
15
|
+
var color_1 = require("Molstar/mol-util/color/color");
|
|
16
|
+
var script_1 = require("Molstar/mol-script/script");
|
|
17
|
+
var mol_task_1 = require("Molstar/mol-task");
|
|
18
|
+
var superposition_sifts_mapping_1 = require("./superposition-sifts-mapping");
|
|
19
|
+
var alphafold_transparency_1 = require("./alphafold-transparency");
|
|
20
|
+
var structure_1 = require("Molstar/mol-model/structure");
|
|
17
21
|
function getRandomColor(plugin, segmentIndex) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
var clList = lists_1.ColorLists;
|
|
23
|
+
var spState = plugin.customState.superpositionState;
|
|
24
|
+
var palleteIndex = spState.colorState[segmentIndex].palleteIndex;
|
|
25
|
+
var colorIndex = spState.colorState[segmentIndex].colorIndex;
|
|
22
26
|
if (clList[spState.colorPalette[palleteIndex]].list[colorIndex + 1]) {
|
|
23
27
|
colorIndex += 1;
|
|
24
28
|
}
|
|
@@ -26,418 +30,636 @@ function getRandomColor(plugin, segmentIndex) {
|
|
|
26
30
|
colorIndex = 0;
|
|
27
31
|
palleteIndex = spState.colorPalette[palleteIndex + 1] ? palleteIndex + 1 : 0;
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
var palleteName = spState.colorPalette[palleteIndex];
|
|
30
34
|
plugin.customState.superpositionState.colorState[segmentIndex].palleteIndex = palleteIndex;
|
|
31
35
|
plugin.customState.superpositionState.colorState[segmentIndex].colorIndex = colorIndex;
|
|
32
36
|
return clList[palleteName].list[colorIndex];
|
|
33
37
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
38
|
+
function initSuperposition(plugin) {
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
40
|
+
var customState, superpositionParams, segmentData, afStrUrls, segmentIndex, clusterIndexs, entryList, clusters;
|
|
41
|
+
return tslib_1.__generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0: return [4 /*yield*/, plugin.clear()];
|
|
44
|
+
case 1:
|
|
45
|
+
_a.sent();
|
|
46
|
+
customState = plugin.customState;
|
|
47
|
+
superpositionParams = customState.initParams.superpositionParams;
|
|
48
|
+
plugin.customState.superpositionState = {
|
|
49
|
+
models: {},
|
|
50
|
+
entries: {},
|
|
51
|
+
refMaps: {},
|
|
52
|
+
segmentData: void 0,
|
|
53
|
+
matrixData: {},
|
|
54
|
+
activeSegment: 0,
|
|
55
|
+
loadedStructs: [],
|
|
56
|
+
visibleRefs: [],
|
|
57
|
+
invalidStruct: [],
|
|
58
|
+
noMatrixStruct: [],
|
|
59
|
+
hets: {},
|
|
60
|
+
colorPalette: ['dark-2', 'red-yellow-green', 'paired', 'set-1', 'accent', 'set-2', 'rainbow'],
|
|
61
|
+
colorState: [],
|
|
62
|
+
alphafold: {
|
|
63
|
+
apiData: {
|
|
64
|
+
cif: '',
|
|
65
|
+
pae: '',
|
|
66
|
+
length: 0
|
|
67
|
+
},
|
|
68
|
+
length: 0,
|
|
69
|
+
ref: '',
|
|
70
|
+
traceOnly: true,
|
|
71
|
+
visibility: [],
|
|
72
|
+
transforms: [],
|
|
73
|
+
rmsds: [],
|
|
74
|
+
coordinateSystems: []
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// Get segment and cluster information for the given uniprot accession
|
|
78
|
+
return [4 /*yield*/, getSegmentData(plugin)];
|
|
79
|
+
case 2:
|
|
80
|
+
// Get segment and cluster information for the given uniprot accession
|
|
81
|
+
_a.sent();
|
|
82
|
+
segmentData = plugin.customState.superpositionState.segmentData;
|
|
83
|
+
if (!segmentData)
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
// Load Matrix Data
|
|
86
|
+
return [4 /*yield*/, getMatrixData(plugin)];
|
|
87
|
+
case 3:
|
|
88
|
+
// Load Matrix Data
|
|
89
|
+
_a.sent();
|
|
90
|
+
if (!plugin.customState.superpositionState.segmentData)
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
return [4 /*yield*/, getAfUrl(plugin, customState.initParams.moleculeId)];
|
|
93
|
+
case 4:
|
|
94
|
+
afStrUrls = _a.sent();
|
|
95
|
+
if (afStrUrls)
|
|
96
|
+
customState.superpositionState.alphafold.apiData = afStrUrls;
|
|
97
|
+
segmentData.forEach(function () {
|
|
98
|
+
plugin.customState.superpositionState.loadedStructs.push([]);
|
|
99
|
+
plugin.customState.superpositionState.visibleRefs.push([]);
|
|
100
|
+
plugin.customState.superpositionState.colorState.push({ palleteIndex: 0, colorIndex: -1 });
|
|
101
|
+
});
|
|
102
|
+
segmentIndex = (superpositionParams && superpositionParams.segment) ? superpositionParams.segment - 1 : 0;
|
|
103
|
+
plugin.customState.superpositionState.activeSegment = segmentIndex + 1;
|
|
104
|
+
clusterIndexs = (superpositionParams && superpositionParams.cluster) ? superpositionParams.cluster : void 0;
|
|
105
|
+
// Emit segment API data load event
|
|
106
|
+
plugin.customState.events.superpositionInit.next(true);
|
|
107
|
+
entryList = [];
|
|
108
|
+
clusters = segmentData[segmentIndex].clusters;
|
|
109
|
+
clusters.forEach(function (cluster, clusterIndex) {
|
|
110
|
+
// Validate for cluster index if provided in superPositionParams
|
|
111
|
+
if (clusterIndexs && clusterIndexs.indexOf(clusterIndex) === -1)
|
|
112
|
+
return;
|
|
113
|
+
// Add respresentative structure to the list
|
|
114
|
+
if (superpositionParams && superpositionParams.superposeAll) {
|
|
115
|
+
entryList = entryList.concat(cluster);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
entryList.push(cluster[0]);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return [4 /*yield*/, renderSuperposition(plugin, segmentIndex, entryList)];
|
|
122
|
+
case 5:
|
|
123
|
+
_a.sent();
|
|
124
|
+
return [2 /*return*/];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
104
127
|
});
|
|
105
|
-
await renderSuperposition(plugin, segmentIndex, entryList);
|
|
106
128
|
}
|
|
107
|
-
exports.initSuperposition = initSuperposition;
|
|
108
129
|
function createCarbVisLabel(carbLigNamesAndCount) {
|
|
109
|
-
|
|
110
|
-
for (
|
|
111
|
-
compList.push(
|
|
130
|
+
var compList = [];
|
|
131
|
+
for (var carbCompId in carbLigNamesAndCount) {
|
|
132
|
+
compList.push("".concat(carbCompId, " (").concat(carbLigNamesAndCount[carbCompId], ")"));
|
|
112
133
|
}
|
|
113
134
|
return compList.join(', ');
|
|
114
135
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
function getAfUrl(plugin, accession) {
|
|
137
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
138
|
+
var apiResponse, apiData;
|
|
139
|
+
var _this = this;
|
|
140
|
+
return tslib_1.__generator(this, function (_a) {
|
|
141
|
+
switch (_a.label) {
|
|
142
|
+
case 0: return [4 /*yield*/, plugin.runTask(mol_task_1.Task.create('Get AlphaFold URL', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
143
|
+
var e_1;
|
|
144
|
+
return tslib_1.__generator(this, function (_a) {
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0:
|
|
147
|
+
_a.trys.push([0, 2, , 3]);
|
|
148
|
+
return [4 /*yield*/, plugin.fetch({ url: "https://alphafold.ebi.ac.uk/api/prediction/".concat(accession), type: 'json' }).runInContext(ctx)];
|
|
149
|
+
case 1:
|
|
150
|
+
apiResponse = _a.sent();
|
|
151
|
+
if (apiResponse && (apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse[0].bcifUrl)) {
|
|
152
|
+
apiData = {
|
|
153
|
+
cif: apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse[0].cifUrl,
|
|
154
|
+
pae: apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse[0].paeImageUrl,
|
|
155
|
+
length: apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse[0].uniprotEnd
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return [3 /*break*/, 3];
|
|
159
|
+
case 2:
|
|
160
|
+
e_1 = _a.sent();
|
|
161
|
+
return [3 /*break*/, 3];
|
|
162
|
+
case 3: return [2 /*return*/];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}); }))];
|
|
166
|
+
case 1:
|
|
167
|
+
_a.sent();
|
|
168
|
+
return [2 /*return*/, apiData];
|
|
127
169
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// console.warn(e);
|
|
131
|
-
}
|
|
132
|
-
}));
|
|
133
|
-
return apiData;
|
|
170
|
+
});
|
|
171
|
+
});
|
|
134
172
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
173
|
+
function loadAfStructure(plugin) {
|
|
174
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var customState, structure, strInstance, spState, chainSel;
|
|
176
|
+
return tslib_1.__generator(this, function (_a) {
|
|
177
|
+
switch (_a.label) {
|
|
178
|
+
case 0:
|
|
179
|
+
customState = plugin.customState;
|
|
180
|
+
return [4 /*yield*/, loadStructure(plugin, customState.superpositionState.alphafold.apiData.cif, 'mmcif', false)];
|
|
181
|
+
case 1:
|
|
182
|
+
structure = (_a.sent()).structure;
|
|
183
|
+
strInstance = structure;
|
|
184
|
+
if (!strInstance)
|
|
185
|
+
return [2 /*return*/, false];
|
|
186
|
+
spState = plugin.customState.superpositionState;
|
|
187
|
+
spState.alphafold.ref = strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref;
|
|
188
|
+
spState.models["AF-".concat(customState.initParams.moleculeId)] = strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref;
|
|
189
|
+
return [4 /*yield*/, plugin.builders.structure.tryCreateComponentStatic(strInstance, 'polymer', { label: "AlphaFold Structure", tags: ["alphafold-chain", "superposition-sel"] })];
|
|
190
|
+
case 2:
|
|
191
|
+
chainSel = _a.sent();
|
|
192
|
+
if (!chainSel) return [3 /*break*/, 4];
|
|
193
|
+
return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'plddt-confidence', size: 'uniform', sizeParams: { value: 1.5 } }, { tag: "af-superposition-visual" })];
|
|
194
|
+
case 3:
|
|
195
|
+
_a.sent();
|
|
196
|
+
return [2 /*return*/, strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref];
|
|
197
|
+
case 4: return [2 /*return*/, false];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
151
201
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
202
|
+
function superposeAf(plugin, traceOnly, segmentIndex) {
|
|
203
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
204
|
+
var customState, spState, afStrRef, _a, afStr, segmentNum, mappingResult_1, coordinateSystems_1, failedPairsResult_1, zeroOverlapPairsResult_1, minRmsd_1, minIndex_1, rmsdList_1, segmentClusters;
|
|
205
|
+
return tslib_1.__generator(this, function (_b) {
|
|
206
|
+
switch (_b.label) {
|
|
207
|
+
case 0:
|
|
208
|
+
customState = plugin.customState;
|
|
209
|
+
if (!customState.superpositionState || !customState.superpositionState.segmentData)
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
spState = customState.superpositionState;
|
|
212
|
+
_a = spState.alphafold.ref;
|
|
213
|
+
if (_a) return [3 /*break*/, 2];
|
|
214
|
+
return [4 /*yield*/, loadAfStructure(plugin)];
|
|
215
|
+
case 1:
|
|
216
|
+
_a = (_b.sent());
|
|
217
|
+
_b.label = 2;
|
|
218
|
+
case 2:
|
|
219
|
+
afStrRef = _a;
|
|
220
|
+
if (!afStrRef)
|
|
221
|
+
return [2 /*return*/];
|
|
222
|
+
afStr = plugin.managers.structure.hierarchy.current.refs.get(afStrRef);
|
|
223
|
+
segmentNum = segmentIndex ? segmentIndex : spState.activeSegment - 1;
|
|
224
|
+
if (!spState.alphafold.transforms[segmentNum]) {
|
|
225
|
+
mappingResult_1 = [];
|
|
226
|
+
coordinateSystems_1 = [];
|
|
227
|
+
failedPairsResult_1 = [];
|
|
228
|
+
zeroOverlapPairsResult_1 = [];
|
|
229
|
+
minRmsd_1 = 0;
|
|
230
|
+
minIndex_1 = 0;
|
|
231
|
+
rmsdList_1 = [];
|
|
232
|
+
segmentClusters = spState.segmentData[segmentNum].clusters;
|
|
233
|
+
segmentClusters.forEach(function (cluster) {
|
|
234
|
+
var _a, _b, _c;
|
|
235
|
+
var modelRef = spState.models["".concat(cluster[0].pdb_id, "_").concat(cluster[0].struct_asym_id)];
|
|
236
|
+
if (modelRef) {
|
|
237
|
+
var structHierarchy = plugin.managers.structure.hierarchy.current.refs.get(modelRef);
|
|
238
|
+
if (structHierarchy) {
|
|
239
|
+
var input = [structHierarchy.components[0], afStr];
|
|
240
|
+
var structures = input.map(function (s) { var _a; return (_a = s.cell.obj) === null || _a === void 0 ? void 0 : _a.data; });
|
|
241
|
+
var _d = (0, superposition_sifts_mapping_1.alignAndSuperposeWithSIFTSMapping)(structures, { traceOnly: traceOnly, includeResidueTest: function (loc) { return structure_1.StructureProperties.atom.B_iso_or_equiv(loc) > 70; },
|
|
242
|
+
applyTestIndex: [1] }), entries = _d.entries, failedPairs = _d.failedPairs, zeroOverlapPairs = _d.zeroOverlapPairs;
|
|
243
|
+
if (entries.length === 0 || (entries && entries[0] && entries[0].transform.rmsd.toFixed(1) === '0.0')) {
|
|
244
|
+
var alignWithoutPlddt = (0, superposition_sifts_mapping_1.alignAndSuperposeWithSIFTSMapping)(structures, { traceOnly: traceOnly });
|
|
245
|
+
entries = alignWithoutPlddt.entries;
|
|
246
|
+
}
|
|
247
|
+
if (entries && entries[0]) {
|
|
248
|
+
mappingResult_1.push(entries[0]);
|
|
249
|
+
coordinateSystems_1.push((_c = (_b = (_a = input[0]) === null || _a === void 0 ? void 0 : _a.transform) === null || _b === void 0 ? void 0 : _b.cell.obj) === null || _c === void 0 ? void 0 : _c.data.coordinateSystem);
|
|
250
|
+
var totalMappings = mappingResult_1.length;
|
|
251
|
+
if (totalMappings === 1 || entries[0].transform.rmsd < minRmsd_1) {
|
|
252
|
+
minRmsd_1 = entries[0].transform.rmsd;
|
|
253
|
+
minIndex_1 = totalMappings === 1 ? 0 : mappingResult_1.length - 1;
|
|
254
|
+
}
|
|
255
|
+
rmsdList_1.push("".concat(cluster[0].pdb_id, " chain ").concat(cluster[0].struct_asym_id, ":").concat(entries[0].transform.rmsd.toFixed(2)));
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
if (failedPairs.length > 0)
|
|
259
|
+
failedPairsResult_1.push(failedPairs);
|
|
260
|
+
if (zeroOverlapPairs.length > 0)
|
|
261
|
+
zeroOverlapPairsResult_1.push(zeroOverlapPairs);
|
|
262
|
+
// rmsdList.push(`${cluster[0].pdb_id} ${cluster[0].struct_asym_id}:-`)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
// console.log(failedPairsResult);
|
|
268
|
+
// console.log(zeroOverlapPairsResult);
|
|
269
|
+
if (mappingResult_1.length > 0) {
|
|
270
|
+
spState.alphafold.visibility[segmentNum] = true;
|
|
271
|
+
spState.alphafold.transforms[segmentNum] = mappingResult_1[minIndex_1].transform.bTransform;
|
|
272
|
+
spState.alphafold.coordinateSystems[segmentNum] = coordinateSystems_1[minIndex_1];
|
|
273
|
+
spState.alphafold.rmsds[segmentNum] = rmsdList_1.sort(function (a, b) { return parseFloat(a.split(':')[1]) - parseFloat(b.split(':')[1]); });
|
|
196
274
|
}
|
|
197
|
-
rmsdList.push(`${cluster[0].pdb_id} chain ${cluster[0].struct_asym_id}:${entries[0].transform.rmsd.toFixed(2)}`);
|
|
198
275
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// rmsdList.push(`${cluster[0].pdb_id} ${cluster[0].struct_asym_id}:-`)
|
|
205
|
-
}
|
|
206
|
-
}
|
|
276
|
+
return [4 /*yield*/, afTransform(plugin, afStr.cell, spState.alphafold.transforms[segmentNum], spState.alphafold.coordinateSystems[segmentNum])];
|
|
277
|
+
case 3:
|
|
278
|
+
_b.sent();
|
|
279
|
+
(0, alphafold_transparency_1.applyAFTransparency)(plugin, afStr, 0.8, 70);
|
|
280
|
+
return [2 /*return*/, true];
|
|
207
281
|
}
|
|
208
282
|
});
|
|
209
|
-
|
|
210
|
-
// console.log(zeroOverlapPairsResult);
|
|
211
|
-
if (mappingResult.length > 0) {
|
|
212
|
-
spState.alphafold.visibility[segmentNum] = true;
|
|
213
|
-
spState.alphafold.transforms[segmentNum] = mappingResult[minIndex].transform.bTransform;
|
|
214
|
-
spState.alphafold.coordinateSystems[segmentNum] = coordinateSystems[minIndex];
|
|
215
|
-
spState.alphafold.rmsds[segmentNum] = rmsdList.sort((a, b) => parseFloat(a.split(':')[1]) - parseFloat(b.split(':')[1]));
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
await afTransform(plugin, afStr.cell, spState.alphafold.transforms[segmentNum], spState.alphafold.coordinateSystems[segmentNum]);
|
|
219
|
-
(0, alphafold_transparency_1.applyAFTransparency)(plugin, afStr, 0.8, 70);
|
|
220
|
-
return true;
|
|
283
|
+
});
|
|
221
284
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const spState = plugin.customState.superpositionState;
|
|
234
|
-
for await (const s of entryList) {
|
|
235
|
-
// validate matrix availability
|
|
236
|
-
if (!spState.matrixData[`${s.pdb_id}_${s.auth_asym_id}`]) {
|
|
237
|
-
spState.noMatrixStruct.push(`${s.pdb_id}_${s.struct_asym_id}`);
|
|
238
|
-
spState.invalidStruct.push(`${s.pdb_id}_${s.struct_asym_id}`);
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
spState.loadedStructs[segmentIndex].push(`${s.pdb_id}_${s.struct_asym_id}`);
|
|
242
|
-
// Set Coordinate server url
|
|
243
|
-
let strUrl = `${customState.initParams.pdbeUrl}model-server/v1/${s.pdb_id}/atoms?auth_asym_id=${s.auth_asym_id}&encoding=${customState.initParams.encoding}`;
|
|
244
|
-
if (superpositionParams && superpositionParams.ligandView)
|
|
245
|
-
strUrl = `https://www.ebi.ac.uk/pdbe/entry-files/download/${s.pdb_id}.bcif`;
|
|
246
|
-
// Load Data
|
|
247
|
-
let strInstance;
|
|
248
|
-
let modelRef;
|
|
249
|
-
let clearOnFail = true;
|
|
250
|
-
if (superpositionParams && superpositionParams.ligandView && spState.entries[s.pdb_id]) {
|
|
251
|
-
const polymerInstance = plugin.state.data.select(spState.entries[s.pdb_id])[0];
|
|
252
|
-
modelRef = polymerInstance.transform.parent;
|
|
253
|
-
const modelInstance = plugin.state.data.select(modelRef)[0];
|
|
254
|
-
strInstance = await plugin.builders.structure.createStructure(modelInstance, { name: 'model', params: {} });
|
|
255
|
-
clearOnFail = false;
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
const isBinary = customState.initParams.encoding === 'bcif' ? true : false;
|
|
259
|
-
const { model, structure } = await loadStructure(plugin, strUrl, 'mmcif', isBinary);
|
|
260
|
-
strInstance = structure;
|
|
261
|
-
modelRef = model.ref;
|
|
262
|
-
}
|
|
263
|
-
if (!strInstance)
|
|
264
|
-
continue;
|
|
265
|
-
// Store Refs in state
|
|
266
|
-
if (!spState.models[`${s.pdb_id}_${s.struct_asym_id}`])
|
|
267
|
-
spState.models[`${s.pdb_id}_${s.struct_asym_id}`] = strInstance?.ref;
|
|
268
|
-
if (superpositionParams && superpositionParams.ligandView && !spState.entries[s.pdb_id])
|
|
269
|
-
spState.entries[s.pdb_id] = strInstance?.ref;
|
|
270
|
-
// Apply tranform matrix
|
|
271
|
-
const matrix = linear_algebra_1.Mat4.ofRows(plugin.customState.superpositionState.matrixData[`${s.pdb_id}_${s.auth_asym_id}`].matrix);
|
|
272
|
-
await transform(plugin, strInstance, matrix);
|
|
273
|
-
// Create representations
|
|
274
|
-
let chainSel;
|
|
275
|
-
if ((superpositionParams && superpositionParams.ligandView) && s.is_representative) {
|
|
276
|
-
const uniformColor1 = getRandomColor(plugin, segmentIndex); // random color
|
|
277
|
-
chainSel = await plugin.builders.structure.tryCreateComponentFromExpression(strInstance, chainSelection(s.struct_asym_id), `Chain-${segmentIndex}`, { label: `Chain`, tags: [`superposition-sel`] });
|
|
278
|
-
if (chainSel) {
|
|
279
|
-
await plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'uniform', colorParams: { value: uniformColor1 }, size: 'uniform' }, { tag: `superposition-visual` });
|
|
280
|
-
spState.refMaps[chainSel.ref] = `${s.pdb_id}_${s.struct_asym_id}`;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else if ((superpositionParams && superpositionParams.ligandView) && !s.is_representative) {
|
|
284
|
-
// Do nothing
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
const uniformColor2 = getRandomColor(plugin, segmentIndex); // random color
|
|
288
|
-
chainSel = await plugin.builders.structure.tryCreateComponentStatic(strInstance, 'polymer', { label: `Chain`, tags: [`Chain-${segmentIndex}`, `superposition-sel`] });
|
|
289
|
-
if (chainSel) {
|
|
290
|
-
await plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'uniform', colorParams: { value: uniformColor2 }, size: 'uniform' }, { tag: `superposition-visual` });
|
|
291
|
-
spState.refMaps[chainSel.ref] = `${s.pdb_id}_${s.struct_asym_id}`;
|
|
292
|
-
}
|
|
293
|
-
// // const addTooltipUpdate = plugin.state.behaviors.build().to(BestDatabaseSequenceMapping.id).update(BestDatabaseSequenceMapping, (old: any) => { old.showTooltip = true; });
|
|
294
|
-
// // await plugin.runTask(plugin.state.behaviors.updateTree(addTooltipUpdate));
|
|
295
|
-
// BestDatabaseSequenceMapping
|
|
296
|
-
// console.log(plugin.state.data.select(modelRef)[0])
|
|
285
|
+
function renderSuperposition(plugin, segmentIndex, entryList) {
|
|
286
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
287
|
+
var customState, superpositionParams, busyFlagOn;
|
|
288
|
+
var _this = this;
|
|
289
|
+
return tslib_1.__generator(this, function (_a) {
|
|
290
|
+
customState = plugin.customState;
|
|
291
|
+
superpositionParams = customState.initParams.superpositionParams;
|
|
292
|
+
busyFlagOn = false;
|
|
293
|
+
if (entryList.length > 1) {
|
|
294
|
+
busyFlagOn = true;
|
|
295
|
+
customState.events.isBusy.next(true);
|
|
297
296
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
const carbEntityCount = hetInfo ? hetInfo.carbEntityCount : 0;
|
|
327
|
-
if (carbEntityCount > 0) {
|
|
328
|
-
// Get Carbohydrate Polymers details from PDBe API
|
|
329
|
-
const allCarbPolymers = await getCarbPolymerDetailsFromApi(plugin, s.pdb_id);
|
|
330
|
-
// Polymer chain + surroundings query
|
|
331
|
-
const polymerChainWithSurroundings = builder_1.MolScriptBuilder.struct.modifier.includeSurroundings({
|
|
332
|
-
0: builder_1.MolScriptBuilder.struct.generator.atomGroups({
|
|
333
|
-
'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'polymer']),
|
|
334
|
-
'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), s.auth_asym_id]),
|
|
335
|
-
'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
|
|
336
|
-
}),
|
|
337
|
-
radius: 5,
|
|
338
|
-
'as-whole-residues': true
|
|
339
|
-
});
|
|
340
|
-
let i = 0;
|
|
341
|
-
for (const carbEntityChainId of allCarbPolymers.branchedChains) {
|
|
342
|
-
const carbEntityChain = builder_1.MolScriptBuilder.struct.generator.atomGroups({
|
|
343
|
-
'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'branched']),
|
|
344
|
-
'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), carbEntityChainId]),
|
|
345
|
-
'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
|
|
346
|
-
});
|
|
347
|
-
const carbEntityChainInVicinity = builder_1.MolScriptBuilder.struct.filter.intersectedBy({
|
|
348
|
-
0: polymerChainWithSurroundings,
|
|
349
|
-
by: carbEntityChain
|
|
350
|
-
});
|
|
351
|
-
const data = (plugin.state.data.select(strInstance.ref)[0].obj).data;
|
|
352
|
-
const carbChainSel = script_1.Script.getStructureSelection(carbEntityChainInVicinity, data);
|
|
353
|
-
if (carbChainSel && carbChainSel.kind === 'sequence') {
|
|
354
|
-
// console.log(carbEntityChainId + ' chain present in 5 A radius');
|
|
355
|
-
const carbLigands = [];
|
|
356
|
-
const carbLigNamesAndCount = {};
|
|
357
|
-
const carbLigList = [];
|
|
358
|
-
for (const carbLigs of allCarbPolymers.branchedLigands[i]) {
|
|
359
|
-
const ligResDetails = carbLigs.split('-');
|
|
360
|
-
carbLigands.push(builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_seq_id(), +ligResDetails[1]]));
|
|
361
|
-
if (carbLigNamesAndCount[ligResDetails[0]]) {
|
|
362
|
-
carbLigNamesAndCount[ligResDetails[0]]++;
|
|
297
|
+
// Load Coordinates and render respresentations
|
|
298
|
+
return [2 /*return*/, plugin.dataTransaction(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
299
|
+
var spState, _a, entryList_1, entryList_1_1, s, strUrl, strInstance, modelRef, clearOnFail, polymerInstance, modelInstance, isBinary, _b, model, structure, matrix, chainSel, uniformColor1, uniformColor2, invalidStruct, state, hetInfo, hets, _c, hets_1, hets_1_1, het, ligand, labelTagParams, hetColor, _d, r, g, b, ligandExp, e_2_1, carbEntityCount, allCarbPolymers, polymerChainWithSurroundings, i, _e, _f, carbEntityChainId, carbEntityChain, carbEntityChainInVicinity, data, carbChainSel, carbLigands, carbLigNamesAndCount, carbLigList, _g, _h, carbLigs, ligResDetails, carbVisLabel, branchedEntity, labelTagParams, ligandExp, e_3_1, loadedStructIndex, e_4_1;
|
|
300
|
+
var e_3, _j, e_5, _k;
|
|
301
|
+
var _l, e_4, _m, _o, _p, e_2, _q, _r;
|
|
302
|
+
return tslib_1.__generator(this, function (_s) {
|
|
303
|
+
switch (_s.label) {
|
|
304
|
+
case 0:
|
|
305
|
+
spState = plugin.customState.superpositionState;
|
|
306
|
+
_s.label = 1;
|
|
307
|
+
case 1:
|
|
308
|
+
_s.trys.push([1, 45, 46, 51]);
|
|
309
|
+
_a = true, entryList_1 = tslib_1.__asyncValues(entryList);
|
|
310
|
+
_s.label = 2;
|
|
311
|
+
case 2: return [4 /*yield*/, entryList_1.next()];
|
|
312
|
+
case 3:
|
|
313
|
+
if (!(entryList_1_1 = _s.sent(), _l = entryList_1_1.done, !_l)) return [3 /*break*/, 44];
|
|
314
|
+
_o = entryList_1_1.value;
|
|
315
|
+
_a = false;
|
|
316
|
+
s = _o;
|
|
317
|
+
// validate matrix availability
|
|
318
|
+
if (!spState.matrixData["".concat(s.pdb_id, "_").concat(s.auth_asym_id)]) {
|
|
319
|
+
spState.noMatrixStruct.push("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
|
|
320
|
+
spState.invalidStruct.push("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
|
|
321
|
+
return [3 /*break*/, 43];
|
|
363
322
|
}
|
|
364
|
-
|
|
365
|
-
|
|
323
|
+
spState.loadedStructs[segmentIndex].push("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
|
|
324
|
+
strUrl = "".concat(customState.initParams.pdbeUrl, "model-server/v1/").concat(s.pdb_id, "/atoms?auth_asym_id=").concat(s.auth_asym_id, "&encoding=").concat(customState.initParams.encoding);
|
|
325
|
+
if (superpositionParams && superpositionParams.ligandView)
|
|
326
|
+
strUrl = "https://www.ebi.ac.uk/pdbe/entry-files/download/".concat(s.pdb_id, ".bcif");
|
|
327
|
+
strInstance = void 0;
|
|
328
|
+
modelRef = void 0;
|
|
329
|
+
clearOnFail = true;
|
|
330
|
+
if (!(superpositionParams && superpositionParams.ligandView && spState.entries[s.pdb_id])) return [3 /*break*/, 5];
|
|
331
|
+
polymerInstance = plugin.state.data.select(spState.entries[s.pdb_id])[0];
|
|
332
|
+
modelRef = polymerInstance.transform.parent;
|
|
333
|
+
modelInstance = plugin.state.data.select(modelRef)[0];
|
|
334
|
+
return [4 /*yield*/, plugin.builders.structure.createStructure(modelInstance, { name: 'model', params: {} })];
|
|
335
|
+
case 4:
|
|
336
|
+
strInstance = _s.sent();
|
|
337
|
+
clearOnFail = false;
|
|
338
|
+
return [3 /*break*/, 7];
|
|
339
|
+
case 5:
|
|
340
|
+
isBinary = customState.initParams.encoding === 'bcif' ? true : false;
|
|
341
|
+
return [4 /*yield*/, loadStructure(plugin, strUrl, 'mmcif', isBinary)];
|
|
342
|
+
case 6:
|
|
343
|
+
_b = _s.sent(), model = _b.model, structure = _b.structure;
|
|
344
|
+
strInstance = structure;
|
|
345
|
+
modelRef = model.ref;
|
|
346
|
+
_s.label = 7;
|
|
347
|
+
case 7:
|
|
348
|
+
if (!strInstance)
|
|
349
|
+
return [3 /*break*/, 43];
|
|
350
|
+
// Store Refs in state
|
|
351
|
+
if (!spState.models["".concat(s.pdb_id, "_").concat(s.struct_asym_id)])
|
|
352
|
+
spState.models["".concat(s.pdb_id, "_").concat(s.struct_asym_id)] = strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref;
|
|
353
|
+
if (superpositionParams && superpositionParams.ligandView && !spState.entries[s.pdb_id])
|
|
354
|
+
spState.entries[s.pdb_id] = strInstance === null || strInstance === void 0 ? void 0 : strInstance.ref;
|
|
355
|
+
matrix = linear_algebra_1.Mat4.ofRows(plugin.customState.superpositionState.matrixData["".concat(s.pdb_id, "_").concat(s.auth_asym_id)].matrix);
|
|
356
|
+
return [4 /*yield*/, transform(plugin, strInstance, matrix)];
|
|
357
|
+
case 8:
|
|
358
|
+
_s.sent();
|
|
359
|
+
chainSel = void 0;
|
|
360
|
+
if (!((superpositionParams && superpositionParams.ligandView) && s.is_representative)) return [3 /*break*/, 12];
|
|
361
|
+
uniformColor1 = getRandomColor(plugin, segmentIndex);
|
|
362
|
+
return [4 /*yield*/, plugin.builders.structure.tryCreateComponentFromExpression(strInstance, chainSelection(s.struct_asym_id), "Chain-".concat(segmentIndex), { label: "Chain", tags: ["superposition-sel"] })];
|
|
363
|
+
case 9:
|
|
364
|
+
chainSel = _s.sent();
|
|
365
|
+
if (!chainSel) return [3 /*break*/, 11];
|
|
366
|
+
return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'uniform', colorParams: { value: uniformColor1 }, size: 'uniform' }, { tag: "superposition-visual" })];
|
|
367
|
+
case 10:
|
|
368
|
+
_s.sent();
|
|
369
|
+
spState.refMaps[chainSel.ref] = "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
|
|
370
|
+
_s.label = 11;
|
|
371
|
+
case 11: return [3 /*break*/, 16];
|
|
372
|
+
case 12:
|
|
373
|
+
if (!((superpositionParams && superpositionParams.ligandView) && !s.is_representative)) return [3 /*break*/, 13];
|
|
374
|
+
return [3 /*break*/, 16];
|
|
375
|
+
case 13:
|
|
376
|
+
uniformColor2 = getRandomColor(plugin, segmentIndex);
|
|
377
|
+
return [4 /*yield*/, plugin.builders.structure.tryCreateComponentStatic(strInstance, 'polymer', { label: "Chain", tags: ["Chain-".concat(segmentIndex), "superposition-sel"] })];
|
|
378
|
+
case 14:
|
|
379
|
+
chainSel = _s.sent();
|
|
380
|
+
if (!chainSel) return [3 /*break*/, 16];
|
|
381
|
+
return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(chainSel, { type: 'putty', color: 'uniform', colorParams: { value: uniformColor2 }, size: 'uniform' }, { tag: "superposition-visual" })];
|
|
382
|
+
case 15:
|
|
383
|
+
_s.sent();
|
|
384
|
+
spState.refMaps[chainSel.ref] = "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
|
|
385
|
+
_s.label = 16;
|
|
386
|
+
case 16:
|
|
387
|
+
invalidStruct = chainSel ? false : true;
|
|
388
|
+
if (!(superpositionParams && superpositionParams.ligandView)) return [3 /*break*/, 43];
|
|
389
|
+
state = plugin.state.data;
|
|
390
|
+
return [4 /*yield*/, getLigandNamesFromModelData(plugin, state, modelRef)];
|
|
391
|
+
case 17:
|
|
392
|
+
hetInfo = _s.sent();
|
|
393
|
+
hets = hetInfo ? hetInfo.hetNames : [];
|
|
394
|
+
if (!(hets && hets.length > 0)) return [3 /*break*/, 31];
|
|
395
|
+
_s.label = 18;
|
|
396
|
+
case 18:
|
|
397
|
+
_s.trys.push([18, 25, 26, 31]);
|
|
398
|
+
_c = true, hets_1 = (e_2 = void 0, tslib_1.__asyncValues(hets));
|
|
399
|
+
_s.label = 19;
|
|
400
|
+
case 19: return [4 /*yield*/, hets_1.next()];
|
|
401
|
+
case 20:
|
|
402
|
+
if (!(hets_1_1 = _s.sent(), _p = hets_1_1.done, !_p)) return [3 /*break*/, 24];
|
|
403
|
+
_r = hets_1_1.value;
|
|
404
|
+
_c = false;
|
|
405
|
+
het = _r;
|
|
406
|
+
ligand = builder_1.MolScriptBuilder.struct.generator.atomGroups({
|
|
407
|
+
'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), s.auth_asym_id]),
|
|
408
|
+
'residue-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.label_comp_id(), het]),
|
|
409
|
+
'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
|
|
410
|
+
});
|
|
411
|
+
labelTagParams = { label: "".concat(het), tags: ["superposition-ligand-sel"] };
|
|
412
|
+
hetColor = color_1.Color.fromRgb(253, 3, 253);
|
|
413
|
+
if (superpositionParams && superpositionParams.ligandColor) {
|
|
414
|
+
_d = superpositionParams.ligandColor, r = _d.r, g = _d.g, b = _d.b;
|
|
415
|
+
hetColor = color_1.Color.fromRgb(r, g, b);
|
|
366
416
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
});
|
|
376
|
-
let labelTagParams = { label: `${carbVisLabel}`, tags: [`superposition-carb-sel`] };
|
|
377
|
-
const ligandExp = await plugin.builders.structure.tryCreateComponentFromExpression(strInstance, branchedEntity, `${carbLigList.join('-')}-${segmentIndex}`, labelTagParams);
|
|
378
|
-
if (ligandExp) {
|
|
379
|
-
await plugin.builders.structure.representation.addRepresentation(ligandExp, { type: 'carbohydrate' }, { tag: `superposition-carb-visual` });
|
|
380
|
-
spState.refMaps[ligandExp.ref] = `${s.pdb_id}_${s.struct_asym_id}`;
|
|
417
|
+
return [4 /*yield*/, plugin.builders.structure.tryCreateComponentFromExpression(strInstance, ligand, "".concat(het, "-").concat(segmentIndex), labelTagParams)];
|
|
418
|
+
case 21:
|
|
419
|
+
ligandExp = _s.sent();
|
|
420
|
+
if (!ligandExp) return [3 /*break*/, 23];
|
|
421
|
+
return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(ligandExp, { type: 'ball-and-stick', color: 'uniform', colorParams: { value: hetColor } }, { tag: "superposition-ligand-visual" })];
|
|
422
|
+
case 22:
|
|
423
|
+
_s.sent();
|
|
424
|
+
spState.refMaps[ligandExp.ref] = "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
|
|
381
425
|
invalidStruct = false;
|
|
382
|
-
|
|
426
|
+
_s.label = 23;
|
|
427
|
+
case 23:
|
|
428
|
+
_c = true;
|
|
429
|
+
return [3 /*break*/, 19];
|
|
430
|
+
case 24: return [3 /*break*/, 31];
|
|
431
|
+
case 25:
|
|
432
|
+
e_2_1 = _s.sent();
|
|
433
|
+
e_2 = { error: e_2_1 };
|
|
434
|
+
return [3 /*break*/, 31];
|
|
435
|
+
case 26:
|
|
436
|
+
_s.trys.push([26, , 29, 30]);
|
|
437
|
+
if (!(!_c && !_p && (_q = hets_1.return))) return [3 /*break*/, 28];
|
|
438
|
+
return [4 /*yield*/, _q.call(hets_1)];
|
|
439
|
+
case 27:
|
|
440
|
+
_s.sent();
|
|
441
|
+
_s.label = 28;
|
|
442
|
+
case 28: return [3 /*break*/, 30];
|
|
443
|
+
case 29:
|
|
444
|
+
if (e_2) throw e_2.error;
|
|
445
|
+
return [7 /*endfinally*/];
|
|
446
|
+
case 30: return [7 /*endfinally*/];
|
|
447
|
+
case 31:
|
|
448
|
+
carbEntityCount = hetInfo ? hetInfo.carbEntityCount : 0;
|
|
449
|
+
if (!(carbEntityCount > 0)) return [3 /*break*/, 42];
|
|
450
|
+
return [4 /*yield*/, getCarbPolymerDetailsFromApi(plugin, s.pdb_id)];
|
|
451
|
+
case 32:
|
|
452
|
+
allCarbPolymers = _s.sent();
|
|
453
|
+
polymerChainWithSurroundings = builder_1.MolScriptBuilder.struct.modifier.includeSurroundings({
|
|
454
|
+
0: builder_1.MolScriptBuilder.struct.generator.atomGroups({
|
|
455
|
+
'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'polymer']),
|
|
456
|
+
'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), s.auth_asym_id]),
|
|
457
|
+
'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
|
|
458
|
+
}),
|
|
459
|
+
radius: 5,
|
|
460
|
+
'as-whole-residues': true
|
|
461
|
+
});
|
|
462
|
+
i = 0;
|
|
463
|
+
_s.label = 33;
|
|
464
|
+
case 33:
|
|
465
|
+
_s.trys.push([33, 40, 41, 42]);
|
|
466
|
+
_e = (e_3 = void 0, tslib_1.__values(allCarbPolymers.branchedChains)), _f = _e.next();
|
|
467
|
+
_s.label = 34;
|
|
468
|
+
case 34:
|
|
469
|
+
if (!!_f.done) return [3 /*break*/, 39];
|
|
470
|
+
carbEntityChainId = _f.value;
|
|
471
|
+
carbEntityChain = builder_1.MolScriptBuilder.struct.generator.atomGroups({
|
|
472
|
+
'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'branched']),
|
|
473
|
+
'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), carbEntityChainId]),
|
|
474
|
+
'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()])
|
|
475
|
+
});
|
|
476
|
+
carbEntityChainInVicinity = builder_1.MolScriptBuilder.struct.filter.intersectedBy({
|
|
477
|
+
0: polymerChainWithSurroundings,
|
|
478
|
+
by: carbEntityChain
|
|
479
|
+
});
|
|
480
|
+
data = (plugin.state.data.select(strInstance.ref)[0].obj).data;
|
|
481
|
+
carbChainSel = script_1.Script.getStructureSelection(carbEntityChainInVicinity, data);
|
|
482
|
+
if (!(carbChainSel && carbChainSel.kind === 'sequence')) return [3 /*break*/, 37];
|
|
483
|
+
carbLigands = [];
|
|
484
|
+
carbLigNamesAndCount = {};
|
|
485
|
+
carbLigList = [];
|
|
486
|
+
try {
|
|
487
|
+
for (_g = (e_5 = void 0, tslib_1.__values(allCarbPolymers.branchedLigands[i])), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
488
|
+
carbLigs = _h.value;
|
|
489
|
+
ligResDetails = carbLigs.split('-');
|
|
490
|
+
carbLigands.push(builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_seq_id(), +ligResDetails[1]]));
|
|
491
|
+
if (carbLigNamesAndCount[ligResDetails[0]]) {
|
|
492
|
+
carbLigNamesAndCount[ligResDetails[0]]++;
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
carbLigNamesAndCount[ligResDetails[0]] = 1;
|
|
496
|
+
}
|
|
497
|
+
carbLigList.push(ligResDetails[0]);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
501
|
+
finally {
|
|
502
|
+
try {
|
|
503
|
+
if (_h && !_h.done && (_k = _g.return)) _k.call(_g);
|
|
504
|
+
}
|
|
505
|
+
finally { if (e_5) throw e_5.error; }
|
|
506
|
+
}
|
|
507
|
+
carbVisLabel = createCarbVisLabel(carbLigNamesAndCount);
|
|
508
|
+
branchedEntity = builder_1.MolScriptBuilder.struct.generator.atomGroups({
|
|
509
|
+
'entity-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.ammp('entityType'), 'branched']),
|
|
510
|
+
'group-by': builder_1.MolScriptBuilder.core.str.concat([builder_1.MolScriptBuilder.struct.atomProperty.core.operatorName(), builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.residueKey()]),
|
|
511
|
+
'chain-test': builder_1.MolScriptBuilder.core.rel.eq([builder_1.MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), carbEntityChainId]),
|
|
512
|
+
'residue-test': builder_1.MolScriptBuilder.core.logic.or(carbLigands)
|
|
513
|
+
});
|
|
514
|
+
labelTagParams = { label: "".concat(carbVisLabel), tags: ["superposition-carb-sel"] };
|
|
515
|
+
return [4 /*yield*/, plugin.builders.structure.tryCreateComponentFromExpression(strInstance, branchedEntity, "".concat(carbLigList.join('-'), "-").concat(segmentIndex), labelTagParams)];
|
|
516
|
+
case 35:
|
|
517
|
+
ligandExp = _s.sent();
|
|
518
|
+
if (!ligandExp) return [3 /*break*/, 37];
|
|
519
|
+
return [4 /*yield*/, plugin.builders.structure.representation.addRepresentation(ligandExp, { type: 'carbohydrate' }, { tag: "superposition-carb-visual" })];
|
|
520
|
+
case 36:
|
|
521
|
+
_s.sent();
|
|
522
|
+
spState.refMaps[ligandExp.ref] = "".concat(s.pdb_id, "_").concat(s.struct_asym_id);
|
|
523
|
+
invalidStruct = false;
|
|
524
|
+
_s.label = 37;
|
|
525
|
+
case 37:
|
|
526
|
+
i++;
|
|
527
|
+
_s.label = 38;
|
|
528
|
+
case 38:
|
|
529
|
+
_f = _e.next();
|
|
530
|
+
return [3 /*break*/, 34];
|
|
531
|
+
case 39: return [3 /*break*/, 42];
|
|
532
|
+
case 40:
|
|
533
|
+
e_3_1 = _s.sent();
|
|
534
|
+
e_3 = { error: e_3_1 };
|
|
535
|
+
return [3 /*break*/, 42];
|
|
536
|
+
case 41:
|
|
537
|
+
try {
|
|
538
|
+
if (_f && !_f.done && (_j = _e.return)) _j.call(_e);
|
|
539
|
+
}
|
|
540
|
+
finally { if (e_3) throw e_3.error; }
|
|
541
|
+
return [7 /*endfinally*/];
|
|
542
|
+
case 42:
|
|
543
|
+
if (invalidStruct) {
|
|
544
|
+
spState.invalidStruct.push("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
|
|
545
|
+
loadedStructIndex = spState.loadedStructs[segmentIndex].indexOf("".concat(s.pdb_id, "_").concat(s.struct_asym_id));
|
|
546
|
+
if (loadedStructIndex > -1)
|
|
547
|
+
spState.loadedStructs[segmentIndex].splice(loadedStructIndex, 1);
|
|
548
|
+
// remove downloaded data
|
|
549
|
+
if (clearOnFail) {
|
|
550
|
+
// const m = plugin.state.data.select(modelRef)[0];
|
|
551
|
+
// const t = plugin.state.data.select(m.transform.parent)[0];
|
|
552
|
+
// const d = plugin.state.data.select(t.transform.parent)[0];
|
|
553
|
+
// PluginCommands.State.RemoveObject(plugin, { state: d.parent!, ref: d.transform.parent, removeParentGhosts: true });
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
// if(interactingHets.length > 0) spState.hets[`${s.pdb_id}_${s.struct_asym_id}`] = interactingHets;
|
|
558
|
+
}
|
|
559
|
+
_s.label = 43;
|
|
560
|
+
case 43:
|
|
561
|
+
_a = true;
|
|
562
|
+
return [3 /*break*/, 2];
|
|
563
|
+
case 44: return [3 /*break*/, 51];
|
|
564
|
+
case 45:
|
|
565
|
+
e_4_1 = _s.sent();
|
|
566
|
+
e_4 = { error: e_4_1 };
|
|
567
|
+
return [3 /*break*/, 51];
|
|
568
|
+
case 46:
|
|
569
|
+
_s.trys.push([46, , 49, 50]);
|
|
570
|
+
if (!(!_a && !_l && (_m = entryList_1.return))) return [3 /*break*/, 48];
|
|
571
|
+
return [4 /*yield*/, _m.call(entryList_1)];
|
|
572
|
+
case 47:
|
|
573
|
+
_s.sent();
|
|
574
|
+
_s.label = 48;
|
|
575
|
+
case 48: return [3 /*break*/, 50];
|
|
576
|
+
case 49:
|
|
577
|
+
if (e_4) throw e_4.error;
|
|
578
|
+
return [7 /*endfinally*/];
|
|
579
|
+
case 50: return [7 /*endfinally*/];
|
|
580
|
+
case 51:
|
|
581
|
+
if (busyFlagOn) {
|
|
582
|
+
busyFlagOn = false;
|
|
583
|
+
customState.events.isBusy.next(false);
|
|
584
|
+
}
|
|
585
|
+
return [2 /*return*/];
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}); })];
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
function getLigandNamesFromModelData(plugin, state, modelRef) {
|
|
593
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
594
|
+
var cell, model, structures, _a, _b, s, structure, info;
|
|
595
|
+
var e_6, _c;
|
|
596
|
+
var _d;
|
|
597
|
+
return tslib_1.__generator(this, function (_e) {
|
|
598
|
+
switch (_e.label) {
|
|
599
|
+
case 0:
|
|
600
|
+
cell = state.select(modelRef)[0];
|
|
601
|
+
if (!cell || !cell.obj)
|
|
602
|
+
return [2 /*return*/, void 0];
|
|
603
|
+
model = cell.obj.data;
|
|
604
|
+
if (!model)
|
|
605
|
+
return [2 /*return*/];
|
|
606
|
+
structures = [];
|
|
607
|
+
try {
|
|
608
|
+
for (_a = tslib_1.__values(plugin.managers.structure.hierarchy.selection.structures), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
609
|
+
s = _b.value;
|
|
610
|
+
structure = (_d = s.cell.obj) === null || _d === void 0 ? void 0 : _d.data;
|
|
611
|
+
if (structure)
|
|
612
|
+
structures.push(structure);
|
|
383
613
|
}
|
|
384
|
-
i++;
|
|
385
614
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
// remove downloaded data
|
|
393
|
-
if (clearOnFail) {
|
|
394
|
-
// const m = plugin.state.data.select(modelRef)[0];
|
|
395
|
-
// const t = plugin.state.data.select(m.transform.parent)[0];
|
|
396
|
-
// const d = plugin.state.data.select(t.transform.parent)[0];
|
|
397
|
-
// PluginCommands.State.RemoveObject(plugin, { state: d.parent!, ref: d.transform.parent, removeParentGhosts: true });
|
|
615
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
616
|
+
finally {
|
|
617
|
+
try {
|
|
618
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
619
|
+
}
|
|
620
|
+
finally { if (e_6) throw e_6.error; }
|
|
398
621
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
622
|
+
return [4 /*yield*/, helpers_1.ModelInfo.get(model, structures)];
|
|
623
|
+
case 1:
|
|
624
|
+
info = _e.sent();
|
|
625
|
+
return [2 /*return*/, info];
|
|
403
626
|
}
|
|
404
|
-
}
|
|
405
|
-
if (busyFlagOn) {
|
|
406
|
-
busyFlagOn = false;
|
|
407
|
-
customState.events.isBusy.next(false);
|
|
408
|
-
}
|
|
627
|
+
});
|
|
409
628
|
});
|
|
410
629
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
630
|
+
function loadStructure(plugin, url, format, isBinary) {
|
|
631
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
632
|
+
var data, trajectory, model, modelProperties, structure, e_7;
|
|
633
|
+
return tslib_1.__generator(this, function (_a) {
|
|
634
|
+
switch (_a.label) {
|
|
635
|
+
case 0:
|
|
636
|
+
_a.trys.push([0, 7, , 8]);
|
|
637
|
+
return [4 /*yield*/, plugin.builders.data.download({ url: assets_1.Asset.Url(url), isBinary: isBinary })];
|
|
638
|
+
case 1:
|
|
639
|
+
data = _a.sent();
|
|
640
|
+
return [4 /*yield*/, plugin.builders.structure.parseTrajectory(data, format)];
|
|
641
|
+
case 2:
|
|
642
|
+
trajectory = _a.sent();
|
|
643
|
+
return [4 /*yield*/, plugin.builders.structure.createModel(trajectory)];
|
|
644
|
+
case 3:
|
|
645
|
+
model = _a.sent();
|
|
646
|
+
return [4 /*yield*/, plugin.builders.structure.insertModelProperties(model)];
|
|
647
|
+
case 4:
|
|
648
|
+
modelProperties = _a.sent();
|
|
649
|
+
return [4 /*yield*/, plugin.builders.structure.createStructure(modelProperties || model, { name: 'model', params: {} })];
|
|
650
|
+
case 5:
|
|
651
|
+
structure = _a.sent();
|
|
652
|
+
return [4 /*yield*/, plugin.builders.structure.insertStructureProperties(structure)];
|
|
653
|
+
case 6:
|
|
654
|
+
_a.sent();
|
|
655
|
+
return [2 /*return*/, { data: data, trajectory: trajectory, model: model, structure: structure }];
|
|
656
|
+
case 7:
|
|
657
|
+
e_7 = _a.sent();
|
|
658
|
+
return [2 /*return*/, { structure: void 0 }];
|
|
659
|
+
case 8: return [2 /*return*/];
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
});
|
|
441
663
|
}
|
|
442
664
|
function chainSelection(struct_asym_id) {
|
|
443
665
|
return builder_1.MolScriptBuilder.struct.generator.atomGroups({
|
|
@@ -445,114 +667,207 @@ function chainSelection(struct_asym_id) {
|
|
|
445
667
|
});
|
|
446
668
|
}
|
|
447
669
|
function transform(plugin, s, matrix) {
|
|
448
|
-
|
|
670
|
+
var b = plugin.state.data.build().to(s)
|
|
449
671
|
.insert(transforms_1.StateTransforms.Model.TransformStructureConformation, { transform: { name: 'matrix', params: { data: matrix, transpose: false } } });
|
|
450
672
|
return plugin.runTask(plugin.state.data.updateTree(b));
|
|
451
673
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
return
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
674
|
+
function afTransform(plugin, s, matrix, coordinateSystem) {
|
|
675
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
676
|
+
var r, o, transform, params, b;
|
|
677
|
+
return tslib_1.__generator(this, function (_a) {
|
|
678
|
+
switch (_a.label) {
|
|
679
|
+
case 0:
|
|
680
|
+
r = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, s);
|
|
681
|
+
if (!r)
|
|
682
|
+
return [2 /*return*/];
|
|
683
|
+
o = plugin.state.data.selectQ(function (q) { return q.byRef(r.transform.ref).subtree().withTransformer(transforms_1.StateTransforms.Model.TransformStructureConformation); })[0];
|
|
684
|
+
transform = coordinateSystem && !linear_algebra_1.Mat4.isIdentity(coordinateSystem.matrix)
|
|
685
|
+
? linear_algebra_1.Mat4.mul((0, linear_algebra_1.Mat4)(), coordinateSystem.matrix, matrix)
|
|
686
|
+
: matrix;
|
|
687
|
+
params = {
|
|
688
|
+
transform: {
|
|
689
|
+
name: 'matrix',
|
|
690
|
+
params: { data: transform, transpose: false }
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
b = o
|
|
694
|
+
? plugin.state.data.build().to(o).update(params)
|
|
695
|
+
: plugin.state.data.build().to(s)
|
|
696
|
+
.insert(transforms_1.StateTransforms.Model.TransformStructureConformation, params, { tags: 'SuperpositionTransform' });
|
|
697
|
+
return [4 /*yield*/, plugin.runTask(plugin.state.data.updateTree(b))];
|
|
698
|
+
case 1:
|
|
699
|
+
_a.sent();
|
|
700
|
+
return [2 /*return*/];
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
function getMatrixData(plugin) {
|
|
706
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
707
|
+
var customState, matrixAccession, clusterRecUrlStr, assetManager, clusterRecUrl, clusterRecData, e_8;
|
|
708
|
+
return tslib_1.__generator(this, function (_a) {
|
|
709
|
+
switch (_a.label) {
|
|
710
|
+
case 0:
|
|
711
|
+
customState = plugin.customState;
|
|
712
|
+
matrixAccession = customState.initParams.superpositionParams.matrixAccession ? customState.initParams.superpositionParams.matrixAccession : customState.initParams.moleculeId;
|
|
713
|
+
clusterRecUrlStr = "".concat(customState.initParams.pdbeUrl, "static/superpose/matrices/").concat(matrixAccession);
|
|
714
|
+
assetManager = plugin.managers.asset;
|
|
715
|
+
clusterRecUrl = assets_1.Asset.getUrlAsset(assetManager, clusterRecUrlStr);
|
|
716
|
+
_a.label = 1;
|
|
717
|
+
case 1:
|
|
718
|
+
_a.trys.push([1, 3, , 4]);
|
|
719
|
+
return [4 /*yield*/, plugin.runTask(assetManager.resolve(clusterRecUrl, 'json', false))];
|
|
720
|
+
case 2:
|
|
721
|
+
clusterRecData = _a.sent();
|
|
722
|
+
if (clusterRecData && clusterRecData.data) {
|
|
723
|
+
plugin.customState.superpositionState.matrixData = clusterRecData.data;
|
|
724
|
+
}
|
|
725
|
+
return [3 /*break*/, 4];
|
|
726
|
+
case 3:
|
|
727
|
+
e_8 = _a.sent();
|
|
728
|
+
customState['superpositionError'] = "Matrix data not available for ".concat(matrixAccession);
|
|
729
|
+
plugin.customState.events.superpositionInit.next(true); // Emit segment API data load event
|
|
730
|
+
return [3 /*break*/, 4];
|
|
731
|
+
case 4: return [2 /*return*/];
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
});
|
|
471
735
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
736
|
+
function getSegmentData(plugin) {
|
|
737
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
738
|
+
var customState, segmentsUrl, assetManager, url, result, e_9;
|
|
739
|
+
return tslib_1.__generator(this, function (_a) {
|
|
740
|
+
switch (_a.label) {
|
|
741
|
+
case 0:
|
|
742
|
+
customState = plugin.customState;
|
|
743
|
+
segmentsUrl = "".concat(customState.initParams.pdbeUrl, "graph-api/uniprot/superposition/").concat(customState.initParams.moleculeId);
|
|
744
|
+
assetManager = plugin.managers.asset;
|
|
745
|
+
url = assets_1.Asset.getUrlAsset(assetManager, segmentsUrl);
|
|
746
|
+
_a.label = 1;
|
|
747
|
+
case 1:
|
|
748
|
+
_a.trys.push([1, 3, , 4]);
|
|
749
|
+
return [4 /*yield*/, plugin.runTask(assetManager.resolve(url, 'json', false))];
|
|
750
|
+
case 2:
|
|
751
|
+
result = _a.sent();
|
|
752
|
+
if (result && result.data) {
|
|
753
|
+
customState.superpositionState.segmentData = result.data[customState.initParams.moleculeId];
|
|
754
|
+
}
|
|
755
|
+
return [3 /*break*/, 4];
|
|
756
|
+
case 3:
|
|
757
|
+
e_9 = _a.sent();
|
|
758
|
+
customState['superpositionError'] = "Superposition data not available for ".concat(customState.initParams.moleculeId);
|
|
759
|
+
plugin.customState.events.superpositionInit.next(true); // Emit segment API data load event
|
|
760
|
+
return [3 /*break*/, 4];
|
|
761
|
+
case 4: return [2 /*return*/];
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
function getChainLigands(carbEntity) {
|
|
767
|
+
var e_10, _a, e_11, _b, e_12, _c;
|
|
768
|
+
var ligandChain = [];
|
|
769
|
+
var ligandLabels = [];
|
|
770
|
+
var ligands = [];
|
|
771
|
+
var labelValueArr = [];
|
|
772
|
+
var ligNameStr = '';
|
|
478
773
|
try {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
774
|
+
for (var _d = tslib_1.__values(carbEntity.chem_comp_list), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
775
|
+
var chemComp = _e.value;
|
|
776
|
+
labelValueArr.push("".concat(chemComp.chem_comp_id, " (").concat(chemComp.count, ")"));
|
|
482
777
|
}
|
|
483
778
|
}
|
|
484
|
-
catch (
|
|
485
|
-
|
|
486
|
-
|
|
779
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
780
|
+
finally {
|
|
781
|
+
try {
|
|
782
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
783
|
+
}
|
|
784
|
+
finally { if (e_10) throw e_10.error; }
|
|
487
785
|
}
|
|
488
|
-
|
|
489
|
-
async function getSegmentData(plugin) {
|
|
490
|
-
const customState = plugin.customState;
|
|
491
|
-
// Get Data
|
|
492
|
-
const segmentsUrl = `${customState.initParams.pdbeUrl}graph-api/uniprot/superposition/${customState.initParams.moleculeId}`;
|
|
493
|
-
const assetManager = plugin.managers.asset;
|
|
494
|
-
const url = assets_1.Asset.getUrlAsset(assetManager, segmentsUrl);
|
|
786
|
+
ligNameStr = labelValueArr.join(', ');
|
|
495
787
|
try {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
788
|
+
for (var _f = tslib_1.__values(carbEntity.chains), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
789
|
+
var chain = _g.value;
|
|
790
|
+
ligandChain.push(chain.chain_id);
|
|
791
|
+
ligandLabels.push(ligNameStr);
|
|
792
|
+
var chainLigands = [];
|
|
793
|
+
try {
|
|
794
|
+
for (var _h = (e_12 = void 0, tslib_1.__values(chain.residues)), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
795
|
+
var residue = _j.value;
|
|
796
|
+
chainLigands.push(residue.chem_comp_id + '-' + residue.residue_number);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
800
|
+
finally {
|
|
801
|
+
try {
|
|
802
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
803
|
+
}
|
|
804
|
+
finally { if (e_12) throw e_12.error; }
|
|
805
|
+
}
|
|
806
|
+
ligands.push(chainLigands);
|
|
499
807
|
}
|
|
500
808
|
}
|
|
501
|
-
catch (
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
function getChainLigands(carbEntity) {
|
|
507
|
-
const ligandChain = [];
|
|
508
|
-
const ligandLabels = [];
|
|
509
|
-
const ligands = [];
|
|
510
|
-
const labelValueArr = [];
|
|
511
|
-
let ligNameStr = '';
|
|
512
|
-
for (const chemComp of carbEntity.chem_comp_list) {
|
|
513
|
-
labelValueArr.push(`${chemComp.chem_comp_id} (${chemComp.count})`);
|
|
514
|
-
}
|
|
515
|
-
ligNameStr = labelValueArr.join(', ');
|
|
516
|
-
for (const chain of carbEntity.chains) {
|
|
517
|
-
ligandChain.push(chain.chain_id);
|
|
518
|
-
ligandLabels.push(ligNameStr);
|
|
519
|
-
const chainLigands = [];
|
|
520
|
-
for (const residue of chain.residues) {
|
|
521
|
-
chainLigands.push(residue.chem_comp_id + '-' + residue.residue_number);
|
|
809
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
810
|
+
finally {
|
|
811
|
+
try {
|
|
812
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
522
813
|
}
|
|
523
|
-
|
|
814
|
+
finally { if (e_11) throw e_11.error; }
|
|
524
815
|
}
|
|
525
816
|
return {
|
|
526
|
-
ligands,
|
|
527
|
-
ligandChain,
|
|
528
|
-
ligandLabels
|
|
817
|
+
ligands: ligands,
|
|
818
|
+
ligandChain: ligandChain,
|
|
819
|
+
ligandLabels: ligandLabels
|
|
529
820
|
};
|
|
530
821
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
822
|
+
function getCarbPolymerDetailsFromApi(plugin, pdb_id) {
|
|
823
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
824
|
+
var customState, apiUrl, assetManager, url, branchedLigands, branchedChains, branchedlabels, result, carbEntities, carbEntities_1, carbEntities_1_1, carbEntity, carbLigData, e_13;
|
|
825
|
+
var e_14, _a;
|
|
826
|
+
return tslib_1.__generator(this, function (_b) {
|
|
827
|
+
switch (_b.label) {
|
|
828
|
+
case 0:
|
|
829
|
+
customState = plugin.customState;
|
|
830
|
+
apiUrl = "".concat(customState.initParams.pdbeUrl, "api/pdb/entry/carbohydrate_polymer/").concat(pdb_id);
|
|
831
|
+
assetManager = plugin.managers.asset;
|
|
832
|
+
url = assets_1.Asset.getUrlAsset(assetManager, apiUrl);
|
|
833
|
+
branchedLigands = [];
|
|
834
|
+
branchedChains = [];
|
|
835
|
+
branchedlabels = [];
|
|
836
|
+
_b.label = 1;
|
|
837
|
+
case 1:
|
|
838
|
+
_b.trys.push([1, 3, , 4]);
|
|
839
|
+
return [4 /*yield*/, plugin.runTask(assetManager.resolve(url, 'json', false))];
|
|
840
|
+
case 2:
|
|
841
|
+
result = _b.sent();
|
|
842
|
+
if (result && result.data) {
|
|
843
|
+
carbEntities = result.data[pdb_id];
|
|
844
|
+
try {
|
|
845
|
+
for (carbEntities_1 = tslib_1.__values(carbEntities), carbEntities_1_1 = carbEntities_1.next(); !carbEntities_1_1.done; carbEntities_1_1 = carbEntities_1.next()) {
|
|
846
|
+
carbEntity = carbEntities_1_1.value;
|
|
847
|
+
carbLigData = getChainLigands(carbEntity);
|
|
848
|
+
branchedLigands = branchedLigands.concat(carbLigData.ligands);
|
|
849
|
+
branchedChains = branchedChains.concat(carbLigData.ligandChain);
|
|
850
|
+
branchedlabels = branchedlabels.concat(carbLigData.ligandLabels);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
854
|
+
finally {
|
|
855
|
+
try {
|
|
856
|
+
if (carbEntities_1_1 && !carbEntities_1_1.done && (_a = carbEntities_1.return)) _a.call(carbEntities_1);
|
|
857
|
+
}
|
|
858
|
+
finally { if (e_14) throw e_14.error; }
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return [3 /*break*/, 4];
|
|
862
|
+
case 3:
|
|
863
|
+
e_13 = _b.sent();
|
|
864
|
+
return [3 /*break*/, 4];
|
|
865
|
+
case 4: return [2 /*return*/, {
|
|
866
|
+
branchedChains: branchedChains,
|
|
867
|
+
branchedLigands: branchedLigands,
|
|
868
|
+
branchedlabels: branchedlabels
|
|
869
|
+
}];
|
|
549
870
|
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
catch (e) { }
|
|
553
|
-
return {
|
|
554
|
-
branchedChains,
|
|
555
|
-
branchedLigands,
|
|
556
|
-
branchedlabels
|
|
557
|
-
};
|
|
871
|
+
});
|
|
872
|
+
});
|
|
558
873
|
}
|