-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproview_3d.js
60 lines (51 loc) · 1.5 KB
/
proview_3d.js
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
// Create a new instance of the viewer
var iv = new iview('iview');
// Set the default options
var options = {};
options["camera"] = "perspective";
options["background"] = "white";
options["primaryStructure"] = "lines";
options["secondaryStructure"] = "cylinder & plate";
options["colorBy"] = "spectrum";
options["ligands"] = "nothing";
options["waters"] = "nothing";
options["ions"] = "nothing";
options["selectedRes"] = [];
//options["labels"] = "yes";
iv.rebuildScene(options);
iv.render();
// Load the PDB when a new file is uploaded
$("#pdbInput").change(function() {
var file = this.files[0];
if (file === undefined) return;
var reader = new FileReader();
reader.onload = function () {
// Reset the current visualization
clearHighlight3D();
// Load in the new PDB
iv.loadPDB(reader.result);
};
reader.readAsText(file);
});
// Highlight res based off what's selected in the dataset
function highlight3D(res_array){
if(res_array.length){
iv.options.colorBy = 'highlight';
iv.options.selectedRes = res_array;
iv.rebuildScene();
iv.render();
} else {
clearHighlight3D();
}
}
// Clear any highlighting
function clearHighlight3D(){
iv.options.colorBy = options['colorBy'];
iv.options.selectedRes = [];
iv.rebuildScene();
iv.render();
}
// Load the example file if it's available
$.get("pdb/3KFN.pdb",function(pdb){
iv.loadPDB(pdb);
})