10 #ifndef IMPNPCTRANSPORT_SITES_PAIR_SCORE_H
11 #define IMPNPCTRANSPORT_SITES_PAIR_SCORE_H
13 #include "npctransport_config.h"
16 #include "internal/RigidBodyInfo.h"
17 #include "internal/sites.h"
31 #include <boost/unordered_set.hpp>
33 #include <boost/array.hpp>
35 IMPNPCTRANSPORT_BEGIN_NAMESPACE
53 bool is_orientational_score_;
61 double ubound_distance2_;
127 double sigma0_deg,
double sigma1_deg,
128 double range_nonspec_attraction,
double k_nonspec_attraction,
129 double k_nonspec_repulsion,
138 unsigned int lower_bound,
139 unsigned int upper_bound,
140 bool all_indexes_checked=
false)
const override final;
147 double max,
unsigned int lower_bound,
148 unsigned int upper_bound,
149 bool all_indexes_checked=
false)
const override
154 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
155 ret += evaluate_if_good_index(m, p[i], da, max - ret);
156 if (ret > max)
return std::numeric_limits<double>::max();
194 evaluate_site_contributions_with_internal_tables
196 double const**quaternions_tables,
198 double **torques_tables,
201 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
202 (*contacts_accumulator) =
nullptr
226 evaluate_site_contributions
230 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
231 (*contacts_accumulator)
260 inline double evaluate_index_with_internal_tables
263 double const **quaternions_tables,
265 double **torques_tables,
272 inline internal::RigidBodyInfo
275 double const** quaternions_tables,
318 SitesPairScore::evaluate_index
323 m->access_spheres_data();
324 double const* quaternions_tables[4];
325 for(
unsigned int i = 0; i < 4; i++){
326 quaternions_tables[i]=
327 core::RigidBody::access_quaternion_i_data(m, i);
330 m->access_sphere_derivatives_data();
331 double* torques_tables[3];
332 for(
unsigned int i = 0; i < 3; i++){
334 core::RigidBody::access_torque_i_data(m, i);
337 return evaluate_index_with_internal_tables(m,
340 sphere_derivatives_table,
356 SitesPairScore::evaluate_index_with_internal_tables
359 double const** quaternions_tables,
361 double **torques_tables,
368 double non_specific_score = P::evaluate_index(m, pip, da);
370 lips_cache= P::get_evaluation_cache();
374 double const& distance2= lips_cache.particles_delta_squared;
375 IMP_LOG(
PROGRESS,
"distance2 " << distance2
376 <<
" ; distance upper-bound " << ubound_distance2_ << std::endl);
377 if (distance2 > ubound_distance2_) {
378 IMP_LOG(
PROGRESS,
"Sites contribution is 0.0 and non-specific score is "
379 << non_specific_score << std::endl);
380 return non_specific_score;
383 double site_score=evaluate_site_contributions_with_internal_tables
386 sphere_derivatives_table,
390 return site_score + non_specific_score;
397 SitesPairScore::evaluate_site_contributions_with_internal_tables
399 double const**quaternions_tables,
401 double **torques_tables,
404 boost::tuple<
unsigned int,
405 std::vector<unsigned int>,
406 std::vector<unsigned int>,
408 * contacts_accumulator
413 static unsigned int n_contacts;
414 static std::vector<unsigned int> occupied_sites0;
415 static std::vector<unsigned int> occupied_sites1;
416 if(contacts_accumulator){
418 occupied_sites0.resize(sites0_.size());
419 occupied_sites1.resize(sites1_.size());
420 std::fill(occupied_sites0.begin(), occupied_sites0.end(),0);
421 std::fill(occupied_sites1.begin(), occupied_sites1.end(),0);
428 internal::RigidBodyInfo rbi0 = get_rigid_body_info(spheres_table,
431 internal::RigidBodyInfo rbi1 = get_rigid_body_info(spheres_table,
435 <<
" RB0.cache_id " << rbi0.cache_id
436 <<
"RBI0.tr " << rbi0.tr << std::endl);
438 <<
"RBI1.pi " << rbi1.pi
439 <<
"RBI1.tr " << rbi1.tr << std::endl);
442 if(is_orientational_score_){
448 for (
unsigned int i0 = 0; i0 < sites0_.size(); ++i0) {
451 double cosSigma0 = gUnitRB0Site0*gUnitRB0RB1;
452 if(cosSigma0 < params_.cosSigma1_max) {
455 double kFactor0=internal::get_k_factor(cosSigma0, params_.cosSigma1_max);
461 dKFactor0=internal::get_derivative_k_factor(absSinSigma0, params_.cosSigma1_max);
463 for(
unsigned int i1 = 0 ; i1 < sites1_.size(); ++i1) {
466 <<
" ; " << gSite1 << std::endl );
469 internal::evaluate_pair_of_sites(params_,
472 gUnitRB0RB1, distRB0RB1,
476 sphere_derivatives_table,
479 if(contacts_accumulator && cur_score!=0.0){
481 occupied_sites0[i0]++;
482 occupied_sites1[i1]++;
489 for (
unsigned int i = 0; i < sites0_.size(); ++i) {
491 for(
unsigned int j = 0 ; j < sites1_.size(); ++j) {
493 IMP_LOG_PROGRESS(
"Evaluating sites at global coordinates: " << g0 <<
" ; " << g1 << std::endl );
497 internal::evaluate_one_site_3(params_.k,
500 sites0_[i], sites1_[j],
503 sphere_derivatives_table,
507 if(contacts_accumulator && cur_score!=0.0){
509 occupied_sites0[i]++;
510 occupied_sites1[i]++;
515 if(contacts_accumulator){
516 double non_specific_range= P::get_range_attraction();
519 bool is_nonspecific_interaction= d_spheres < non_specific_range;
520 (*contacts_accumulator)=
521 boost::make_tuple(n_contacts,
524 is_nonspecific_interaction);
534 SitesPairScore::evaluate_site_contributions
538 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
539 (*contacts_accumulator)
544 m->access_spheres_data();
545 double const* quaternions_tables[4];
546 for(
unsigned int i = 0; i < 4; i++){
547 quaternions_tables[i]=
548 core::RigidBody::access_quaternion_i_data(m, i);
551 m->access_sphere_derivatives_data();
552 double* torques_tables[3];
553 for(
unsigned int i = 0; i < 3; i++){
555 core::RigidBody::access_torque_i_data(m, i);
558 return evaluate_site_contributions_with_internal_tables
561 sphere_derivatives_table,
565 contacts_accumulator);
568 #endif // ifndef SWIG
571 inline internal::RigidBodyInfo
572 SitesPairScore::get_rigid_body_info
574 double const **quaternions_tables,
598 return internal::RigidBodyInfo(spheres_table,
607 IMPNPCTRANSPORT_END_NAMESPACE
Apply a PairScore to each Pair in a list.
virtual double evaluate_indexes(Model *m, const ParticleIndexPairs &pips, DerivativeAccumulator *da, unsigned int lower_bound, unsigned int upper_bound, bool all_indexes_checked=false) const override
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
#define IMP_OBJECT_LOG
Set the log level to the object's log level.
Single variable function.
#define IMP_LOG_PROGRESS(expr)
A particle with a user-defined type.
Macros to choose the best set or map for different purposes.
Class for storing model, its restraints, constraints, and particles.
double get_magnitude_and_normalize_in_place(VT &vt)
Returns the magnitude of vt and turns it to a unit vector in place.
Apply a function to the distance between two particles with a set of specific binding sites...
virtual double evaluate_if_good_indexes(Model *m, const ParticleIndexPairs &o, DerivativeAccumulator *da, double max, unsigned int lower_bound, unsigned int upper_bound, bool all_indexes_checked=false) const
Vector3D get_vector_product(const Vector3D &p1, const Vector3D &p2)
Return the vector product (cross product) of two vectors.
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
#define IMP_UNUSED(variable)
Represent an XYZR particle with a sphere.
A score on the distance between the surfaces of two spheres.
A nullptr-initialized pointer to an IMP Object.
double get_sites_range() const
return the range for site-site attraction
ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the inputs.
double get_sites_k() const
return the k for site-site attraction
double evaluate_index(algebra::Sphere3D const &s0, algebra::Sphere3D const &s1, algebra::Sphere3D &ds0, algebra::Sphere3D &ds1, DerivativeAccumulator *da) const
Functions to search over vectors.
A Score on the distance between a pair of particles.
A summary of useful information about rigid bodies and their transformation for eg, caching purposes for SitesPairScore.
Decorator for a sphere-like particle.
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.
Class for adding derivatives from restraints to the model.
Estimates of various physical quantities.
Compile-time generic restraint and constraint support.