Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OnTheFlyInteractionGraph.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 core/pack/interaction_graph/OnTheFlyInteractionGraph.hh
11 /// @brief
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 #ifndef INCLUDED_core_pack_interaction_graph_OnTheFlyInteractionGraph_hh
15 #define INCLUDED_core_pack_interaction_graph_OnTheFlyInteractionGraph_hh
16 
17 // Unit headers
19 
20 // Package headers
21 // AUTO-REMOVED #include <core/pack/interaction_graph/AminoAcidNeighborSparseMatrix.hh>
24 
26 
27 // Project headers
29 #ifdef WIN32
30 #include <core/conformation/Residue.hh> // WIN32 INCLUDE
31 #endif
32 
33 #include <core/pose/Pose.fwd.hh>
35 
36 // Numeric headers
37 #include <numeric/xyzVector.hh>
38 
39 /// C++ headers
40 // AUTO-REMOVED #include <utility> // std::pair
41 
42 // ObjexxFCL headers
43 #include <ObjexxFCL/FArray1D.hh>
44 #include <ObjexxFCL/FArray2D.hh>
45 
46 #include <utility/vector1.hh>
47 
48 
49 // Utility headers
50 
51 //Auto using namespaces
52 namespace ObjexxFCL { } using namespace ObjexxFCL; // AUTO USING NS
53 //Auto using namespaces end
54 
55 
56 namespace core {
57 namespace pack {
58 namespace interaction_graph {
59 
65 };
66 
67 class OnTheFlyNode : public FixedBBNode
68 {
69 public:
70  typedef std::pair< Vector, Real > BoundingSphere;
71 
72 public:
74  InteractionGraphBase * owner,
75  int node_id,
76  int num_states);
77 
78  virtual ~OnTheFlyNode();
79 
80  void set_rotamers(
82  );
83 
84  virtual void zero_one_body_energies();
85  virtual void add_to_one_body_energies( ObjexxFCL::FArray1< core::PackerEnergy > & energy1b );
86  virtual void update_one_body_energy( int state, core::PackerEnergy energy);
87  virtual void set_one_body_energy( int state, core::PackerEnergy energy );
88  virtual void add_to_one_body_energy( int state, core::PackerEnergy energy );
89  virtual void zero_one_body_energy( int state );
90 
91  inline
92  int
94  {
95  return num_aa_types_;
96  }
97 
98  inline
101  {
102  return num_states_for_aatype_;
103  }
104 
105  inline
108  {
109  return num_states_for_aatype_;
110  }
111 
112  inline
113  int
115  {
116  return num_states_for_aatype_[ aa_type ];
117  }
118 
119  inline
120  SparseMatrixIndex const &
121  get_sparse_mat_info_for_state( int state ) const
122  {
123  assert( state > 0 && state <= get_num_states() );
124  return sparse_mat_info_for_state_[ state ];
125  }
126 
127  inline
128  int
129  get_state_offset_for_aatype( int aatype ) const {
130  return state_offset_for_aatype_[ aatype ];
131  }
132 
133  inline
135  get_one_body_energy( int state ) const
136  {
137  return one_body_energies_[ state ];
138  }
139 
140  bool
142  return distinguish_backbone_and_sidechain_;
143  }
144 
145  void
146  distinguish_backbone_and_sidechain( bool setting );
147 
148  virtual unsigned int count_static_memory() const = 0;
149  virtual unsigned int count_dynamic_memory() const;
150 
152  compute_rotamer_pair_energy(
153  int edge_making_energy_request,
154  int state_this,
155  int state_other
156  ) const;
157 
158 protected:
159 
160  inline
161  OnTheFlyEdge *
162  get_incident_otf_edge( int edge );
163 
164  inline
165  OnTheFlyEdge const *
166  get_incident_otf_edge( int edge ) const;
167 
168  inline
169  OnTheFlyNode *
170  get_adjacent_otf_node( int index );
171 
172  inline
173  OnTheFlyNode const *
174  get_adjacent_otf_node( int index ) const;
175 
176  inline
178  get_on_the_fly_owner();
179 
180  inline
182  get_on_the_fly_owner() const;
183 
184  inline
185  conformation::Residue const &
186  get_rotamer( int state ) const
187  {
188  return *rotamers_[ state ];
189  }
190 
191  inline
192  BoundingSphere const &
193  sc_bounding_sphere( int state ) const
194  {
195  return sc_bounding_spheres_[ state ];
196  }
197 
198  inline
199  BoundingSphere const & bb_bounding_sphere() const { return bb_bounding_sphere_; }
200 
201 private:
206 
207  int num_aa_types_; // rename num_aa_groups_
213 };
214 
215 class OnTheFlyEdge : public FixedBBEdge
216 {
217 public:
218  virtual ~OnTheFlyEdge();
219 
220  OnTheFlyEdge(
221  InteractionGraphBase * owner,
222  int first_node_ind,
223  int second_node_ind
224  );
225 
226  void
227  set_ProCorrection_values(
228  int node_not_necessarily_proline,
229  int state,
230  core::PackerEnergy bb_nonprobb_E,
231  core::PackerEnergy bb_probb_E,
232  core::PackerEnergy sc_nonprobb_E,
233  core::PackerEnergy sc_probb_E
234  );
235 
236  inline
239  int node_ind,
240  int state
241  ) const
242  {
243  int which_node = node_ind == get_node_index( 0 ) ? 0 : 1;
244  return get_proline_correction( which_node, state );
245  }
246 
247 
248  virtual unsigned int count_static_memory() const = 0;
249  virtual unsigned int count_dynamic_memory() const;
250 
251  bool long_range_interactions_exist() const { return long_range_interactions_exist_; }
252  bool short_range_interactions_exist() const { return short_range_interactions_exist_; }
253 
254  void note_long_range_interactions_exist() { long_range_interactions_exist_ = true; }
255  void note_short_range_interactions_exist() { short_range_interactions_exist_ = true; }
256 
258  eval_type( int node_index ) const {
259  return eval_types_[ which_node( node_index ) ];
260  }
261 
262 protected:
263 
264  inline
267  int which_node,
268  int state
269  ) const
270  {
271  return proline_corrections_[ which_node ][ state ];
272  }
273 
274  inline
275  OnTheFlyNode const *
276  get_otf_node( int which_node ) const
277  {
278  return static_cast< OnTheFlyNode const * > (get_node( which_node ));
279  }
280 
281  inline
282  OnTheFlyNode *
283  get_otf_node( int which_node )
284  {
285  return static_cast< OnTheFlyNode * > (get_node( which_node ));
286  }
287 
288 private:
289 
290  utility::vector1< core::PackerEnergy > proline_corrections_[ 2 ];
291  ResiduePairEvalType eval_types_[ 2 ];
294 };
295 
297 {
298 public:
299  typedef pose::Pose Pose;
303 
304 public:
305  OnTheFlyInteractionGraph( int num_nodes );
307 
308  virtual void initialize( rotamer_set::RotamerSetsBase const & rot_sets );
309 
310  inline
311  int get_num_aatypes() const
312  {
313  return num_aa_types_;
314  }
315 
316  bool
317  distinguish_backbone_and_sidechain_for_node( int node ) const;
318 
319  void
320  distinguish_backbone_and_sidechain_for_node( int node, bool setting );
321 
322 
323  void
324  set_score_function( ScoreFunction const & );
325 
326  void
327  set_pose( Pose const & );
328 
329  inline
330  Pose const &
331  pose() const
332  {
333  return *pose_;
334  }
335 
336  /// @brief debugging only -- modify the pose during simulated annealing, if you're so inclined
337  inline
338  Pose &
340  {
341  return *pose_;
342  }
343 
344 
345  inline
346  ScoreFunction const &
348  {
349  assert( score_function_ );
350  return *score_function_;
351  }
352 
353  /*
354  // for using ResidueWeightMap
355  inline void set_residue_weight_map(PackerTaskResidueWeightMap const & residue_weight_map_in) {
356  residue_weight_map_ = residue_weight_map_in;
357  }
358  inline float get_residue_weights(int seqpos1, int aa1, int seqpos2, int aa2 ) const {
359  { return residue_weight_map_.get_weight(seqpos1, aa1, seqpos2, aa2); };
360  }
361  inline bool check_empty_weight_map() { return residue_weight_map_.check_empty_map(); };
362  */
363 
364 
365  void
366  zero_one_body_energy_for_node_state(
367  int node_ind,
368  int state
369  );
370 
371  void
372  add_to_one_body_energy_for_node_state(
373  int node_ind,
374  int state,
375  core::PackerEnergy one_body_energy
376  );
377 
378  void
379  set_one_body_energy_for_node_state(
380  int node_ind,
381  int state,
382  core::PackerEnergy one_body_energy
383  );
384 
385  virtual
387  get_one_body_energy_for_node_state( int node, int state);
388 
389  void
390  set_sparse_aa_info_for_edge(
391  int node1,
392  int node2,
393  FArray2_bool const & sparse_conn_info
394  );
395 
396 
397  void
398  reset_rpe_calculations_count();
399 
400 
401  Size
402  get_num_rpe_calculations_count() const;
403 
404  /// @brief to be called by owned OTF node only
405  void
407  ++num_rpe_calcs_;
408  }
409 
410  //virtual bool build_sc_only_rotamer() const = 0;
411 
412  void
413  set_ProCorrection_values_for_edge(
414  int node1,
415  int node2,
416  int node_not_neccessarily_proline,
417  int state,
418  core::PackerEnergy bb_nonprobb_E,
419  core::PackerEnergy bb_probb_E,
420  core::PackerEnergy sc_nonprobb_E,
421  core::PackerEnergy sc_probb_E
422  );
423 
424 
425  void
426  note_short_range_interactions_exist_for_edge(
427  int node1,
428  int node2
429  );
430 
431  void
432  note_long_range_interactions_exist_for_edge(
433  int node1,
434  int node2
435  );
436 
437  virtual unsigned int count_dynamic_memory() const;
438 
439 protected:
440 
441  inline
442  OnTheFlyNode *
443  get_on_the_fly_node( int node_index )
444  {
445  return ( static_cast< OnTheFlyNode * > (get_node( node_index )) );
446  }
447 
448  inline
449  OnTheFlyNode const *
450  get_on_the_fly_node( int node_index ) const
451  {
452  return ( static_cast< OnTheFlyNode const * > (get_node( node_index )) );
453  }
454 
455 private:
458 
461 
462  // Additional per-residue (or per-residue-per-aa) weights
463  // Note: currently computed OUTSIDE the IG, except in the case of OnTheFly IGs
464  //PackerTaskResidueWeightMap residue_weight_map_;
465 
466 };
467 
468 
469 inline
470 OnTheFlyEdge *
471 OnTheFlyNode::get_incident_otf_edge( int edge )
472 {
473  assert( dynamic_cast< OnTheFlyEdge * > (get_incident_edge( edge )) );
474  return static_cast< OnTheFlyEdge * > (get_incident_edge( edge ));
475 }
476 
477 inline
478 OnTheFlyEdge const *
479 OnTheFlyNode::get_incident_otf_edge( int edge ) const
480 {
481  assert( dynamic_cast< OnTheFlyEdge const * > (get_incident_edge( edge )) );
482  return static_cast< OnTheFlyEdge const * > (get_incident_edge( edge ));
483 }
484 
485 inline
486 OnTheFlyNode *
487 OnTheFlyNode::get_adjacent_otf_node( int index )
488 {
489  assert( dynamic_cast< OnTheFlyNode * > ( get_adjacent_node( index ) ));
490  return static_cast< OnTheFlyNode * > ( get_adjacent_node( index ) );
491 }
492 
493 inline
494 OnTheFlyNode const *
495 OnTheFlyNode::get_adjacent_otf_node( int index ) const
496 {
497  assert( dynamic_cast< OnTheFlyNode const * > ( get_adjacent_node( index ) ));
498  return static_cast< OnTheFlyNode const * > ( get_adjacent_node( index ) );
499 }
500 
501 
502 inline
504 OnTheFlyNode::get_on_the_fly_owner()
505 {
506  assert( dynamic_cast< OnTheFlyInteractionGraph * > ( get_owner() ) );
507  return static_cast< OnTheFlyInteractionGraph * > ( get_owner() );
508 }
509 
510 inline
512 OnTheFlyNode::get_on_the_fly_owner() const
513 {
514  assert( dynamic_cast< OnTheFlyInteractionGraph const * > ( get_owner() ) );
515  return static_cast< OnTheFlyInteractionGraph const * > ( get_owner() );
516 }
517 
518 }
519 }
520 }
521 
522 #endif //INCLUDED_core_pack_interaction_graph_OnTheFlyInteractionGraph_HH
523