Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConstraintEnergyContainer.cc
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/scoring/constraints/ConstraintsEnergyContainer.cc
11 /// @brief Constraints Energy Container class implementation
12 /// @author Andrew Leaver-Fay
13 
14 // Unit headers
16 
17 // Package headers
21 
22 #include <core/pose/Pose.hh>
23 
24 // STL Headers
25 #include <cassert>
26 
27 #include <utility/vector1.hh>
28 
29 
30 namespace core {
31 namespace scoring {
32 namespace constraints {
33 
35  Size focused_node,
37 )
38 :
39  focused_node_( focused_node ),
40  edge_iter_( edge_iter )
41 {}
42 
43 
45 {}
46 
49 {
50  assert( &(dynamic_cast< CstResNeighbIterator const & > ( rhs )) );
51  CstResNeighbIterator const & crni_rhs = static_cast< CstResNeighbIterator const & > ( rhs );
52 
53  focused_node_ = crni_rhs.focused_node_;
54  edge_iter_ = crni_rhs.edge_iter_;
55  return *this;
56 }
57 
60 {
61  ++edge_iter_;
62  return *this;
63 }
64 
65 bool
67 {
68  assert( &( dynamic_cast< CstResNeighbIterator const & > ( rhs )) );
69  CstResNeighbIterator const & crni_rhs = static_cast< CstResNeighbIterator const & > ( rhs );
70 
71  return ( edge_iter_ == crni_rhs.edge_iter_ );
72 }
73 
74 bool
76 {
77  assert( &( dynamic_cast< CstResNeighbIterator const & > ( rhs )) );
78  CstResNeighbIterator const & crni_rhs = static_cast< CstResNeighbIterator const & > ( rhs );
79  return ( edge_iter_ != crni_rhs.edge_iter_ );
80 }
81 
82 
83 Size
85 {
86  return (Size) (*edge_iter_)->get_second_node_ind();
87 }
88 
89 Size
91 {
92  return (Size) (*edge_iter_)->get_first_node_ind();
93 }
94 
95 Size
97 {
98  return focused_node_;
99 }
100 
101 Size
103 {
104  return (Size) (*edge_iter_)->get_other_ind( (int) focused_node_ );
105 }
106 
107 
108 void
110 {
118 
119 }
120 
121 
122 void
124 {
132 
133 }
134 
135 
136 void
138 {
142  emap[ angle_constraint ] += downcast_cstedge(*edge_iter_)->angle_constraint_energy();
146 
147 }
148 
150 {
151  downcast_cstedge(*edge_iter_)->energy_computed( true );
152 }
153 
155 {
156  downcast_cstedge(*edge_iter_)->energy_computed( false );
157 }
158 
159 
160 bool
162 {
163  return downcast_cstedge(*edge_iter_)->energy_computed();
164 }
165 
168 {
169  assert( dynamic_cast< ConstraintEdge * > ( edge ) );
170  return static_cast< ConstraintEdge * > (edge);
171 }
172 
173 ////////////////////////////////////////////////////////////////////////
174 ///// Constraint Residue Neighbor Constant Iterator class implementation
175 ////////////////////////////////////////////////////////////////////////
176 
178  Size focused_node,
180 )
181 :
182  focused_node_( focused_node ),
183  edge_iter_( edge_iter )
184 {}
185 
187 {}
188 
191 {
192  //assert( dynamic_cast< CstResNeighbConstIterator const & > ( rhs ) );
193  CstResNeighbConstIterator const & crnci_rhs = static_cast< CstResNeighbConstIterator const & > ( rhs );
194 
195  focused_node_ = crnci_rhs.focused_node_;
196  edge_iter_ = crnci_rhs.edge_iter_;
197  return *this;
198 }
199 
202 {
203  ++edge_iter_;
204  return *this;
205 }
206 
207 /// @brief returns true if the two edge-list iterators are equal
208 bool
210 {
211  assert( &( dynamic_cast< CstResNeighbConstIterator const & > ( rhs )) );
212  CstResNeighbConstIterator const & crnci_rhs = static_cast< CstResNeighbConstIterator const & > ( rhs );
213  return ( edge_iter_ == crnci_rhs.edge_iter_ );
214 }
215 
216 
217 /// @brief returns true if the two edge-list iterators are not equal
218 bool
220 {
221  assert( &( dynamic_cast< CstResNeighbConstIterator const & > ( rhs )) );
222  CstResNeighbConstIterator const & crnci_rhs = static_cast< CstResNeighbConstIterator const & > ( rhs );
223  return ( edge_iter_ != crnci_rhs.edge_iter_ );
224 }
225 
226 Size
228 {
229  return (Size) (*edge_iter_)->get_second_node_ind();
230 }
231 
232 Size
234 {
235  return (Size) (*edge_iter_)->get_first_node_ind();
236 }
237 
238 
239 Size
241 {
242  return focused_node_;
243 }
244 
245 Size
247 {
248  return (Size) (*edge_iter_)->get_other_ind( (int) focused_node_ );
249 }
250 
251 /// @brief overwrites the three constraint-energy positions in the emap with
252 /// the three contraint energies stored on the edge pointed to by the edge iter.
253 /// Does not zero out the other positions in the emap.
254 void
256 {
264 
265 }
266 
267 /// @brief accumulates the three constraint-energy positions in the emap with
268 /// the three contraint energies stored on the edge pointed to by the edge iter.
269 /// Does not touch the other positions in the emap.
270 void
272 {
276  emap[ angle_constraint ] += downcast_cstedge(*edge_iter_)->angle_constraint_energy();
280 
281 }
282 
283 bool
285 {
286  return downcast_cstedge(*edge_iter_)->energy_computed();
287 }
288 
289 ConstraintEdge const *
291 {
292  assert( dynamic_cast< ConstraintEdge const * > ( edge ) );
293  return static_cast< ConstraintEdge const * > (edge);
294 }
295 
296 /////////////////////////////////////////////////////
297 /// Constraints Energy Container Class Implementation
298 /////////////////////////////////////////////////////
299 
300 CstEnergyContainer::CstEnergyContainer() : cst_graph_( 0 ), cst_set_revision_id_( 0 ), constraint_set_( 0 ) {}
301 
302 bool
304  return cst_graph_ == 0;
305 }
306 
307 
309 {
310  cst_graph_ = new ConstraintGraph();
311  cst_graph_->set_num_nodes( pose.total_residue() );
312 
314  for ( Size ii = 1; ii <= pose.total_residue(); ++ii ) {
316  rpc_iter = constraint_set_->residue_pair_constraints_begin( ii ),
317  rpc_end = constraint_set_->residue_pair_constraints_end( ii );
318  rpc_iter != rpc_end; ++rpc_iter ) {
319  if ( ii < rpc_iter->first ) {
320  cst_graph_->add_edge( ii, rpc_iter->first );
321  }
322  }
323  }
324  cst_set_revision_id_ = constraint_set_->revision_id();
325 }
326 
327 
328 
330 {}
331 
334 {
336  if ( !empty() ) {
337  cstec->cst_graph_ = new ConstraintGraph( *cst_graph_ );
338  cstec->cst_set_revision_id_ = cst_set_revision_id_;
339  cstec->constraint_set_ = constraint_set_;
340  }
341  return cstec;
342 }
343 
344 void
346 {
347  if ( !empty() ) {
348  cst_graph_->set_num_nodes( newsize );
350  constraint_set_ = 0; // flag that the CstEnergyContainer needs to be recreated.
351  }
352 }
353 
354 
357 {
358  assert( !empty() );
359  return new CstResNeighbConstIterator( resid, cst_graph_->get_node( resid )->const_edge_list_begin() );
360 }
361 
364 {
365  assert( !empty() );
366  return new CstResNeighbConstIterator( resid, cst_graph_->get_node( resid )->const_edge_list_end() );
367 }
368 
371 {
372  assert( !empty() );
373  return new CstResNeighbConstIterator( resid, cst_graph_->get_node( resid )->const_upper_edge_list_begin() );
374 }
375 
378 {
379  assert( !empty() );
380  return new CstResNeighbConstIterator( resid, cst_graph_->get_node( resid )->const_upper_edge_list_end() );
381 }
382 
385 {
386  assert( !empty() );
387  return new CstResNeighbIterator( resid, cst_graph_->get_node( resid )->edge_list_begin() );
388 }
389 
392 {
393  assert( !empty() );
394  return new CstResNeighbIterator( resid, cst_graph_->get_node( resid )->edge_list_end() );
395 }
396 
399 {
400  assert( !empty() );
401  return new CstResNeighbIterator( resid, cst_graph_->get_node( resid )->upper_edge_list_begin() );
402 }
403 
406 {
407  assert( !empty() );
408  return new CstResNeighbIterator( resid, cst_graph_->get_node( resid )->upper_edge_list_end() ); // pbmod
409 }
410 
411 bool
413 {
414  assert( !empty() );
415  return ( cst_set.get() == constraint_set_.get() && cst_set_revision_id_ == cst_set->revision_id() );
416 }
417 
418 
419 }
420 }
421 }
422