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();
190 evaluate_site_contributions_with_internal_tables
192 double const**quaternions_tables,
194 double **torques_tables,
197 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
198 (*contacts_accumulator) =
nullptr
222 evaluate_site_contributions
226 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
227 (*contacts_accumulator)
256 inline double evaluate_index_with_internal_tables
259 double const **quaternions_tables,
261 double **torques_tables,
268 inline internal::RigidBodyInfo
271 double const** quaternions_tables,
314 SitesPairScore::evaluate_index
319 m->access_spheres_data();
320 double const* quaternions_tables[4];
321 for(
unsigned int i = 0; i < 4; i++){
322 quaternions_tables[i]=
323 core::RigidBody::access_quaternion_i_data(m, i);
326 m->access_sphere_derivatives_data();
327 double* torques_tables[3];
328 for(
unsigned int i = 0; i < 3; i++){
330 core::RigidBody::access_torque_i_data(m, i);
333 return evaluate_index_with_internal_tables(m,
336 sphere_derivatives_table,
352 SitesPairScore::evaluate_index_with_internal_tables
355 double const** quaternions_tables,
357 double **torques_tables,
364 double non_specific_score = P::evaluate_index(m, pip, da);
366 lips_cache= P::get_evaluation_cache();
370 double const& distance2= lips_cache.particles_delta_squared;
371 IMP_LOG(
PROGRESS,
"distance2 " << distance2
372 <<
" ; distance upper-bound " << ubound_distance2_ << std::endl);
373 if (distance2 > ubound_distance2_) {
374 IMP_LOG(
PROGRESS,
"Sites contribution is 0.0 and non-specific score is "
375 << non_specific_score << std::endl);
376 return non_specific_score;
379 double site_score=evaluate_site_contributions_with_internal_tables
382 sphere_derivatives_table,
386 return site_score + non_specific_score;
393 SitesPairScore::evaluate_site_contributions_with_internal_tables
395 double const**quaternions_tables,
397 double **torques_tables,
400 boost::tuple<
unsigned int,
401 std::vector<unsigned int>,
402 std::vector<unsigned int>,
404 * contacts_accumulator
409 static unsigned int n_contacts;
410 static std::vector<unsigned int> occupied_sites0;
411 static std::vector<unsigned int> occupied_sites1;
412 if(contacts_accumulator){
414 occupied_sites0.resize(sites0_.size());
415 occupied_sites1.resize(sites1_.size());
416 std::fill(occupied_sites0.begin(), occupied_sites0.end(),0);
417 std::fill(occupied_sites1.begin(), occupied_sites1.end(),0);
424 internal::RigidBodyInfo rbi0 = get_rigid_body_info(spheres_table,
427 internal::RigidBodyInfo rbi1 = get_rigid_body_info(spheres_table,
431 <<
" RB0.cache_id " << rbi0.cache_id
432 <<
"RBI0.tr " << rbi0.tr << std::endl);
434 <<
"RBI1.pi " << rbi1.pi
435 <<
"RBI1.tr " << rbi1.tr << std::endl);
438 if(is_orientational_score_){
444 for (
unsigned int i0 = 0; i0 < sites0_.size(); ++i0) {
447 double cosSigma0 = gUnitRB0Site0*gUnitRB0RB1;
448 if(cosSigma0 < params_.cosSigma1_max) {
451 double kFactor0=internal::get_k_factor(cosSigma0, params_.cosSigma1_max);
457 dKFactor0=internal::get_derivative_k_factor(absSinSigma0, params_.cosSigma1_max);
459 for(
unsigned int i1 = 0 ; i1 < sites1_.size(); ++i1) {
462 <<
" ; " << gSite1 << std::endl );
465 internal::evaluate_pair_of_sites(params_,
468 gUnitRB0RB1, distRB0RB1,
472 sphere_derivatives_table,
475 if(contacts_accumulator && cur_score!=0.0){
477 occupied_sites0[i0]++;
478 occupied_sites1[i1]++;
485 for (
unsigned int i = 0; i < sites0_.size(); ++i) {
487 for(
unsigned int j = 0 ; j < sites1_.size(); ++j) {
489 IMP_LOG_PROGRESS(
"Evaluating sites at global coordinates: " << g0 <<
" ; " << g1 << std::endl );
493 internal::evaluate_one_site_3(params_.k,
496 sites0_[i], sites1_[j],
499 sphere_derivatives_table,
503 if(contacts_accumulator && cur_score!=0.0){
505 occupied_sites0[i]++;
506 occupied_sites1[i]++;
511 if(contacts_accumulator){
512 double non_specific_range= P::get_range_attraction();
515 bool is_nonspecific_interaction= d_spheres < non_specific_range;
516 (*contacts_accumulator)=
517 boost::make_tuple(n_contacts,
520 is_nonspecific_interaction);
530 SitesPairScore::evaluate_site_contributions
534 boost::tuple<
unsigned int, std::vector<unsigned int>, std::vector<unsigned int>,
bool >
535 (*contacts_accumulator)
540 m->access_spheres_data();
541 double const* quaternions_tables[4];
542 for(
unsigned int i = 0; i < 4; i++){
543 quaternions_tables[i]=
544 core::RigidBody::access_quaternion_i_data(m, i);
547 m->access_sphere_derivatives_data();
548 double* torques_tables[3];
549 for(
unsigned int i = 0; i < 3; i++){
551 core::RigidBody::access_torque_i_data(m, i);
554 return evaluate_site_contributions_with_internal_tables
557 sphere_derivatives_table,
561 contacts_accumulator);
564 #endif // ifndef SWIG
567 inline internal::RigidBodyInfo
568 SitesPairScore::get_rigid_body_info
570 double const **quaternions_tables,
594 return internal::RigidBodyInfo(spheres_table,
603 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.