diff --git a/include/GaussianEMRestraint.h b/include/GaussianEMRestraint.h index d6767eb..67539f9 100755 --- a/include/GaussianEMRestraint.h +++ b/include/GaussianEMRestraint.h @@ -85,7 +85,9 @@ class IMPBAYESIANEMEXPORT GaussianEMRestraint : public Restraint \param[in] density_ps particles for the density GMM \param[in] global_sigma Particle to modulate the uncertainty \param[in] model_cutoff_dist Cutoff for the model-model interactions - \param[in] density_cutoff_dist Cutoff for model-density interactions + \param[in] density_cutoff_dist Cutoff for model-density interactions. + Only pairs of Gaussians whose spheres (XYZR) are closer + than the cutoff plus 2A are scored. \param[in] slope Gentle term to move all particles to the density \param[in] update_model (DEPRECATED) update model each cycle \param[in] backbone_slope Limit the slope only to backbone particles diff --git a/src/GaussianEMRestraint.cpp b/src/GaussianEMRestraint.cpp index ab2bfbc..e713183 100755 --- a/src/GaussianEMRestraint.cpp +++ b/src/GaussianEMRestraint.cpp @@ -15,10 +15,27 @@ #include #include #include +#include #include IMPBAYESIANEM_BEGIN_NAMESPACE +namespace { +// The close pair container lists every pair closer than its cutoff, plus +// other pairs that depend on where the particles were when the list was +// last updated. Score only pairs whose spheres are closer than the cutoff +// plus this margin, so that the score depends only on the coordinates. The +// margin (twice the container's default slack of 1A) is the set of pairs a +// freshly updated list holds, so scores are unchanged right after an update. +const double pair_margin = 2.0; + +inline bool get_is_close(Model *m, const ParticleIndexPair &pp, + double cutoff) { + return core::get_distance(core::XYZR(m, std::get<0>(pp)), + core::XYZR(m, std::get<1>(pp))) < cutoff; +} +} // anonymous namespace + GaussianEMRestraint::GaussianEMRestraint(Model *mdl, ParticleIndexes model_ps, ParticleIndexes density_ps, ParticleIndex global_sigma, @@ -52,7 +69,7 @@ GaussianEMRestraint::GaussianEMRestraint(Model *mdl, ParticleIndexes model_ps, md_container_ = new container::CloseBipartitePairContainer( new container::ListSingletonContainer(mdl, model_ps), new container::ListSingletonContainer(mdl, density_ps), - density_cutoff_dist); + density_cutoff_dist + pair_margin); compute_initial_scores(); @@ -146,16 +163,19 @@ GaussianEMRestraint::unprotected_evaluate(DerivativeAccumulator *accum) const { std::map map_score_dm; // std::cout<<"calculating MD score"< map_score_dm; // std::cout<<"calculating MD score"<