IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
KinematicForestScoreState.h
Go to the documentation of this file.
1 /**
2  \file IMP/kinematics/KinematicForestScoreState.h
3  \brief
4 
5  \authors Dina Schneidman, Barak Raveh
6  Copyright 2007-2022 IMP Inventors. All rights reserved.
7  */
8 
9 #ifndef IMPKINEMATICS_KINEMATIC_FOREST_SCORE_STATE_H
10 #define IMPKINEMATICS_KINEMATIC_FOREST_SCORE_STATE_H
11 
12 #include <IMP/kinematics/kinematics_config.h>
13 #include <IMP/ScoreState.h>
14 #include <IMP/warning_macros.h>
15 #include <IMP/core/rigid_bodies.h>
17 
18 IMPKINEMATICS_BEGIN_NAMESPACE
19 
20 namespace {
21 Model *extract_model(const IMP::core::RigidBodies &rbs,
22  const IMP::ParticlesTemp &atoms) {
23  if (!rbs.empty())
24  return rbs[0].get_model();
25  else if (!atoms.empty())
26  return atoms[0]->get_model();
27  else {
28  IMP_FAILURE("No particles passed to KinematicForestScoreState");
29  }
30 }
31 }
32 
33 /**
34  A score state that uses a KinematicForest of the model to update
35  external coordinates before energy evaluation, if internal coordinates
36  in the forest were altered previously.
37 
38  \see KinematicForest
39  \see Joint
40  */
41 class IMPKINEMATICSEXPORT KinematicForestScoreState : public IMP::ScoreState {
42  public:
44 
46  IMP::ParticlesTemp atoms)
47  : ScoreState(extract_model(rbs, atoms), "KinematicForestScoreState%1%"),
48  kf_(kf),
49  rbs_(rbs),
50  atoms_(atoms) {}
51 
52  // functions that ScoreState requires
53  void do_before_evaluate() override {
54  kf_->update_all_external_coordinates();
55  }
56 
58  IMP_UNUSED(da);
59  }
60 
61  ModelObjectsTemp do_get_inputs() const override;
62 
63  ModelObjectsTemp do_get_outputs() const override;
64 
65  private:
66  KinematicForest *kf_;
68  IMP::ParticlesTemp atoms_;
69 };
70 
71 IMPKINEMATICS_END_NAMESPACE
72 
73 #endif /* IMPKINEMATICS_KINEMATIC_FOREST_SCORE_STATE_H */
#define IMP_FAILURE(message)
A runtime failure for IMP.
Definition: check_macros.h:72
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
void do_before_evaluate() override
Update the state given the current state of the model.
Macros to control compiler warnings.
#define IMP_UNUSED(variable)
ScoreStates maintain invariants in the Model.
Definition: ScoreState.h:56
functionality for defining rigid bodies
Shared score state.
virtual ModelObjectsTemp do_get_outputs() const =0
Define and manipulate a kinematic structure over a model.
void do_after_evaluate(DerivativeAccumulator *da) override
Do any necessary updates after the model score is calculated.
Define and manipulate a kinematic structure over a model.
virtual ModelObjectsTemp do_get_inputs() const =0
Class for adding derivatives from restraints to the model.