IMP  2.0.0
The Integrative Modeling Platform
restrainer/simple_distance.py

This example shows how to create simple IMP::core::DistanceRestraint.

1 ## \example restrainer/simple_distance.py
2 ## This example shows how to create simple IMP::core::DistanceRestraint.
3 ##
4 
5 #-- File: simple_distance.py --#
6 
7 import IMP
8 import IMP.core
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"), 0, True)
16 p1.add_attribute(IMP.FloatKey("y"), 0, True)
17 p1.add_attribute(IMP.FloatKey("z"), 0, True)
18 p1.add_attribute(IMP.FloatKey("radius"), 1.0, False)
19 
20 # Create particle point 2
21 p2 = IMP.Particle(imp_model)
22 p2.add_attribute(IMP.FloatKey("x"), 100, True)
23 p2.add_attribute(IMP.FloatKey("y"), 100, True)
24 p2.add_attribute(IMP.FloatKey("z"), 100, True)
25 p2.add_attribute(IMP.FloatKey("radius"), 1.0, False)
26 
27 particles = []
28 particles.append(p1)
29 particles.append(p2)
30 
31 sd = IMP.restrainer.create_simple_distance(particles)
32 
33 r = sd.get_restraint()
34 h = sd.get_harmonic_upper_bound()
35 
36 sd.set_mean(10.0)
37 sd.set_standard_deviation(3.5)
38 sd.set_k(0.1)
39 
40 imp_model.add_restraint(r)
41 r.show()
42 
43 imp_model.evaluate(False)