IMP logo
IMP Reference Guide  2.10.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-2018 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 "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() { kf_->update_all_external_coordinates(); }
54 
55  void do_after_evaluate(DerivativeAccumulator *da) { IMP_UNUSED(da); }
56 
58 
60 
61  private:
62  KinematicForest *kf_;
64  IMP::ParticlesTemp atoms_;
65 };
66 
67 IMPKINEMATICS_END_NAMESPACE
68 
69 #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
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition: base_types.h:82
Various general useful macros for IMP.
#define IMP_UNUSED(variable)
ScoreStates maintain invariants in the Model.
Definition: ScoreState.h:53
functionality for defining rigid bodies
Shared score state.
virtual ModelObjectsTemp do_get_outputs() const =0
Define and manipulate a kinematic structure over a model.
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.