IMP  2.3.0
The Integrative Modeling Platform
ProteinKinematics.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kinematics/ProteinKinematics.h
3  * \brief functionality for defining a kinematic forest for proteins
4  *
5  * Copyright 2007-2014 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 #include <boost/unordered_map.hpp>
22 #include <IMP/base/Vector.h>
23 #include <vector>
24 #include <iostream>
25 
26 #include <boost/graph/adjacency_list.hpp>
27 #include <boost/graph/undirected_dfs.hpp>
28 
29 IMPKINEMATICS_BEGIN_NAMESPACE
30 
31 typedef boost::adjacency_list<
32  boost::vecS, boost::vecS, boost::undirectedS, boost::no_property,
33  boost::property<boost::edge_color_t, boost::default_color_type> > Graph;
34 
35 /**
36  Defines a kinematic structure over a protein, with backbone
37  and side chain dihedrals
38  */
39 class IMPKINEMATICSEXPORT ProteinKinematics {
40  public:
41  /* Constructors */
42 
43  // all phi/psi rotatable
44  ProteinKinematics(IMP::atom::Hierarchy mhd, bool flexible_backbone = true,
45  bool flexible_side_chains = false);
46 
47  // only torsions from dihedral_angles list are rotatable
49  const IMP::atom::Residues& flexible_residues,
50  const std::vector<IMP::atom::Atoms>& dihedral_angles,
51  bool flexible_backbone = true,
52  bool flexible_side_chains = false);
53 
54  private:
55  //! the actual construction is done here,
56  //! see constructors for documentation
57  void init(const IMP::atom::Residues& flexible_residues,
58  const std::vector<IMP::atom::Atoms>& dihedral_angles,
59  bool flexible_backbone, bool flexible_side_chains);
60 
61  public:
62  /* Access methods */
63 
64  double get_phi(const IMP::atom::Residue r) const {
65  return get_phi_joint(r)->get_angle();
66  }
67 
68  double get_psi(const IMP::atom::Residue r) const {
69  return get_psi_joint(r)->get_angle();
70  }
71 
72  DihedralAngleRevoluteJoints get_joints() { return joints_; }
73 
74  DihedralAngleRevoluteJoints get_ordered_joints() {
76  IMP_FOREACH(Joint *j, kf_->get_ordered_joints() ){
77  ret.push_back(dynamic_cast<DihedralAngleRevoluteJoint*>(j));
78  }
79  return ret;
80  }
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  // TODO: add chi
88 
89  /* Modifier methods */
90 
91  void set_phi(const IMP::atom::Residue r, double angle) {
92  get_phi_joint(r)->set_angle(angle);
93  kf_->update_all_external_coordinates();
94  }
95 
96  void set_psi(const IMP::atom::Residue r, double angle) {
97  get_psi_joint(r)->set_angle(angle);
98  kf_->update_all_external_coordinates();
99  }
100 
101  // TODO: add chi
102 
103  private:
104  enum ProteinAngleType {
105  PHI,
106  PSI,
107  CHI1,
108  CHI2,
109  CHI3,
110  CHI4,
111  OTHER,
112  TOTAL
113  };
114 
115  void build_topology_graph();
116 
117  void mark_rotatable_angles(
118  const std::vector<IMP::atom::Atoms>& dihedral_angles);
119 
120  void build_rigid_bodies();
121 
122  void add_dihedral_joints(
123  const std::vector<IMP::atom::Atoms>& dihedral_angles);
124 
125  void add_dihedral_joints(
126  const std::vector<IMP::atom::Residue>& residues,
127  ProteinAngleType angle_type,
128  const std::vector<IMP::atom::Atoms>& dihedral_angles);
129 
130  void add_dihedral_joint(const IMP::atom::Residue r,
131  ProteinAngleType angle_type,
132  const IMP::atom::Atoms& atoms);
133 
134  /* Joint access methods */
135  DihedralAngleRevoluteJoint* get_phi_joint(const IMP::atom::Residue r) const {
136  return (DihedralAngleRevoluteJoint*)joint_map_.get_joint(r, PHI);
137  }
138 
139  DihedralAngleRevoluteJoint* get_psi_joint(const IMP::atom::Residue r) const {
140  return (DihedralAngleRevoluteJoint*)joint_map_.get_joint(r, PSI);
141  }
142 
143 // DihedralAngleRevoluteJoints get_joints(const IMP::atom::Residue r) const;
144 
145 #ifndef IMP_DOXYGEN
146  // A map between residue phi/psi and joints
147  class AngleToJointMap {
148  public:
149  // Joint access
150  Joint* get_joint(const IMP::atom::Residue r,
151  ProteinAngleType angle_type) const;
152 
153  // store Joint
154  void add_joint(const IMP::atom::Residue r, ProteinAngleType angle_type,
155  Joint* joint);
156 
157  private:
158  /* mapping to phi/psi/chi for a specific residue.
159  the joints are stored using ProteinAngleType as an index */
160  typedef std::vector<Joint*> ResidueJoints;
161  /* mapping between residue and its joints */
162  boost::unordered_map<IMP::kernel::ParticleIndex, ResidueJoints>
163  residue_to_joints_;
164  };
165 #endif // IMP_DOXYGEN
166 
167  private:
168  // protein hierarchy
170 
171  // atom particles
172  IMP::kernel::ParticlesTemp atom_particles_;
173 
174  // topology graph: nodes = atoms, edges = bonds
175  Graph graph_;
176 
177  // mapping between atom kernel::ParticleIndex and node number in the graph
178  boost::unordered_map<IMP::kernel::ParticleIndex, int>
179  particle_index_to_node_map_;
180  IMP::base::Vector<IMP::kernel::ParticleIndex> node_to_particle_index_map_;
181 
182  // rigid bodies
184 
185  // joints
187 
189 
190  // map between residue phi/psi/chis and joints
191  AngleToJointMap joint_map_;
192 };
193 
194 IMPKINEMATICS_END_NAMESPACE
195 
196 #endif /* IMPKINEMATICS_PROTEIN_KINEMATICS_H */
Simple atom decorator.
A smart pointer to a reference counted object.
Definition: 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:134
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...