IMP  2.2.1
The Integrative Modeling Platform
PredicateTripletsRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/container/PredicateTripletsRestraint.h
3  * \brief Apply a TripletScore to each Triplet in a list.
4  *
5  * WARNING This file was generated from PredicateTripletsRestraint.h
6  * in /tmp/nightly-build-90828/imp-2.2.1/tools/build/container_templates/container
7  * by tools/maintenance/setup_containers.py.
8  *
9  * Copyright 2007-2014 IMP Inventors. All rights reserved.
10  *
11  */
12 
13 #ifndef IMPCONTAINER_PREDICATE_TRIPLETS_RESTRAINT_H
14 #define IMPCONTAINER_PREDICATE_TRIPLETS_RESTRAINT_H
15 
16 #include <IMP/container/container_config.h>
17 #include <boost/unordered_map.hpp>
18 #include <IMP/TripletPredicate.h>
19 #include "generic.h"
20 
21 #include <iostream>
22 
23 IMPCONTAINER_BEGIN_NAMESPACE
24 
25 //! Applies a TripletScore to each Triplet 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 PredicateTripletsRestraint : public Restraint {
37  mutable boost::unordered_map<int, kernel::ParticleIndexTriplets> lists_;
38  boost::unordered_map<int, base::PointerMember<TripletScore> > scores_;
39  mutable std::size_t input_version_;
40  bool error_on_unknown_;
41  void update_lists_if_necessary() const;
42 
43  public:
45  TripletContainerAdaptor input,
46  std::string name =
47  "PredicateTripletsRestraint %1%");
48 
49  /** Apply the passed score to all pairs whose predicate values match
50  the passed value.*/
51  void set_score(int predicate_value, kernel::TripletScore *score);
52 
53  /** Apply this score to any pair whose predicate value does not match
54  one passed to set_score().*/
55  void set_unknown_score(kernel::TripletScore *score);
56 
57  /** By default, it is an error if the predicate returns a value that is
58  not known. If this is false, then they are silently skipped.
59  */
60  void set_is_complete(bool tf) { error_on_unknown_ = tf; }
61 
62  /** return the indexes of all particles for a given predicate value.*/
63  kernel::ParticleIndexTriplets get_indexes(int predicate_value) const {
64  return lists_.find(predicate_value)->second;
65  }
66 
67  public:
69  IMP_OVERRIDE;
70  IMP::kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
72 
73  private:
74  Restraints do_create_current_decomposition() const;
75 };
76 
77 IMPCONTAINER_END_NAMESPACE
78 
79 #endif /* IMPCONTAINER_PREDICATE_TRIPLETS_RESTRAINT_H */
Applies a TripletScore to each Triplet in a list based on a predicate.
Various important functionality for implementing decorators.
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:147
Import IMP/kernel/TripletPredicate.h in the namespace.
IMP::base::Vector< IMP::base::Pointer< Restraint > > Restraints
virtual void do_add_score_and_derivatives(ScoreAccumulator sa) const
Abstract predicate function.
Class for adding up scores during ScoringFunction evaluation.
A restraint is a term in an IMP ScoringFunction.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
virtual ModelObjectsTemp do_get_inputs() const =0
Abstract score function.
kernel::ParticleIndexTriplets get_indexes(int predicate_value) const