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.
20 for i
in range(0, np):
22 p.add_attribute(ik, i)
30 print "without", [(x[0].get_name(), x[1].get_name())
for x
in cpc.get_particle_pairs()]
36 IMP.PairPredicate.__init__(self,
"ConsecutiveFilter%1%")
38 def get_value(self, pp):
39 diff = pp[0].get_value(ik) - pp[1].get_value(ik)
40 if diff == -1
or diff == 1:
44 def do_get_inputs(self, m, pis):
45 return [m.get_particle(i)
for i
in pis]
47 def do_show(self, out):
49 f = ConsecutiveFilter()
50 cpc.add_pair_filter(f)
52 print "with", [(x[0].get_name(), x[1].get_name())
for x
in cpc.get_particle_pairs()]