IMP  2.1.1
The Integrative Modeling Platform
simplify_restraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/restrainer/simplify_restraint.h
3  * \brief Restrainer functions for restraints
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPRESTRAINER_SIMPLIFY_RESTRAINT_H
9 #define IMPRESTRAINER_SIMPLIFY_RESTRAINT_H
10 
11 #include <IMP/restrainer/restrainer_config.h>
12 #include <IMP/SingletonContainer.h>
13 #include <IMP/atom.h>
14 #include <IMP/core.h>
15 #include <IMP/em/FitRestraint.h>
16 #include <IMP/em/DensityMap.h>
17 #include <IMP/core/rigid_bodies.h>
18 #include <IMP/base/VersionInfo.h>
19 
20 IMPRESTRAINER_BEGIN_NAMESPACE
21 
22 class SimpleConnectivity;
23 class SimpleDistance;
24 class SimpleDiameter;
25 class SimpleExcludedVolume;
26 class SimpleEMFit;
27 
28 
29 /** Creates ConnectivityRestraint on rigid bodies.
30 
31  \note Having the default be RigidMembersRefiner is most likely a bad
32  idea, but it is needed to make things work. The refiner should
33  probably be exposed, otherwise this method cannot be used with the
34  rigid bodies created from molecular hierarchies, which is kind of
35  an unintuitive result. A better solution may be to ensure that
36  everything is an atom.Hierarchy and use the LeavesRefiner implicitly.
37  */
38 IMPRESTRAINEREXPORT SimpleConnectivity
39 create_simple_connectivity_on_rigid_bodies(const core::RigidBodies &rbs,
40  Refiner
41  *ref=IMP::core::internal::get_rigid_members_refiner());
42 
43 
44 /** Creates ConnectivityRestraint on molecules using LowestRefinedPairScore
45  and LeavesRefiner.
46 
47  \see LowestRefinedPairScore
48  \see SphereDistancePairScore
49  \see HarmonicUpperBound
50  \see LeavesRefiner
51  See SimpleConnectivity
52  */
53 IMPRESTRAINEREXPORT SimpleConnectivity create_simple_connectivity_on_molecules(
54  const atom::Hierarchies &mhs);
55 
56 
57 /** Creates DistanceRestraint using HarmonicUpperBound scoring function
58  as default.
59  \param[in] ps Pointer to two particles in distance restraint.
60  See SimpleDistance
61 */
62 IMPRESTRAINEREXPORT SimpleDistance
63 create_simple_distance(const kernel::Particles &ps);
64 
65 
66 
67 /** Creates DiameterRestraint using HarmonicUpperBound scoring function
68  as default.
69  \param[in] ps Pointer to particles in diameter restraint.
70  \param[in] diameter Diameter.
71  \see ListSingletonContainer
72  See SimpleDiameter
73  */
74 IMPRESTRAINEREXPORT SimpleDiameter create_simple_diameter(
75  const kernel::Particles &ps, Float diameter);
76 
77 
78 /* Having the default be RigidMembersRefiner is most likely a bad
79  idea, but it is needed to make things work. The refiner should
80  probably be exposed, otherwise this method cannot be used with the
81  rigid bodies created from molecular hierarchies, which is kind of
82  an unintuitive result. A better solution may be to ensure that
83  everything is an atom.Hierarchy and use the LeavesRefiner
84  implicitly (as the docs say, but not as it was doing before).
85  */
86 
87 /** Creates ExcludedVolumeRestraint using LeavesRefiner.
88  \see ListSingletonContainer
89  See SimpleExcludedVolume
90 */
91 IMPRESTRAINEREXPORT SimpleExcludedVolume
93  const core::RigidBodies &rbs,
94  Refiner *ref= IMP::core::internal::get_rigid_members_refiner());
95 
96 
97 
98 /** Creates ExcludedVolumeRestraint using RigidMembersRefiner.
99  \see RigidMembersRefiner
100  See SimpleExcludedVolume
101 */
102 IMPRESTRAINEREXPORT SimpleExcludedVolume
104  const atom::Hierarchies &mhs);
105 
106 
107 
108 /** Creates EM FitRestraint.
109  \see FitRestraint
110  \see DensityMap
111  See SimpleEMFit
112 */
113 IMPRESTRAINEREXPORT SimpleEMFit create_simple_em_fit(
114  atom::Hierarchies const &mhs, em::DensityMap *dmap);
115 //! Creates EM FitRestraint.
116 /**
117  \param[in] mh a molecule to fit in the density
118  \param[in] dmap the density map
119  \see FitRestraint
120  \see DensityMap
121  See SimpleEMFit
122 */
123 IMPRESTRAINEREXPORT SimpleEMFit create_simple_em_fit(
124  atom::Hierarchy const &mh, em::DensityMap *dmap);
125 
126 /** Load EM density file (.mrc or .em file). */
127 IMPRESTRAINEREXPORT em::DensityMap *load_em_density_map(
128  char const *map_fn, float spacing, float resolution);
129 
130 /** Set each of the given hierachies to be a rigid body.
131  \deprecated_at{2.1} Use atom::create_rigid_body() instead. */
132 IMPRESTRAINER_DEPRECATED_FUNCTION_DECL(2.1)
133 IMPRESTRAINEREXPORT core::RigidBodies set_rigid_bodies(
134  atom::Hierarchies const &mhs);
135 
136 //! Simple connectivity restraint.
137 /**
138  \note SimpleConnectivity stores pointers to ConnectivityRestraint,
139  HarmonicUpperBound, and SphereDistancePairScore.
140  \note It provides convenient methods to change mean, k,
141  and standard deviation.
142  \see ConnectivityRestraint
143  */
144 class IMPRESTRAINEREXPORT SimpleConnectivity
145 {
146  IMP_NO_SWIG(
147  friend IMPRESTRAINEREXPORT SimpleConnectivity
149  const core::RigidBodies &rbs, Refiner *ref);
150  friend IMPRESTRAINEREXPORT SimpleConnectivity
152  atom::Hierarchies const &mhs);
153  )
154  public:
155  core::ConnectivityRestraint *get_restraint()
156  {
157  return connectivity_restraint_;
158  }
159 
160  core::HarmonicUpperBound *get_harmonic_upper_bound()
161  {
162  return harmonic_upper_bound_;
163  }
164 
165  core::SphereDistancePairScore *get_sphere_distance_pair_score()
166  {
167  return sphere_distance_pair_score_;
168  }
169 
170  //! Set the mean for the HarmonicUpperBound.
171  /** The default mean is 0.
172  */
173  void set_mean(Float mean)
174  {
175  harmonic_upper_bound_->set_mean(mean);
176  }
177 
178  //! Set the standard deviation for the HarmonicUpperBound.
180  {
181  static Float k = harmonic_upper_bound_->get_k_from_standard_deviation(sd);
182  harmonic_upper_bound_->set_k(k);
183  }
184 
185  //! Set the spring constant for the HarmonicUpperBound.
186  /** The default k is 1.
187  */
188  void set_k(Float k)
189  {
190  harmonic_upper_bound_->set_k(k);
191  }
192 
193  base::VersionInfo get_version_info() const
194  {
195  return base::VersionInfo("restrainer",
196  get_module_version());
197  }
198 
199  void show(std::ostream &out = std::cout) const
200  {
201  out << "SimpleConnectivity(";
202  if ( connectivity_restraint_ )
203  connectivity_restraint_->show(out);
204  out << ")";
205  }
206 
207 private:
208  // prevent unauthorized creation
209  SimpleConnectivity(
210  core::ConnectivityRestraint *connectivity_restraint,
211  core::HarmonicUpperBound *harmonic_upper_bound,
212  core::SphereDistancePairScore *sphere_distance_pair_score)
213  : connectivity_restraint_(connectivity_restraint)
214  , harmonic_upper_bound_(harmonic_upper_bound)
215  , sphere_distance_pair_score_(sphere_distance_pair_score)
216  {}
217 
218  base::Pointer<core::ConnectivityRestraint> connectivity_restraint_;
219  base::Pointer<core::HarmonicUpperBound> harmonic_upper_bound_;
220  base::Pointer<core::SphereDistancePairScore> sphere_distance_pair_score_;
221 };
222 IMP_VALUES(SimpleConnectivity, SimpleConnectivities);
223 
224 //! Simple distance restraint between two particles.
225 /**
226  \note SimpleDistance stores pointers to DistanceRestraint, and
227  HarmonicUpperBound.
228  \note It provides convenient methods to change mean, k, and
229  standard deviation.
230 
231  \see DistanceRestraint
232  */
233 class IMPRESTRAINEREXPORT SimpleDistance
234 {
235  IMP_NO_SWIG(friend IMPRESTRAINEREXPORT SimpleDistance
237  public:
238  core::DistanceRestraint *get_restraint()
239  {
240  return distance_restraint_;
241  }
242 
243  core::HarmonicUpperBound *get_harmonic_upper_bound()
244  {
245  return harmonic_upper_bound_;
246  }
247 
248  //! Set the mean for the HarmonicUpperBound.
249  /** The default mean is 0.
250  */
251  void set_mean(Float mean)
252  {
253  harmonic_upper_bound_->set_mean(mean);
254  }
255 
256  //! Set the standard deviation for the HarmonicUpperBound.
258  {
259  static Float k = harmonic_upper_bound_->get_k_from_standard_deviation(sd);
260  harmonic_upper_bound_->set_k(k);
261  }
262 
263  //! Set the spring constant for the HarmonicUpperBound.
264  /** The default k is 1.
265  */
266  void set_k(Float k)
267  {
268  harmonic_upper_bound_->set_k(k);
269  }
270 
271  base::VersionInfo get_version_info() const
272  {
273  return base::VersionInfo("restrainer",
274  get_module_version());
275  }
276 
277  void show(std::ostream &out = std::cout) const
278  {
279  out << "SimpleDistance(";
280  if ( distance_restraint_ )
281  distance_restraint_->show(out);
282  out << ")";
283  }
284 
285 private:
286  // prevent unauthorized creation
287  SimpleDistance(
288  core::DistanceRestraint *distance_restraint,
289  core::HarmonicUpperBound *harmonic_upper_bound)
290  : distance_restraint_(distance_restraint)
291  , harmonic_upper_bound_(harmonic_upper_bound)
292  {}
293 
294  base::Pointer<core::DistanceRestraint> distance_restraint_;
295  base::Pointer<core::HarmonicUpperBound> harmonic_upper_bound_;
296 };
298 
299 //! Simple diameter restraint.
300 /**
301  \note SimpleDiameter stores pointers to DiameterRestraint, and
302  HarmonicUpperBound.
303  \note It provides convenient methods to change mean, k, and
304  standard deviation.
305  \see DiameterRestraint
306  */
307 class IMPRESTRAINEREXPORT SimpleDiameter
308 {
309  IMP_NO_SWIG(friend IMPRESTRAINEREXPORT SimpleDiameter
311  Float diameter));
312  public:
313 
314  core::DiameterRestraint *get_restraint()
315  {
316  return diameter_restraint_;
317  }
318 
319  core::HarmonicUpperBound *get_harmonic_upper_bound()
320  {
321  return harmonic_upper_bound_;
322  }
323 
324  //! Set the mean for the HarmonicUpperBound.
325  /** The default mean is 0.
326  */
327  void set_mean(Float mean)
328  {
329  harmonic_upper_bound_->set_mean(mean);
330  }
331 
332  //! Set the standard deviation for the HarmonicUpperBound.
334  {
335  static Float k = harmonic_upper_bound_->get_k_from_standard_deviation(sd);
336  harmonic_upper_bound_->set_k(k);
337  }
338 
339  //! Set the spring constant for the HarmonicUpperBound.
340  /** The default k is 1.
341  */
342  void set_k(Float k)
343  {
344  harmonic_upper_bound_->set_k(k);
345  }
346 
347  base::VersionInfo get_version_info() const
348  {
349  return base::VersionInfo("restrainer",
350  get_module_version());
351  }
352 
353  void show(std::ostream &out = std::cout) const
354  {
355  out << "SimpleDiameter(";
356  if ( diameter_restraint_ )
357  diameter_restraint_->show(out);
358  out << ")";
359  }
360 
361 private:
362  // prevent unauthorized creation
363  SimpleDiameter(
364  core::DiameterRestraint *diameter_restraint,
365  core::HarmonicUpperBound *harmonic_upper_bound)
366  : diameter_restraint_(diameter_restraint)
367  , harmonic_upper_bound_(harmonic_upper_bound)
368  {}
369 
370  base::Pointer<core::DiameterRestraint> diameter_restraint_;
371  base::Pointer<core::HarmonicUpperBound> harmonic_upper_bound_;
372 };
374 
375 //! Simple excluded volume restraint.
376 /**
377  \see ExcludedVolumeRestraint
378  */
379 class IMPRESTRAINEREXPORT SimpleExcludedVolume
380 {
381  IMP_NO_SWIG(friend IMPRESTRAINEREXPORT SimpleExcludedVolume
383  const core::RigidBodies &rbs, Refiner*ref)
384  );
385  IMP_NO_SWIG(friend IMPRESTRAINEREXPORT SimpleExcludedVolume
387  atom::Hierarchies const &mhs)
388  );
389  public:
390 
391  core::ExcludedVolumeRestraint *get_restraint()
392  {
393  return excluded_volume_restraint_;
394  }
395 
396  base::VersionInfo get_version_info() const
397  {
398  return base::VersionInfo("restrainer",
399  get_module_version());
400  }
401 
402  void show(std::ostream &out = std::cout) const
403  {
404  out << "SimpleExcludedVolume(";
405  if ( excluded_volume_restraint_ )
406  excluded_volume_restraint_->show(out);
407  out << ")";
408  }
409 
410 private:
411  // prevent unauthorized creation
413  core::ExcludedVolumeRestraint *excluded_volume_restraint)
414  : excluded_volume_restraint_(excluded_volume_restraint)
415  {}
416 
417  base::Pointer<core::ExcludedVolumeRestraint> excluded_volume_restraint_;
418 };
420 
421 //! Simple EM fit restraint.
422 /**
423  \note SimpleEMFit stores pointer to FitRestraint.
424  \see FitRestraint
425  */
426 class IMPRESTRAINEREXPORT SimpleEMFit
427 {
428  IMP_NO_SWIG(friend IMPRESTRAINEREXPORT SimpleEMFit create_simple_em_fit(
429  atom::Hierarchies const &mhs, em::DensityMap *dmap));
430 public:
431  em::FitRestraint *get_restraint()
432  {
433  return fit_restraint_;
434  }
435 
436  base::VersionInfo get_version_info() const
437  {
438  return base::VersionInfo("restrainer",
439  get_module_version());
440  }
441 
442  void show(std::ostream &out = std::cout) const
443  {
444  out << "SimpleEMFit(";
445  if ( fit_restraint_ )
446  fit_restraint_->show(out);
447  out << ")";
448  }
449 
450 private:
451  // prevent unauthorized creation
452  SimpleEMFit(
453  em::FitRestraint *fit_restraint)
454  : fit_restraint_(fit_restraint)
455  {}
456 
457  base::Pointer<em::FitRestraint> fit_restraint_;
458 };
460 
461 IMPRESTRAINER_END_NAMESPACE
462 
463 #endif /* IMPRESTRAINER_SIMPLIFY_RESTRAINT_H */
SimpleDiameter create_simple_diameter(const kernel::Particles &ps, Float diameter)
Calculate score based on fit to EM map.
Import IMP/kernel/SingletonContainer.h in the namespace.
void set_k(Float k)
Set the spring constant for the HarmonicUpperBound.
Upper bound harmonic function (non-zero when feature &gt; mean)
void set_k(Float k)
Set the spring constant for the HarmonicUpperBound.
void set_mean(Float mean)
Set the mean for the HarmonicUpperBound.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
A score on the distance between the surfaces of two spheres.
Distance restraint between two particles.
SimpleEMFit create_simple_em_fit(atom::Hierarchies const &mhs, em::DensityMap *dmap)
void set_mean(Float mean)
Set the mean for the HarmonicUpperBound.
Class for handling density maps.
Class for handling density maps.
Definition: DensityMap.h:98
void set_standard_deviation(Float sd)
Set the standard deviation for the HarmonicUpperBound.
SimpleExcludedVolume create_simple_excluded_volume_on_molecules(const atom::Hierarchies &mhs)
void set_k(Float k)
Set the spring constant for the HarmonicUpperBound.
IMP::kernel::Refiner Refiner
functionality for defining rigid bodies
Version and authorship of IMP objects.
Restrain the diameter of a set of points.
Simple connectivity restraint.
SimpleConnectivity create_simple_connectivity_on_rigid_bodies(const core::RigidBodies &rbs, Refiner *ref=IMP::core::internal::get_rigid_members_refiner())
#define IMP_NO_SWIG(x)
Hide the line when SWIG is compiled or parses it.
void set_standard_deviation(Float sd)
Set the standard deviation for the HarmonicUpperBound.
SimpleConnectivity create_simple_connectivity_on_molecules(const atom::Hierarchies &mhs)
Ensure that a set of particles remains connected with one another.
Simple EM fit restraint.
Simple distance restraint between two particles.
void set_mean(Float mean)
Set the mean for the HarmonicUpperBound.
Calculate score based on fit to EM map.
Definition: FitRestraint.h:31
Version and module information for Objects.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
core::RigidBodies set_rigid_bodies(atom::Hierarchies const &mhs)
SimpleDistance create_simple_distance(const kernel::Particles &ps)
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
Prevent a set of particles and rigid bodies from inter-penetrating.
Simple diameter restraint.
em::DensityMap * load_em_density_map(char const *map_fn, float spacing, float resolution)
SimpleExcludedVolume create_simple_excluded_volume_on_rigid_bodies(const core::RigidBodies &rbs, Refiner *ref=IMP::core::internal::get_rigid_members_refiner())
Simple excluded volume restraint.
Abstract class to implement hierarchical methods.
void set_standard_deviation(Float sd)
Set the standard deviation for the HarmonicUpperBound.