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.
8 from __future__
import print_function
21 for i
in range(0, np):
23 p.add_attribute(ik, i)
31 print(
"without", [(x[0].get_name(), x[1].get_name())
for x
in cpc.get_particle_pairs()])
37 IMP.PairPredicate.__init__(self,
"ConsecutiveFilter%1%")
39 def get_value(self, pp):
40 diff = pp[0].get_value(ik) - pp[1].get_value(ik)
41 if diff == -1
or diff == 1:
45 def do_get_inputs(self, m, pis):
46 return [m.get_particle(i)
for i
in pis]
48 def do_show(self, out):
50 f = ConsecutiveFilter()
51 cpc.add_pair_filter(f)
53 print(
"with", [(x[0].get_name(), x[1].get_name())
for x
in cpc.get_particle_pairs()])