Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimpleInteractionGraph.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/SimpleInteractionGraph.hh
11 /// @brief
12 /// @author Liz Kellogg (ekellogg@u.washington.edu)
13 
14 
15 #ifndef INCLUDED_core_pack_interaction_graph_SimpleInteractionGraph_HH
16 #define INCLUDED_core_pack_interaction_graph_SimpleInteractionGraph_HH
17 
18 // Unit headers
20 
21 // Project headers
22 #include <core/types.hh>
23 #include <core/graph/Graph.hh>
26 #include <core/pose/Pose.fwd.hh>
27 
28 // Numeric headers
29 #include <numeric/xyzVector.hh>
30 
31 #include <utility/vector1.hh>
32 
33 
34 namespace core {
35 namespace pack{
36 namespace interaction_graph{
37 
38 class SimpleNode : public graph::Node
39 {
40 public:
41 
42  // SimpleNode::SimpleNode();
43  SimpleNode( graph::Graph * owner, Size resnum );
44  virtual ~SimpleNode();
45 
46  virtual void copy_from( graph::Node const * ) {}
47 
48  virtual void print() const {}
49 
50  virtual platform::Size count_static_memory() const {return 1;}
51  virtual platform::Size count_dynamic_memory() const {return 1;}
52 
53  Real
54  one_body_energy() const;
55 
56  Real
58 
59  Real
61 
62  /// @brief Is this node considering a state substitution?
63  bool
64  moved() const;
65 
66  /// @brief Copy the alternate_residue_ pointer to the current_residue_ pointer;
67  /// copy the alternate energies to the current energies for this node and its
68  /// incident edges.
69  void
70  commit_change();
71 
72  /// @brief Copy the alternate energies to the current energies for this node
73  /// and its incident edges.
74  void
76 
77  /// @brief Reset state on this node so that its incident edges will no longer
78  /// think it is considering an alternate conformation.
79  void
80  reject_change();
81 
82  /// @brief Set the current residue COP, and follow by computing the energy
83  /// for this residue with its neighbors and storing those computed energies
84  /// on this node's edges as their "current" energies.
86 
87  /// @brief Set the alternate residue COP and follow by computing the energy
88  /// for this residue with its neighbors and storing those computed energies
89  /// on this node's edges as their "proposed" energies
91 
92  /// @brief Passive mode behavior: set the current residue pointer without updating
93  /// the current one body or two body energies.
95 
96  /// @brief Passive mode behavior: set the current residue pointer without updating
97  /// the alternate one body or proposed two body energies.
99 
101 
102  /// @brief return the pointer to the current state (might be 0)
104  get_current() const;
105 
106  /// @brief return the pointer to the alternate state (might be 0)
108  get_alternate() const;
109 
110  Vector const &
111  bb_centroid() const;
112 
113  Real
114  bb_radius() const;
115 
116  Vector const &
117  curr_sc_centroid() const;
118 
119  Real
120  curr_sc_radius() const;
121 
122  Vector const &
123  alt_sc_centroid() const;
124 
125  Real
126  alt_sc_radius() const;
127 
128 private:
129 
131 
133 
134  void
135  initialize();
136 
137  /*Vector
138  calc_sc_centroid( conformation::Residue const & res ) const;
139 
140  Real
141  calc_sc_radius( conformation::Residue const & res, Vector const & centroid );*/
142 
143 
144 private:
145  bool moved_;
149 
152 
153  Vector bb_centroid_; // should be same for curr and alt
154  Real bb_radius_; // should be same for curr and alt
155 
158 
161 
162 }; //SimpleNode
163 
164 
165 class SimpleEdge : public graph::Edge {
166 
167 public:
168 
169  //SimpleEdge( graph::Graph* owner );
170  SimpleEdge( graph::Graph* owner, Size res1, Size res2 );
171  virtual ~SimpleEdge();
172 
173  virtual void copy_from( graph::Edge const * ) {}
174 
175  virtual platform::Size count_static_memory() const {return 1;}
176  virtual platform::Size count_dynamic_memory() const {return 1;}
177 
178  void compute_energy( bool use_current_node1, bool use_current_node2 );
179 
180  Real get_current_energy() const;
181 
182  Real get_proposed_energy() const;
183 
184  void update_current_energy();
185 
186  void
188 
189  void commit_change();
190 
191  //required functions to override
192 
193  /**
194  Real curr_scsc_E_;
195  Real curr_bbsc_E_;
196  Real curr_scbb_E_;
197 
198  Real alt_scsc_E_;
199  Real alt_bbsc_E_;
200  Real alt_scbb_E_;
201  **/
202 
203 private:
204 
205  inline
208 
209  inline
210  SimpleInteractionGraph const *
211  get_simple_ig_owner() const;
212 
213  Real
214  get_bb_E( conformation::Residue const & r1, conformation::Residue const & r2 );
215 
216  /// These functions are to carefully gate access to the c-style, index-from-zero arrays.
217  Size
218  get_bb_index( conformation::Residue const & r ) const;
219 
220  bool
221  bb_bb_boundaries( Size ind1, Size ind2 ) const;
222 
223  bool
224  bb_bbE_calced( Size ind1, Size ind2 ) const;
225 
226  void
227  set_bb_bbE_calced( Size ind1, Size ind2 );
228 
229  void
230  set_bb_bbE( Size ind1, Size ind2, Real val );
231 
232  Real
233  bb_bbE( Size ind1, Size ind2 ) const;
234 
235 
236 private:
237  bool short_range_energies_exist_; // only evaluate short-range energies for edges between nearby residues
238  bool long_range_energies_exist_; // only evaluate long range energies for edges that have them
239 
242 
243  bool bb_bbE_calced_[ 3 ][ 3 ]; // indexed 0 for non-pro&non-gly, 1 for pro, 2 for gly
244  Real bb_bbE_[ 3 ][ 3 ]; // indexed 0 for non-pro&non-gly, 1 for pro, 2 for gly
245 
246 }; //SimpleEdge
247 
248 
249 
250 /// @brief A simple graph class for calculating pairwise decomposable
251 /// energies as sidechains are moving on a fixed backbone. This class
252 /// is responsible for calculating energy changes, but is passive about
253 /// how the sidechains are changing. There are two main ways to drive
254 /// the graph: one where the graph ACTIVELY takes charge of updating pointers
255 /// to the sidechains, where, each external change of one pointer
256 /// triggers an update to the energies; and a second, where the graph
257 /// is PASSIVE wrt the pointers, and they must be maintained by
258 /// an external driver.
260 
261 public:
262 
264  virtual ~SimpleInteractionGraph();
265 
266  void set_scorefunction( scoring::ScoreFunction const & sfxn );
267 
268  scoring::ScoreFunction const &
269  scorefunction() const {
270  return *sfxn_;
271  }
272 
273  pose::Pose const &
274  pose() const {
275  return *pose_;
276  }
277 
278  /// @brief Initialization where the graph adds its own edges
279  void initialize( pose::Pose const & pose);
280 
281  void set_pose_no_initialize( pose::Pose const & pose );
282 
283  void commit_change( Size node_id );
284  void reject_change( Size node_id );
285 
286  //returns delta-energy
288 
289  Real total_energy();
290 
291  //required functions to override
292 
293  virtual Size count_static_memory() const {return 0;}
294  virtual Size count_dynamic_memory() const {return 0;}
295 
296  virtual void delete_edge( graph::Edge * );
297 
298  SimpleNode *
300  return static_cast< SimpleNode * > ( get_node( ind ) );
301  }
302 
303  SimpleNode const *
304  get_simple_node( Size ind ) const {
305  return static_cast< SimpleNode const * > ( get_node( ind ) );
306  }
307 
308 protected:
309 
310  virtual graph::Node* create_new_node( Size node_index );
311  virtual graph::Edge* create_new_edge( Size index1, platform::Size index2 );
312 
313  //virtual Edge* create_new_edge( Edge * example_edge );
314 
315 private:
316 
319  Real accumulated_ediff_; //since data stored in energies
320  //object, need to subtract out diffs
321 
322 }; //SimpleInteractionGraph
323 
324 
325 inline
328  return static_cast< SimpleInteractionGraph * > ( get_owner() );
329 }
330 
331 inline
334  return static_cast< SimpleInteractionGraph const * > ( get_owner() );
335 }
336 
337 
338 } //namespace interaction_graph
339 } //namespace pack
340 } //namespace core
341 
342 #endif