IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
ProteinLocalizationRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/npc/ProteinLocalizationRestraint.h
3  * \brief protein localization restraints
4  *
5  * Restrict max distance between at least one pair of particles of any
6  * two distinct types. It also handles multiple copies of the same particles.
7  *
8  * Copyright 2007-2022 IMP Inventors. All rights reserved.
9  *
10  */
11 
12 #ifndef IMPNPC_PROTEIN_LOCALIZATION_RESTRAINT_H
13 #define IMPNPC_PROTEIN_LOCALIZATION_RESTRAINT_H
14 
15 #include <IMP/Pointer.h>
16 #include <IMP/Restraint.h>
17 #include <IMP/npc/npc_config.h>
18 #include <IMP/SingletonContainer.h>
19 #include <cereal/access.hpp>
20 #include <cereal/types/base_class.hpp>
21 
22 IMPNPC_BEGIN_NAMESPACE
23 
24 //! Restrain particles by their z coordinate
25 /** Each particle's z coordinate is harmonically restrained to lie between
26  the given lower and upper bounds.
27  */
28 class IMPNPCEXPORT ZAxialPositionRestraint : public Restraint
29 {
31  double lower_bound_;
32  double upper_bound_;
33  double sigma_;
34  bool consider_radius_;
35 
36  friend class cereal::access;
37  template<class Archive> void serialize(Archive &ar) {
38  ar(cereal::base_class<Restraint>(this),
39  sc_, lower_bound_, upper_bound_, sigma_, consider_radius_);
40  }
42 
43 public:
45  double lower_bound, double upper_bound, bool consider_radius, double sigma=1);
47  double lower_bound, double upper_bound, bool consider_radius, double sigma=1);
49 
50 #ifndef IMP_DOXYGEN
51  void add_particle(Particle *p);
52  void add_particles(const ParticlesTemp &ps);
53  void set_particles(const ParticlesTemp &ps);
54 #endif
55 
56  double unprotected_evaluate(
57  IMP::DerivativeAccumulator *accum) const override;
58  ModelObjectsTemp do_get_inputs() const override;
59 
60  //! \return Information for writing to RMF files
61  RestraintInfo *get_static_info() const override;
62 
64 };
65 
66 //! Restrain particles by their z coordinate
67 /** Each particle's z coordinate is harmonically restrained to lie above
68  the given lower bound.
69  */
70 class IMPNPCEXPORT ZAxialPositionLowerRestraint : public Restraint
71 {
73  double lower_bound_;
74  double sigma_;
75  bool consider_radius_;
76 
77  friend class cereal::access;
78  template<class Archive> void serialize(Archive &ar) {
79  ar(cereal::base_class<Restraint>(this),
80  sc_, lower_bound_, sigma_, consider_radius_);
81  }
83 
84 public:
86  double lower_bound, bool consider_radius, double sigma=1);
88  double lower_bound, bool consider_radius, double sigma=1);
90 
91 #ifndef IMP_DOXYGEN
92  void add_particle(Particle *p);
93  void add_particles(const ParticlesTemp &ps);
94  void set_particles(const ParticlesTemp &ps);
95 #endif
96 
97  double unprotected_evaluate(
98  IMP::DerivativeAccumulator *accum) const override;
99  ModelObjectsTemp do_get_inputs() const override;
100 
101  //! \return Information for writing to RMF files
102  RestraintInfo *get_static_info() const override;
103 
105 };
106 
107 //! Restrain particles by their z coordinate
108 /** Each particle's z coordinate is harmonically restrained to lie below
109  the given upper bound.
110  */
111 class IMPNPCEXPORT ZAxialPositionUpperRestraint : public Restraint
112 {
114  double upper_bound_;
115  double sigma_;
116  bool consider_radius_;
117 
118  friend class cereal::access;
119  template<class Archive> void serialize(Archive &ar) {
120  ar(cereal::base_class<Restraint>(this),
121  sc_, upper_bound_, sigma_, consider_radius_);
122  }
124 
125 public:
127  double upper_bound, bool consider_radius, double sigma=1);
129  double upper_bound, bool consider_radius, double sigma=1);
131 
132 #ifndef IMP_DOXYGEN
133  void add_particle(Particle *p);
134  void add_particles(const ParticlesTemp &ps);
135  void set_particles(const ParticlesTemp &ps);
136 #endif
137 
138  double unprotected_evaluate(
139  IMP::DerivativeAccumulator *accum) const override;
140  ModelObjectsTemp do_get_inputs() const override;
141 
142  //! \return Information for writing to RMF files
143  RestraintInfo *get_static_info() const override;
144 
146 };
147 
148 
149 //! Restrain particles by their y coordinate
150 /** Each particle's y coordinate is harmonically restrained to lie between
151  the given lower and upper bounds.
152  */
153 class IMPNPCEXPORT YAxialPositionRestraint : public Restraint
154 {
156  double lower_bound_;
157  double upper_bound_;
158  double sigma_;
159  bool consider_radius_;
160 
161  friend class cereal::access;
162  template<class Archive> void serialize(Archive &ar) {
163  ar(cereal::base_class<Restraint>(this),
164  sc_, lower_bound_, upper_bound_, sigma_, consider_radius_);
165  }
167 
168 public:
170  double lower_bound, double upper_bound, bool consider_radius, double sigma=1);
172  double lower_bound, double upper_bound, bool consider_radius, double sigma=1);
174 
175 #ifndef IMP_DOXYGEN
176  void add_particle(Particle *p);
177  void add_particles(const ParticlesTemp &ps);
178  void set_particles(const ParticlesTemp &ps);
179 #endif
180 
181  double unprotected_evaluate(
182  IMP::DerivativeAccumulator *accum) const override;
183  ModelObjectsTemp do_get_inputs() const override;
184 
185  //! \return Information for writing to RMF files
186  RestraintInfo *get_static_info() const override;
187 
189 };
190 
191 //! Restrain particles by their y coordinate
192 /** Each particle's y coordinate is harmonically restrained to lie above
193  the given lower bound.
194  */
195 class IMPNPCEXPORT YAxialPositionLowerRestraint : public Restraint
196 {
198  double lower_bound_;
199  double sigma_;
200  bool consider_radius_;
201 
202  friend class cereal::access;
203  template<class Archive> void serialize(Archive &ar) {
204  ar(cereal::base_class<Restraint>(this),
205  sc_, lower_bound_, sigma_, consider_radius_);
206  }
208 
209 public:
211  double lower_bound, bool consider_radius, double sigma=1);
213  double lower_bound, bool consider_radius, double sigma=1);
215 
216 #ifndef IMP_DOXYGEN
217  void add_particle(Particle *p);
218  void add_particles(const ParticlesTemp &ps);
219  void set_particles(const ParticlesTemp &ps);
220 #endif
221 
222  double unprotected_evaluate(
223  IMP::DerivativeAccumulator *accum) const override;
224  ModelObjectsTemp do_get_inputs() const override;
225 
226  //! \return Information for writing to RMF files
227  RestraintInfo *get_static_info() const override;
228 
230 };
231 
232 //! Restrain particles by their y coordinate
233 /** Each particle's y coordinate is harmonically restrained to lie below
234  the given upper bound.
235  */
236 class IMPNPCEXPORT YAxialPositionUpperRestraint : public Restraint
237 {
239  double upper_bound_;
240  double sigma_;
241  bool consider_radius_;
242 
243  friend class cereal::access;
244  template<class Archive> void serialize(Archive &ar) {
245  ar(cereal::base_class<Restraint>(this),
246  sc_, upper_bound_, sigma_, consider_radius_);
247  }
249 
250 public:
252  double upper_bound, bool consider_radius, double sigma=1);
254  double upper_bound, bool consider_radius, double sigma=1);
256 
257 #ifndef IMP_DOXYGEN
258  void add_particle(Particle *p);
259  void add_particles(const ParticlesTemp &ps);
260  void set_particles(const ParticlesTemp &ps);
261 #endif
262 
263  double unprotected_evaluate(
264  IMP::DerivativeAccumulator *accum) const override;
265  ModelObjectsTemp do_get_inputs() const override;
266 
267  //! \return Information for writing to RMF files
268  RestraintInfo *get_static_info() const override;
269 
271 };
272 
273 
274 //! Restrain particles by their distance from the z axis in the xy plane
275 /** Each particle's distance to the z axis is harmonically restrained to
276  lie between the given lower and upper bounds.
277  */
278 class IMPNPCEXPORT XYRadialPositionRestraint : public Restraint
279 {
281  double lower_bound_;
282  double upper_bound_;
283  double sigma_;
284  bool consider_radius_;
285 
286  friend class cereal::access;
287  template<class Archive> void serialize(Archive &ar) {
288  ar(cereal::base_class<Restraint>(this),
289  sc_, lower_bound_, upper_bound_, sigma_, consider_radius_);
290  }
292 
293 public:
295  double lower_bound, double upper_bound, bool consider_radius, double sigma=1);
297  double lower_bound, double upper_bound, bool consider_radius, double sigma=1);
299 
300 #ifndef IMP_DOXYGEN
301  void add_particle(Particle *p);
302  void add_particles(const ParticlesTemp &ps);
303  void set_particles(const ParticlesTemp &ps);
304 #endif
305 
306  double unprotected_evaluate(
307  IMP::DerivativeAccumulator *accum) const override;
308  ModelObjectsTemp do_get_inputs() const override;
309 
310  //! \return Information for writing to RMF files
311  RestraintInfo *get_static_info() const override;
312 
314 };
315 
316 //! Restrain particles by their distance from the z axis in the xy plane
317 /** Each particle's distance to the z axis is harmonically restrained to
318  lie above the given lower bound.
319  */
320 class IMPNPCEXPORT XYRadialPositionLowerRestraint : public Restraint
321 {
323  double lower_bound_;
324  double sigma_;
325  bool consider_radius_;
326 
327  friend class cereal::access;
328  template<class Archive> void serialize(Archive &ar) {
329  ar(cereal::base_class<Restraint>(this),
330  sc_, lower_bound_, sigma_, consider_radius_);
331  }
333 
334 public:
336  double lower_bound, bool consider_radius, double sigma=1);
338  double lower_bound, bool consider_radius, double sigma=1);
340 
341 #ifndef IMP_DOXYGEN
342  void add_particle(Particle *p);
343  void add_particles(const ParticlesTemp &ps);
344  void set_particles(const ParticlesTemp &ps);
345 #endif
346 
347  double unprotected_evaluate(
348  IMP::DerivativeAccumulator *accum) const override;
349  ModelObjectsTemp do_get_inputs() const override;
350 
351  //! \return Information for writing to RMF files
352  RestraintInfo *get_static_info() const override;
353 
355 };
356 
357 //! Restrain particles by their distance from the z axis in the xy plane
358 /** Each particle's distance to the z axis is harmonically restrained to
359  lie below the given upper bound.
360  */
361 class IMPNPCEXPORT XYRadialPositionUpperRestraint : public Restraint
362 {
364  double upper_bound_;
365  double sigma_;
366  bool consider_radius_;
367 
368  friend class cereal::access;
369  template<class Archive> void serialize(Archive &ar) {
370  ar(cereal::base_class<Restraint>(this),
371  sc_, upper_bound_, sigma_, consider_radius_);
372  }
374 
375 public:
377  double upper_bound, bool consider_radius, double sigma=1);
379  double upper_bound, bool consider_radius, double sigma=1);
381 
382 #ifndef IMP_DOXYGEN
383  void add_particle(Particle *p);
384  void add_particles(const ParticlesTemp &ps);
385  void set_particles(const ParticlesTemp &ps);
386 #endif
387 
388  double unprotected_evaluate(
389  IMP::DerivativeAccumulator *accum) const override;
390  ModelObjectsTemp do_get_inputs() const override;
391 
392  //! \return Information for writing to RMF files
393  RestraintInfo *get_static_info() const override;
394 
396 };
397 
398 
399 //! Try to keep all particle surfaces in contact
400 /** The particles (each of which should be a core::XYZR) are harmonically
401  restrained such that each particle's sphere surface is in contact
402  with every other surface.
403  */
404 class IMPNPCEXPORT ProteinContactRestraint : public Restraint
405 {
407  double tolerance_factor_;
408  double sigma_;
409 
410  friend class cereal::access;
411  template<class Archive> void serialize(Archive &ar) {
412  ar(cereal::base_class<Restraint>(this), sc_, tolerance_factor_, sigma_);
413  }
415 
416 public:
418  double tolerance_factor, double sigma=0.1);
420  double tolerance_factor, double sigma=0.1);
422 
423 #ifndef IMP_DOXYGEN
424  void add_particle(Particle *p);
425  void add_particles(const ParticlesTemp &ps);
426  void set_particles(const ParticlesTemp &ps);
427 #endif
428 
429  double unprotected_evaluate(
430  IMP::DerivativeAccumulator *accum) const override;
431  ModelObjectsTemp do_get_inputs() const override;
432 
434 };
435 
436 
437 //! Try to keep particle surfaces in contact in a chain
438 /** The particles (each of which should be a core::XYZR) are harmonically
439  restrained such that each particle's sphere surface is in contact
440  with the surface of the previous particle.
441  */
442 class IMPNPCEXPORT ProteinChainRestraint : public Restraint
443 {
445  double sigma_;
446 
447  friend class cereal::access;
448  template<class Archive> void serialize(Archive &ar) {
449  ar(cereal::base_class<Restraint>(this), sc_, sigma_);
450  }
452 
453 public:
455  double sigma=0.1);
457  double sigma=0.1);
459 
460 #ifndef IMP_DOXYGEN
461  void add_particle(Particle *p);
462  void add_particles(const ParticlesTemp &ps);
463  void set_particles(const ParticlesTemp &ps);
464 #endif
465 
466  double unprotected_evaluate(
467  IMP::DerivativeAccumulator *accum) const override;
468  ModelObjectsTemp do_get_inputs() const override;
469 
471 };
472 
473 
474 //! Try to keep particles localized on a membrane surface
475 /** The membrane is defined in this case to be a half torus in the xy
476  plane with center at the origin.
477  */
478 class IMPNPCEXPORT MembraneSurfaceLocationRestraint : public Restraint
479 {
481  double R_;
482  double r_;
483  double sigma_;
484  double thickness_;
485 
486  friend class cereal::access;
487  template<class Archive> void serialize(Archive &ar) {
488  ar(cereal::base_class<Restraint>(this), sc_, R_, r_, sigma_, thickness_);
489  }
491 
492 public:
494  double R, double r, double thickness, double sigma=2);
496  double R, double r, double thickness, double sigma=2);
498 
499 #ifndef IMP_DOXYGEN
500  void add_particle(Particle *p);
501  void add_particles(const ParticlesTemp &ps);
502  void set_particles(const ParticlesTemp &ps);
503 #endif
504 
505  double unprotected_evaluate(
506  IMP::DerivativeAccumulator *accum) const override;
507  ModelObjectsTemp do_get_inputs() const override;
508 
509  //! \return Information for writing to RMF files
510  RestraintInfo *get_static_info() const override;
511 
513 };
514 
515 
516 //! Try to keep one set of particles localized on a membrane surface
517 /** The membrane is defined in this case to be a half torus in the xy
518  plane with center at the origin. One of the two sets of particles
519  (whichever is closer) is restrained to the membrane surface.
520  */
522 {
525  double R_;
526  double r_;
527  double sigma_;
528  double thickness_;
529 
530  friend class cereal::access;
531  template<class Archive> void serialize(Archive &ar) {
532  ar(cereal::base_class<Restraint>(this),
533  sc1_, sc2_, R_, r_, sigma_, thickness_);
534  }
536 
537 public:
539  double R, double r, double thickness, double sigma=2);
541  double R, double r, double thickness, double sigma=2);
543 
544 #ifndef IMP_DOXYGEN
545  void add_particle1(Particle *p);
546  void add_particle2(Particle *p);
547  void add_particles1(const ParticlesTemp &ps);
548  void add_particles2(const ParticlesTemp &ps);
549  void set_particles1(const ParticlesTemp &ps);
550  void set_particles2(const ParticlesTemp &ps);
551 #endif
552 
553  double unprotected_evaluate(
554  IMP::DerivativeAccumulator *accum) const override;
555  ModelObjectsTemp do_get_inputs() const override;
556 
557  //! \return Information for writing to RMF files
558  RestraintInfo *get_static_info() const override;
559 
561 };
562 
563 
564 //! Try to keep particles away from a membrane
565 /** The membrane is defined in this case to be a half torus in the xy
566  plane with center at the origin.
567  */
568 class IMPNPCEXPORT MembraneExclusionRestraint : public Restraint
569 {
571  double R_;
572  double r_;
573  double sigma_;
574  double thickness_;
575 
576  friend class cereal::access;
577  template<class Archive> void serialize(Archive &ar) {
578  ar(cereal::base_class<Restraint>(this), sc_, R_, r_, sigma_, thickness_);
579  }
581 
582 public:
584  double R, double r, double thickness, double sigma=2);
586  double R, double r, double thickness, double sigma=2);
588 
589 #ifndef IMP_DOXYGEN
590  void add_particle(Particle *p);
591  void add_particles(const ParticlesTemp &ps);
592  void set_particles(const ParticlesTemp &ps);
593 #endif
594 
595  double unprotected_evaluate(
596  IMP::DerivativeAccumulator *accum) const override;
597  ModelObjectsTemp do_get_inputs() const override;
598 
599  //! \return Information for writing to RMF files
600  RestraintInfo *get_static_info() const override;
601 
603 };
604 
605 
606 //! Try to keep particles on the pore side of a membrane
607 /** The membrane is defined in this case to be a half torus in the xy
608  plane with center at the origin.
609  */
610 class IMPNPCEXPORT PoreSideVolumeLocationRestraint : public Restraint
611 {
613  double R_;
614  double r_;
615  double sigma_;
616  double thickness_;
617  bool consider_radius_;
618 
619  friend class cereal::access;
620  template<class Archive> void serialize(Archive &ar) {
621  ar(cereal::base_class<Restraint>(this),
622  sc_, R_, r_, sigma_, thickness_, consider_radius_);
623  }
625 
626 public:
628  double R, double r, double thickness, bool consider_radius, double sigma=2);
630  double R, double r, double thickness, bool consider_radius, double sigma=2);
632 
633 #ifndef IMP_DOXYGEN
634  void add_particle(Particle *p);
635  void add_particles(const ParticlesTemp &ps);
636  void set_particles(const ParticlesTemp &ps);
637 #endif
638 
639  double unprotected_evaluate(
640  IMP::DerivativeAccumulator *accum) const override;
641  ModelObjectsTemp do_get_inputs() const override;
642 
644 };
645 
646 
647 //! Try to keep particles on the perinuclear side of a membrane
648 /** The membrane is defined in this case to be a half torus in the xy
649  plane with center at the origin.
650  */
652 {
654  double R_;
655  double r_;
656  double sigma_;
657  double thickness_;
658  bool consider_radius_;
659 
660  friend class cereal::access;
661  template<class Archive> void serialize(Archive &ar) {
662  ar(cereal::base_class<Restraint>(this),
663  sc_, R_, r_, sigma_, thickness_, consider_radius_);
664  }
666 
667 public:
669  double R, double r, double thickness, bool consider_radius, double sigma=2);
671  double R, double r, double thickness, bool consider_radius, double sigma=2);
673 
674 #ifndef IMP_DOXYGEN
675  void add_particle(Particle *p);
676  void add_particles(const ParticlesTemp &ps);
677  void set_particles(const ParticlesTemp &ps);
678 #endif
679 
680  double unprotected_evaluate(
681  IMP::DerivativeAccumulator *accum) const override;
682  ModelObjectsTemp do_get_inputs() const override;
683 
685 };
686 
687 
688 //! Restrain two interparticle distances to be the same
689 /** This restraint must be given 4 particles. They are restrained to
690  be symmetric, by enforcing a harmonic penalty on the difference
691  between the distance between the first 2 particles and the distance
692  between the last two.
693  */
695 {
697  double sigma_;
698 
699  friend class cereal::access;
700  template<class Archive> void serialize(Archive &ar) {
701  ar(cereal::base_class<Restraint>(this), sc_, sigma_);
702  }
704 
705 public:
707  double sigma=4);
709  double sigma=4);
711 
712 #ifndef IMP_DOXYGEN
713  void add_particle(Particle *p);
714  void add_particles(const ParticlesTemp &ps);
715  void set_particles(const ParticlesTemp &ps);
716 #endif
717 
718  double unprotected_evaluate(
719  IMP::DerivativeAccumulator *accum) const override;
720  ModelObjectsTemp do_get_inputs() const override;
721 
723 };
724 
725 
726 //! Restrain two interparticle dihedrals to be the same
727 /** This restraint must be given 8 particles. They are restrained to
728  be symmetric, by enforcing a harmonic penalty on the difference
729  between the dihedral angle between the first 4 particles and the dihedral
730  between the last 4.
731  */
733  : public Restraint
734 {
736  double sigma_;
737 
738  friend class cereal::access;
739  template<class Archive> void serialize(Archive &ar) {
740  ar(cereal::base_class<Restraint>(this), sc_, sigma_);
741  }
743 
744 public:
746  double sigma=0.1);
748  double sigma=0.1);
750 
751 #ifndef IMP_DOXYGEN
752  void add_particle(Particle *p);
753  void add_particles(const ParticlesTemp &ps);
754  void set_particles(const ParticlesTemp &ps);
755 #endif
756 
757  double unprotected_evaluate(
758  IMP::DerivativeAccumulator *accum) const override;
759  ModelObjectsTemp do_get_inputs() const override;
760 
762 };
763 
764 //! Restrain a set of particles to be proximate to each other
765 /** Each particle is harmonically restrained to be no more than
766  `max_dist` away from every other particle.
767  */
768 class IMPNPCEXPORT ProteinProximityRestraint
769  : public Restraint
770 {
772  double sigma_;
773  double max_dist_;
774 
775  friend class cereal::access;
776  template<class Archive> void serialize(Archive &ar) {
777  ar(cereal::base_class<Restraint>(this), sc_, sigma_, max_dist_);
778  }
780 
781 public:
783  double max_dist, double sigma=0.1);
785  double max_dist, double sigma=0.1);
787 
788 #ifndef IMP_DOXYGEN
789  void add_particle(Particle *p);
790  void add_particles(const ParticlesTemp &ps);
791  void set_particles(const ParticlesTemp &ps);
792 #endif
793 
794  double unprotected_evaluate(
795  IMP::DerivativeAccumulator *accum) const override;
796  ModelObjectsTemp do_get_inputs() const override;
797 
799 };
800 
801 
802 
803 IMPNPC_END_NAMESPACE
804 
805 #endif /* IMPNPC_PROTEIN_LOCALIZATION_RESTRAINT_H */
Try to keep particles on the perinuclear side of a membrane.
Restrain particles by their z coordinate.
void add_particles(RMF::FileHandle fh, const ParticlesTemp &hs)
virtual RestraintInfo * get_static_info() const
Definition: Restraint.h:178
A container for Singletons.
Restrain two interparticle dihedrals to be the same.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Restrain particles by their y coordinate.
virtual double unprotected_evaluate(DerivativeAccumulator *da) const
Return the unweighted score for the restraint.
Restrain particles by their distance from the z axis in the xy plane.
void add_particle(RMF::FileHandle fh, Particle *hs)
Try to keep particles on the pore side of a membrane.
Try to keep one set of particles localized on a membrane surface.
Restrain particles by their z coordinate.
Restrain two interparticle distances to be the same.
Try to keep all particle surfaces in contact.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Try to keep particles away from a membrane.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
Try to keep particle surfaces in contact in a chain.
Restrain particles by their distance from the z axis in the xy plane.
Report key:value information on restraints.
Definition: RestraintInfo.h:47
Try to keep particles localized on a membrane surface.
A nullptr-initialized pointer to an IMP Object.
Restrain a set of particles to be proximate to each other.
Class to handle individual particles of a Model object.
Definition: Particle.h:43
Abstract base class for all restraints.
Restrain particles by their z coordinate.
Restrain particles by their distance from the z axis in the xy plane.
Restrain particles by their y coordinate.
virtual ModelObjectsTemp do_get_inputs() const =0
Class for adding derivatives from restraints to the model.
Restrain particles by their y coordinate.
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:56