IMP  2.4.0
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
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
Represent an RGB color.
Definition: Color.h:24
Write geometry to a Python file for Chimera to read.
Definition: ChimeraWriter.h:29
Various classes to hold sets of particles.
Display an IMP::SingletonContainer of IMP::core::XYZR particles as balls.
Definition: XYZR.h:149
Store a kernel::ParticleIndexes.
XYZRs create_xyzr_particles(kernel::Model *m, unsigned int num, Float radius, Float box_side=10)
Create a set of particles with random coordinates.
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
Output IMP model data in various file formats.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73