-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·513 lines (450 loc) · 18.8 KB
/
index.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
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
<!DOCTYPE html>
<!--
GLmol - Molecular Viewer on WebGL/Javascript
(C) Copyright 2011-2012, biochem_fan
License: dual license of MIT or LGPL3
This program uses
Three.js
https://github.com/mrdoob/three.js
Copyright (c) 2010-2011 three.js Authors. All rights reserved.
jQuery
http://jquery.org/
Copyright (c) 2011 John Resig
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, target-densitydpi=device-dpi">
<title>GLmol - Molecular Viewer on WebGL/Javascript</title>
<style type="text/css">
html, body {width:100%; height:100%; margin: 0px; background-color: rgba(0, 0, 0, 0.65)}
body {overflow: hidden;}
input, select, button, textarea{border: 1px solid white; background-color: black; color: white;}
option {background-color: black; color: white;}
a {color: white;}
button {
color: rgb(255,255,255);
background: transparent;
border: 0px;
padding: 5px 10px;
cursor: pointer;
}
#menu {
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
padding: 0;
margin: 0;
z-index: 1;
}
#topmenu {
position: absolute;
top: 10px;
right: 10px;
width: 100%;
text-align: right;
padding: 0;
margin: 0;
z-index: 1;
}
button {
color: rgb(255,255,255);
background: transparent;
border: 0px;
padding: 5px 10px;
cursor: pointer;
}
button:hover {
background-color: rgba(0,255,255,0.5);
}
button:active {
color: #000000;
background-color: rgba(0,255,255,1);
}
#glmol01 {width: 100%; height: 100%; background-color: black; position: absolute;}
.settings {position: absolute; right: 0px; top: 10%;
background-color: grey;
-moz-transform: rotate(-90deg); -webkit-transform: rotate(-90deg);
margin:0px; padding:10px;
-moz-transform-origin: 110% 100%; -webkit-transform-origin: 110% 100%;
-webkit-border-radius: 10px 10px 0px 0px; -moz-border-radius: 10px 10px 0px 0px;}
.controller {position: absolute; width: 0px; right: 0px; top: 10%;
background-color: rgba(0, 0, 0, 0.65); color: white;}
.tabBox {position: absolute; padding: 0px; color: white; bottom: 0px; height: 20px; width: 60%;}
.bottomTab {background-color: black; border: 1px solid white; color: white; margin: 0px; padding: 10px 10px 0px 10px; -webkit-border-radius: 10px 10px 0px 0px; -moz-border-radius: 10px 10px 0px 0px;}
.insideTab {border: 1px solid white; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.85); margin:0px; overflow: scroll;}
.tabBox p, .tabBox h1, .tabBox ul {margin-left: 10px; font-size: 90%;}
</style>
</head>
<body>
<!-- menu -->
<div id="topmenu">
<button id="b_a">Capa 1</button>
<button id="b_b">Capa 2</button>
<button id="b_ab">Capa 1 + Capa 2</button>
</div>
<div id="menu"></div>
<script>
var MOLECULES = {
"9rnt":"9rnt.pdb",
"arginina5":"arginina5.pdb",
//"Caffeine": "caffeine.pdb",
"glicina":"glicina.pdb",
"helix_310":"helix_310.pdb",
"helix_alfa_short":"helix_alfa_short.pdb",
"trp":"trp.pdb",
"1aoi":"1aoi.pdb",
"1BU3":"1BU3",
"manoEF":"manoEF.pdb",
"Betass3":"betas3.pdb"
};
var menu = document.getElementById( "menu" );
b_a.addEventListener( 'click', function() { visualizationType = 0; showAtoms() } );
b_b.addEventListener( 'click', function() { visualizationType = 1; showBonds() } );
b_ab.addEventListener( 'click', function() { visualizationType = 2; showAtomsBonds() } );
function showAtoms(){
$('#glmol01_showMainchain').each(function(){ this.checked = false; });
$('#glmol01_showHetatms').each(function(){ this.checked = true; });
glmol01.defineRepresentation = defineRepFromController;
glmol01.rebuildScene();
glmol01.show();
}
function showBonds(){
$('#glmol01_showMainchain').each(function(){ this.checked = true; });
$('#glmol01_showHetatms').each(function(){ this.checked = false; });
glmol01.defineRepresentation = defineRepFromController;
glmol01.rebuildScene();
glmol01.show();
}
function showAtomsBonds(){
//createMenu();
$('#glmol01_showHetatms').each(function(){ this.checked = true; });
$('#glmol01_showMainchain').each(function(){ this.checked = true; });
// $("#estado_cat").prop("checked", false);
glmol01.defineRepresentation = defineRepFromController;
glmol01.rebuildScene();
glmol01.show();
animate();
}
function generateButtonCallback( url ) {
return function ( event ) {
newmol( url );
}
}
function createMenu() {
for ( var m in MOLECULES ) {
var button = document.createElement( 'button' );
button.innerHTML = m;
menu.appendChild( button );
var url = "prote/" + MOLECULES[ m ];
button.addEventListener( 'click', generateButtonCallback( url ), false );
}
}
function animate() {
requestAnimationFrame( animate );
var time = Date.now() * 0.0004;
// root.rotation.x = time * 0.1;
glmol01.rotation.y = time * 0.2;
//render();
}
</script>
<!-- end menu -->
<div id="glmol01"></div>
<!--
<div class="tabBox" id="glmol01_infobox" style="left: 40%; z-index: 2;">
<span class="bottomTab">About</span>
<div class="insideTab" style="overflow: auto;">
<h1>About</h1>
<p>GLmol -- Molecular Viewer on WebGL/Javascript<br>
Version 0.47 (20120827)</p>
<p>This program is written by biochem_fan and released under LGPL. Please visit <a href="http://webglmol.sfjp.jp/">my project page</a> for the details and source code distribution.</p>
<p>Comments and Suggestions are welcome. Please mail to biochem_fan at users.sourceforge.jp or write in <a href="http://sourceforge.jp/projects/webglmol/forums/">the forum</a>.</p>
<h1>How to use</h1>
<ul><li>Rotation: left button</li>
<li>Translation: middle button or Ctrl-key + left button</li>
<li>Zoom: mousewheel or right button(up/down) or Shift-key + left button(up/down)</li>
<li>Slab: left button + Ctrl-key. horizontal move adjusts near clipping plane, vertical move far clipping plane.</li>
</ul>
<p>You can also change mouse mode with radio buttons at right-bottom corner.</p>
</div>
</div> -->
<div class="tabBox" id="glmol01_srcbox" style="left: 10%; z-index:0; display:none;">
<span class="bottomTab">Load</span>
<div class="insideTab">
You can load PDB, MOL2, SDF/MOL(MDL not SYBYL) or XYZ files <br>
-from local disk (don't worry. your file will not be uploaded),
<input id="glmol01_file" type="file" size=1><button onClick="loadFile()">Load from file</button><br>
-from RCSB PDB server,
PDBID: <input id="glmol01_pdbid" value="2POR" size=4><button onClick="download('pdb:' + $('#glmol01_pdbid').val())">Download</button><br>
-from PubChem server,
Compound ID(CID): <input id="glmol01_cid" value="2244" size=4><button onClick="download('cid:' + $('#glmol01_cid').val())">Download</button><br>
<!-- CHECK: CSS nowrap is not working? -->
-or from the textarea below.<br><!-- white-space: nowrap not only doesn't work in Firefox but also let Chrome reformatting continuous spaces!!! -->
<textarea wrap="off" id="glmol01_src" style="width: 100%; height: 8em; overflow:scroll;"></textarea><br>
<button onClick="glmol01.loadMolecule(); $('#loading').hide();">Reload molecule from textarea</button>
</div>
</div>
<div class="tabBox" id="glmol01_viewbox" style="left: 25%; z-index:1;">
<span class="bottomTab">View</span>
<div class="insideTab" style="overflow: auto;">
Color by <select id="glmol01_color">
<option selected="selected" value="chainbow">spectrum</option>
<option value="chain">chain</option>
<option value="ss">secondary strcuture</option>
<option value="b">B factor</option>
<option value="polarity">polar/nonpolar</option>
</select><br>
<input id="glmol01_showMainchain" type="checkbox" checked>Main chain as <select id="glmol01_mainchain">
<option selected="selected" value="thickRibbon">thick ribbon</option>
<option value="ribbon">thin ribbon(faster)</option>
<option value="strand">strand</option>
<option value="cylinderHelix">cylinder & plate</option>
<option value="chain">C alpha trace</option>
<option value="tube">B factor Tube</option>
<option value="bonds">bonds (everything)</option>
</select><br>
<input id="glmol01_showBases" type="checkbox" checked>Nucleic acid bases as
<select id="glmol01_base">
<option value="nuclStick">sticks</option>
<option selected="selected" value="nuclLine">lines</option>
<option value="nuclPolygon">polygons</option>
</select><br>
<input id="glmol01_line" type="checkbox">Side chains as lines<br>
<input id="glmol01_doNotSmoothen" type="checkbox">Don't smooth beta-sheets in ribbons<br>
<input id="glmol01_showNonBonded" type="checkbox">Non-bonded atoms (solvent/ions) as
<select id="glmol01_nb">
<option value="nb_sphere">spheres</option>
<option selected="selected" value="nb_cross">stars</option>
</select>
<br>
<input id="glmol01_showHetatms" type="checkbox" checked>Small molecules(HETATMs) as
<select id="glmol01_hetatm">
<option value="stick">sticks</option>
<option value="ballAndStick">ball and stick</option>
<option value="ballAndStick2">ball and stick (multiple bond)</option>
<option selected="selected" value="sphere">spheres</option>
<option value="icosahedron">icosahedrons</option>
<option value="line">lines</option>
</select><br>
Multiple bond option is for SDF/MOL file ONLY.<br>
<input id="glmol01_cell" type="checkbox">Unit cell<br>
<input id="glmol01_biomt" type="checkbox">Biological assembly (the last one defined)<br>
<input id="glmol01_packing" type="checkbox">Crystal packing<br>
<input id="glmol01_symopHetatms" type="checkbox">Show HETATMs in symmetry mates (slower)<br>
Background color: <select id="glmol01_bgcolor">
<option value="0xffffff">white</option>
<option selected="selected" value="0x000000">black</option>
<option value="0x888888">grey</option>
</select>
Projection: <select id="glmol01_projection">
<option value="orthoscopic">orthoscopic</option>
<option selected="selected" value="perspective">perspective</option>
</select><br><br>
<button id="glmol01_reload">Apply</button> <button onClick="saveImage()">Take screenshot</button>
</div></div>
<div style="position: absolute; color: white; right: 10px; bottom: 10px; z-index: 99; background-color: rgba(0, 0, 0, 0.65);">
<!--<input type="radio" name="glmol01_mouseMode" value="0" checked>Rotate<br>
<input type="radio" name="glmol01_mouseMode" value="1">Translate<br>
<input type="radio" name="glmol01_mouseMode" value="2">Zoom<br>
<input type="radio" name="glmol01_mouseMode" value="3">Slab<br><br> -->
<button onClick="glmol01.doFunc(function(mol) {mol.zoomInto(mol.getAllAtoms());mol.show()});">Resetear vista</button>
</div>
<div id="loading" style="border: 2px solid white; position: absolute; color: white; left: 10%; top: 10%; padding: 5px; z-index:101;">
<p>Cargando Modelo.</p>
</div>
<!-- <div id="glmol01_pdbTitle" style="position:absolute; color: white; background-color: rgba(0, 0, 0, 0.65); font-size:80%"></div> -->
<script src="js/jquery-1.7.min.js"></script>
<script src="js/Three49custom.js"></script>
<script type="text/javascript" src="js/GLmol.js"></script>
<script type="text/javascript">
addTab('#glmol01_srcbox', '400px', 0);
addTab('#glmol01_viewbox', '400px', 1);
//addTab('#glmol01_infobox', '400px', 2);
var glmol01 = new GLmol('glmol01', true);
var query = window.location.search.substring(1);
if (query == '') download('pdb:2POR');
else download(query);
createMenu();
function download(query) {
var baseURL = '';
if (query.substr(0, 4) == 'pdb:') {
query = query.substr(4).toUpperCase();
if (!query.match(/^[1-9][A-Za-z0-9]{3}$/)) {
alert("Wrong PDB ID"); return;
}
// uri = "http://www.pdb.org/pdb/files/" + query + ".pdb";
uri = "prote/9rnt.pdb";
} else if (query.substr(0, 4) == 'cid:') {
query = query.substr(4);
if (!query.match(/^[1-9]+$/)) {
alert("Wrong Compound ID"); return;
}
uri = "http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/" + query +
"/SDF?record_type=3d";
}
$('#loading').show();
$.get(uri, function(ret) {
$("#glmol01_src").val(ret);
glmol01.loadMolecule();
$('#loading').hide();
});
}
function addTab(tabId, height, zIndex) {
$(tabId + ' .bottomTab').toggle(
function() {
$(tabId).
css('z-index', 100).
animate({bottom: '0px', 'height': (window.innerWidth > 800) ? height : '600px'});
},
function() {
$(tabId).
css('z-index', zIndex).
animate({bottom: '0px', 'height': '20px'});
}
);
}
function newmol(uri){
$('#loading').show();
$.get(uri, function(ret) {
$("#glmol01_src").val(ret);
glmol01.loadMolecule();
$('#loading').hide();
});
}
function loadFile(url) {
//var file = $('#glmol01_file').get(0);
var file = url;
if (file) file = file.files;
if (!file || !window.FileReader || !file[0]) {
alert("No file is selected. Or File API is not supported in your browser. Please try Firefox or Chrome.");
return;
}
$('#loading').show();
var reader = new FileReader();
reader.onload = function() {
$('#glmol01_src').val(reader.result);
glmol01.loadMolecule();
$('#loading').hide();
};
reader.readAsText(file[0]);
}
function saveImage() {
glmol01.show();
var imageURI = glmol01.renderer.domElement.toDataURL("image/png");
window.open(imageURI);
}
$('#glmol01_reload').click(function(ev) {
console.log(ev);
glmol01.defineRepresentation = defineRepFromController;
glmol01.rebuildScene();
glmol01.show();
});
function defineRepFromController() {
var idHeader = "#" + this.id + '_';
var time = new Date();
var all = this.getAllAtoms();
if ($(idHeader + 'biomt').attr('checked') && this.protein.biomtChains != "") all = this.getChain(all, this.protein.biomtChains);
var allHet = this.getHetatms(all);
var hetatm = this.removeSolvents(allHet);
console.log("selection " + (+new Date() - time)); time = new Date();
this.colorByAtom(all, {});
var colorMode = $(idHeader + 'color').val();
if (colorMode == 'ss') {
this.colorByStructure(all, 0xcc00cc, 0x00cccc);
} else if (colorMode == 'chain') {
this.colorByChain(all);
} else if (colorMode == 'chainbow') {
this.colorChainbow(all);
} else if (colorMode == 'b') {
this.colorByBFactor(all);
} else if (colorMode == 'polarity') {
this.colorByPolarity(all, 0xcc0000, 0xcccccc);
}
console.log("color " + (+new Date() - time)); time = new Date();
var asu = new THREE.Object3D();
var mainchainMode = $(idHeader + 'mainchain').val();
var doNotSmoothen = ($(idHeader + 'doNotSmoothen').attr('checked') == 'checked');
if ($(idHeader + 'showMainchain').attr('checked')) {
if (mainchainMode == 'ribbon') {
this.drawCartoon(asu, all, doNotSmoothen);
this.drawCartoonNucleicAcid(asu, all);
} else if (mainchainMode == 'thickRibbon') {
this.drawCartoon(asu, all, doNotSmoothen, this.thickness);
this.drawCartoonNucleicAcid(asu, all, null, this.thickness);
} else if (mainchainMode == 'strand') {
this.drawStrand(asu, all, null, null, null, null, null, doNotSmoothen);
this.drawStrandNucleicAcid(asu, all);
} else if (mainchainMode == 'chain') {
this.drawMainchainCurve(asu, all, this.curveWidth, 'CA', 1);
this.drawMainchainCurve(asu, all, this.curveWidth, 'O3\'', 1);
} else if (mainchainMode == 'cylinderHelix') {
this.drawHelixAsCylinder(asu, all, 1.6);
this.drawCartoonNucleicAcid(asu, all);
} else if (mainchainMode == 'tube') {
this.drawMainchainTube(asu, all, 'CA');
this.drawMainchainTube(asu, all, 'O3\''); // FIXME: 5' end problem!
} else if (mainchainMode == 'bonds') {
this.drawBondsAsLine(asu, all, this.lineWidth);
}
}
if ($(idHeader + 'line').attr('checked')) {
this.drawBondsAsLine(this.modelGroup, this.getSidechains(all), this.lineWidth);
}
console.log("mainchain " + (+new Date() - time)); time = new Date();
if ($(idHeader + 'showBases').attr('checked')) {
var hetatmMode = $(idHeader + 'base').val();
if (hetatmMode == 'nuclStick') {
this.drawNucleicAcidStick(this.modelGroup, all);
} else if (hetatmMode == 'nuclLine') {
this.drawNucleicAcidLine(this.modelGroup, all);
} else if (hetatmMode == 'nuclPolygon') {
this.drawNucleicAcidLadder(this.modelGroup, all);
}
}
var target = $(idHeader + 'symopHetatms').attr('checked') ? asu : this.modelGroup;
if ($(idHeader + 'showNonBonded').attr('checked')) {
var nonBonded = this.getNonbonded(allHet);
var nbMode = $(idHeader + 'nb').val();
if (nbMode == 'nb_sphere') {
this.drawAtomsAsIcosahedron(target, nonBonded, 0.3, true);
} else if (nbMode == 'nb_cross') {
this.drawAsCross(target, nonBonded, 0.3, true);
}
}
if ($(idHeader + 'showHetatms').attr('checked')) {
var hetatmMode = $(idHeader + 'hetatm').val();
if (hetatmMode == 'stick') {
this.drawBondsAsStick(target, hetatm, this.cylinderRadius, this.cylinderRadius, true);
} else if (hetatmMode == 'sphere') {
this.drawAtomsAsSphere(target, hetatm, this.sphereRadius);
} else if (hetatmMode == 'line') {
this.drawBondsAsLine(target, hetatm, this.curveWidth);
} else if (hetatmMode == 'icosahedron') {
this.drawAtomsAsIcosahedron(target, hetatm, this.sphereRadius);
} else if (hetatmMode == 'ballAndStick') {
this.drawBondsAsStick(target, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, false, 0.3);
} else if (hetatmMode == 'ballAndStick2') {
this.drawBondsAsStick(target, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, true, 0.3);
}
}
console.log("hetatms " + (+new Date() - time)); time = new Date();
var projectionMode = $(idHeader + 'projection').val();
if (projectionMode == 'perspective') this.camera = this.perspectiveCamera;
else if (projectionMode == 'orthoscopic') this.camera = this.orthoscopicCamera;
this.setBackground(parseInt($(idHeader + 'bgcolor').val()));
if ($(idHeader + 'cell').attr('checked')) {
this.drawUnitcell(this.modelGroup);
}
if ($(idHeader + 'biomt').attr('checked')) {
this.drawSymmetryMates2(this.modelGroup, asu, this.protein.biomtMatrices);
}
if ($(idHeader + 'packing').attr('checked')) {
this.drawSymmetryMatesWithTranslation2(this.modelGroup, asu, this.protein.symMat);
}
this.modelGroup.add(asu);
};
glmol01.defineRepresentation = defineRepFromController;
</script>
</body></html>