home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.21.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
version 2.21.0
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
from
__future__
import
print_function
6
import
IMP.display
7
import
sys
8
9
IMP.setup_from_argv
(
10
sys.argv,
11
"Write basic geometric primitives to a file with color and name."
)
12
13
name =
IMP.create_temporary_file_name
(
"example"
,
".py"
)
14
print(
"File name is"
, name)
15
w =
IMP.display.PymolWriter
(name)
16
17
bb =
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0, 0, 0),
18
IMP.algebra.Vector3D
(100, 100, 100))
19
# we could skip the outer loop if we only have one frame
20
for
f
in
range(0, 10):
21
w.set_frame(f)
22
g =
IMP.display.BoundingBoxGeometry
(bb)
23
g.set_name(
"bb"
)
24
w.add_geometry(g)
25
for
i
in
range(0, 10):
26
p =
IMP.algebra.get_random_vector_in
(bb)
27
g =
IMP.display.SphereGeometry
(
IMP.algebra.Sphere3D
(p, 10))
28
# give each a distinctive color
29
g.set_color(
IMP.display.get_display_color
(i))
30
g.set_name(str(i))
31
# add it to the file
32
w.add_geometry(g)