IMP logo
IMP Reference Guide  2.7.0
The Integrative Modeling Platform
show_particles_as_spheres.py
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
Represent an RGB color.
Definition: Color.h:24
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Various classes to hold sets of particles.
XYZRs create_xyzr_particles(Model *m, unsigned int num, Float radius, Float box_side=10)
Create a set of particles with random coordinates.
Display an IMP::SingletonContainer of IMP::core::XYZR particles as balls.
Definition: XYZR.h:151
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Store a list of ParticleIndexes.
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...
Write a CGO file with the geometry.
Definition: PymolWriter.h:34
Output IMP model data in various file formats.