IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
display_slab.py
1 import IMP.npctransport
2 import IMP
3 import RMF
4 import IMP.rmf
5 import IMP.atom
6 import IMP.display
7 
8 height = 20
9 radius = 30
10 particle_radius = 10
11 sz = 60
12 use_rmf = True
13 
14 m = IMP.Model()
15 m.set_log_level(IMP.WARNING)
16 p_slab = IMP.Particle(m, "slab")
17 pi_slab = p_slab.get_index()
19  p_slab, height, radius)
20 p = IMP.Particle(m)
21 pi = p.get_index()
23 d.set_radius(10)
24 d.set_coordinates_are_optimized(True)
27 
29 r = IMP.core.PairRestraint(m, slabps, [pi_slab, pi], "slab")
30 r.set_log_level(IMP.WARNING)
31 nm = IMP.create_temporary_file_name("display_slab", ".pym")
33 if use_rmf:
34  rnm = IMP.create_temporary_file_name("display_slab", ".rmf")
35  rmf = RMF.create_rmf_file(rnm)
37 sg.set_was_used(True)
38 if 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)
42  IMP.rmf.add_geometries(nh, sgs)
43 w.add_geometry(sg)
44 
46  IMP.algebra.Vector3D(sz, sz, sz))
47 
48 gs = []
49 if 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)
62 if use_rmf:
64 w.add_geometry(gs)
65 if use_rmf:
66  nh = rmf.get_root_node().add_child("displacements", RMF.GEOMETRY)
67 
68 gs = []
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)
82 if use_rmf:
84 w.add_geometry(gs)
85 
86 if use_rmf:
88  print("chimera", rnm)
89 print("pymol", nm)
Represent an RGB color.
Definition: Color.h:25
Simulation of transport through the Nuclear Pore Complex.
RMF::FrameID save_frame(RMF::FileHandle file, std::string name="")
Save the current state of the linked objects as a new RMF frame.
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition: XYZR.h:48
Color get_hot_color(double f)
Return the color for f from the hot color map.
static SlabWithCylindricalPore setup_particle(Model *m, ParticleIndex pi, double thickness, double radius)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
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
void add_geometries(RMF::NodeHandle parent, const display::GeometriesTemp &r)
Add geometries to a given parent node.
Writer * create_writer(std::string filename)
Simple implementation of segments in 3D.
Definition: Segment3D.h:25
VectorD< 3 > Vector3D
Definition: VectorD.h:408
Class to handle individual particles of a Model object.
Definition: Particle.h:43
Vector< VectorD< D > > get_grid_interior_cover_by_spacing(const BoundingBoxD< D > &bb, double s)
Applies a PairScore to a Pair.
Definition: PairRestraint.h:31
Output IMP model data in various file formats.
Functionality for loading, creating, manipulating and scoring atomic structures.
Support for the RMF file format for storing hierarchical molecular data and markup.
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.