IMP  2.0.1
The Integrative Modeling Platform
show_particles_as_spheres.py
1 ## \example display/show_particles_as_spheres.py
2 ## 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.
3 
4 import IMP
5 import IMP.algebra
6 import IMP.container
7 import IMP.core
8 import IMP.display
9 
10 
11 # create two lists of random particles for display
12 m = IMP.Model()
13 n = 10
14 radius = 1.0
15 bounding_box_size = 10.0
16 xyzrs0 = IMP.core.create_xyzr_particles(m, 10, radius, bounding_box_size)
17 xyzrs1 = IMP.core.create_xyzr_particles(m, 10, radius, bounding_box_size)
18 xyzrs0_container = IMP.container.ListSingletonContainer(xyzrs0)
19 xyzrs1_container = IMP.container.ListSingletonContainer(xyzrs1)
20 
21 # create a writer that generates Chimera python scripts for visualizing the particle lists
22 w = IMP.display.ChimeraWriter("out.py")
23 # write first list of particles
24 g0= IMP.core.XYZRsGeometry(xyzrs0_container)
25 g0.set_name("my particles")
26 g0.set_color(IMP.display.Color(1,0,0))
27 w.add_geometry(g0)
28 # write second list of particles
29 g1= IMP.core.XYZRsGeometry(xyzrs1_container)
30 g1.set_name("my other particles")
31 g1.set_color(IMP.display.Color(0,1,0))
32 w.add_geometry(g1)
33 # make sure that the file is flushed
34 del w