Spaces:
Paused
Paused
Commit
·
54c4c68
1
Parent(s):
f591191
Update app.py
Browse filesspectrum coloring looks nice but actually has no real meaning.
It is informative to display the pLDDT value which indicates how confident the model is about its prediction.
Additionally I added a hover tooltip :)
app.py
CHANGED
@@ -50,8 +50,36 @@ def molecule(input_pdb):
|
|
50 |
let element = $("#container");
|
51 |
let config = { backgroundColor: "white" };
|
52 |
let viewer = $3Dmol.createViewer(element, config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
viewer.addModel(pdb, "pdb");
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
viewer.zoomTo();
|
56 |
viewer.render();
|
57 |
viewer.zoom(1.2, 2000);
|
|
|
50 |
let element = $("#container");
|
51 |
let config = { backgroundColor: "white" };
|
52 |
let viewer = $3Dmol.createViewer(element, config);
|
53 |
+
let colorAlpha = function (atom) {
|
54 |
+
if (atom.b < 50) {
|
55 |
+
return "OrangeRed";
|
56 |
+
} else if (atom.b < 70) {
|
57 |
+
return "Gold";
|
58 |
+
} else if (atom.b < 90) {
|
59 |
+
return "MediumTurquoise";
|
60 |
+
} else {
|
61 |
+
return "Blue";
|
62 |
+
}
|
63 |
+
};
|
64 |
+
|
65 |
viewer.addModel(pdb, "pdb");
|
66 |
+
// set plddt coloring
|
67 |
+
viewer.getModel(0).setStyle({cartoon: { colorfunc: colorAlpha }});
|
68 |
+
// display pLDDT tooltips when hovering over atoms
|
69 |
+
viewer.getModel(0).setHoverable({}, true,
|
70 |
+
function (atom, viewer, event, container) {
|
71 |
+
if (!atom.label) {
|
72 |
+
atom.label = viewer.addLabel(atom.resn + atom.resi + " pLDDT=" + atom.b, { position: atom, backgroundColor: "mintcream", fontColor: "black" });
|
73 |
+
}
|
74 |
+
},
|
75 |
+
function (atom, viewer) {
|
76 |
+
if (atom.label) {
|
77 |
+
viewer.removeLabel(atom.label);
|
78 |
+
delete atom.label;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
);
|
82 |
+
}
|
83 |
viewer.zoomTo();
|
84 |
viewer.render();
|
85 |
viewer.zoom(1.2, 2000);
|