IMP  2.2.1
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  KinematicForest* get_kinematic_forest() { return kf_; }
75  // TODO: not sure if we have to return Pointer or just raw pointer
76 
77  IMP::core::RigidBodies get_rigid_bodies() { return rbs_; }
78 
79  // TODO: add chi
80 
81  /* Modifier methods */
82 
83  void set_phi(const IMP::atom::Residue r, double angle) {
84  get_phi_joint(r)->set_angle(angle);
85  kf_->update_all_external_coordinates();
86  }
87 
88  void set_psi(const IMP::atom::Residue r, double angle) {
89  get_psi_joint(r)->set_angle(angle);
90  kf_->update_all_external_coordinates();
91  }
92 
93  // TODO: add chi
94 
95  private:
96  enum ProteinAngleType {
97  PHI,
98  PSI,
99  CHI1,
100  CHI2,
101  CHI3,
102  CHI4,
103  OTHER,
104  TOTAL
105  };
106 
107  void build_topology_graph();
108 
109  void mark_rotatable_angles(
110  const std::vector<IMP::atom::Atoms>& dihedral_angles);
111 
112  void build_rigid_bodies();
113 
114  void add_dihedral_joints(
115  const std::vector<IMP::atom::Atoms>& dihedral_angles);
116 
117  void add_dihedral_joints(
118  const std::vector<IMP::atom::Residue>& residues,
119  ProteinAngleType angle_type,
120  const std::vector<IMP::atom::Atoms>& dihedral_angles);
121 
122  void add_dihedral_joint(const IMP::atom::Residue r,
123  ProteinAngleType angle_type,
124  const IMP::atom::Atoms& atoms);
125 
126  /* Joint access methods */
127  DihedralAngleRevoluteJoint* get_phi_joint(const IMP::atom::Residue r) const {
128  return (DihedralAngleRevoluteJoint*)joint_map_.get_joint(r, PHI);
129  }
130 
131  DihedralAngleRevoluteJoint* get_psi_joint(const IMP::atom::Residue r) const {
132  return (DihedralAngleRevoluteJoint*)joint_map_.get_joint(r, PSI);
133  }
134 
135 // DihedralAngleRevoluteJoints get_joints(const IMP::atom::Residue r) const;
136 
137 #ifndef IMP_DOXYGEN
138  // A map between residue phi/psi and joints
139  class AngleToJointMap {
140  public:
141  // Joint access
142  Joint* get_joint(const IMP::atom::Residue r,
143  ProteinAngleType angle_type) const;
144 
145  // store Joint
146  void add_joint(const IMP::atom::Residue r, ProteinAngleType angle_type,
147  Joint* joint);
148 
149  private:
150  /* mapping to phi/psi/chi for a specific residue.
151  the joints are stored using ProteinAngleType as an index */
152  typedef std::vector<Joint*> ResidueJoints;
153  /* mapping between residue and its joints */
154  boost::unordered_map<IMP::kernel::ParticleIndex, ResidueJoints>
155  residue_to_joints_;
156  };
157 #endif // IMP_DOXYGEN
158 
159  private:
160  // protein hierarchy
162 
163  // atom particles
164  IMP::kernel::ParticlesTemp atom_particles_;
165 
166  // topology graph: nodes = atoms, edges = bonds
167  Graph graph_;
168 
169  // mapping between atom kernel::ParticleIndex and node number in the graph
170  boost::unordered_map<IMP::kernel::ParticleIndex, int>
171  particle_index_to_node_map_;
172  IMP::base::Vector<IMP::kernel::ParticleIndex> node_to_particle_index_map_;
173 
174  // rigid bodies
176 
177  // joints
179 
181 
182  // map between residue phi/psi/chis and joints
183  AngleToJointMap joint_map_;
184 };
185 
186 IMPKINEMATICS_END_NAMESPACE
187 
188 #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
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...