This example shows how to filter the list of close pairs generated in the IMP.container.ClosePairContainer (or IMP.container.CloseBipartitePairContainer). Eventually the filter should probably be implemented in C++, for speed but implementing the filter in python is good for prototyping.
16 for i
in range(0, np):
18 p.add_attribute(ik, i)
25 print "without",[(x[0].get_name(), x[1].get_name())
for x
in cpc.get_particle_pairs()]
29 IMP.PairPredicate.__init__(self,
"ConsecutiveFilter%1%")
30 def get_value(self, pp):
31 diff= pp[0].get_value(ik) - pp[1].get_value(ik)
32 if diff==-1
or diff ==1:
35 def _do_get_inputs(self, m, pis):
36 return [m.get_particle(i)
for i
in pis]
37 def do_show(self, out):
39 f= ConsecutiveFilter()
40 cpc.add_pair_filter(f)
42 print "with",[(x[0].get_name(), x[1].get_name())
for x
in cpc.get_particle_pairs()]