IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
5import IMP
6import IMP.algebra
7import IMP.container
8import IMP.core
9import IMP.display
10import 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
17m = IMP.Model()
18n = 10
19radius = 1.0
20bounding_box_size = 10.0
21xyzrs0 = IMP.core.create_xyzr_particles(m, 10, radius, bounding_box_size)
22xyzrs1 = IMP.core.create_xyzr_particles(m, 10, radius, bounding_box_size)
23xyzrs0_container = IMP.container.ListSingletonContainer(m, xyzrs0)
24xyzrs1_container = IMP.container.ListSingletonContainer(m, xyzrs1)
25
26# create a writer that generates Pymol Python scripts for visualizing
27# the particle lists
28w = IMP.display.PymolWriter("out.pym")
29# write first list of particles
30g0 = IMP.core.XYZRsGeometry(xyzrs0_container)
31g0.set_name("my particles")
32g0.set_color(IMP.display.Color(1, 0, 0))
33w.add_geometry(g0)
34# write second list of particles
35g1 = IMP.core.XYZRsGeometry(xyzrs1_container)
36g1.set_name("my other particles")
37g1.set_color(IMP.display.Color(0, 1, 0))
38w.add_geometry(g1)
39# make sure that the file is flushed
40del w
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Display an IMP::SingletonContainer of IMP::core::XYZR particles as balls.
Definition XYZR.h:151
Represent an RGB color.
Definition Color.h:25
Write a CGO file with the geometry.
Definition PymolWriter.h:34
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
Various classes to hold sets of particles.
Basic functionality that is expected to be used by a wide variety of IMP users.
XYZRs create_xyzr_particles(Model *m, unsigned int num, Float radius, Float box_side=10)
Create a set of particles with random coordinates.
Output IMP model data in various file formats.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.