float get_actual_radius_of_gyration(kernel::ParticlesTemp ps) { algebra::Vector3D cm(0,0,0); for (unsigned int i=0; i< ps.size(); ++i) { cm+= core::XYZ(ps[i]).get_coordinates(); } cm/=ps.size(); double ret=0; for (unsigned int i=0; i < ps.size(); ++i) { double d= get_distance(core::XYZ(ps[i]).get_coordinates(),cm); ret+= d; } return ret/ps.size(); }
void ConnectivityRestraint::add_particles(const kernel::ParticlesTemp &ps) { if (!sc_ && !ps.empty()) { sc_ = new IMP::internal::InternalListSingletonContainer( ps[0]->get_model(), "connectivity list"); } get_list(sc_)->add(IMP::internal::get_index(ps)); }
IMPCORE_BEGIN_NAMESPACE FixedRefiner::FixedRefiner(const kernel::ParticlesTemp &ps) : Refiner("FixedRefiner%d"), ps_(ps) { IMP_LOG_VERBOSE("Created fixed particle refiner with " << ps.size() << " particles" << std::endl); }
void CollisionCrossSection::set_model_particles( const kernel::ParticlesTemp &ps) { IMP_LOG_TERSE("CollisionCrossSection: kernel::Model particles set" << std::endl); for (unsigned int i = 0; i < ps.size(); ++i) { IMP_USAGE_CHECK( (core::XYZR::get_is_setup(ps[i]) && atom::Mass::get_is_setup(ps[i])), "Particle " << i << " does not have the required attributes" << std::endl); } masks_manager_->create_masks(ps); // Compute projections collision_cross_section_ = 0.0; for (unsigned int i = 0; i < n_projections_; ++i) { ProjectingOptions options(pixel_size_, resolution_); do_project_particles(ps, average_projection_, regs_[i].get_rotation(), pixel_size_ * regs_[i].get_shift_3d(), options, masks_manager_); collision_cross_section_ += get_projected_area(average_projection_); } collision_cross_section_ /= static_cast<double>(n_projections_); particles_set_ = true; }
Selection::Selection(const kernel::ParticlesTemp &h) : radius_(-1) { if (h.empty()) { m_ = nullptr; return; } else { set_hierarchies(h[0]->get_model(), IMP::get_indexes(h)); } }
ExampleSubsetFilterTable::ExampleSubsetFilterTable( unsigned int max_diff, const kernel::ParticlesTemp& ps) : domino::SubsetFilterTable("ExampleSubsetFilterTable%1%"), max_diff_(max_diff), ps_(ps.begin(), ps.end()) {}
/** Take a set of core::XYZR particles and relax them relative to a set of restraints. Excluded volume is handle separately, so don't include it in the passed list of restraints. */ void optimize_balls(const kernel::ParticlesTemp &ps, const kernel::RestraintsTemp &rs, const PairPredicates &excluded, const OptimizerStates &opt_states, base::LogLevel ll) { // make sure that errors and log messages are marked as coming from this // function IMP_FUNCTION_LOG; base::SetLogState sls(ll); IMP_ALWAYS_CHECK(!ps.empty(), "No kernel::Particles passed.", ValueException); kernel::Model *m = ps[0]->get_model(); //double scale = core::XYZR(ps[0]).get_radius(); IMP_NEW(core::SoftSpherePairScore, ssps, (10)); IMP_NEW(core::ConjugateGradients, cg, (m)); cg->set_optimizer_states(opt_states); { // set up restraints for cg IMP_NEW(container::ListSingletonContainer, lsc, (ps)); IMP_NEW(container::ClosePairContainer, cpc, (lsc, 0, core::XYZR(ps[0]).get_radius())); cpc->add_pair_filters(excluded); base::Pointer<kernel::Restraint> r = container::create_restraint(ssps.get(), cpc.get()); cg->set_scoring_function(rs + kernel::RestraintsTemp(1, r.get())); cg->set_optimizer_states(opt_states); } IMP_NEW(core::MonteCarlo, mc, (m)); mc->set_optimizer_states(opt_states); IMP_NEW(core::IncrementalScoringFunction, isf, (ps, rs)); { // set up MC mc->add_mover(create_serial_mover(ps)); // we are special casing the nbl term for montecarlo, but using all for CG mc->set_incremental_scoring_function(isf); // use special incremental support for the non-bonded part isf->add_close_pair_score(ssps, 0, ps, excluded); // make pointer vector } IMP_LOG_PROGRESS("Performing initial optimization" << std::endl); { boost::ptr_vector<ScopedSetFloatAttribute> attrs; for (unsigned int j = 0; j < attrs.size(); ++j) { attrs.push_back( new ScopedSetFloatAttribute(ps[j], core::XYZR::get_radius_key(), 0)); } cg->optimize(1000); } // shrink each of the particles, relax the configuration, repeat for (int i = 0; i < 11; ++i) { boost::ptr_vector<ScopedSetFloatAttribute> attrs; double factor = .1 * i; IMP_LOG_PROGRESS("Optimizing with radii at " << factor << " of full" << std::endl); for (unsigned int j = 0; j < ps.size(); ++j) { attrs.push_back( new ScopedSetFloatAttribute(ps[j], core::XYZR::get_radius_key(), core::XYZR(ps[j]).get_radius() * factor)); } // changed all radii isf->set_moved_particles(isf->get_movable_indexes()); for (int j = 0; j < 5; ++j) { mc->set_kt(100.0 / (3 * j + 1)); mc->optimize(ps.size() * (j + 1) * 100); double e = cg->optimize(10); IMP_LOG_PROGRESS("Energy is " << e << std::endl); if (e < .000001) break; } } }