IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
display_slab.py
1 from __future__ import print_function
2 import IMP.npctransport
3 import IMP
4 import RMF
5 import IMP.rmf
6 import IMP.atom
7 import IMP.display
8 
9 height = 20
10 radius = 30
11 particle_radius = 10
12 sz = 60
13 use_rmf = True
14 
15 m = IMP.Model()
16 m.set_log_level(IMP.WARNING)
17 p_slab = IMP.Particle(m, "slab")
18 pi_slab = p_slab.get_index()
20  p_slab, height, radius)
21 p = IMP.Particle(m)
22 pi = p.get_index()
24 d.set_radius(10)
25 d.set_coordinates_are_optimized(True)
28 
30 r = IMP.core.PairRestraint(m, slabps, [pi_slab, pi], "slab")
31 r.set_log_level(IMP.WARNING)
32 nm = IMP.create_temporary_file_name("display_slab", ".pym")
34 if use_rmf:
35  rnm = IMP.create_temporary_file_name("display_slab", ".rmf")
36  rmf = RMF.create_rmf_file(rnm)
38 sg.set_was_used(True)
39 if use_rmf:
40  sg.set_color(IMP.display.Color(0, 1, 0))
41  sgs = sg.get_components()
42  nh = rmf.get_root_node().add_child("slab", RMF.GEOMETRY)
43  IMP.rmf.add_geometries(nh, sgs)
44 w.add_geometry(sg)
45 
47  IMP.algebra.Vector3D(sz, sz, sz))
48 
49 gs = []
50 if use_rmf:
51  nh = rmf.get_root_node().add_child("deriv", RMF.GEOMETRY)
53  d.set_coordinates(c)
54  v = r.evaluate(True)
55  if v == 0:
56  continue
57  color = IMP.display.get_hot_color(v/20.0)
58  seg = IMP.algebra.Segment3D(c, c+d.get_derivatives())
60  g.set_color(color)
61  g.set_name("deriv")
62  gs.append(g)
63 if use_rmf:
65 w.add_geometry(gs)
66 if use_rmf:
67  nh = rmf.get_root_node().add_child("displacements", RMF.GEOMETRY)
68 
69 gs = []
71  dv = slabps.get_displacement_direction(slab, c)
72  dm = slabps.get_displacement_magnitude(slab, c)
73  if dm > particle_radius:
74  continue
76  -(dm-particle_radius)/(height+particle_radius))
77  m.update()
78  seg = IMP.algebra.Segment3D(c, c+dv)
80  g.set_color(color)
81  g.set_name("displace")
82  gs.append(g)
83 if use_rmf:
85 w.add_geometry(gs)
86 
87 if use_rmf:
89  print("chimera", rnm)
90 print("pymol", nm)
Represent an RGB color.
Definition: Color.h:25
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:425
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.