ModelObjectsTemp CoverBond::do_get_inputs( Model *m, const ParticleIndexes &pis) const { ModelObjectsTemp ret(3 * pis.size()); for (unsigned int i = 0; i < pis.size(); ++i) { Bond bd(m, pis[i]); ret[3 * i + 0] = m->get_particle(pis[i]); ret[3 * i + 1] = bd.get_bonded(0); ret[3 * i + 2] = bd.get_bonded(1); } return ret; }
ParticleIndexPairs DummyPairContainer::get_range_indexes() const { ParticleIndexes pis = c_->get_range_indexes(); ParticleIndexPairs ret; ret.reserve(pis.size() * (pis.size() - 1) / 2); for (unsigned int i = 0; i < pis.size(); ++i) { for (unsigned int j = 0; j < i; ++j) { ret.push_back(ParticleIndexPair(pis[i], pis[j])); } } return ret; }
ParticleIndexPairs AllPairContainer::get_range_indexes() const { ParticleIndexes ia = c_->get_range_indexes(); ParticleIndexPairs ret; ret.reserve(ia.size() * (ia.size() - 1) / 2); for (unsigned int i = 0; i < ia.size(); ++i) { for (unsigned int j = 0; j < i; ++j) { ret.push_back(ParticleIndexPair(ia[i], ia[j])); } } return ret; }
ModelObjectsTemp AngleSingletonScore::do_get_inputs( Model *m, const ParticleIndexes &pi) const { ModelObjectsTemp ret(4 * pi.size()); for (unsigned int i = 0; i < pi.size(); ++i) { Angle ad(m, pi[i]); ret[4 * i + 0] = ad.get_particle(0); ret[4 * i + 1] = ad.get_particle(1); ret[4 * i + 2] = ad.get_particle(2); ret[4 * i + 3] = m->get_particle(pi[i]); } return ret; }
ParticleIndexPairs BondPairContainer::get_range_indexes() const { ParticleIndexes ia = sc_->get_range_indexes(); ParticleIndexPairs ret; ret.reserve(ia.size()); for (unsigned int i = 0; i < ia.size(); ++i) { Bond b(get_model(), ia[i]); ret.push_back( ParticleIndexPair(b.get_bonded(0).get_particle_index(), b.get_bonded(1).get_particle_index())); } return ret; }
ParticleIndexes BondPairContainer::get_all_possible_indexes() const { ParticleIndexes scapp = sc_->get_all_possible_indexes(); ParticleIndexes ret(3 * scapp.size()); for (unsigned int i = 0; i < scapp.size(); ++i) { ret[i * 3] = scapp[i]; ret[i * 3 + 1] = Bond(get_model(), scapp[i]).get_bonded(0).get_particle_index(); ret[i * 3 + 2] = Bond(get_model(), scapp[i]).get_bonded(1).get_particle_index(); } return ret; }
void NormalMover::initialize(ParticleIndexes pis, FloatKeys keys, double radius) { pis_ = pis; keys_ = keys; stddev_ = radius; originals_.resize(pis.size(), algebra::get_zero_vector_kd(keys.size())); }
ParticleIndexPairs QuadraticClosePairsFinder::get_close_pairs( Model *m, const ParticleIndexes &pta, const ParticleIndexes &ptb) const { set_was_used(true); IMP_OBJECT_LOG; IMP_LOG_TERSE("Quadratic add_close_pairs called with " << pta.size() << " and " << ptb.size() << std::endl); ParticleIndexPairs ret; for (unsigned int i = 0; i < pta.size(); ++i) { for (unsigned int j = 0; j < ptb.size(); ++j) { if (get_are_close(m, pta[i], ptb[j])) { ret.push_back(ParticleIndexPair(pta[i], ptb[j])); } } } return ret; }
ParticleIndexPairs QuadraticClosePairsFinder::get_close_pairs( Model *m, const ParticleIndexes &pt) const { set_was_used(true); IMP_OBJECT_LOG; IMP_LOG_TERSE("Adding close pairs from " << pt.size() << " particles with threshold " << get_distance() << std::endl); ParticleIndexPairs ret; for (unsigned int i = 0; i < pt.size(); ++i) { for (unsigned int j = 0; j < i; ++j) { if (get_are_close(m, pt[i], pt[j])) { ret.push_back(ParticleIndexPair(pt[i], pt[j])); } } } return ret; }
ModelObjectsTemp WeightedDerivativesToRefined::do_get_outputs( Model *m, const ParticleIndexes &pis) const { ModelObjectsTemp ret; for (unsigned int i = 0; i < pis.size(); ++i) { ret += IMP::get_particles(m, refiner_->get_refined_indexes(m, pis[i])); } return ret; }
ModelObjectsTemp ParticleOutputs::do_get_outputs( Model *m, const ParticleIndexes &pis) const { ModelObjectsTemp ret; for (unsigned int i = 0; i < pis.size(); ++i) { ret += get_output_containers(m->get_particle(pis[i])); ret += get_output_particles(m->get_particle(pis[i])); } return ret; }
void transform(atom::Hierarchy h, const algebra::Transformation3D &tr) { Model *m = h.get_model(); typedef std::pair<ParticleIndex, ParticleIndexes> RBP; boost::unordered_map<ParticleIndex, ParticleIndexes> rigid_bodies; transform_impl(m, h.get_particle_index(), tr, rigid_bodies); IMP_FOREACH(const RBP & rbp, rigid_bodies) { core::RigidBody rb(m, rbp.first); ParticleIndexes members = rb.get_member_indexes(); if (rbp.second.size() != members.size()) { IMP_USAGE_CHECK( rbp.second.size() == members.size(), "Hierarchy contains rigid body members of incomplete rigid bodies. " "It must contain all members of a rigid body or no members. Rigid " "body is " << m->get_particle_name(rbp.first)); } core::transform(rb, tr); }
ModelObjectsTemp CentroidOfRefined::do_get_inputs( Model *m, const ParticleIndexes &pis) const { ModelObjectsTemp ret = refiner_->get_inputs(m, pis); ret += IMP::get_particles(m, pis); for (unsigned int i = 0; i < pis.size(); ++i) { ret += IMP::get_particles(m, refiner_->get_refined_indexes(m, pis[i])); } return ret; }
ModelObjectsTemp RigidLeavesRefiner::do_get_inputs( Model *m, const ParticleIndexes &pis) const { ModelObjectsTemp ret = IMP::get_particles(m, pis); for (unsigned int i = 0; i < pis.size(); ++i) { ParticleIndexes members = core::RigidBody(m, pis[i]).get_member_particle_indexes(); ret += IMP::get_particles(m, members); } return ret; }
void HierarchyLoadXYZs::setup_particle( RMF::NodeConstHandle n, Model *m, ParticleIndex p, const ParticleIndexes &rigid_bodies) { if (!ip_factory_.get_is(n)) return; if (!core::XYZ::get_is_setup(m, p)) core::XYZ::setup_particle(m, p); /* If there is a rigid body parent set up, add this particle as a child (unless it's an old-style rigid body, in which case this has been done already) */ if (!rigid_bodies.empty() && !(rigid_bodies.size()==1 && rigid_bodies.back() == p) && !n.get_has_value(rb_index_key_)) { core::RigidBody rb(m, rigid_bodies.back()); /* For nested rigid bodies, this XYZ particle is *also* the rigid body. So don't make ourselves our own child - add to the parent rigid body instead. */ if (rigid_bodies.back() == p) { IMP_INTERNAL_CHECK(rigid_bodies.size() >= 2, "Nested rigid body " << m->get_particle_name(p) << " but could not find parent rigid body"); rb = core::RigidBody(m, rigid_bodies[rigid_bodies.size() - 2]); } rb.add_member(p); if (reference_frame_factory_.get_is(n) && !reference_frame_factory_.get_is_static(n)) { IMP_LOG_VERBOSE("Member particle " << m->get_particle_name(p) << " is not static and is also a rigid body" << std::endl); rb.set_is_rigid_member(p, false); } else if (!ip_factory_.get_is_static(n)) { IMP_LOG_VERBOSE("Member particle " << m->get_particle_name(p) << " is not static" << std::endl); rb.set_is_rigid_member(p, false); } else { IMP_LOG_VERBOSE("Member particle " << m->get_particle_name(p) << " is static" << std::endl); rb.set_is_rigid_member(p, true); core::RigidBodyMember(m, p) .set_internal_coordinates(get_coordinates(n, ip_factory_)); } } link_particle(n, m, p, rigid_bodies); }
/* This is implemented like this so that it doesn't read any particles other than a and b. To do otherwise would make it rather annoying to use in evaluate. */ Bond get_bond(Bonded a, Bonded b) { if (a == b) return Bond(); ParticleIndexes ba = a.get_bond_indexes(); ParticleIndexes bb = b.get_bond_indexes(); std::sort(bb.begin(), bb.end()); for (unsigned int i = 0; i < ba.size(); ++i) { if (std::binary_search(bb.begin(), bb.end(), ba[i])) { return Bond(a.get_model(), ba[i]); } } return Bond(); }
ModelObjectsTemp SameResiduePairFilter::do_get_inputs( Model *m, const ParticleIndexes &pis) const { ModelObjectsTemp ret = IMP::get_particles(m, pis); for (unsigned int i = 0; i < pis.size(); ++i) { if (Atom::get_is_setup(m, pis[i])) { Particle *parent = Hierarchy(m, pis[i]).get_parent(); if (parent) { ret.push_back(parent); } } } return ret; }
Coord get_coordinates_from_rbs(Model* m, ParticleIndexes pis, ParticleIndex refidx) { // get current reference frame of rbs Referential ref(m, refidx); // get x Coord x; for (unsigned i = 0; i < pis.size(); i++) { internal::Referential target(m, pis[i]); x.coms.push_back(ref.get_local_coords(target.get_centroid())); x.quats.push_back(ref.get_local_rotation(target.get_rotation())); } return x; }
ModelObjectsTemp BondedPairFilter::do_get_inputs( Model *m, const ParticleIndexes &pis) const { ModelObjectsTemp ret = IMP::get_particles(m, pis); for (unsigned int i = 0; i < pis.size(); ++i) { if (Bonded::get_is_setup(m, pis[i])) { Bonded b(m, pis[i]); for (unsigned int i = 0; i < b.get_number_of_bonds(); ++i) { ret.push_back(b.get_bond(i)); } } } return ret; }
void MolecularDynamics::propagate_velocities(const ParticleIndexes &ps, double ts) { for (unsigned int i = 0; i < ps.size(); ++i) { Float invmass = 1.0 / Mass(get_model(), ps[i]).get_mass(); core::XYZ d(get_model(), ps[i]); algebra::Vector3D dcoord = d.get_derivatives(); LinearVelocity v(get_model(), ps[i]); // calculate velocity at t+(delta t) from that at t+(delta t/2) algebra::Vector3D velocity = v.get_velocity(); velocity += 0.5 * dcoord * deriv_to_acceleration * invmass * ts; v.set_velocity(velocity); } }
bool InternalDynamicListTripletContainer:: check_list(const ParticleIndexes& cp) const { ParticleIndexes app = IMP::internal::get_index(scope_->get_all_possible_particles()); compatibility::set<ParticleIndex> all(app.begin(), app.end()); for (unsigned int i=0; i< cp.size(); ++i) { IMP_USAGE_CHECK(all.find(cp[i]) != all.end(), "Particle " << cp[i] << " is not in the list of all possible particles"); } return true; }
void MolecularDynamics::setup_degrees_of_freedom( const ParticleIndexes &ps) { degrees_of_freedom_ = 3 * ps.size(); // If global rotation and translation have been removed, reduce degrees // of freedom accordingly (kind of ugly...) for (OptimizerStateIterator o = optimizer_states_begin(); o != optimizer_states_end(); ++o) { OptimizerState *os = *o; if (dynamic_cast<RemoveRigidMotionOptimizerState *>(os)) { degrees_of_freedom_ -= 6; break; } } }
void MolecularDynamics::propagate_velocities(const ParticleIndexes &ps, double ts) { for (unsigned int i=0; i< ps.size(); ++i) { Float invmass = 1.0 / Mass(get_model(), ps[i]).get_mass(); for (unsigned j = 0; j < 3; ++j) { core::XYZ d(get_model(), ps[i]); Float dcoord = d.get_derivative(j); // calculate velocity at t+(delta t) from that at t+(delta t/2) Float velocity = get_model()->get_attribute(vs_[j], ps[i]); velocity += 0.5 * dcoord * deriv_to_acceleration * invmass * ts; get_model()->set_attribute(vs_[j], ps[i], velocity); } } }
void XYZRMovedSingletonContainer::validate() const { IMP_OBJECT_LOG; ParticleIndexes pis = get_singleton_container()->get_indexes(); IMP_USAGE_CHECK(pis.size() == backup_.size(), "Backup is not the right size"); }