IMP  2.0.0
The Integrative Modeling Platform
ComplementarityRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/multifit/ComplementarityRestraint.h
3  * \brief Calculate weighted excluded volume between rigid bodies
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPMULTIFIT_COMPLEMENTARITY_RESTRAINT_H
10 #define IMPMULTIFIT_COMPLEMENTARITY_RESTRAINT_H
11 
12 #include <IMP/multifit/multifit_config.h>
13 #include <IMP/core/rigid_bodies.h>
14 #include <IMP/core/DataObject.h>
16 
17 IMPMULTIFIT_BEGIN_NAMESPACE
18 
19 //! Compute the complementarity between two molecules.
20 /**
21  The score returned is infinity if the two molecules overlap by more
22  than the value set for set_maximum_penetration_score() or if the
23  two molecules are separated by more than set_maximum_separation().
24 
25  Otherwise, the integral of the set_complementarity_value() value over
26  a layer of thickness set_complementarity_thickness() around the molecule
27  is returned.
28 
29  \note currently each of the particle lists must belong to exactly one
30  rigid body. And, currently, each rigid body can only be associated with
31  one list of particles (that is, there cannot be multiple restraints with
32  different lists of particles that all belong to the same rigid body).
33 
34  \note The restraint does not support derivatives.
35 
36  \note The restraint pretty much only makes sense for use with Domino as it
37  returns infinity for many cases. Monte Carlo might make sense with certain
38  parameters.
39 */
40 class IMPMULTIFITEXPORT ComplementarityRestraint : public Restraint
41 {
42 public:
43  ComplementarityRestraint(const ParticlesTemp &a, const ParticlesTemp &b,
44  std::string name="ComplementarityRestraint %1%");
45  /** If the two molecules have a penetration score of more than this,
46  infinity is returned as the score. This score is roughly the number of
47  cubic angstroms that the two molecules overlap (assuming only one
48  internal layer). */
50  maximum_penetration_score_=s;
51  }
52  /** Alternatively, you can bound the maximum allowed penetration.
53  */
54  void set_maximum_penetration(double d) {
55  maximum_penetration_=d;
56  }
57  /** If the two molecules' bounding sphere surfaces are separated by more
58  than this distance, infinity is returned.
59  */
60  void set_maximum_separation(double s) {
61  maximum_separation_=s;
62  }
63  /** Set the thickness to use for the external complementarity layer.*/
65  complementarity_thickness_=th;
66  update_voxel();
67  }
68  /** Set the value to use for external complementarity voxels.
69  */
70  void set_complementarity_value(double th) {
71  complementarity_value_=th;
72  }
73  /** Set the thickness of the interior layers. */
74  void set_interior_layer_thickness(double th) {
75  interior_thickness_=th;
76  update_voxel();
77  }
78 
79  void set_penetration_coefficient(double pc)
80  {
81  penetration_coef_ = pc;
82  }
83 
84  void set_complementarity_coefficient(double cc)
85  {
86  complementarity_coef_ = cc;
87  }
88 
89  void set_boundary_coefficient(double bc)
90  {
91  boundary_coef_ = bc;
92  }
93  float get_voxel_size() const {return voxel_size_;}
94  IMP_RESTRAINT(ComplementarityRestraint);
95 #ifndef IMP_DOXYGEN
96  double unprotected_evaluate_if_good(DerivativeAccumulator *accum,
97  double max) const;
98 #endif
99  private:
100  typedef std::pair<algebra::Transformation3D,
101  algebra::DenseGrid3D<float> > GridPair;
102  typedef core::DataObject<GridPair> GridObject;
103  GridObject *get_grid_object(core::RigidBody rb,
104  const ParticlesTemp &a,
105  ObjectKey ok,
106  double thickness,
107  double value,
108  double interior_thickness,
109  double voxel) const;
111  get_grid(const ParticlesTemp &a,
112  double thickness,
113  double value,
114  double interior_thickness,
115  double voxel) const;
116  void update_voxel();
117  ParticlesTemp a_, b_;
118  core::RigidBody rba_, rbb_;
119  ObjectKey ok_;
120  // parameters
121  double maximum_separation_, maximum_penetration_score_;
122  double maximum_penetration_;
123  double complementarity_thickness_, complementarity_value_;
124  double penetration_coef_, complementarity_coef_, boundary_coef_;
125  double interior_thickness_, voxel_size_;
126 };
127 
128 IMPMULTIFIT_END_NAMESPACE
129 
130 #endif /* IMPMULTIFIT_COMPLEMENTARITY_RESTRAINT_H */