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.
   23 for i 
in range(0, np):
 
   24     p = m.add_particle(
"p%d" % i)
 
   25     m.add_attribute(ik, p, i)
 
   33 print(
"without", [(m.get_particle_name(x[0]), m.get_particle_name(x[1]))
 
   34                   for x 
in cpc.get_contents()])
 
   40         IMP.PairPredicate.__init__(self, 
"ConsecutiveFilter%1%")
 
   42     def get_value_index(self, m, pp):
 
   43         diff = m.get_attribute(ik, pp[0]) - m.get_attribute(ik, pp[1])
 
   44         if diff == -1 
or diff == 1:
 
   48     def do_get_inputs(self, m, pis):
 
   49         return [m.get_particle(i) 
for i 
in pis]
 
   51     def do_show(self, out):
 
   55 f = ConsecutiveFilter()
 
   56 cpc.add_pair_filter(f)
 
   58 print(
"with", [(m.get_particle_name(x[0]), m.get_particle_name(x[1]))
 
   59                for x 
in cpc.get_contents()])