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)
const IMP_FINAL;
146 double max,
unsigned int lower_bound,
unsigned int upper_bound)
const
150 for (
unsigned int i = lower_bound; i < upper_bound; ++i) {
151 ret += evaluate_if_good_index(m, p[i], da, max - ret);
152 if (ret > max)
return std::numeric_limits<double>::max();
189 evaluate_site_contributions_with_internal_tables
191 double const**quaternions_tables,
193 double **torques_tables,
196 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int> >
197 (*contacts_accumulator) =
nullptr
220 evaluate_site_contributions
224 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int> >
225 (*contacts_accumulator)
254 inline double evaluate_index_with_internal_tables
257 double const **quaternions_tables,
259 double **torques_tables,
266 inline internal::RigidBodyInfo
269 double const** quaternions_tables,
312 SitesPairScore::evaluate_index
317 m->access_spheres_data();
318 double const* quaternions_tables[4];
319 for(
unsigned int i = 0; i < 4; i++){
320 quaternions_tables[i]=
321 core::RigidBody::access_quaternion_i_data(m, i);
324 m->access_sphere_derivatives_data();
325 double* torques_tables[3];
326 for(
unsigned int i = 0; i < 3; i++){
328 core::RigidBody::access_torque_i_data(m, i);
331 return evaluate_index_with_internal_tables(m,
334 sphere_derivatives_table,
350 SitesPairScore::evaluate_index_with_internal_tables
353 double const** quaternions_tables,
355 double **torques_tables,
362 double non_specific_score = P::evaluate_index(m, pip, da);
364 lips_cache= P::get_evaluation_cache();
368 double const& distance2= lips_cache.particles_delta_squared;
369 IMP_LOG(
PROGRESS,
"distance2 " << distance2
370 <<
" ; distance upper-bound " << ubound_distance2_ << std::endl);
371 if (distance2 > ubound_distance2_) {
372 IMP_LOG(
PROGRESS,
"Sites contribution is 0.0 and non-specific score is "
373 << non_specific_score << std::endl);
374 return non_specific_score;
377 double site_score=evaluate_site_contributions_with_internal_tables
380 sphere_derivatives_table,
384 return site_score + non_specific_score;
391 SitesPairScore::evaluate_site_contributions_with_internal_tables
393 double const**quaternions_tables,
395 double **torques_tables,
398 boost::tuple<
unsigned int,
399 std::vector<unsigned int>,
400 std::vector<unsigned int> >
401 * contacts_accumulator
406 static unsigned int n_contacts;
407 static std::vector<unsigned int> occupied_sites0;
408 static std::vector<unsigned int> occupied_sites1;
409 if(contacts_accumulator){
411 occupied_sites0.resize(sites0_.size());
412 occupied_sites1.resize(sites1_.size());
413 std::fill(occupied_sites0.begin(), occupied_sites0.end(),0);
414 std::fill(occupied_sites1.begin(), occupied_sites1.end(),0);
421 internal::RigidBodyInfo rbi0 = get_rigid_body_info(spheres_table,
424 internal::RigidBodyInfo rbi1 = get_rigid_body_info(spheres_table,
428 <<
" RB0.cache_id " << rbi0.cache_id
429 <<
"RBI0.tr " << rbi0.tr << std::endl);
431 <<
"RBI1.pi " << rbi1.pi
432 <<
"RBI1.tr " << rbi1.tr << std::endl);
435 if(is_orientational_score_){
441 for (
unsigned int i = 0; i < sites0_.size(); ++i) {
444 double cosSigma0 = gUnitRB0Site0*gUnitRB0RB1;
445 if(cosSigma0 < params_.cosSigma1_max) {
448 double kFactor0=internal::get_k_factor(cosSigma0, params_.cosSigma1_max);
454 dKFactor0=internal::get_derivative_k_factor(absSinSigma0, params_.cosSigma1_max);
456 for(
unsigned int j = 0 ; j < sites1_.size(); ++j) {
459 <<
" ; " << gSite1 << std::endl );
462 internal::evaluate_pair_of_sites(params_,
465 gUnitRB0RB1, distRB0RB1,
469 sphere_derivatives_table,
472 if(contacts_accumulator && cur_score!=0.0){
474 occupied_sites0[i]++;
475 occupied_sites1[i]++;
482 for (
unsigned int i = 0; i < sites0_.size(); ++i) {
484 for(
unsigned int j = 0 ; j < sites1_.size(); ++j) {
486 IMP_LOG_PROGRESS(
"Evaluating sites at global coordinates: " << g0 <<
" ; " << g1 << std::endl );
490 internal::evaluate_one_site_3(params_.k,
493 sites0_[i], sites1_[j],
496 sphere_derivatives_table,
500 if(contacts_accumulator && cur_score!=0.0){
502 occupied_sites0[i]++;
503 occupied_sites1[i]++;
508 if(contacts_accumulator){
509 (*contacts_accumulator)=
510 boost::make_tuple(n_contacts,
522 SitesPairScore::evaluate_site_contributions
526 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int> >
527 (*contacts_accumulator)
532 m->access_spheres_data();
533 double const* quaternions_tables[4];
534 for(
unsigned int i = 0; i < 4; i++){
535 quaternions_tables[i]=
536 core::RigidBody::access_quaternion_i_data(m, i);
539 m->access_sphere_derivatives_data();
540 double* torques_tables[3];
541 for(
unsigned int i = 0; i < 3; i++){
543 core::RigidBody::access_torque_i_data(m, i);
546 return evaluate_site_contributions_with_internal_tables
549 sphere_derivatives_table,
553 contacts_accumulator);
556 #endif // ifndef SWIG
559 inline internal::RigidBodyInfo
560 SitesPairScore::get_rigid_body_info
562 double const **quaternions_tables,
586 return internal::RigidBodyInfo(spheres_table,
595 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.
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.
#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.
Various important functionality for implementing decorators.