Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OTFFlexbbInteractionGraph.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/flexpack/interaction_graph/OTFFlexbbIteractionGraph.hh
11 /// @brief Declaration for on-the-fly flexible-backbone-packing interaction graph interface & base classes
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 #ifndef INCLUDED_protocols_flexpack_interaction_graph_OTFFlexbbInteractionGraph_hh
15 #define INCLUDED_protocols_flexpack_interaction_graph_OTFFlexbbInteractionGraph_hh
16 
17 //#ifndef DEBUG_OTF_FLEXBB_ENERGIES
18 //#define DEBUG_OTF_FLEXBB_ENERGIES // disable this line for speed
19 //#endif
20 
21 
22 /// Unit headers
24 
25 /// Package headers
27 // AUTO-REMOVED #include <protocols/flexpack/rotamer_set/FlexbbRotamerSet.fwd.hh>
28 #include <protocols/flexpack/OtherContextScoreFunction.hh> /// CREATE THE .FWD.HH FILE
29 
30 /// Project headers
32 #include <core/pose/Pose.fwd.hh>
34 #include <core/types.hh>
35 
36 #ifdef WIN32
38 #endif
39 /// ObjexxFCL headers
40 #include <ObjexxFCL/FArray4D.hh>
41 
42 #include <utility/vector1.hh>
43 
44 
45 namespace protocols {
46 namespace flexpack {
47 namespace interaction_graph {
48 
49 class OTFFlexbbNode : public FlexbbNode
50 {
51 public:
52  typedef FlexbbNode parent;
55  typedef core::Size Size;
57  typedef core::Real Real;
60 
61 public:
62 
63  OTFFlexbbNode( OTFFlexbbInteractionGraph *, int node_id, int num_states );
64  virtual ~OTFFlexbbNode();
65  virtual void print() const;
66 
67  virtual unsigned int count_dynamic_memory() const;
68 
69  Residue const &
70  rotamer( int index ) const {
71  return *rotamers_[ index ];
72  }
73 
74  void set_rotamer( int state, ResidueCOP rotamer );
76 
77  Real bounding_radius_for_rotamers( int aatype, int bb ) const;
78 
79  bool rotamer_is_proline( int state ) const { return rotamer_is_proline_[ state ]; }
80  bool rotamer_is_glycine( int state ) const { return rotamer_is_glycine_[ state ]; }
81 
82 protected:
83  /// Downcast pointers to incident edges, adjacent nodes, and the owning graph
84  inline
85  OTFFlexbbEdge const * get_incident_otfflexbb_edge( int index ) const;
86 
87  inline
89 
90  inline
91  OTFFlexbbNode const * get_adjacent_otfflexbb_node( int index ) const;
92 
93  inline
95 
96  inline
98 
99  inline
101 
102 private:
107 
108 };
109 
110 class OTFFlexbbEdge : public FlexbbEdge
111 {
112 public:
115  typedef ObjexxFCL::FArray2D< PackerEnergy > FArray2D_PackerEnergy;
116 
117 public:
118  OTFFlexbbEdge( OTFFlexbbInteractionGraph * owner, int node1, int node2 );
119  virtual ~OTFFlexbbEdge();
120 
123 
126 
129 
130  void
132 
133  virtual unsigned int count_dynamic_memory() const;
134 
135  void
137  int node_not_necessarily_proline,
138  int state,
139  int other_bb,
140  PackerEnergy bb_nonprobb_E,
141  PackerEnergy bb_probb_E,
142  PackerEnergy sc_nonprobb_E,
143  PackerEnergy sc_probb_E
144  );
145 
146  void
148  int node_not_necessarily_glycine,
149  int state,
150  int other_bb,
151  PackerEnergy bb_nonglybb_E,
152  PackerEnergy bb_glybb_E,
153  PackerEnergy sc_nonglybb_E,
154  PackerEnergy sc_glybb_E
155  );
156 
157  virtual void prepare_for_simulated_annealing();
158 
160 
161  void print_alt_energies() const;
162 
163 protected:
164 
165  /// Downcasts
166  inline
167  OTFFlexbbNode const * get_otfflexbb_node( int index ) const;
168 
169  inline
170  OTFFlexbbNode * get_otfflexbb_node( int index );
171 
172  inline
174 
175  inline
177 
178 protected:
179 
180  Residue const &
181  alt_rot( int which_node ) const {
182  return get_otfflexbb_node( which_node )->rotamer( nodes_alt_state( which_node ) );
183  }
184 
185  void
187 
188 private:
189 
190  //// @brief Is a particular state proline? Used as a signal for proline correction terms.
191  inline
192  bool state_is_proline( int which_node, int state ) const;
193 
194  inline
195  bool
196  state_is_glycine( int which_node, int state ) const;
197 
198  int compact_bbindex( int index ) const { return nodes_part_of_same_flexseg() ? 1 : index; }
199 
200  /// If this flag is "true" then the two tables below are not allocated, and instead
201  /// sc/bb and bb/bb energies are calculated alongside sc/sc energies in the OTF
202  /// calculations. Slower, but uses less memory.
204 
209 
214 
215  // if both nodes are flexible, they store their "1 body" sc/bb and bb/bb energies here.
216  // This is relatively expensive. I'm considering an alternative that computes
217  // sc/bb and bb/bb energies on the fly as well...
218  // Farray indexed ( state_this, compact bb_other )
219  // compact == if the edge connects two nodes that are part of the same flexible segment, then
220  // the backbone index is always "1" and the dimension for anything that's indexed by the backbone
221  // is 1 (thereby occupying less memory).
223 
224  // if either node becomes proline, add in the proline correction for the state on the other node.
225  /// Farray indexed ( state_this, compact bb_other )
227 
228 
229  // if either node becomes glycine, add in the glycine correction for the state on the other node.
230  /// Farray indexed ( state_this, compact bb_other )
232 
233  ObjexxFCL::FArray4D< unsigned char > sr_aa_neighbors_; // indexed ( aa1, aa2, non-compact bb1, compact bb2 )
235 
238 };
239 
241 {
242 public:
244  typedef core::Real Real;
251 
252 
253 public:
254 
255  OTFFlexbbInteractionGraph( int num_nodes );
256  virtual ~OTFFlexbbInteractionGraph();
257 
259 
260  void
262  int node1,
263  int node2,
264  int node_not_necessarily_proline,
265  int state,
266  int other_bb,
267  PackerEnergy bb_nonprobb_E,
268  PackerEnergy bb_probb_E,
269  PackerEnergy sc_nonprobb_E,
270  PackerEnergy sc_probb_E
271  );
272 
273  void
275  int node1,
276  int node2,
277  int node_not_necessarily_glycine,
278  int state,
279  int other_bb,
280  PackerEnergy bb_nonglybb_E,
281  PackerEnergy bb_glybb_E,
282  PackerEnergy sc_nonglybb_E,
283  PackerEnergy sc_glybb_E
284  );
285 
286  virtual unsigned int count_dynamic_memory() const;
287 
288  /// @brief Pose must be set before any edges are added to the graph.
289  virtual void set_pose( Pose const & pose );
290  /// @brief Score function must be set before any edges are added to the graph.
291  virtual void set_scorefxn( ScoreFunction const & sfxn );
292 
293  /// @brief Edges request the pose and the score function at the time of their creation.
294  PoseCOP get_pose() const;
296 
297  /// @brief Informs the edge connecting nodes 1 and 2 that they require long range interactions.
298  /// Note -- the edge must already exist.
299  void note_long_range_interactions_exist_for_edge( int node1, int node2 );
300 
301  void debug_note_considered_substitution( core::conformation::Residue const & alt_rotamer, int index );
302  void debug_note_projected_deltaE_of_considered_substitution( PackerEnergy deltaE, PackerEnergy node_alt_total, bool require_match = true );
305 
306 protected:
307  /// Downcasts
308  OTFFlexbbNode const * get_otfflexbb_node( int index ) const
309  { return static_cast< OTFFlexbbNode const * > (get_node( index )); }
310 
312  { return static_cast< OTFFlexbbNode * > (get_node( index )); }
313 
314  OTFFlexbbEdge const * find_otfflexbb_edge( int node1, int node2 ) const
315  {
316  core::pack::interaction_graph::EdgeBase const * edge = find_edge( node1, node2 );
317  if ( edge ) return static_cast< OTFFlexbbEdge const * > ( edge );
318  else return 0;
319  }
320 
321  OTFFlexbbEdge * find_otfflexbb_edge( int node1, int node2 )
322  {
323  core::pack::interaction_graph::EdgeBase * edge = find_edge( node1, node2 );
324  if ( edge ) return static_cast< OTFFlexbbEdge * > ( edge );
325  else return 0;
326  }
327 
328  OTFFlexbbEdge const * cast_otfflexbb_edge( EdgeBase const * edge ) const
329  { assert( mine( edge ) ); return static_cast< OTFFlexbbEdge const * > ( edge ); }
330 
332  { assert( mine( edge ) ); return static_cast< OTFFlexbbEdge * > ( edge ); }
333 
334 
335 private:
336 
340 
341  /// For debugging purposes
346 
350 
353 };
354 
355 inline
357 { return static_cast< OTFFlexbbEdge const * > ( get_incident_edge( index )); }
358 
359 inline
361 { return static_cast< OTFFlexbbEdge * > ( get_incident_edge( index )); }
362 
363 inline
365 { return static_cast< OTFFlexbbNode const * > ( get_adjacent_node( index )); }
366 
367 inline
369 { return static_cast< OTFFlexbbNode * > ( get_adjacent_node( index )); }
370 
371 inline
373 { return static_cast< OTFFlexbbInteractionGraph const * > (get_owner()); }
374 
375 inline
377 { return static_cast< OTFFlexbbInteractionGraph * > (get_owner()); }
378 
379 
380 /// Downcasts
381 inline
383 { return static_cast< OTFFlexbbNode const * > (get_node( index )); }
384 
385 inline
387 { return static_cast< OTFFlexbbNode * > (get_node( index )); }
388 
389 inline
391 { return static_cast< OTFFlexbbInteractionGraph const * > (get_owner()); }
392 
393 inline
395 { return static_cast< OTFFlexbbInteractionGraph * > (get_owner()); }
396 
397 
398 }
399 }
400 }
401 
402 #endif