IMP logo
IMP Reference Guide  2.6.0
The Integrative Modeling Platform
display/show_particles_as_spheres.py

Write two colored sets of random IMP::core::XYZR particles to a Pymol input file.

1 ## \example display/show_particles_as_spheres.py
2 # Write two colored sets of random IMP::core::XYZR particles to a Pymol
3 # input file.
4 
5 import IMP
6 import IMP.algebra
7 import IMP.container
8 import IMP.core
9 import IMP.display
10 import sys
11 
12 IMP.setup_from_argv(sys.argv,
13  "Write two colored sets of random XYZR particles to a Pymol input file")
14 
15 # create two lists of random particles for display
16 m = IMP.Model()
17 n = 10
18 radius = 1.0
19 bounding_box_size = 10.0
20 xyzrs0 = IMP.core.create_xyzr_particles(m, 10, radius, bounding_box_size)
21 xyzrs1 = IMP.core.create_xyzr_particles(m, 10, radius, bounding_box_size)
22 xyzrs0_container = IMP.container.ListSingletonContainer(m, xyzrs0)
23 xyzrs1_container = IMP.container.ListSingletonContainer(m, xyzrs1)
24 
25 # create a writer that generates Pymol Python scripts for visualizing
26 # the particle lists
27 w = IMP.display.PymolWriter("out.pym")
28 # write first list of particles
29 g0 = IMP.core.XYZRsGeometry(xyzrs0_container)
30 g0.set_name("my particles")
31 g0.set_color(IMP.display.Color(1, 0, 0))
32 w.add_geometry(g0)
33 # write second list of particles
34 g1 = IMP.core.XYZRsGeometry(xyzrs1_container)
35 g1.set_name("my other particles")
36 g1.set_color(IMP.display.Color(0, 1, 0))
37 w.add_geometry(g1)
38 # make sure that the file is flushed
39 del w