# module name to make the example use that module. from Scientific.Visualization import VRML2 module = VRML2 # Create the protein and find its center of mass and tensor of inertia. protein = Protein('insulin') center, inertia = protein.centerAndMomentOfInertia() # Diagonalize the inertia tensor and scale the axes to a suitable length. mass = protein.mass() diagonal, directions = LA.eigenvectors(inertia.array) diagonal = N.sqrt(diagonal / mass) # Generate the backbone graphics objects. graphics = protein.graphicsObjects(graphics_module=module, model='backbone', color='red') # Add an atomic wireframe representation of all valine sidechains valines = protein.residuesOfType('val') sidechains = valines.map(lambda r: r.sidechain) graphics = graphics + sidechains.graphicsObjects( graphics_module=module, model='wireframe', color='blue') # Add three arrows corresponding to the principal axes of inertia. for length, axis in map(None, diagonal, directions): graphics.append( module.Arrow(center, center + length * Vector(axis), 0.02, material=module.EmissiveMaterial('green')))
orientation=(Vector(0, 1, 0),3.14159), description="Back") left_cam = visualization_module.Camera(position=[center[0]-distance_away,center[1],center[2]], orientation=(Vector(0, 1, 0),3.14159*1.5), description="Left") #Other visualisation methods ("models") you might like to try:- model_name = 'vdw' #model_name = 'tube' #model_name = 'ball_and_stick' print "Creating " + model_name + " graphic of Protein" #You can also specify colour for the whole molecule if you want, #otherwise the individual atom colours are used (Oxygen = Red, #Hydrogen = White, Sulphur = Yellow etc) graphics = protein.graphicsObjects(graphics_module = visualization_module, model = model_name) print "Creating arrows below protein" #In order to help visualise what the camera objects are doing, I #am adding some arrows in the x-z planes above and below the molecule. # #The red arrows point towards the "front" camera, green towards the #"right" camera, blue towards the "back" camera and yellow towards the #"left" camera. # d = 2.0 #distance from centre of mass (above or below) l = 2.0 #length of each arrow graphics.append(visualization_module.Arrow(center + Vector(0,-d,0), center + Vector(0,-d,l), 0.1, material=visualization_module.DiffuseMaterial('red'))) graphics.append(visualization_module.Arrow(center + Vector(0,-d,0),
description="Back") left_cam = visualization_module.Camera( position=[center[0] - distance_away, center[1], center[2]], orientation=(Vector(0, 1, 0), 3.14159 * 1.5), description="Left") #Other visualisation methods ("models") you might like to try:- model_name = 'vdw' #model_name = 'tube' #model_name = 'ball_and_stick' print "Creating " + model_name + " graphic of Protein" #You can also specify colour for the whole molecule if you want, #otherwise the individual atom colours are used (Oxygen = Red, #Hydrogen = White, Sulphur = Yellow etc) graphics = protein.graphicsObjects(graphics_module=visualization_module, model=model_name) print "Creating arrows below protein" #In order to help visualise what the camera objects are doing, I #am adding some arrows in the x-z planes above and below the molecule. # #The red arrows point towards the "front" camera, green towards the #"right" camera, blue towards the "back" camera and yellow towards the #"left" camera. # d = 2.0 #distance from centre of mass (above or below) l = 2.0 #length of each arrow graphics.append( visualization_module.Arrow( center + Vector(0, -d, 0), center + Vector(0, -d, l),