IMP logo
IMP Reference Guide  2.17.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 
13  sys.argv,
14  "Write two colored sets of random XYZR particles to a Pymol input file")
15 
16 # create two lists of random particles for display
17 m = IMP.Model()
18 n = 10
19 radius = 1.0
20 bounding_box_size = 10.0
21 xyzrs0 = IMP.core.create_xyzr_particles(m, 10, radius, bounding_box_size)
22 xyzrs1 = IMP.core.create_xyzr_particles(m, 10, radius, bounding_box_size)
23 xyzrs0_container = IMP.container.ListSingletonContainer(m, xyzrs0)
24 xyzrs1_container = IMP.container.ListSingletonContainer(m, xyzrs1)
25 
26 # create a writer that generates Pymol Python scripts for visualizing
27 # the particle lists
28 w = IMP.display.PymolWriter("out.pym")
29 # write first list of particles
30 g0 = IMP.core.XYZRsGeometry(xyzrs0_container)
31 g0.set_name("my particles")
32 g0.set_color(IMP.display.Color(1, 0, 0))
33 w.add_geometry(g0)
34 # write second list of particles
35 g1 = IMP.core.XYZRsGeometry(xyzrs1_container)
36 g1.set_name("my other particles")
37 g1.set_color(IMP.display.Color(0, 1, 0))
38 w.add_geometry(g1)
39 # make sure that the file is flushed
40 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:73
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.