Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SymmOnTheFlyInteractionGraph.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/SymmOnTheFlyInteractionGraph.hh
11 /// @brief
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 #ifndef INCLUDED_core_pack_interaction_graph_SymmOnTheFlyInteractionGraph_hh
15 #define INCLUDED_core_pack_interaction_graph_SymmOnTheFlyInteractionGraph_hh
16 
17 // Unit headers
19 
20 // Package headers
21 // AUTO-REMOVED #include <core/pack/interaction_graph/AminoAcidNeighborSparseMatrix.hh>
25 
28 
29 // Project headers
31 #ifdef WIN32
32 #include <core/conformation/Residue.hh> // WIN32 INCLUDE
33 #endif
34 
36 #include <core/pose/Pose.fwd.hh>
38 
39 // Numeric headers
40 #include <numeric/xyzVector.hh>
41 
42 /// C++ headers
43 // AUTO-REMOVED #include <utility> // std::pair
44 
45 // ObjexxFCL headers
46 #include <ObjexxFCL/FArray1D.hh>
47 #include <ObjexxFCL/FArray2D.hh>
48 #include <ObjexxFCL/FArray4D.hh>
49 
50 #include <utility/vector1.hh>
51 
52 #include <numeric/HomogeneousTransform.hh>
53 
54 // Utility headers
55 
56 //Auto using namespaces
57 namespace ObjexxFCL { } using namespace ObjexxFCL; // AUTO USING NS
58 //Auto using namespaces end
59 
60 
61 namespace core {
62 namespace pack {
63 namespace interaction_graph {
64 
66 {
67 public:
68  typedef std::pair< Vector, Real > BoundingSphere;
69 
70 public:
72  InteractionGraphBase * owner,
73  int node_id,
74  int num_states);
75 
76  virtual ~SymmOnTheFlyNode();
77 
78  void set_rotamers(
80  );
81 
82  virtual void zero_one_body_energies();
83  virtual void add_to_one_body_energies( ObjexxFCL::FArray1< core::PackerEnergy > & energy1b );
84  virtual void update_one_body_energy( int state, core::PackerEnergy energy);
85  virtual void set_one_body_energy( int state, core::PackerEnergy energy );
86  virtual void add_to_one_body_energy( int state, core::PackerEnergy energy );
87  virtual void zero_one_body_energy( int state );
88 
89  /// @brief the number of distinct ResidueType objects pointed to by all of the
90  /// rotamrs for this node.
91  inline
92  int
94  {
95  return num_res_types_;
96  }
97 
98  /// @brief the number of ResidueType groups, as defined by the RotamerSet's logic
99  /// for grouping different ResidueType objects which have the same "name3" and
100  /// the same neighbor radius.
101  inline
102  int
104  {
105  return num_restype_groups_;
106  }
107 
108  inline
111  {
112  return num_states_for_restype_group_;
113  }
114 
115  inline
118  {
119  return num_states_for_restype_group_;
120  }
121 
122  inline
123  int
124  get_num_states_for_restype_group( int restype_group )
125  {
126  return num_states_for_restype_group_[ restype_group ];
127  }
128 
129  //inline
130  //SparseMatrixIndex const &
131  //get_sparse_mat_info_for_state( int state ) const
132  //{
133  // assert( state > 0 && state <= get_num_states() );
134  // return sparse_mat_info_for_state_[ state ];
135  //}
136 
137  inline
138  int
139  get_state_offset_for_restype_group( int restype_group ) const {
140  return state_offset_for_restype_group_[ restype_group ];
141  }
142 
143  inline
145  get_one_body_energy( int state ) const
146  {
147  return one_body_energies_[ state ];
148  }
149 
150  bool
152  return distinguish_backbone_and_sidechain_;
153  }
154 
155  void
156  distinguish_backbone_and_sidechain( bool setting );
157 
158  virtual unsigned int count_static_memory() const = 0;
159  virtual unsigned int count_dynamic_memory() const;
160 
162  compute_rotamer_pair_energy(
163  int edge_making_energy_request,
164  int state_this,
165  int state_other
166  ) const;
167 
168  /// @brief Returns a reference to the rotamer object in the requested subunit. This reference
169  /// is valid only until the next call to get_rotamer, and which point, the coordinates inside
170  /// the requested rotamer may change.
171  conformation::Residue const &
172  get_rotamer( int state, int subunit ) const;
173 
174  /// @brief Returns a bounding sphere for the sidechain of a given state on a particular subunit.
175  BoundingSphere
176  sc_bounding_sphere( int state, int subunit ) const;
177 
178  /// @brief Returns a bounding sphere for the backbone on a particular subunit.
179  BoundingSphere
180  bb_bounding_sphere( int subunit ) const;
181 
182 public:
183 
184  inline
186  get_incident_otf_edge( int edge );
187 
188  inline
189  SymmOnTheFlyEdge const *
190  get_incident_otf_edge( int edge ) const;
191 
192  inline
194  get_adjacent_otf_node( int index );
195 
196  inline
197  SymmOnTheFlyNode const *
198  get_adjacent_otf_node( int index ) const;
199 
200  inline
202  get_on_the_fly_owner();
203 
204  inline
206  get_on_the_fly_owner() const;
207 
208 
209 private:
211  /// Pointers to the rotamers held in the rotamer set
213 
214  /// An array of arrays of rotamer_set_->get_n_residue_types()
215  /// rotamer representatives who will be filled, just in time, with the
216  /// transformed coordinates that map between the rotamers built for the asymmetric
217  /// unit, and those on all of the symmetric clones.
219 
220  /// Bounding spheres for each of the rotamers in the asymmetric unit
223 
228  //utility::vector1< SparseMatrixIndex > sparse_mat_info_for_state_;
231 };
232 
234 {
235 public:
236  virtual ~SymmOnTheFlyEdge();
237 
239  InteractionGraphBase * owner,
240  int first_node_ind,
241  int second_node_ind
242  );
243 
244  void
245  add_ProCorrection_values(
246  int node_not_necessarily_proline,
247  int state,
248  core::PackerEnergy bb_nonprobb_E,
249  core::PackerEnergy bb_probb_E,
250  core::PackerEnergy sc_nonprobb_E,
251  core::PackerEnergy sc_probb_E
252  );
253 
254  inline
257  int node_ind,
258  int state
259  ) const
260  {
261  int which_node = node_ind == get_node_index( 0 ) ? 0 : 1;
262  return get_proline_correction( which_node, state );
263  }
264 
265 
266  virtual unsigned int count_static_memory() const = 0;
267  virtual unsigned int count_dynamic_memory() const;
268 
269  bool long_range_interactions_exist() const { return long_range_interactions_exist_; }
270  bool short_range_interactions_exist() const { return short_range_interactions_exist_; }
271 
272  void note_long_range_interactions_exist() { long_range_interactions_exist_ = true; }
273  void note_short_range_interactions_exist() { short_range_interactions_exist_ = true; }
274 
276  eval_type( int node_index ) const {
277  return eval_types_[ which_node( node_index ) ];
278  }
279 
280  void
281  set_residues_adjacent_for_subunit_pair(
282  int which_node,
283  int other_node_subunit
284  );
285 
286  unsigned char
287  residues_adjacent_for_subunit_pair(
288  int which_node, // 1 or 2
289  int other_node_subunit, // subunit for othernode
290  int whichnode_restypegroup, // restype group for first node
291  int othernode_restypegroup // restype group for the other node
292  ) const;
293 
294  /// @brief fullfilling base class virtual member request -- however, this funciton does not quite
295  /// make sense for a symmetric oft ig so this is just stubbed out as a noop.
296  virtual
297  void set_sparse_aa_info(ObjexxFCL::FArray2_bool const & ) {}
298 
299  /// @brief fullfilling base class virtual member request -- however, this function does not quite
300  /// make sense for a symmetric otf ig, so this is just stubbed out to return true.
301  virtual
302  bool get_sparse_aa_info( int, int ) const { return true; }
303 
304  /// @brief fullfilling base class virtual member request -- however, this funciton does not quite
305  /// make sense for a symmetric oft ig so this is just stubbed out as a noop.
306  virtual
307  void force_aa_neighbors( int, int ) {}
308 
309  /// @brief fullfilling base class virtual member request -- however, this funciton does not quite
310  /// make sense for a symmetric oft ig so this is just stubbed out as a noop.
311  virtual
313 
314  virtual core::PackerEnergy get_two_body_energy( int const, int const ) const = 0;
315 
316 protected:
317 
318  inline
321  int which_node,
322  int state
323  ) const
324  {
325  return proline_corrections_[ which_node ][ state ];
326  }
327 
328  inline
329  SymmOnTheFlyNode const *
330  get_otf_node( int which_node ) const
331  {
332  return static_cast< SymmOnTheFlyNode const * > (get_node( which_node ));
333  }
334 
335  inline
337  get_otf_node( int which_node )
338  {
339  return static_cast< SymmOnTheFlyNode * > (get_node( which_node ));
340  }
341 
342  inline
344  get_otf_owner() const;
345 
346  inline
348  get_otf_owner();
349 
350 private:
351  /// Dimensions: naatypes x naatypes x n_subunits x 2
352  /// aa_adjacency( l, k, j, i );
353  /// i = 1 or 2, repesnting either the lower or upper node respectively, the residue of which lives in the asymmetric unit
354  /// j = 1..n_subunits, representing the subunit of origin for the other node's residue
355  /// k = amino acid type for node i
356  /// l = amino acid type for the other node
357  ObjexxFCL::FArray4D< unsigned char > restypegroup_adjacency_;
358 
359  utility::vector1< core::PackerEnergy > proline_corrections_[ 2 ];
360  ResiduePairEvalType eval_types_[ 2 ];
363 };
364 
366 {
367 public:
368  typedef pose::Pose Pose;
372  typedef numeric::HomogeneousTransform< Real > HTReal;
373 
374 public:
375  SymmOnTheFlyInteractionGraph( int num_nodes );
377 
378  virtual void initialize( rotamer_set::RotamerSetsBase const & rot_sets );
379 
380  virtual int get_num_aatypes() const { return num_restype_groups_; }
381 
382  inline
384  {
385  return num_restype_groups_;
386  }
387 
388  bool
389  distinguish_backbone_and_sidechain_for_node( int node ) const;
390 
391  void
392  distinguish_backbone_and_sidechain_for_node( int node, bool setting );
393 
394 
395  void
396  set_score_function( ScoreFunction const & );
397 
398  void
399  set_pose( Pose const & );
400 
401  inline
402  Pose const &
403  pose() const
404  {
405  return *pose_;
406  }
407 
409  symm_info() const;
410 
411  /// @brief debugging only -- modify the pose during simulated annealing, if you're so inclined
412  inline
413  Pose &
415  {
416  return *pose_;
417  }
418 
419 
420  inline
421  ScoreFunction const &
423  {
424  assert( score_function_ );
425  return *score_function_;
426  }
427 
428  /*
429  // for using ResidueWeightMap
430  inline void set_residue_weight_map(PackerTaskResidueWeightMap const & residue_weight_map_in) {
431  residue_weight_map_ = residue_weight_map_in;
432  }
433  inline float get_residue_weights(int seqpos1, int aa1, int seqpos2, int aa2 ) const {
434  { return residue_weight_map_.get_weight(seqpos1, aa1, seqpos2, aa2); };
435  }
436  inline bool check_empty_weight_map() { return residue_weight_map_.check_empty_map(); };
437  */
438 
439 
440  void
441  zero_one_body_energy_for_node_state(
442  int node_ind,
443  int state
444  );
445 
446  void
447  add_to_one_body_energy_for_node_state(
448  int node_ind,
449  int state,
450  core::PackerEnergy one_body_energy
451  );
452 
453  void
454  set_one_body_energy_for_node_state(
455  int node_ind,
456  int state,
457  core::PackerEnergy one_body_energy
458  );
459 
460  virtual
462  get_one_body_energy_for_node_state( int node, int state);
463 
464 // void
465 // set_sparse_aa_info_for_edge(
466 // int node1,
467 // int node2,
468 // FArray2_bool const & sparse_conn_info
469 // );
470 
471  void
472  set_residues_adjacent_for_subunit_pair_for_edge(
473  int node1,
474  int node2,
475  int asu_node_index,
476  int other_node_subunit );
477 
478  void
479  reset_rpe_calculations_count();
480 
481 
482  Size
483  get_num_rpe_calculations_count() const;
484 
485  /// @brief to be called by owned OTF node only
486  void
488  ++num_rpe_calcs_;
489  }
490 
491  //virtual bool build_sc_only_rotamer() const = 0;
492 
493  void
494  add_ProCorrection_values_for_edge(
495  int node1,
496  int node2,
497  int node_not_neccessarily_proline,
498  int state,
499  core::PackerEnergy bb_nonprobb_E,
500  core::PackerEnergy bb_probb_E,
501  core::PackerEnergy sc_nonprobb_E,
502  core::PackerEnergy sc_probb_E
503  );
504 
505 
506  void
507  note_short_range_interactions_exist_for_edge(
508  int node1,
509  int node2
510  );
511 
512  void
513  note_long_range_interactions_exist_for_edge(
514  int node1,
515  int node2
516  );
517 
518  virtual unsigned int count_dynamic_memory() const;
519 
520  /// @brief Return the homogeneous transform to translate and rotate coordinates
521  /// originally in the asymmetric unit into a given destination subunit.
522  inline
523  HTReal const &
524  symmetric_transform( Size dst_subunit ) const { return symmetric_transforms_[ dst_subunit ]; }
525 
526 public:
527 
528  inline
530  get_on_the_fly_node( int node_index )
531  {
532  return ( static_cast< SymmOnTheFlyNode * > (get_node( node_index )) );
533  }
534 
535  inline
536  SymmOnTheFlyNode const *
537  get_on_the_fly_node( int node_index ) const
538  {
539  return ( static_cast< SymmOnTheFlyNode const * > (get_node( node_index )) );
540  }
541 
542 private:
545 
550 
551  // Additional per-residue (or per-residue-per-aa) weights
552  // Note: currently computed OUTSIDE the IG, except in the case of SymmOnTheFly IGs
553  //PackerTaskResidueWeightMap residue_weight_map_;
554 
555 };
556 
557 
558 inline
560 SymmOnTheFlyNode::get_incident_otf_edge( int edge )
561 {
562  assert( dynamic_cast< SymmOnTheFlyEdge * > (get_incident_edge( edge )) );
563  return static_cast< SymmOnTheFlyEdge * > (get_incident_edge( edge ));
564 }
565 
566 inline
567 SymmOnTheFlyEdge const *
568 SymmOnTheFlyNode::get_incident_otf_edge( int edge ) const
569 {
570  assert( dynamic_cast< SymmOnTheFlyEdge const * > (get_incident_edge( edge )) );
571  return static_cast< SymmOnTheFlyEdge const * > (get_incident_edge( edge ));
572 }
573 
574 inline
576 SymmOnTheFlyNode::get_adjacent_otf_node( int index )
577 {
578  assert( dynamic_cast< SymmOnTheFlyNode * > ( get_adjacent_node( index ) ));
579  return static_cast< SymmOnTheFlyNode * > ( get_adjacent_node( index ) );
580 }
581 
582 inline
583 SymmOnTheFlyNode const *
584 SymmOnTheFlyNode::get_adjacent_otf_node( int index ) const
585 {
586  assert( dynamic_cast< SymmOnTheFlyNode const * > ( get_adjacent_node( index ) ));
587  return static_cast< SymmOnTheFlyNode const * > ( get_adjacent_node( index ) );
588 }
589 
590 
591 inline
593 SymmOnTheFlyNode::get_on_the_fly_owner()
594 {
595  assert( dynamic_cast< SymmOnTheFlyInteractionGraph * > ( get_owner() ) );
596  return static_cast< SymmOnTheFlyInteractionGraph * > ( get_owner() );
597 }
598 
599 inline
601 SymmOnTheFlyNode::get_on_the_fly_owner() const
602 {
603  assert( dynamic_cast< SymmOnTheFlyInteractionGraph const * > ( get_owner() ) );
604  return static_cast< SymmOnTheFlyInteractionGraph const * > ( get_owner() );
605 }
606 
607 inline
609 SymmOnTheFlyEdge::get_otf_owner() const {
610  return static_cast< SymmOnTheFlyInteractionGraph const * > (get_owner());
611 }
612 
613 inline
615 SymmOnTheFlyEdge::get_otf_owner() {
616  return static_cast< SymmOnTheFlyInteractionGraph * > (get_owner() );
617 }
618 
619 }
620 }
621 }
622 
623 #endif //INCLUDED_core_pack_interaction_graph_SymmOnTheFlyInteractionGraph_HH
624