void Fragment::set_residue_indexes(kernel::Model *m, kernel::ParticleIndex pi, Ints o) { if (o.empty()) { set_residue_indexes(m, pi, IntPairs()); return; } std::sort(o.begin(), o.end()); o.erase(std::unique(o.begin(), o.end()), o.end()); IntPairs pairs; int begin = 0; for (unsigned int i = 1; i < o.size(); ++i) { if (o[i] != o[i - 1] + 1) { pairs.push_back(IntPair(o[begin], o[i - 1] + 1)); begin = i; } } pairs.push_back(IntPair(o[begin], o.back() + 1)); set_residue_indexes(m, pi, pairs); using IMP::operator<<; IMP_IF_CHECK(USAGE) { for (unsigned int i = 0; i < o.size(); ++i) { IMP_INTERNAL_CHECK(Fragment(m, pi).get_contains_residue(o[i]), "Residue index not found after addition: " << o << " became " << pairs); } } }
IntPairs QuadraticClosePairsFinder::get_close_pairs( const algebra::BoundingBox3Ds &bbs) const { set_was_used(true); IMP_OBJECT_LOG; IMP_LOG_TERSE("Adding close pairs from " << bbs.size() << " boxes with threshold " << get_distance() << std::endl); IntPairs ret; const double d2 = get_distance() / 2.0; for (unsigned int i = 0; i < bbs.size(); ++i) { algebra::BoundingBox3D bi = bbs[i] + d2; for (unsigned int j = 0; j < i; ++j) { algebra::BoundingBox3D bj = bbs[j] + d2; if (get_interiors_intersect(bi, bj)) { ret.push_back(IntPair(i, j)); } } } return ret; }
IntPairs NearestNeighborsClosePairsFinder::get_close_pairs( const algebra::BoundingBox3Ds &bas, const algebra::BoundingBox3Ds &bbs) const { set_was_used(true); IMP_OBJECT_LOG; IMP_LOG_TERSE("Quadratic add_close_pairs called with " << bas.size() << " and " << bbs.size() << std::endl); IntPairs ret; const double d2 = get_distance() / 2.0; for (unsigned int i = 0; i < bas.size(); ++i) { algebra::BoundingBox3D bi = bas[i] + d2; for (unsigned int j = 0; j < bbs.size(); ++j) { algebra::BoundingBox3D bj = bbs[j] + d2; if (get_interiors_intersect(bi, bj)) { ret.push_back(IntPair(i, j)); } } } return ret; }