-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.html
More file actions
464 lines (412 loc) · 26.8 KB
/
index.html
File metadata and controls
464 lines (412 loc) · 26.8 KB
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<!--
index.html
----------
AI Context: STANDALONE WEB APP ENTRY POINT
- The main HTML file for the standalone web application.
- Loads: web/utils.js, viewer-mol.js, viewer-pae.js, viewer-seq.js, viewer-msa.js, web/app.js
- Defines the DOM structure for the viewer, sidebar, and controls.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2Dmol</title>
<!-- PRODUCTION NOTE: Replace CDN script below with locally built Tailwind CSS
Install: npm install -D tailwindcss postcss autoprefixer
Build: npx tailwindcss -i ./input.css -o ./output.css --watch
See: https://tailwindcss.com/docs/installation -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- JSZip library for handling zip file uploads -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<!-- Numeric.js for SVD calculations -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeric/1.2.6/numeric.min.js"></script>
<!-- canvas2svg is now integrated into viewer-mol.js -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
xintegrity="sha512-SnH5WK+bZxgPHs44uWIX+LLMDJd4gYm4zQ6UvE6j3v/3Tf7U7T2Y9p6gJzU0bW5V6f6G6X6b6W6w6+g6w=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="web/style.css">
</head>
<body class="bg-gray-50 text-gray-800 font-sans p-8">
<!-- Global Drop Overlay Element -->
<div id="global-drop-overlay">
<p><i class="fa-solid fa-cloud-arrow-up mr-3"></i> Drop File Anywhere to Load</p>
</div>
<!-- End Global Drop Overlay -->
<!-- Total width (600 + 8 + 340 = 948px) -->
<div class="mx-auto" style="width: 948px; position: relative;">
<div style="position: absolute; top: 0; right: 0; display: flex; gap: 8px;">
<button id="saveStateButton" class="btn btn-primary">
<i class="fa-solid fa-floppy-disk"></i>
<span>Save</span>
</button>
<button id="clearAllButton" class="btn btn-danger">
<i class="fa-solid fa-trash"></i>
<span>Clear All</span>
</button>
</div>
<h1 class="text-4xl font-extrabold text-gray-900 mb-2">2Dmol</h1>
<p class="text-gray-500 mb-4">Load a PDB/CIF file or fetch from RCSB PDB (4-char ID) / AlphaFold DB (UniProt ID)
to visualize protein structures.</p>
<div id="upload-options-container" class="container-box" style="width: 948px; margin-bottom: 10px;">
<!-- Use table for reliable layout -->
<table style="width: 100%; border-collapse: collapse; table-layout: fixed; margin-bottom: 0;">
<tr>
<!-- Left Column: Fetch + Load -->
<td style="width: 50%; padding-right: 12px; vertical-align: top;">
<!-- Fetch Section -->
<label for="fetch-id"
style="display: block; font-size: 14px; font-weight: 500; color: #374151; margin-bottom: 4px;">PDB
(4-char) or UniProt ID</label>
<div id="fetch-input-container" style="margin-bottom: 8px;">
<input type="text" id="fetch-id" placeholder="e.g., 4HHB or P0A8I3">
<button id="fetch-btn" class="btn btn-primary">Fetch</button>
</div>
<!-- Load Section -->
<div style="display: flex; gap: 8px; align-items: flex-start;">
<div style="flex: 1;">
<label
style="display: block; font-size: 14px; font-weight: 500; color: #374151; margin-bottom: 4px;">Load
Files</label>
<div id="uploadControlsContainer" style="display: flex; gap: 8px;">
<!-- Load Button (Triggers hidden input) -->
<button id="upload-button" class="btn btn-secondary">
<i class="fa-solid fa-file-arrow-up"></i>
<span>Choose Files</span>
</button>
<input type="file" id="file-upload"
accept=".pdb,.cif,.ent,.zip,.json,.cst,.a3m,.fasta,.fa,.fas,.sto,.csv" multiple
class="hidden">
</div>
</div>
<!-- Separator Bar -->
<div style="width: 1px; background: #e5e7eb; align-self: stretch;"></div>
<div style="flex: 1;">
<label
style="display: block; font-size: 14px; font-weight: 500; color: #374151; margin-bottom: 4px;">Example</label>
<div style="display: flex; gap: 8px;">
<button class="btn btn-success" data-example-value="Q5VSL9">
<span>Q5VSL9</span>
</button>
<button class="btn btn-success" data-example-value="1YNE">
<span>1YNE</span>
</button>
<button class="btn btn-success" data-example-value="4HHB">
<span>4HHB</span>
</button>
</div>
</div>
</div>
</td>
<!-- Right Column: Options (split into two columns) -->
<td style="vertical-align: top;">
<label
style="display: block; font-size: 14px; font-weight: 500; color: #374151; margin-bottom: 4px;">Options</label>
<div style="display: flex; gap: 16px;">
<!-- Left Column: Existing Options -->
<div class="upload-options-section" style="margin-bottom: 0; flex: 1;">
<!-- Load as Frames Toggle -->
<div class="upload-toggle-item">
<label class="switch">
<input type="checkbox" id="loadAsFramesCheckbox" checked>
<span class="slider-toggle"></span>
</label>
<label for="loadAsFramesCheckbox" class="upload-toggle-label">Load as Frames</label>
</div>
<!-- Align Frames Toggle -->
<div class="upload-toggle-item">
<label class="switch">
<input type="checkbox" id="alignFramesCheckbox" checked>
<span class="slider-toggle"></span>
</label>
<label for="alignFramesCheckbox" class="upload-toggle-label">Align Frames</label>
</div>
</div>
<!-- Right Column: New Options -->
<div class="upload-options-section" style="margin-bottom: 0; flex: 1;">
<!-- Load PAE Toggle -->
<div class="upload-toggle-item">
<label class="switch">
<input type="checkbox" id="loadPAECheckbox" checked>
<span class="slider-toggle"></span>
</label>
<label for="loadPAECheckbox" class="upload-toggle-label">Load PAE</label>
</div>
<!-- Load MSA Toggle -->
<div class="upload-toggle-item">
<label class="switch">
<input type="checkbox" id="loadMSACheckbox">
<span class="slider-toggle"></span>
</label>
<label for="loadMSACheckbox" class="upload-toggle-label">Load MSA</label>
</div>
<!-- Load Biounit Toggle -->
<div class="upload-toggle-item">
<label class="switch">
<input type="checkbox" id="biounitCheckbox" checked>
<span class="slider-toggle"></span>
</label>
<label for="biounitCheckbox" class="upload-toggle-label">Load Biounit</label>
</div>
<!-- Load Ligands Toggle -->
<div class="upload-toggle-item">
<label class="switch">
<input type="checkbox" id="loadLigandsCheckbox">
<span class="slider-toggle"></span>
</label>
<label for="loadLigandsCheckbox" class="upload-toggle-label">Load Ligands</label>
</div>
</div>
</div>
</td>
</tr>
</table>
<!-- Status message below the table -->
<div id="status-message" style="margin-top: 12px;"></div>
</div>
<div id="viewer-container" class="py2dmol-viewer-instance" style="display: none;">
<div id="mainContainer">
<div id="viewerColumn">
<div id="canvasContainer" class="container-box">
<canvas id="canvas"></canvas>
<!-- Resize handle -->
<div class="resize-handle"></div>
</div>
<div id="controlsContainer" class="container-box">
<button id="playButton" class="btn btn-secondary btn-icon-only"><i
class="fa-solid fa-play"></i></button>
<button id="recordButton" class="btn btn-secondary btn-icon-only"
title="Record animation to video file">
<i class="fa-solid fa-video"></i>
</button>
<input type="range" id="frameSlider" min="0" max="0" value="0">
<span id="frameCounter">0 / 0</span>
<button id="speedButton" class="btn btn-grey btn-icon-only"
title="Cycle playback speed">1x</button>
<button id="overlayButton" class="btn btn-secondary" title="Overlay all frames"
style="font-weight: 400;">⧉</button>
</div>
</div>
<!-- Right side panels container -->
<div id="rightPanelsContainer">
<div id="rightPanelContainer" class="container-box">
<!-- Toolbar (two rows) -->
<div id="navigationControls" class="toolbar" style="margin-bottom: 4px;">
<div class="toolbar-row">
<label class="btn-toggle btn-flex" id="orientToggle" title="Orient to best view">
<input type="checkbox" style="display: none;">
<span><i class="fa-solid fa-crosshairs"></i>Orient</span>
</label>
<!-- Rotate: checkbox styled as a button -->
<label class="btn-toggle btn-flex" id="rotateToggle" title="Toggle auto-rotation">
<input type="checkbox" id="rotationCheckbox">
<span><i class="fa-solid fa-rotate"></i>Rotate</span>
</label>
</div>
<!-- New second row -->
<div class="toolbar-row">
<label class="btn-toggle btn-flex btn-small" title="Toggle shadow">
<input type="checkbox" id="shadowEnabledCheckbox" checked>
<span>Shadow</span>
</label>
<button id="outlineModeButton" class="btn-toggle btn-flex btn-small"
title="Cycle outline mode: none → partial → full">
<span>Outline</span>
</button>
<button id="saveSvgButton" class="btn-toggle btn-flex btn-icon-only btn-small"
title="Save as SVG">
<span>
<i class="fa-solid fa-camera"></i>
</span>
</button>
</div>
</div>
<div id="styleAppearanceContainer" class="control-group">
<div class="toggle-item" style="display: flex; align-items: center; gap: 8px;">
<label for="colorSelect" class="font-medium text-gray-700"
style="font-size: 12px;">Color:</label>
<select id="colorSelect"
style="flex: 1; height: 28px; font-size: 12px; padding: 0 8px;">
<option value="auto">Auto</option>
<option value="plddt">pLDDT</option>
<option value="deepmind">DeepMind</option>
<option value="rainbow">Rainbow</option>
<option value="chain">Chain</option>
<option value="entropy" id="entropyColorOption" hidden>Entropy</option>
</select>
<label class="btn-toggle btn-no-margin btn-small" title="Colorblind-safe colors">
<input type="checkbox" id="colorblindCheckbox">
<span>Colorblind</span>
</label>
</div>
<div class="toggle-item" style="display: flex; align-items: center; gap: 8px;">
<div style="flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0;">
<label for="lineWidthSlider" class="font-medium text-gray-700"
style="width: 50px; font-size: 12px; flex-shrink: 0;">Width:</label>
<input type="range" id="lineWidthSlider" min="2.0" max="4.7" value="3.0" step="0.1"
style="flex: 1; min-width: 0; outline: none;">
</div>
<div style="flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0;">
<label for="outlineWidthSlider" class="font-medium text-gray-700"
style="width: 50px; font-size: 12px; flex-shrink: 0;">Outline:</label>
<input type="range" id="outlineWidthSlider" min="0" max="10" value="3.0" step="0.1"
style="flex: 1; min-width: 0; outline: none;">
</div>
</div>
<div class="toggle-item" style="display: flex; align-items: center; gap: 8px;">
<div style="flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0;">
<label for="orthoSlider" class="font-medium text-gray-700"
style="width: 50px; font-size: 12px; flex-shrink: 0;">Ortho:</label>
<input type="range" id="orthoSlider" min="0" max="1" value="1.0" step="0.01"
style="flex: 1; min-width: 0; outline: none;">
</div>
<div style="flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0;">
<label for="shadowSlider" class="font-medium text-gray-700"
style="width: 50px; font-size: 12px; flex-shrink: 0;">Shadow:</label>
<input type="range" id="shadowSlider" min="0" max="1" value="0.5" step="0.01"
style="flex: 1; min-width: 0; outline: none;">
</div>
</div>
<div class="toggle-item" style="display: flex; align-items: center; gap: 8px;">
<label for="objectSelect" class="font-medium text-gray-700"
style="font-size: 12px;">Object:</label>
<select id="objectSelect"
style="flex: 1; height: 28px; font-size: 12px; padding: 0 8px;">
<!-- Initially empty -->
</select>
</div>
</div>
</div>
<!-- PAE Canvas Container -->
<div id="paeContainer" class="container-box" style="display: none;">
<canvas id="paeCanvas" style="cursor: crosshair;"></canvas>
</div>
<!-- Scatter Plot Container (mirrors main viewer sizing; JS sets dimensions) -->
<div id="scatterContainer" class="container-box" style="display: none; position: relative;">
<canvas id="scatterCanvas" style="cursor: pointer;"></canvas>
<div class="resize-handle" aria-label="Resize scatter plot"></div>
</div>
</div>
</div>
</div>
<!-- Sequence container with box and toggle -->
<div id="sequence-viewer-container" class="container-box sequence-section-container"
style="width: 948px; display: none;">
<div id="sequenceHeader" class="sequence-header">
<!-- Left side: Mode dropdown -->
<div style="display: flex; align-items: center; gap: 8px;">
<select id="sequenceModeSelect" class="btn btn-grey btn-small"
style="min-width: 100px; height: 28px; font-size: 12px; padding: 0 8px;">
<option value="sequence" selected>Sequence</option>
<option value="chain">Chain</option>
</select>
</div>
<!-- Action buttons aligned to the right -->
<div class="sequence-actions" style="margin-left: auto;">
<button id="selectAllResidues" class="btn btn-grey btn-small">Show all</button>
<button id="clearAllResidues" class="btn btn-grey btn-small">Hide all</button>
<button id="copySelectionButton" class="btn btn-grey btn-small" disabled>Copy selection</button>
</div>
</div>
<div id="sequenceView" class="sequence-content hidden"></div>
</div>
<!-- MSA container with box and toggle -->
<div id="msa-buttons" class="sequence-section-container" style="display: none;">
<div id="msaHeader" class="sequence-header">
<!-- Left side: Mode dropdown, Save buttons, Sort checkbox, Bit-score checkbox -->
<div style="display: flex; align-items: center; gap: 8px;">
<select id="msaModeSelect" class="btn btn-grey btn-small"
style="min-width: 100px; height: 28px; font-size: 12px; padding: 0 8px;">
<option value="msa" selected>MSA</option>
<option value="pssm">PSSM</option>
<option value="logo">Logo</option>
<option value="coverage">Coverage</option>
</select>
<div id="msaSaveContainer" style="display: none; align-items: center; gap: 4px;">
<button id="msaSaveFastaButton" class="btn btn-grey btn-small" style="font-size: 11px;">Save
Fasta</button>
</div>
<div id="logoSaveContainer" style="display: none; align-items: center; gap: 4px;">
<button id="logoSaveSvgButton" class="btn btn-grey btn-small" style="font-size: 11px;">Save
SVG</button>
</div>
<div id="pssmSaveContainer" style="display: none; align-items: center; gap: 4px;">
<button id="pssmSaveSvgButton" class="btn btn-grey btn-small" style="font-size: 11px;">Save
SVG</button>
<button id="pssmSaveCsvButton" class="btn btn-grey btn-small" style="font-size: 11px;">Save
CSV</button>
</div>
<div id="msaSortContainer" style="display: flex; align-items: center; gap: 4px;">
<label for="msaSortCheckbox"
style="font-size: 12px; color: #666; white-space: nowrap; display: flex; align-items: center; gap: 4px; cursor: pointer;">
<input type="checkbox" id="msaSortCheckbox" checked style="cursor: pointer;">
<span>Sort</span>
</label>
</div>
<div id="logoBitScoreContainer" style="display: none; align-items: center; gap: 4px;">
<label for="logoBitScoreCheckbox"
style="font-size: 12px; color: #666; white-space: nowrap; display: flex; align-items: center; gap: 4px; cursor: pointer;">
<input type="checkbox" id="logoBitScoreCheckbox" checked style="cursor: pointer;">
<span>Bit-score</span>
</label>
</div>
</div>
<!-- Right: Filters box and Chain selector -->
<div style="display: flex; align-items: center; gap: 8px; margin-left: auto;">
<div
style="display: flex; align-items: center; gap: 10px; padding: 4px 10px; border: 1px solid #ccc; border-radius: 4px; background: #f9f9f9;">
<span style="font-size: 12px; color: #666; font-weight: 500;">Filters:</span>
<div style="display: flex; align-items: center; gap: 4px;">
<label for="coverageSlider"
style="font-size: 11px; color: #666; white-space: nowrap;">cov:</label>
<input type="range" id="coverageSlider" min="0" max="100" value="75" step="5"
style="width: 100px;">
<span id="coverageValue"
style="font-size: 11px; color: #666; width: 40px; text-align: right; display: inline-block;">75%</span>
</div>
<div style="display: flex; align-items: center; gap: 4px;">
<label for="identitySlider"
style="font-size: 11px; color: #666; white-space: nowrap;">qid:</label>
<input type="range" id="identitySlider" min="0" max="100" value="15" step="5"
style="width: 100px;">
<span id="identityValue"
style="font-size: 11px; color: #666; width: 40px; text-align: right; display: inline-block;">15%</span>
</div>
<span id="msaSequenceCount"
style="font-size: 11px; color: #666; white-space: nowrap; min-width: 80px; text-align: center; margin-left: 4px; display: inline-block;">-</span>
</div>
<!-- Chain selector (hidden by default, shown when multiple chains available) -->
<select id="msaChainSelect" class="btn btn-grey btn-small"
style="display: none; min-width: 50px; height: 28px; font-size: 12px; padding: 0 8px;"></select>
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer style="margin-top: var(--container-gap); padding: 0; color: #6b7280; font-size: 13px;">
<div
style="width: 948px; margin: 0 auto; padding: 10px 0 0 0; border-top: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;">
<div style="flex: 0 0 auto; display: flex; align-items: center; gap: 12px;">
<a href="https://github.com/sokrypton/py2Dmol" target="_blank" rel="noopener noreferrer"
style="color: #3b82f6; text-decoration: none;">
<i class="fab fa-github" style="margin-right: 6px;"></i>View on GitHub
</a>
</div>
<div style="flex: 0 0 auto; font-size: 12px;">
<i class="fa-solid fa-shield-halved" style="margin-right: 6px; color: #10b981;"></i>
<strong>Privacy:</strong> All processing is performed locally in your browser. No data is uploaded to a
server.
</div>
</div>
</footer>
<!-- Load scripts in order -->
<script src="web/utils.js"></script>
<script src="py2Dmol/resources/viewer-mol.js"></script>
<script src="py2Dmol/resources/viewer-pae.js"></script>
<script src="py2Dmol/resources/viewer-scatter.js"></script>
<script src="py2Dmol/resources/viewer-seq.js"></script>
<script src="py2Dmol/resources/viewer-msa.js"></script>
<script src="web/app.js"></script>
</body>
</html>