IMP logo
IMP Reference Guide  2.8.0
The Integrative Modeling Platform
PredicateQuadsRestraint.h
Go to the documentation of this file.
1 // Autogenerated by ../../../../tmp/nightly-build-97111/imp-2.8.0/tools/build/make_containers.py
2 // from ../../../../tmp/nightly-build-97111/imp-2.8.0/tools/build/container_templates/container/PredicateClassnamesRestraint.h
3 // Do not edit - any changes will be lost!
4 
5 /**
6  * \file IMP/container/PredicateQuadsRestraint.h
7  * \brief Apply a QuadScore to each Quad in a list.
8  *
9  * Copyright 2007-2017 IMP Inventors. All rights reserved.
10  *
11  */
12 
13 #ifndef IMPCONTAINER_PREDICATE_QUADS_RESTRAINT_H
14 #define IMPCONTAINER_PREDICATE_QUADS_RESTRAINT_H
15 
16 #include <IMP/container/container_config.h>
17 #include <boost/unordered_map.hpp>
18 #include <IMP/QuadPredicate.h>
19 #include "generic.h"
20 
21 #include <iostream>
22 
23 IMPCONTAINER_BEGIN_NAMESPACE
24 
25 //! Applies a QuadScore to each Quad in a list based on a predicate
26 /** This restraint uses a passed predicate to choose which score to apply
27  to each tuple in the input container. The selections are cached, making it
28  substantially faster than using a core::TypedPairScore.
29 
30  \note The ordering of particles within a tuple may vary depending on the
31  input container used. You may need to call set_score() with several
32  different predicate values for different orderings.
33 */
34 class IMPCONTAINEREXPORT PredicateQuadsRestraint : public Restraint {
37  mutable boost::unordered_map<int, ParticleIndexQuads> lists_;
38  boost::unordered_map<int, PointerMember<QuadScore> > scores_;
39  mutable std::size_t input_version_;
40  bool is_unknown_score_set_;
41  bool error_on_unknown_;
42  void update_lists_if_necessary() const;
43 
44  public:
47  std::string name =
48  "PredicateQuadsRestraint %1%");
49 
50  /** Apply the passed score to all pairs whose predicate values match
51  the passed value.*/
52  void set_score(int predicate_value, QuadScore *score);
53 
54  /** Apply this score to any pair whose predicate value does not match
55  one passed to set_score().*/
56  void set_unknown_score(QuadScore *score);
57 
58  /** By default, it is an error if the predicate returns a value that is
59  not known. If this is false, then they are silently skipped.
60  */
61  void set_is_complete(bool tf) { error_on_unknown_ = tf; }
62 
63  /** return the indexes of all particles for a given predicate value.*/
64  ParticleIndexQuads get_indexes(int predicate_value) const {
65  return lists_.find(predicate_value)->second;
66  }
67 
68  public:
73 
74  private:
75  Restraints do_create_current_decomposition() const;
76 };
77 
78 IMPCONTAINER_END_NAMESPACE
79 
80 #endif /* IMPCONTAINER_PREDICATE_QUADS_RESTRAINT_H */
Define QuadPredicate.
Abstract predicate function.
Definition: QuadPredicate.h:31
Various important functionality for implementing decorators.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual void do_add_score_and_derivatives(ScoreAccumulator sa) const
A restraint should override this to compute the score and derivatives.
Applies a QuadScore to each Quad in a list based on a predicate.
Abstract class for scoring object(s) of type ParticleIndexQuad.
Definition: QuadScore.h:37
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
Class for adding up scores during ScoringFunction evaluation.
ParticleIndexQuads get_indexes(int predicate_value) const
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:52