IMP  2.1.1
The Integrative Modeling Platform
ProteinKinematics.h
Go to the documentation of this file.
1 /**
2  * \file kinematics/ProteinKinematics.h
3  * \brief functionality for defining a kinematic forest for proteins
4  *
5  * Copyright 2007-2012 IMP Inventors. All rights reserved.
6  * \authors Dina Schneidman, Barak Raveh
7  *
8  */
9 
10 #ifndef IMPKINEMATICS_PROTEIN_KINEMATICS_H
11 #define IMPKINEMATICS_PROTEIN_KINEMATICS_H
12 
13 #include "kinematics_config.h"
14 
17 
18 #include <IMP/core/rigid_bodies.h>
19 #include <IMP/atom/Atom.h>
20 
21 
22 #include <IMP/base/map.h>
23 #include <IMP/base/Vector.h>
24 #include <vector>
25 #include <iostream>
26 
27 #include <boost/graph/adjacency_list.hpp>
28 #include <boost/graph/undirected_dfs.hpp>
29 
30 IMPKINEMATICS_BEGIN_NAMESPACE
31 
32 typedef boost::adjacency_list <boost::vecS,
33  boost::vecS,
34  boost::undirectedS,
35  boost::no_property,
36  boost::property<boost::edge_color_t, boost::default_color_type> > Graph;
37 
38 /**
39  Defines a kinematic structure over a protein, with backbone
40  and side chain dihedrals
41  */
42 class IMPKINEMATICSEXPORT ProteinKinematics {
43  public:
44  /* Constructors */
45 
46  // all phi/psi rotatable
48  bool flexible_backbone = true,
49  bool flexible_side_chains = false);
50 
51  // only torsions from dihedral_angles list are rotatable
53  const IMP::atom::Residues& flexible_residues,
54  const std::vector<IMP::atom::Atoms>& dihedral_angles,
55  bool flexible_backbone = true,
56  bool flexible_side_chains = false);
57 
58  private:
59 
60  //! the actual construction is done here,
61  //! see constructors for documentation
62  void init( const IMP::atom::Residues& flexible_residues,
63  const std::vector<IMP::atom::Atoms>& dihedral_angles,
64  bool flexible_backbone,
65  bool flexible_side_chains) ;
66 
67  public:
68 
69 
70  /* Access methods */
71 
72  double get_phi(const IMP::atom::Residue r) const {
73  return get_phi_joint(r)->get_angle();
74  }
75 
76  double get_psi(const IMP::atom::Residue r) const {
77  return get_psi_joint(r)->get_angle();
78  }
79 
80  DihedralAngleRevoluteJoints get_joints() { return joints_; }
81 
82  KinematicForest* get_kinematic_forest() { return kf_; }
83  // TODO: not sure if we have to return Pointer or just raw pointer
84 
85  IMP::core::RigidBodies get_rigid_bodies() { return rbs_; }
86 
87 
88  // TODO: add chi
89 
90  /* Modifier methods */
91 
92  void set_phi(const IMP::atom::Residue r, double angle) {
93  get_phi_joint(r)->set_angle(angle);
94  kf_->update_all_external_coordinates();
95  }
96 
97  void set_psi(const IMP::atom::Residue r, double angle) {
98  get_psi_joint(r)->set_angle(angle);
99  kf_->update_all_external_coordinates();
100  }
101 
102  // TODO: add chi
103 
104 
105 private:
106 
107  enum ProteinAngleType { PHI, PSI, CHI1, CHI2, CHI3, CHI4, OTHER, TOTAL };
108 
109  void build_topology_graph();
110 
111  void mark_rotatable_angles(
112  const std::vector<IMP::atom::Atoms>& dihedral_angles);
113 
114  void build_rigid_bodies();
115 
116  void add_dihedral_joints(
117  const std::vector<IMP::atom::Atoms>& dihedral_angles);
118 
119  void add_dihedral_joints(const std::vector<IMP::atom::Residue>& residues,
120  ProteinAngleType angle_type,
121  const std::vector<IMP::atom::Atoms>& dihedral_angles);
122 
123  void add_dihedral_joint(const IMP::atom::Residue r,
124  ProteinAngleType angle_type,
125  const IMP::atom::Atoms& atoms);
126 
127  /* Joint access methods */
128  DihedralAngleRevoluteJoint* get_phi_joint(const IMP::atom::Residue r) const {
129  return (DihedralAngleRevoluteJoint*)joint_map_.get_joint(r, PHI);
130  }
131 
132  DihedralAngleRevoluteJoint* get_psi_joint(const IMP::atom::Residue r) const {
133  return (DihedralAngleRevoluteJoint*)joint_map_.get_joint(r, PSI);
134  }
135 
136  //DihedralAngleRevoluteJoints get_joints(const IMP::atom::Residue r) const;
137 
138 #ifndef IMP_DOXYGEN
139  // A map between residue phi/psi and joints
140  class AngleToJointMap {
141  public:
142  // Joint access
143  Joint* get_joint(const IMP::atom::Residue r,
144  ProteinAngleType angle_type) const;
145 
146  // store Joint
147  void add_joint(const IMP::atom::Residue r,
148  ProteinAngleType angle_type,
149  Joint* joint);
150 
151  private:
152  /* mapping to phi/psi/chi for a specific residue.
153  the joints are stored using ProteinAngleType as an index */
154  typedef std::vector<Joint*> ResidueJoints;
155  /* mapping between residue and its joints */
157  ResidueJoints> residue_to_joints_;
158  };
159 #endif // IMP_DOXYGEN
160 
161  private:
162  // protein hierarchy
164 
165  // atom particles
166  IMP::kernel::ParticlesTemp atom_particles_;
167 
168  // topology graph: nodes = atoms, edges = bonds
169  Graph graph_;
170 
171  // mapping between atom kernel::ParticleIndex and node number in the graph
172  IMP::base::map<IMP::kernel::ParticleIndex, int> particle_index_to_node_map_;
173  IMP::base::Vector<IMP::kernel::ParticleIndex> node_to_particle_index_map_;
174 
175  // rigid bodies
177 
178  // joints
180 
182 
183  // map between residue phi/psi/chis and joints
184  AngleToJointMap joint_map_;
185 };
186 
187 IMPKINEMATICS_END_NAMESPACE
188 
189 #endif /* IMPKINEMATICS_PROTEIN_KINEMATICS_H */
Simple atom decorator.
A smart pointer to a reference counted object.
Definition: base/Pointer.h:87
The standard decorator for manipulating molecular structures.
functionality for defining rigid bodies
A class for storing lists of IMP items.
A decorator for a residue.
Definition: Residue.h:133
base::Index< ParticleIndexTag > ParticleIndex
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.
functionality for defining various revolute kinematic joints between rigid bodies as part of a kinema...
Declare an efficient stl-compatible map.