IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
doc/examples/domino/merge_tree.py
1
## \example domino/merge_tree.py
2
## The example shows how to generate and inspect a merge tree for use in Domino.
3
4
import
IMP
5
import
IMP.domino
6
import
IMP.core
7
import
IMP.container
8
import
IMP.algebra
9
10
IMP.base.set_log_level
(IMP.base.TERSE)
11
m=
IMP.Model
()
12
# don't print messages about evaluation
13
m.set_log_level(IMP.base.SILENT)
14
15
bb=
IMP.algebra.BoundingBox3D
((0,0,0), (10,10,10))
16
allc=[]
17
for
i
in
range(0,7):
18
p=
IMP.Particle
(m)
19
d=
IMP.core.XYZR.setup_particle
(p,
IMP.algebra.Sphere3D
(
IMP.algebra.get_random_vector_in
(bb), 1))
20
allc.append(d.get_coordinates())
21
pst=
IMP.domino.ParticleStatesTable
()
22
ss=
IMP.domino.XYZStates
(allc)
23
for
p
in
m.get_particles():
24
pst.set_particle_states(p, ss)
25
# generate a set of restraints based on the close pairs in this randomly chosen configuration
26
cp=
IMP.core.GridClosePairsFinder
()
27
cp.set_distance(1)
28
cps=cp.get_close_pairs(m.get_particles())
29
30
if
len(cps)>0:
31
# one cannot create a container from an empty list
32
acp=
IMP.container.ListPairContainer
(cps)
33
else
:
34
acp=
IMP.container.ListPairContainer
(m)
35
ps=
IMP.core.SoftSpherePairScore
(1)
36
r=
IMP.container.PairsRestraint
(ps, acp)
37
r.set_model(m)
38
39
# compute the interaction graph based on all the restraints
40
ig=
IMP.domino.get_interaction_graph
([r],
41
pst)
42
# generate a junction tree from the interaction graph
43
jt=
IMP.domino.get_junction_tree
(ig)
44
print
dir(jt)
45
print
type(jt)
46
# create a merge tree from the junction tree, this can be passed to IMP.domin.DominoSampler
47
mt=
IMP.domino.get_merge_tree
(jt)
48
s=pst.get_subset()
49
print
s, type(s)