OpenStructure
Loading...
Searching...
No Matches
bbox.py

Illustrates the use of BoundingBoxFromEntity().

1# This code example shows how to calculate and display an oriented bounding box
2# that contains all the atoms of an entity.
3
4# remove all objects from scene, just in case
5scene.RemoveAll()
6
7# Load sdh molecule
8sdh=io.LoadPDB('data/sdh.pdb')
9# Select backbone atoms of residues 99-128, which form a helix.
10helix=sdh.Select('rnum=99:128 and cname=A and aname=CA,C,N,O')
11# create a graphical representation of the helix and render it with simple
12# lines.
13go=gfx.Entity('helix', gfx.SIMPLE, helix)
14# add it to the scene
15scene.Add(go)
16
17# calculate the bounding box for the helix
18bbox=mol.BoundingBoxFromEntity(helix)
19
20# create a graphical representation of the bounding box and add it to the scene
21bb=gfx.Cuboid('xxx', bbox)
22bb.SetFillColor(gfx.Color(0.5, 0.8, 0.5, 0.2))
23scene.Add(bb)
24
25# center the camera on the graphical object
26scene.center=go.center