IMP  2.4.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-2015 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())
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 where altered previously.
37 
38  \see KinematicForest
39  \see Joint
40  */
41 class IMPKINEMATICSEXPORT KinematicForestScoreState : public IMP::ScoreState {
42  public:
44 
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_;
65 };
66 
67 IMPKINEMATICS_END_NAMESPACE
68 
69 #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_FAILURE(message)
A runtime failure for IMP.
Definition: check_macros.h:74
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
ScoreStates maintain invariants in the Model.
Various general useful macros for IMP.
#define IMP_UNUSED(variable)
IMP::kernel::Model Model
functionality for defining rigid bodies
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
virtual ModelObjectsTemp do_get_outputs() const =0