IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
display_slab.py
2import IMP
3import RMF
4import IMP.rmf
5import IMP.atom
6import IMP.display
7
8height = 20
9radius = 30
10particle_radius = 10
11sz = 60
12use_rmf = True
13
14m = IMP.Model()
15m.set_log_level(IMP.WARNING)
16p_slab = IMP.Particle(m, "slab")
17pi_slab = p_slab.get_index()
19 p_slab, height, radius)
20p = IMP.Particle(m)
21pi = p.get_index()
23d.set_radius(10)
24d.set_coordinates_are_optimized(True)
27
29r = IMP.core.PairRestraint(m, slabps, [pi_slab, pi], "slab")
30r.set_log_level(IMP.WARNING)
31nm = IMP.create_temporary_file_name("display_slab", ".pym")
33if use_rmf:
34 rnm = IMP.create_temporary_file_name("display_slab", ".rmf")
35 rmf = RMF.create_rmf_file(rnm)
37sg.set_was_used(True)
38if use_rmf:
39 sg.set_color(IMP.display.Color(0, 1, 0))
40 sgs = sg.get_components()
41 nh = rmf.get_root_node().add_child("slab", RMF.GEOMETRY)
43w.add_geometry(sg)
44
46 IMP.algebra.Vector3D(sz, sz, sz))
47
48gs = []
49if use_rmf:
50 nh = rmf.get_root_node().add_child("deriv", RMF.GEOMETRY)
52 d.set_coordinates(c)
53 v = r.evaluate(True)
54 if v == 0:
55 continue
56 color = IMP.display.get_hot_color(v/20.0)
57 seg = IMP.algebra.Segment3D(c, c+d.get_derivatives())
59 g.set_color(color)
60 g.set_name("deriv")
61 gs.append(g)
62if use_rmf:
64w.add_geometry(gs)
65if use_rmf:
66 nh = rmf.get_root_node().add_child("displacements", RMF.GEOMETRY)
67
68gs = []
70 dv = slabps.get_displacement_direction(slab, c)
71 dm = slabps.get_displacement_magnitude(slab, c)
72 if dm > particle_radius:
73 continue
75 -(dm-particle_radius)/(height+particle_radius))
76 m.update()
77 seg = IMP.algebra.Segment3D(c, c+dv)
79 g.set_color(color)
80 g.set_name("displace")
81 gs.append(g)
82if use_rmf:
84w.add_geometry(gs)
85
86if use_rmf:
88 print("chimera", rnm)
89print("pymol", nm)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
Simple implementation of segments in 3D.
Definition Segment3D.h:24
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
static Mass setup_particle(Model *m, ParticleIndex pi, Float mass)
Definition Mass.h:48
Applies a PairScore to a Pair.
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition XYZR.h:48
Represent an RGB color.
Definition Color.h:25
static SlabWithCylindricalPore setup_particle(Model *m, ParticleIndex pi, double thickness, double radius)
VectorD< 3 > Vector3D
Definition VectorD.h:407
Vector< VectorD< D > > get_grid_interior_cover_by_spacing(const BoundingBoxD< D > &bb, double s)
Functionality for loading, creating, manipulating and scoring atomic structures.
Output IMP model data in various file formats.
Writer * create_writer(std::string filename)
Color get_hot_color(double f)
Return the color for f from the hot color map.
Simulation of transport through the Nuclear Pore Complex.
Support for the RMF file format for storing hierarchical molecular data and markup.
void add_geometries(RMF::FileHandle file, const display::GeometriesTemp &r)
Add geometries to the file.
RMF::FrameID save_frame(RMF::FileHandle file, std::string name="")
Save the current state of the linked objects as a new RMF frame.
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.