I try to access the connected pairs of a connectivity restraint via get_connected_pairs(). Directly after defining the restraint, everything works fine. Now my problem is, that after adding it to a RestraintSet and retrieving it, the same function always gives an attribute error. Show() tells me in both cases that it is a connectivity restraint, so get_connected_pairs should work the same way?
My test case is below (modified from the connectivity restraint example). What is wrong? Is there any possibility to get this connected pairs out of the restraint set?
import IMP
import IMP.core
import IMP.misc
import IMP.algebra
import IMP.atom
m=IMP.Model()
hs=[]
# create the molecules, with 5 particles for each of 10 molecules
for i in range(0,10):
p=IMP.Particle(m)
d= IMP.atom.Hierarchy.setup_particle(p)
for j in range(0,5):
p=IMP.Particle(m)
cd= IMP.atom.Fragment.setup_particle(p)
d.add_child(cd)
xd= IMP.core.XYZR.setup_particle(p, IMP.algebra.Sphere3D(IMP.algebra.Vector3D(3*i,j,0), 1))
hs.append(p)
ps= IMP.core.SphereDistancePairScore(IMP.core.HarmonicUpperBound(0,1))
cps= IMP.core.ChildrenRefiner(IMP.atom.Hierarchy.get_traits())
# score based on the one closest particle from each set of balls
lrps = IMP.misc.LowestRefinedPairScore(cps, ps)
#lrps = IMP.core.KClosePairsPairScore(ps, cps, 1)
# connect all 10 molecules together
cr = IMP.core.ConnectivityRestraint(lrps)
cr.set_particles(hs)
rs_set=IMP.RestraintSet('connectivity')
m.add_restraint(rs_set)
rs_set.add_restraint(cr)
cr.show()
print len(cr.get_connected_pairs())
print m.evaluate(False)
for i in range(0,rs_set.get_number_of_restraints()):
res=rs_set.get_restraint(i)
res.show()
if res.get_is_part_of_model():
print "is part of model"
pairs=res.get_connected_pairs()
print len(pairs)