IMP logo
IMP Reference Guide  2.15.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()
19 slab= IMP.npctransport.SlabWithCylindricalPore.setup_particle \
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 #print(dir(slabps))
31 r= IMP.core.PairRestraint(m, slabps, [pi_slab,pi], "slab")
32 r.set_log_level(IMP.WARNING)
33 nm=IMP.create_temporary_file_name("display_slab", ".pym")
35 if use_rmf:
36  rnm=IMP.create_temporary_file_name("display_slab", ".rmf")
37  rmf= RMF.create_rmf_file(rnm)
38  #IMP.rmf.add_hierarchies(rmf, [p])
40 sg.set_was_used(True);
41 if use_rmf:
42  sg.set_color(IMP.display.Color(0,1,0))
43  sgs= sg.get_components()
44  nh= rmf.get_root_node().add_child("slab", RMF.GEOMETRY)
45  IMP.rmf.add_geometries(nh, sgs)
46  #[sc.show() for sc in sgs]
47 w.add_geometry(sg)
48 
50  IMP.algebra.Vector3D(sz, sz, sz))
51 
52 #nh= rmf.get_root_node().add_child("derivatives", RMF.GEOMETRY)
53 
54 gs=[]
55 if use_rmf:
56  nh= rmf.get_root_node().add_child("deriv", RMF.GEOMETRY)
58  #print c
59  d.set_coordinates(c)
60  v=r.evaluate(True)
61  if v ==0:
62  continue
63  color= IMP.display.get_hot_color(v/20.0)
64  seg= IMP.algebra.Segment3D(c, c+d.get_derivatives())
65  #print c, seg
67  g.set_color(color)
68  g.set_name("deriv")
69  gs.append(g)
70 if use_rmf:
72 w.add_geometry(gs)
73 #bb=IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(-sz, -sz, -sz),
74 # IMP.algebra.Vector3D(0, 0, 0))
75 if use_rmf:
76  nh= rmf.get_root_node().add_child("displacements", RMF.GEOMETRY)
77 
78 gs=[]
80  dv= slabps.get_displacement_direction(slab,c)
81  #.get_unit_vector()
82  dm= slabps.get_displacement_magnitude(slab,c)
83  #print c, dm, dv
84  if dm > particle_radius:
85  continue
86  color= IMP.display.get_hot_color(-(dm-particle_radius)/(height+particle_radius))
87  m.update() #evaluate(True)
88  seg= IMP.algebra.Segment3D(c, c+dv)
90  g.set_color(color)
91  g.set_name("displace")
92  gs.append(g)
93 if use_rmf:
95 w.add_geometry(gs)
96 
97 if use_rmf:
99  print("chimera", rnm)
100 print("pymol", nm)
Represent an RGB color.
Definition: Color.h:24
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.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
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:24
VectorD< 3 > Vector3D
Definition: VectorD.h:421
Class to handle individual particles of a Model object.
Definition: Particle.h:41
Vector< VectorD< D > > get_grid_interior_cover_by_spacing(const BoundingBoxD< D > &bb, double s)
Applies a PairScore to a Pair.
Definition: PairRestraint.h:29
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.