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,
146 double max,
unsigned int lower_bound,
151 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
152 ret += evaluate_if_good_index(m, p[i], da, max - ret);
153 if (ret > max)
return std::numeric_limits<double>::max();
191 evaluate_site_contributions_with_internal_tables
193 double const**quaternions_tables,
195 double **torques_tables,
198 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
199 (*contacts_accumulator) =
nullptr
223 evaluate_site_contributions
227 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
228 (*contacts_accumulator)
257 inline double evaluate_index_with_internal_tables
260 double const **quaternions_tables,
262 double **torques_tables,
269 inline internal::RigidBodyInfo
272 double const** quaternions_tables,
315 SitesPairScore::evaluate_index
320 m->access_spheres_data();
321 double const* quaternions_tables[4];
322 for(
unsigned int i = 0; i < 4; i++){
323 quaternions_tables[i]=
324 core::RigidBody::access_quaternion_i_data(m, i);
327 m->access_sphere_derivatives_data();
328 double* torques_tables[3];
329 for(
unsigned int i = 0; i < 3; i++){
331 core::RigidBody::access_torque_i_data(m, i);
334 return evaluate_index_with_internal_tables(m,
337 sphere_derivatives_table,
353 SitesPairScore::evaluate_index_with_internal_tables
356 double const** quaternions_tables,
358 double **torques_tables,
365 double non_specific_score = P::evaluate_index(m, pip, da);
367 lips_cache= P::get_evaluation_cache();
371 double const& distance2= lips_cache.particles_delta_squared;
372 IMP_LOG(
PROGRESS,
"distance2 " << distance2
373 <<
" ; distance upper-bound " << ubound_distance2_ << std::endl);
374 if (distance2 > ubound_distance2_) {
375 IMP_LOG(
PROGRESS,
"Sites contribution is 0.0 and non-specific score is "
376 << non_specific_score << std::endl);
377 return non_specific_score;
380 double site_score=evaluate_site_contributions_with_internal_tables
383 sphere_derivatives_table,
387 return site_score + non_specific_score;
394 SitesPairScore::evaluate_site_contributions_with_internal_tables
396 double const**quaternions_tables,
398 double **torques_tables,
401 boost::tuple<
unsigned int,
402 std::vector<unsigned int>,
403 std::vector<unsigned int>,
405 * contacts_accumulator
410 static unsigned int n_contacts;
411 static std::vector<unsigned int> occupied_sites0;
412 static std::vector<unsigned int> occupied_sites1;
413 if(contacts_accumulator){
415 occupied_sites0.resize(sites0_.size());
416 occupied_sites1.resize(sites1_.size());
417 std::fill(occupied_sites0.begin(), occupied_sites0.end(),0);
418 std::fill(occupied_sites1.begin(), occupied_sites1.end(),0);
425 internal::RigidBodyInfo rbi0 = get_rigid_body_info(spheres_table,
428 internal::RigidBodyInfo rbi1 = get_rigid_body_info(spheres_table,
432 <<
" RB0.cache_id " << rbi0.cache_id
433 <<
"RBI0.tr " << rbi0.tr << std::endl);
435 <<
"RBI1.pi " << rbi1.pi
436 <<
"RBI1.tr " << rbi1.tr << std::endl);
439 if(is_orientational_score_){
445 for (
unsigned int i0 = 0; i0 < sites0_.size(); ++i0) {
448 double cosSigma0 = gUnitRB0Site0*gUnitRB0RB1;
449 if(cosSigma0 < params_.cosSigma1_max) {
452 double kFactor0=internal::get_k_factor(cosSigma0, params_.cosSigma1_max);
458 dKFactor0=internal::get_derivative_k_factor(absSinSigma0, params_.cosSigma1_max);
460 for(
unsigned int i1 = 0 ; i1 < sites1_.size(); ++i1) {
463 <<
" ; " << gSite1 << std::endl );
466 internal::evaluate_pair_of_sites(params_,
469 gUnitRB0RB1, distRB0RB1,
473 sphere_derivatives_table,
476 if(contacts_accumulator && cur_score!=0.0){
478 occupied_sites0[i0]++;
479 occupied_sites1[i1]++;
486 for (
unsigned int i = 0; i < sites0_.size(); ++i) {
488 for(
unsigned int j = 0 ; j < sites1_.size(); ++j) {
490 IMP_LOG_PROGRESS(
"Evaluating sites at global coordinates: " << g0 <<
" ; " << g1 << std::endl );
494 internal::evaluate_one_site_3(params_.k,
497 sites0_[i], sites1_[j],
500 sphere_derivatives_table,
504 if(contacts_accumulator && cur_score!=0.0){
506 occupied_sites0[i]++;
507 occupied_sites1[i]++;
512 if(contacts_accumulator){
513 double non_specific_range= P::get_range_attraction();
516 bool is_nonspecific_interaction= d_spheres < non_specific_range;
517 (*contacts_accumulator)=
518 boost::make_tuple(n_contacts,
521 is_nonspecific_interaction);
531 SitesPairScore::evaluate_site_contributions
535 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
536 (*contacts_accumulator)
541 m->access_spheres_data();
542 double const* quaternions_tables[4];
543 for(
unsigned int i = 0; i < 4; i++){
544 quaternions_tables[i]=
545 core::RigidBody::access_quaternion_i_data(m, i);
548 m->access_sphere_derivatives_data();
549 double* torques_tables[3];
550 for(
unsigned int i = 0; i < 3; i++){
552 core::RigidBody::access_torque_i_data(m, i);
555 return evaluate_site_contributions_with_internal_tables
558 sphere_derivatives_table,
562 contacts_accumulator);
565 #endif // ifndef SWIG
568 inline internal::RigidBodyInfo
569 SitesPairScore::get_rigid_body_info
571 double const **quaternions_tables,
595 return internal::RigidBodyInfo(spheres_table,
604 IMPNPCTRANSPORT_END_NAMESPACE
ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const
Overload this method to specify the inputs.
Apply a PairScore to each Pair in a list.
virtual double evaluate_if_good_indexes(Model *m, const ParticleIndexPairs &o, DerivativeAccumulator *da, double max, unsigned int lower_bound, unsigned int upper_bound) const
#define IMP_FINAL
Have the compiler report an error if anything overrides this method.
#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.
virtual double evaluate_indexes(Model *m, const ParticleIndexPairs &pips, DerivativeAccumulator *da, unsigned int lower_bound, unsigned int upper_bound) const
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...
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)
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
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.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.
Estimates of various physical quantities.
Compile-time generic restraint and constraint support.