IMP  2.0.1
The Integrative Modeling Platform
simple_em_fit.py
1 ## \example restrainer/simple_em_fit.py
2 ## This example shows how to create simple IMP::em::FitRestraint.
3 ##
4 
5 #-- File: simple_em_fit.py --#
6 
7 import IMP
8 import IMP.atom
9 import IMP.restrainer
10 
11 imp_model = IMP.Model()
12 
13 # Create particle point 1
14 p1 = IMP.Particle(imp_model)
15 p1.add_attribute(IMP.FloatKey("x"), 12, True)
16 p1.add_attribute(IMP.FloatKey("y"), 12, True)
17 p1.add_attribute(IMP.FloatKey("z"), 12, True)
18 p1.add_attribute(IMP.FloatKey("radius"), 1.0)
19 p1.add_attribute(IMP.FloatKey("mass"), 1.0)
20 p1.add_attribute(IMP.FloatKey("protein"), 1.0)
21 p1.add_attribute(IMP.FloatKey("id"), 1.0)
22 
23 # Create particle point 2
24 p2 = IMP.Particle(imp_model)
25 p2.add_attribute(IMP.FloatKey("x"), 15, True)
26 p2.add_attribute(IMP.FloatKey("y"), 6, True)
27 p2.add_attribute(IMP.FloatKey("z"), 6, True)
28 p2.add_attribute(IMP.FloatKey("radius"), 1.0)
29 p2.add_attribute(IMP.FloatKey("mass"), 1.0)
30 p2.add_attribute(IMP.FloatKey("protein"), 1.0)
31 p2.add_attribute(IMP.FloatKey("id"), 1.0)
32 
33 # Create particle point 3
34 p3 = IMP.Particle(imp_model)
35 p3.add_attribute(IMP.FloatKey("x"), 6, True)
36 p3.add_attribute(IMP.FloatKey("y"), 15, True)
37 p3.add_attribute(IMP.FloatKey("z"), 15, True)
38 p3.add_attribute(IMP.FloatKey("radius"), 1.0)
39 p3.add_attribute(IMP.FloatKey("mass"), 1.0)
40 p3.add_attribute(IMP.FloatKey("protein"), 1.0)
41 p3.add_attribute(IMP.FloatKey("id"), 1.0)
42 
46 
47 particles = []
48 particles.append(p1)
49 particles.append(p2)
50 particles.append(p3)
51 
52 mhs = IMP.atom.Hierarchies()
53 mhs.append(mp)
54 
55 dmap = IMP.restrainer.load_em_density_map (
56  IMP.restrainer.get_example_path("in.mrc"), 1.0, 3.0)
57 
58 se = IMP.restrainer.create_simple_em_fit(mhs, dmap)
59 
60 r = se.get_restraint()
61 
62 imp_model.add_restraint(r)