IMP
2.3.1
The Integrative Modeling Platform
IMP Mainpage
Modules
Applications
Related Pages
Groups
Classes
Files
Examples
Indexes
IMP
Modules
Applications
All IMP Applications
Argument Index
Class Examples
Factory Index
Function Examples
Design example
Developer Guide
Installation
Introduction
Publications
ChangeLog
Tools
Dependencies
PMI changelog
Deprecated List
Groups
Classes
Files
Examples
Indexes
display/basic_geometry.py
This example shows how to write basic geometric primitives to a file with color and name.
1
## \example display/basic_geometry.py
2
# This example shows how to write basic geometric primitives to a file
3
# with color and name.
4
5
import
IMP.display
6
7
# or IMP.display.ChimeraWriter
8
# if using chimera, make sure there is a %1% in the name to support
9
# multiple frames
10
name = IMP.create_temporary_file_name(
"example"
,
".py"
)
11
print
"File name is"
, name
12
w =
IMP.display.PymolWriter
(name)
13
14
bb =
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0, 0, 0),
15
IMP.algebra.Vector3D
(100, 100, 100))
16
# we could skip the outer loop if we only have one frame
17
for
f
in
range(0, 10):
18
w.set_frame(f)
19
g =
IMP.display.BoundingBoxGeometry
(bb)
20
g.set_name(
"bb"
)
21
w.add_geometry(g)
22
for
i
in
range(0, 10):
23
p =
IMP.algebra.get_random_vector_in
(bb)
24
g =
IMP.display.SphereGeometry
(
IMP.algebra.Sphere3D
(p, 10))
25
# give each a distinctive color
26
g.set_color(
IMP.display.get_display_color
(i))
27
g.set_name(str(i))
28
# add it to the file
29
w.add_geometry(g)