forked from molstar/pdbe-molstar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnomvs.html
276 lines (231 loc) · 10.6 KB
/
nomvs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>EMDB Molstar</title>
<!-- Molstar CSS & JS -->
<link rel="stylesheet" type="text/css" href="build/emdb-molstar-0.9.0.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.msp-plugin ::-webkit-scrollbar-thumb {
background-color: #474748 !important;
}
body {
padding: 30px;
}
h2 {
margin-bottom: 20px;
}
h3 {
margin-bottom: 2px;
}
h4 {
margin-top: 6px;
margin-bottom: 2px;
}
h4:first-child {
margin-top: 0px;
}
.content {
display: flex;
gap: 30px;
}
.controlsSection {
width: 300px;
}
.controlBox {
border: 1px solid lightgray;
padding: 10px;
margin-bottom: 20px;
}
.viewerSection {
width: 100%;
}
.row {
display: flex;
align-items: center;
}
#myViewer {
width: 100%;
height: 600px;
position: relative;
}
input {
margin-right: 8px;
padding: 1px;
padding-inline: 4px;
}
button {
margin-right: 8px;
padding: 1px;
padding-inline: 4px;
}
</style>
</head>
<body>
<h2>EMDB Molstar</h2>
<div class="content">
<div class="controlsSection">
<h3>EMDB control buttons</h3>
<div class="controlBox">
<h4>Load model by ID</h4>
<div class="row">
<input type="text" id="moleculeId" placeholder="Enter molecule ID" />
<button onclick="viewerInstance.loadPdb(document.getElementById('moleculeId').value)">Load</button>
<button onclick="viewerInstance.toogleStructureVisibility(document.getElementById('moleculeId').value, 'show')">Show</button>
<button onclick="viewerInstance.toogleStructureVisibility(document.getElementById('moleculeId').value, 'hide')">Hide</button>
</div>
<h4>Load EM primary map by ID</h4>
<div class="row">
<input type="text" id="mapId" placeholder="Enter map ID" />
<button onclick="viewerInstance.loadEmdb(document.getElementById('mapId').value, 3.5, 0.3)">Load</button>
<button onclick="viewerInstance.toggleVolumeVisibility(document.getElementById('mapId').value, 'show')">Show</button>
<button onclick="viewerInstance.toggleVolumeVisibility(document.getElementById('mapId').value, 'hide')">Hide</button>
</div>
<h4>Controls</h4>
<button onclick="viewerInstance.clear()">Clear</button>
<h4>Colours</h4>
<button onclick="viewerInstance.applyColorTheme('model-index')">Models</button>
<button onclick="viewerInstance.applyColorTheme('chain-id')">Chains</button>
<button onclick="viewerInstance.applyColorTheme('emdb-qscore-report')">Q-Score</button>
<button onclick="viewerInstance.applyColorTheme('emdb-ai-report')">Atom Inclusion</button>
<button onclick="viewerInstance.applyColorTheme('localResolution')">Local Resolution</button>
<h4>Tomography</h4>
<label for="dimension">Dimension</label>
<select id="dimension">
<option value="x">X</option>
<option value="y">Y</option>
<option value="z" selected>Z</option>
</select><br>
<label for="slice">Slice</label>
<input type="number" id="slice" value="0" min="0" max="100" />
<button onclick="changeSliceDimension()">Update</button>
</div>
</div>
<div class="viewerSection">
<h3>EMDB Mol* JS Plugin Demo</h3>
<!-- Molstar container -->
<div id="myViewer"></div>
</div>
</div>
<script type="text/javascript" src="build/emdb-molstar-plugin-0.9.0.js"></script>
<script>
viewerInstance = null;
async function changeSliceDimension() {
const dimension = document.getElementById('dimension').value;
const slice = parseInt(document.getElementById('slice').value);
await viewerInstance.changeSliceDimension(dimension, slice);
}
function getParam(name, regex) {
var r = new RegExp(name + '=' + '(' + regex + ')[&]?', 'i');
return decodeURIComponent(((window.location.search || '').match(r) || [])[1] || '');
}
var debugMode = getParam('debug-mode', '[^&]+').trim() === '1';
if (debugMode) molstar.setDebugMode(debugMode);
var timingMode = getParam('timing-mode', '[^&]+').trim() === '1';
if (timingMode) molstar.setTimingMode(timingMode);
var hideControls = getParam('hide-controls', '[^&]+').trim() === '1';
var collapseLeftPanel = getParam('collapse-left-panel', '[^&]+').trim() === '1';
var pdbProvider = getParam('pdb-provider', '[^&]+').trim().toLowerCase();
var emdbProvider = getParam('emdb-provider', '[^&]+').trim().toLowerCase();
var mapProvider = getParam('map-provider', '[^&]+').trim().toLowerCase();
var pixelScale = getParam('pixel-scale', '[^&]+').trim();
var pickScale = getParam('pick-scale', '[^&]+').trim();
var pickPadding = getParam('pick-padding', '[^&]+').trim();
var disableWboit = getParam('disable-wboit', '[^&]+').trim() === '1';
var enableDpoit = getParam('enable-dpoit', '[^&]+').trim() === '1';
var preferWebgl1 = getParam('prefer-webgl1', '[^&]+').trim() === '1' || void 0;
var allowMajorPerformanceCaveat = getParam('allow-major-performance-caveat', '[^&]+').trim() === '1';
var powerPreference = getParam('power-preference', '[^&]+').trim().toLowerCase();
Viewer.create('myViewer', {
disabledExtensions: [], // anything from Object.keys(molstar.ExtensionMap)
layoutShowControls: !hideControls,
viewportShowExpand: true,
collapseLeftPanel: true,
pdbProvider: pdbProvider || 'pdbe',
emdbProvider: emdbProvider || 'pdbe',
// volumeStreamingServer: (mapProvider || 'pdbe') === 'rcsb'
// ? 'https://maps.rcsb.org'
// : 'https://www.ebi.ac.uk/pdbe/densities',
volumeStreamingServer: 'https://www.ebi.ac.uk/emdb/VolumeServer',
// volumeStreamingServer: 'http://127.0.0.1:1337/VolumeServer',
pixelScale: parseFloat(pixelScale) || 1,
pickScale: parseFloat(pickScale) || 0.25,
pickPadding: isNaN(parseFloat(pickPadding)) ? 1 : parseFloat(pickPadding),
enableWboit: (disableWboit || enableDpoit) ? false : void 0, // use default value if disable-wboit is not set
enableDpoit: enableDpoit ? true : void 0,
preferWebgl1: preferWebgl1,
allowMajorPerformanceCaveat: allowMajorPerformanceCaveat,
powerPreference: powerPreference || 'high-performance',
}).then(viewer => {
viewerInstance = viewer;
const opacity = 0.6;
// Single model
// const emdbId = 'EMD-8117';
// const pdbIds = ['5irx'];
// const contourLevel = 3.5;
// const slice = false;
// Multiple models
// const emdbId = 'EMD-10162';
// const pdbIds = ['6sfw', '6sfx'];
// const contourLevel = 0.02;
// const slice = false;
// Half map
const emdbId = 'EMD-10162_half_map_1';
const pdbIds = ['6sfw', '6sfx'];
const contourLevel = 0.02;
const slice = false;
// Tomogram
// const emdbId = 'EMD-19762';
// const pdbIds = [];
// const contourLevel = 2;
// const slice = true;
// Failed
// const emdbId = 'EMD-16652';
// const pdbIds = ['8cgv'];
// const contourLevel = 0.0309;
// const slice = false;
for (const pdbId of pdbIds) {
viewer.loadPdb(pdbId);
}
(async () => {
await viewer.loadEmdb(emdbId, contourLevel, opacity, "absolute", slice, false);
console.log("Getting component data...");
const component = viewer.getComponentData(emdbId);
console.log(component)
// console.log("Updating component data...");
// const props = {
// type: 'isosurface',
// typeParams: {
// alpha: 1,
// isoValue: { kind: 'relative', relativeValue: 5 }
// },
// color: 'uniform',
// colorParams: { value: component.color }
// }
// await viewer.updateComponentParams('EMD-8117', props);
if (slice) {
const x = viewer.sliceDimensions[0];
const y = viewer.sliceDimensions[1];
const z = viewer.sliceDimensions[2];
if (viewer.sliceDimensions) {
const sliceInput = document.getElementById('slice');
const selectedDimension = document.getElementById('dimension').value;
sliceInput.max = selectedDimension === 'z' ? z : selectedDimension === 'y' ? y : x;
sliceInput.value = Math.floor(sliceInput.max / 2);
}
}
})();
window.addEventListener('unload', () => {
// to aid GC
viewer.dispose();
});
});
</script>
</body>
</html>