home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.17.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
domino/merge_tree.py
The example shows how to generate and inspect a merge tree for use in Domino.
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
import
sys
10
11
IMP.setup_from_argv
(sys.argv,
"merge tree"
)
12
13
IMP.set_log_level
(IMP.TERSE)
14
m =
IMP.Model
()
15
# don't print messages about evaluation
16
m.set_log_level(IMP.SILENT)
17
18
bb =
IMP.algebra.BoundingBox3D
((0, 0, 0), (10, 10, 10))
19
allc = []
20
for
i
in
range(0, 7):
21
p =
IMP.Particle
(m)
22
d =
IMP.core.XYZR.setup_particle
(
23
p,
IMP.algebra.Sphere3D
(
IMP.algebra.get_random_vector_in
(bb), 1))
24
allc.append(d.get_coordinates())
25
pst =
IMP.domino.ParticleStatesTable
()
26
ss =
IMP.domino.XYZStates
(allc)
27
for
p
in
m.get_particle_indexes():
28
pst.set_particle_states(m.get_particle(p), ss)
29
# generate a set of restraints based on the close pairs in this randomly
30
# chosen configuration
31
cp =
IMP.core.GridClosePairsFinder
()
32
cp.set_distance(1)
33
cps = cp.get_close_pairs(m, m.get_particle_indexes())
34
35
if
len(cps) > 0:
36
# one cannot create a container from an empty list
37
acp =
IMP.container.ListPairContainer
(m, cps)
38
else
:
39
acp =
IMP.container.ListPairContainer
(m)
40
ps =
IMP.core.SoftSpherePairScore
(1)
41
r =
IMP.container.PairsRestraint
(ps, acp)
42
43
# compute the interaction graph based on all the restraints
44
ig =
IMP.domino.get_interaction_graph
([r],
45
pst)
46
# generate a junction tree from the interaction graph
47
jt =
IMP.domino.get_junction_tree
(ig)
48
print(dir(jt))
49
print(type(jt))
50
# create a merge tree from the junction tree, this can be passed to
51
# IMP.domin.DominoSampler
52
mt =
IMP.domino.get_merge_tree
(jt)
53
s = pst.get_subset()
54
print(s, type(s))