IMP  2.1.1
The Integrative Modeling Platform
KinematicForestScoreState.h
Go to the documentation of this file.
1 /**
2  \file kinematics/KinematicForestScoreState.h
3  \brief
4 
5  \authors Dina Schneidman, Barak Raveh
6  Copyright 2007-2013 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>
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::kernel::ParticlesTemp& atoms) {
23  if (!rbs.empty()) return rbs[0].get_model();
24  else if (!atoms.empty()) return atoms[0]->get_model();
25  else {
26  IMP_FAILURE("No particles passed to KinematicForestScoreState");
27  }
28 }
29 }
30 
31 /**
32  A score state that uses a KinematicForest of the model to update
33  external coordinates before energy evaluation, if internal coordinates
34  in the forest where altered previously.
35 
36  \see KinematicForest
37  \see Joint
38  */
39 class IMPKINEMATICSEXPORT KinematicForestScoreState : public IMP::ScoreState {
40  public:
41 
43 
47  ScoreState(extract_model(rbs, atoms),
48  "KinematicForestScoreState%1%"),
49  kf_(kf), rbs_(rbs), atoms_(atoms) {}
50 
51  // functions that ScoreState requires
52  void do_before_evaluate() {
53  kf_->update_all_external_coordinates();
54  }
55 
56  void do_after_evaluate(DerivativeAccumulator *da) { IMP_UNUSED(da); }
57 
59 
61 
62  private:
63  KinematicForest *kf_;
66 };
67 
68 IMPKINEMATICS_END_NAMESPACE
69 
70 #endif /* IMPKINEMATICS_KINEMATIC_FOREST_SCORE_STATE_H */
Class for adding derivatives from restraints to the model.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
#define IMP_UNUSED(variable)
ScoreStates maintian invariants in the Model.
IMP::kernel::Model Model
functionality for defining rigid bodies
Various general useful macros for IMP.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Import IMP/kernel/ScoreState.h in the namespace.
Wrapper class for a kinematic forest (collection of trees) made of KinematicNode objects, interconnected by joints. This data structure allows for kinematic control of the tree and interconversion between internal and external coordinates.
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_FAILURE(message)
A runtime failure for IMP.
virtual ModelObjectsTemp do_get_outputs() const =0