Custom representation: bfactors of hit as spheres
The content of this page was edited by matteoferla on the 2022-05-31 22:15:05.856517.The administrators of this site take no legal responsibility for the content of this page, if you believe this page is in violation of the law, please report it.
Description
This is an SGC TEP structure (PDB: 5QQG) composed of Ras-related C3 botulinum toxin substrate 1 (2-178:A) and Kalirin (3-182:B) bound to a hit (N-(5-methyl-1,2-oxazol-3-yl)-N'-[3-(4-phenylpiperazin-1-yl)propylurea (N64 and :A)]).
The ligand is flopping outside clearly. How about showing this as spheres?
This code is generally applicable to NGL.js
, except for the .getStage()
method. This simply gets the stage object.
Also protein is assumed to be compList[0], which it probably is (stage.compList[0].type === "structure"
).
The selection 'ligand' can be changed obvs.
//NGL.setDebug(true);
const stage = NGL.getStage();
var protein = stage.compList[0];
var bfactorMin = +Infinity
var bfactorMax = -Infinity
var ligand = stage.compList[0].structure.getView(new NGL.Selection('ligand and not EDO'));
ligand.eachAtom(function(atom) {
if (bfactorMin > atom.bfactor) bfactorMin = atom.bfactor;
if (bfactorMax < atom.bfactor) bfactorMax = atom.bfactor;
});
var pos = [];
var color = [];
var radius = [];
ligand.eachAtom(function(atom) {
pos.push(atom.x, atom.y, atom.z);
color.push(1, 1 - 1 * atom.bfactor/bfactorMax, 0);
radius.push(atom.bfactor/bfactorMin * 0.5);
});
var sphereBuffer = new NGL.SphereBuffer( {
position: new Float32Array( pos ),
color: new Float32Array( color ),
radius: new Float32Array( radius )
} );
//this has odd side effects.
//protein.addBufferRepresentation(sphereBuffer, {opacity: 0.5});
var shape = new NGL.Shape("bspheres");
shape.addBuffer(sphereBuffer);
var shapeComp = protein.stage.addComponentFromObject(shape);
shapeComp.addRepresentation("buffer", {opacity: 0.5});