IMP  2.3.1
The Integrative Modeling Platform
display/show_particles_as_spheres.py

Write two colored set of random IMP::core::XYZR particles to a Chimera input file. One could write to a pymol file simply by replacing the IMP::display::Writer.

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