Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OTFFlexbbInteractionGraph.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 protocols/flexpack/interaction_graph/OTFFlexbbInteractionGraph.cc
11 /// @brief Class implementation for OTF flexbb IG
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 /// Unit headers
16 
17 /// Package headers
18 // AUTO-REMOVED #include <protocols/flexpack/rotamer_set/FlexbbRotamerSets.hh>
20 
21 /// Project headers
22 #include <core/chemical/AA.hh>
24 #include <core/graph/Graph.hh>
25 #include <core/pose/Pose.hh>
27 #include <core/scoring/Energies.hh>
31 // AUTO-REMOVED #include <core/scoring/methods/EnergyMethodOptions.hh>
33 
34 #include <utility/string_util.hh>
35 
36 #include <utility/vector1.hh>
37 #include <utility/options/IntegerVectorOption.hh>
38 
39 
40 namespace protocols {
41 namespace flexpack {
42 namespace interaction_graph {
43 
46  int node_id,
47  int num_states
48 ) :
49  parent( owner, node_id, num_states ),
50  rotamers_( num_states ),
51  rotamer_is_proline_( num_states, (unsigned char) 0 ),
52  rotamer_is_glycine_( num_states, (unsigned char) 0 )
53 {}
54 
56 
57 void
59 {
60  parent::print();
61 }
62 
63 unsigned int
65 {
66  unsigned int total = sizeof( ResidueCOP ) * rotamers_.size();
67  return parent::count_dynamic_memory() + total;
68 }
69 
70 void
72 {
73  rotamers_[ state ] = rotamer;
74  rotamer_is_proline_[ state ] = rotamer->aa() == core::chemical::aa_pro;
75  rotamer_is_glycine_[ state ] = rotamer->aa() == core::chemical::aa_gly;
76 }
77 
78 /// @details compute bounding radii for the rotamers that actually exist -- maybe they're tighter than
79 /// the nbr_radius for the residue type... maybe I could find the minimal bounding sphere for each.
80 /// maybe I could keep two nbr_radii, one for all atoms and one for just the sidechain atoms?
81 void
83 {
85  for ( int ii = 1; ii <= get_num_distinct_backbones(); ++ii ) {
87  std::fill( bounding_volumes_for_bb_for_aa_[ ii ].begin(), bounding_volumes_for_bb_for_aa_[ ii ].end(), 0.0 );
88  }
89 
90  for ( int ii = 1; ii <= get_num_distinct_backbones(); ++ii ) {
91  //std::cout << get_node_index() << " ii: " << ii << std::endl;
92  for ( int jj = 1; jj <= num_aa_types(); ++jj ) {
93  //std::cout << get_node_index() << " ii: " << ii << " jj: " << jj << std::endl;
94  Vector nbatm;
95  Real bounding_square_radius( 0.0 );
96  for ( int kk = 1; kk <= num_states_for_aa_for_bb()( jj, ii ); ++kk ) {
97  //std::cout << get_node_index() << " ii: " << ii << " jj: " << jj << " kk: " << kk << std::endl;
98  Size kkrotid = state_offsets_for_aa_for_bb()( jj, ii ) + kk;
99  Residue const & kkrot = *rotamers_[ kkrotid ];
100  if ( kk == 1 ) { nbatm = kkrot.xyz( kkrot.nbr_atom() ); }
101  for ( Size ll = 1; ll <= kkrot.nheavyatoms(); ++ll ) {
102  //std::cout << get_node_index() << " ii: " << ii << " jj: " << jj << " kk: " << kk << " ll: " << ll << std::endl;
103  DistanceSquared lldis2 = nbatm.distance_squared( kkrot.xyz( ll ) );
104  if ( bounding_square_radius < lldis2 ) {
105  bounding_square_radius = lldis2;
106  }
107  }
108  }
109  bounding_volumes_for_bb_for_aa_[ ii ][ jj ] = bounding_square_radius;
110  }
111  }
112 
113  /// convert square radii to radii.
114  for ( int ii = 1; ii <= get_num_distinct_backbones(); ++ii ) {
115  for ( int jj = 1; jj <= num_aa_types(); ++jj ) {
116  bounding_volumes_for_bb_for_aa_[ ii ][ jj ] = std::sqrt( bounding_volumes_for_bb_for_aa_[ ii ][ jj ]);
117  }
118  }
119 
120 }
121 
124 {
125  return bounding_volumes_for_bb_for_aa_[ bb ][ aatype ];
126 }
127 
128 
129 /// EDGE
130 
131 OTFFlexbbEdge::OTFFlexbbEdge( OTFFlexbbInteractionGraph * owner, int node1, int node2 ) :
132  parent( owner, node1, node2 ),
133  compute_bbbb_and_scbb_otf_( false ),
134  lr_energies_exist_( false ),
135  pose_( get_otfflexbbig_owner()->get_pose() ),
136  sfxn_( get_otfflexbbig_owner()->get_scorefxn() )
137 {
139  procorr_curr_conf_[ 0 ] = procorr_curr_conf_[ 1 ] = 0.0;
140  glycorr_curr_conf_[ 0 ] = glycorr_curr_conf_[ 1 ] = 0.0;
142 
144  procorr_alt_conf_[ 0 ] = procorr_alt_conf_[ 1 ] = 0.0;
145  glycorr_alt_conf_[ 0 ] = glycorr_alt_conf_[ 1 ] = 0.0;
146  scsc_energy_alt_conf_ = 0.0;
147 
148  if ( nodes_part_of_same_flexseg() ) {
149  sr_aa_neighbors_.dimension(
150  get_otfflexbbig_owner()->get_num_aa_types(),
151  get_otfflexbbig_owner()->get_num_aa_types(),
152  num_bb( 0 ), 1); // num compact bb == 1
153  all_vs_bb_energies_[ 0 ].dimension( get_num_states_for_node( 0 ), 1 ); // num compact bb == 1
154  all_vs_bb_energies_[ 1 ].dimension( get_num_states_for_node( 1 ), 1 ); // num compact bb == 1
155  procorr_energies_[ 0 ].dimension( get_num_states_for_node( 0 ), 1 ); // num compact bb == 1
156  procorr_energies_[ 1 ].dimension( get_num_states_for_node( 1 ), 1 ); // num compact bb == 1
157  glycorr_energies_[ 0 ].dimension( get_num_states_for_node( 0 ), 1 ); // num compact bb == 1
158  glycorr_energies_[ 1 ].dimension( get_num_states_for_node( 1 ), 1 ); // num compact bb == 1
159 
160  } else {
161  sr_aa_neighbors_.dimension(
162  get_otfflexbbig_owner()->get_num_aa_types(),
163  get_otfflexbbig_owner()->get_num_aa_types(),
164  num_bb( 0 ),
165  num_bb( 1 ),
166  (unsigned char) 0 ),
167  all_vs_bb_energies_[ 0 ].dimension( get_num_states_for_node( 0 ), num_bb( 1 ) );
168  all_vs_bb_energies_[ 1 ].dimension( get_num_states_for_node( 1 ), num_bb( 0 ) );
169  procorr_energies_[ 0 ].dimension( get_num_states_for_node( 0 ), num_bb( 1 ) );
170  procorr_energies_[ 1 ].dimension( get_num_states_for_node( 1 ), num_bb( 0 ) );
171  glycorr_energies_[ 0 ].dimension( get_num_states_for_node( 0 ), num_bb( 1 ) );
172  glycorr_energies_[ 1 ].dimension( get_num_states_for_node( 1 ), num_bb( 0 ) );
173  }
174 
175  sr_aa_neighbors_ = 0;
176  all_vs_bb_energies_[ 0 ] = 0;
177  all_vs_bb_energies_[ 1 ] = 0;
178  procorr_energies_[ 0 ] = 0;
179  procorr_energies_[ 1 ] = 0;
180  glycorr_energies_[ 0 ] = 0;
181  glycorr_energies_[ 1 ] = 0;
182 
183 }
184 
186 
187 
188 
189 /// @details compute sc/sc energy while node 0 (first node) is
190 /// considering a fixed-backbone state substitution.
191 /// Prerequisit: alternate state must have already been set.
194 {
195  using namespace core::scoring;
196 
197  FlexbbSparseMatrixIndex const & altinfo0( nodes_alt_info(0));
198  FlexbbSparseMatrixIndex const & altinfo1( nodes_alt_info(1));
199 
200  assert( nodes_cur_state(1) == nodes_alt_state(1) );
201  assert( nodes_cur_state(1) == get_flexbb_node(1)->current_state() );
202  assert( altinfo0.get_bb() == nodes_cur_info(0).get_bb() || nodes_cur_info(0).get_bb() == 0 );
203  assert( nodes_alt_state(0) == get_flexbb_node(0)->alternate_state() );
204  assert( !nodes_part_of_same_flexseg() || altinfo0.get_bb() == altinfo1.get_bb() || nodes_cur_state(0) == 0 || nodes_alt_state(1) == 0 );
205 
206 
207  if ( nodes_cur_state(1) == 0 || nodes_alt_state( 0 ) == 0 ) {
208  set_alt_energy( 0.0 );
209  return 0.0;
210  }
211 
212  int const bb0 = compact_bbindex( altinfo0.get_bb() );
213  int const bb1 = compact_bbindex( altinfo1.get_bb() );
214 
217  procorr_energies_[ 0 ]( nodes_alt_state(0), bb1 ) : 0.0;
219  glycorr_energies_[ 0 ]( nodes_alt_state(0), bb1 ) : 0.0;
220 
223  procorr_energies_[ 1 ]( nodes_alt_state(1), bb0 ) : 0.0;
225  glycorr_energies_[ 1 ]( nodes_alt_state(1), bb0 ) : 0.0;
226 
227 
228  if ( sr_aa_neighbors_( altinfo0.get_aa_type(), altinfo1.get_aa_type(), altinfo0.get_bb(), bb1 ) ) {
229  EnergyMap tbemap;
230  sfxn_->eval_ci_2b_sc_sc( alt_rot(0), alt_rot(1), *pose_, tbemap );
231  sfxn_->eval_cd_2b_sc_sc( alt_rot(0), alt_rot(1), *pose_, tbemap );
232  scsc_energy_alt_conf_ = sfxn_->weights().dot( tbemap );
233  } else {
234  scsc_energy_alt_conf_ = 0.0;
235  }
236 
237  if ( lr_energies_exist_ ) {
238  EnergyMap emap;
239  for ( ScoreFunction::LR_2B_MethodIterator iter = sfxn_->long_range_energies_begin(),
240  iter_end = sfxn_->long_range_energies_end();
241  iter != iter_end; ++iter ) {
242  (*iter)->residue_pair_energy( alt_rot(0), alt_rot(1), *pose_, *sfxn_, emap );
243  }
244  scsc_energy_alt_conf_ += static_cast< PackerEnergy > ( sfxn_->weights().dot( emap ) );
245  }
246 
250  glycorr_alt_conf_[ 0 ] + glycorr_alt_conf_[ 1 ]));
251 
252 #ifdef DEBUG_OTF_FLEXBB_ENERGIES_VERBOSE
253  std::cout << "node 0 alt is gly?" << state_is_glycine( 0, nodes_alt_state(0) ) << std::endl;
254  std::cout << "node 1 alt is gly?" << state_is_glycine( 1, nodes_alt_state(1) ) << std::endl;
255  std::cout << "node 0 alt is pro?" << state_is_proline( 0, nodes_alt_state(0) ) << std::endl;
256  std::cout << "node 1 alt is pro?" << state_is_proline( 1, nodes_alt_state(1) ) << std::endl;
257 
258  std::cout << "compute_samebbconf_alternate_state_energy_first_node: " << get_node_index(0) << " " << get_node_index(1) << " " << alt_energy() << " " << nodes_alt_state(0) << " " << nodes_alt_state(1) << std::endl;
259  std::cout << alt_rot(0).aa() << " " << alt_rot(1).aa() << std::endl;
260  std::cout << "scsc_energy_alt_conf_ " << scsc_energy_alt_conf_ <<
261  " all_vs_bb_energy_alt_conf_[ 0 ] " << all_vs_bb_energy_alt_conf_[ 0 ] <<
262  " all_vs_bb_energy_alt_conf_[ 1 ] " << all_vs_bb_energy_alt_conf_[ 1 ] <<
263  " procorr_alt_conf_[ 0 ] " << procorr_alt_conf_[ 0 ] <<
264  " procorr_alt_conf_[ 1 ] " << procorr_alt_conf_[ 1 ] <<
265  " glycorr_alt_conf_[ 0 ] " << glycorr_alt_conf_[ 0 ] <<
266  " glycorr_alt_conf_[ 1 ] " << glycorr_alt_conf_[ 1 ] << std::endl;
267 
268  std::cout << "scsc_energy_curr_conf_ " << scsc_energy_curr_conf_ <<
269  " all_vs_bb_energy_curr_conf_[ 0 ] " << all_vs_bb_energy_curr_conf_[ 0 ] <<
270  " all_vs_bb_energy_curr_conf_[ 1 ] " << all_vs_bb_energy_curr_conf_[ 1 ] <<
271  " procorr_curr_conf_[ 0 ] " << procorr_curr_conf_[ 0 ] <<
272  " procorr_curr_conf_[ 1 ] " << procorr_curr_conf_[ 1 ] <<
273  " glycorr_curr_conf_[ 0 ] " << glycorr_curr_conf_[ 0 ] <<
274  " glycorr_curr_conf_[ 1 ] " << glycorr_curr_conf_[ 1 ] << std::endl;
275  std::cout << " coord: " << alt_rot(1).xyz( alt_rot(1).nheavyatoms() ).x() <<
276  " " << alt_rot(1).xyz( alt_rot(1).nheavyatoms() ).y() <<
277  " " << alt_rot(1).xyz( alt_rot(1).nheavyatoms() ).z() << std::endl;
278 #endif
279 
280  // Note: scale the interaction energy by the edge_weight held on this edge.
281  return alt_energy();
282 }
283 
284 /// @details Prerequisit: alternate state must have already been set.
287 {
288  using namespace core::scoring;
289 
290  FlexbbSparseMatrixIndex const & altinfo0( nodes_alt_info(0));
291  FlexbbSparseMatrixIndex const & altinfo1( nodes_alt_info(1));
292 
293  assert( nodes_cur_state(0) == nodes_alt_state(0) );
294  assert( nodes_cur_state(0) == get_flexbb_node(0)->current_state() );
295  assert( altinfo1.get_bb() == nodes_cur_info(1).get_bb() || nodes_cur_info(1).get_bb() == 0 );
296  assert( nodes_alt_state(1) == get_flexbb_node(1)->alternate_state() );
297  assert( !nodes_part_of_same_flexseg() || altinfo0.get_bb() == altinfo1.get_bb() || nodes_cur_state(0) == 0 || nodes_alt_state(1) == 0 );
298 
299  if ( nodes_cur_state(0) == 0 || nodes_alt_state(1) == 0 ) {
300  set_alt_energy( 0.0 );
301  return 0.0;
302  }
303 
304 
305  int const bb0 = compact_bbindex( altinfo0.get_bb() );
306  int const bb1 = compact_bbindex( altinfo1.get_bb() );
307 
310  procorr_energies_[ 0 ]( nodes_alt_state(0), bb1 ) : 0.0;
312  glycorr_energies_[ 0 ]( nodes_alt_state(0), bb1 ) : 0.0;
313 
316  procorr_energies_[ 1 ]( nodes_alt_state(1), bb0 ) : 0.0;
318  glycorr_energies_[ 1 ]( nodes_alt_state(1), bb0 ) : 0.0;
319 
320  if ( sr_aa_neighbors_( altinfo0.get_aa_type(), altinfo1.get_aa_type(), altinfo0.get_bb(), bb1 ) ) {
322  sfxn_->eval_ci_2b_sc_sc( alt_rot(0), alt_rot(1), *pose_, tbemap );
323  sfxn_->eval_cd_2b_sc_sc( alt_rot(0), alt_rot(1), *pose_, tbemap );
324  scsc_energy_alt_conf_ = sfxn_->weights().dot( tbemap );
325  } else {
326  scsc_energy_alt_conf_ = 0.0;
327  }
328 
329  if ( lr_energies_exist_ ) {
330  EnergyMap emap;
331  for ( ScoreFunction::LR_2B_MethodIterator iter = sfxn_->long_range_energies_begin(),
332  iter_end = sfxn_->long_range_energies_end();
333  iter != iter_end; ++iter ) {
334  (*iter)->residue_pair_energy( alt_rot(0), alt_rot(1), *pose_, *sfxn_, emap );
335  }
336  scsc_energy_alt_conf_ += static_cast< PackerEnergy > ( sfxn_->weights().dot( emap ) );
337  }
338 
342  glycorr_alt_conf_[ 0 ] + glycorr_alt_conf_[ 1 ]));
343 
344 #ifdef DEBUG_OTF_FLEXBB_ENERGIES_VERBOSE
345  std::cout << "node 0 alt is gly?" << state_is_glycine( 0, nodes_alt_state(0) ) << std::endl;
346  std::cout << "node 1 alt is gly?" << state_is_glycine( 1, nodes_alt_state(1) ) << std::endl;
347  std::cout << "node 0 alt is pro?" << state_is_proline( 0, nodes_alt_state(0) ) << std::endl;
348  std::cout << "node 1 alt is pro?" << state_is_proline( 1, nodes_alt_state(1) ) << std::endl;
349 
350  std::cout << "compute_samebbconf_alternate_state_energy_second_node: " << get_node_index(0) << " " << get_node_index(1) << " " << alt_energy() << " " << nodes_alt_state(0) << " " << nodes_alt_state(1) << std::endl;
351  std::cout << alt_rot(0).aa() << " " << alt_rot(1).aa() << std::endl;
352  std::cout << "scsc_energy_alt_conf_ " << scsc_energy_alt_conf_ <<
353  " all_vs_bb_energy_alt_conf_[ 0 ] " << all_vs_bb_energy_alt_conf_[ 0 ] <<
354  " all_vs_bb_energy_alt_conf_[ 1 ] " << all_vs_bb_energy_alt_conf_[ 1 ] <<
355  " procorr_alt_conf_[ 0 ] " << procorr_alt_conf_[ 0 ] <<
356  " procorr_alt_conf_[ 1 ] " << procorr_alt_conf_[ 1 ] <<
357  " glycorr_alt_conf_[ 0 ] " << glycorr_alt_conf_[ 0 ] <<
358  " glycorr_alt_conf_[ 1 ] " << glycorr_alt_conf_[ 1 ] << std::endl;
359 
360  std::cout << "scsc_energy_curr_conf_ " << scsc_energy_curr_conf_ <<
361  " all_vs_bb_energy_curr_conf_[ 0 ] " << all_vs_bb_energy_curr_conf_[ 0 ] <<
362  " all_vs_bb_energy_curr_conf_[ 1 ] " << all_vs_bb_energy_curr_conf_[ 1 ] <<
363  " procorr_curr_conf_[ 0 ] " << procorr_curr_conf_[ 0 ] <<
364  " procorr_curr_conf_[ 1 ] " << procorr_curr_conf_[ 1 ] <<
365  " glycorr_curr_conf_[ 0 ] " << glycorr_curr_conf_[ 0 ] <<
366  " glycorr_curr_conf_[ 1 ] " << glycorr_curr_conf_[ 1 ] << std::endl;
367  std::cout << " coord: " << alt_rot(0).xyz( alt_rot(0).nheavyatoms() ).x() <<
368  " " << alt_rot(0).xyz( alt_rot(0).nheavyatoms() ).y() <<
369  " " << alt_rot(0).xyz( alt_rot(0).nheavyatoms() ).z() << std::endl;
370 #endif
371 
372 
373  return alt_energy();
374 }
375 
376 /// @details Prerequisit: alternate state(s) must have already been set.
379 {
380  using namespace core::scoring;
381 
382  FlexbbSparseMatrixIndex const & altinfo0( nodes_alt_info(0));
383  FlexbbSparseMatrixIndex const & altinfo1( nodes_alt_info(1));
384 
385  assert( nodes_alt_state(0) == get_flexbb_node(0)->alternate_state() );
386  assert( nodes_alt_state(1) == get_flexbb_node(1)->alternate_state() );
387 
388 
389  if ( nodes_alt_state( 0 ) == 0 || nodes_alt_state( 1 ) == 0 ) {
390  set_alt_energy( 0.0 );
391  return 0.0;
392  }
393 
394  int const bb0 = compact_bbindex( altinfo0.get_bb() );
395  int const bb1 = compact_bbindex( altinfo1.get_bb() );
396 
399  procorr_energies_[ 0 ]( nodes_alt_state(0), bb1 ) : 0.0;
401  glycorr_energies_[ 0 ]( nodes_alt_state(0), bb1 ) : 0.0;
402 
405  procorr_energies_[ 1 ]( nodes_alt_state(1), bb0 ) : 0.0;
407  glycorr_energies_[ 1 ]( nodes_alt_state(1), bb0 ) : 0.0;
408 
409  if ( sr_aa_neighbors_( altinfo0.get_aa_type(), altinfo1.get_aa_type(), altinfo0.get_bb(), bb1 ) ) {
411  sfxn_->eval_ci_2b_sc_sc( alt_rot(0), alt_rot(1), *pose_, tbemap );
412  sfxn_->eval_cd_2b_sc_sc( alt_rot(0), alt_rot(1), *pose_, tbemap );
413  scsc_energy_alt_conf_ = static_cast< PackerEnergy > ( sfxn_->weights().dot( tbemap ));
414  } else {
415  scsc_energy_alt_conf_ = 0.0;
416  }
417 
418  if ( lr_energies_exist_ ) {
419  EnergyMap emap;
420  for ( ScoreFunction::LR_2B_MethodIterator iter = sfxn_->long_range_energies_begin(),
421  iter_end = sfxn_->long_range_energies_end();
422  iter != iter_end; ++iter ) {
423  (*iter)->residue_pair_energy( alt_rot(0), alt_rot(1), *pose_, *sfxn_, emap );
424  }
425  scsc_energy_alt_conf_ += static_cast< PackerEnergy > ( sfxn_->weights().dot( emap ) );
426  }
427 
431  glycorr_alt_conf_[ 0 ] + glycorr_alt_conf_[ 1 ]));
432 
433 #ifdef DEBUG_OTF_FLEXBB_ENERGIES_VERBOSE
434  std::cout << "compute_altbbconf_alternate_state_energy: " << get_node_index(0) << " " << get_node_index(1) << " " << bb0 << " " << bb1 << " " << alt_energy() << " " << nodes_alt_state(0) << " " << nodes_alt_state(1) << std::endl;
435  std::cout << alt_rot(0).aa() << " " << alt_rot(1).aa() << std::endl;
436  std::cout << "scsc_energy_alt_conf_ " << scsc_energy_alt_conf_ <<
437  " all_vs_bb_energy_alt_conf_[ 0 ] " << all_vs_bb_energy_alt_conf_[ 0 ] <<
438  " all_vs_bb_energy_alt_conf_[ 1 ] " << all_vs_bb_energy_alt_conf_[ 1 ] <<
439  " procorr_alt_conf_[ 0 ] " << procorr_alt_conf_[ 1 ] <<
440  " procorr_alt_conf_[ 1 ] " << procorr_alt_conf_[ 1 ] <<
441  " glycorr_alt_conf_[ 0 ] " << glycorr_alt_conf_[ 1 ] <<
442  " glycorr_alt_conf_[ 1 ] " << glycorr_alt_conf_[ 1 ] << std::endl;
443 
444  std::cout << "scsc_energy_curr_conf_ " << scsc_energy_curr_conf_ <<
445  " all_vs_bb_energy_curr_conf_[ 0 ] " << all_vs_bb_energy_curr_conf_[ 0 ] <<
446  " all_vs_bb_energy_curr_conf_[ 1 ] " << all_vs_bb_energy_curr_conf_[ 1 ] <<
447  " procorr_curr_conf_[ 0 ] " << procorr_curr_conf_[ 1 ] <<
448  " procorr_curr_conf_[ 1 ] " << procorr_curr_conf_[ 1 ] <<
449  " glycorr_curr_conf_[ 0 ] " << glycorr_curr_conf_[ 1 ] <<
450  " glycorr_curr_conf_[ 1 ] " << glycorr_curr_conf_[ 1 ] << std::endl;
451 #endif
452 
453  return alt_energy();
454 
455 }
456 
457 void
459 {
460  //std::cout << "otfedge_note_substitution_accepted " << get_node_index(0) << " " << get_node_index(1) << std::endl;
468 /*
469  std::cout << "scsc_energy_alt_conf_ " << scsc_energy_alt_conf_ <<
470  " all_vs_bb_energy_alt_conf_[ 0 ] " << all_vs_bb_energy_alt_conf_[ 0 ] <<
471  " all_vs_bb_energy_alt_conf_[ 1 ] " << all_vs_bb_energy_alt_conf_[ 1 ] <<
472  " procorr_alt_conf_[ 0 ] " << procorr_alt_conf_[ 1 ] <<
473  " procorr_alt_conf_[ 1 ] " << procorr_alt_conf_[ 1 ] <<
474  " glycorr_alt_conf_[ 0 ] " << glycorr_alt_conf_[ 1 ] <<
475  " glycorr_alt_conf_[ 1 ] " << glycorr_alt_conf_[ 1 ] << std::endl;
476 
477  std::cout << "scsc_energy_curr_conf_ " << scsc_energy_curr_conf_ <<
478  " all_vs_bb_energy_curr_conf_[ 0 ] " << all_vs_bb_energy_curr_conf_[ 0 ] <<
479  " all_vs_bb_energy_curr_conf_[ 1 ] " << all_vs_bb_energy_curr_conf_[ 1 ] <<
480  " procorr_curr_conf_[ 0 ] " << procorr_curr_conf_[ 1 ] <<
481  " procorr_curr_conf_[ 1 ] " << procorr_curr_conf_[ 1 ] <<
482  " glycorr_curr_conf_[ 0 ] " << glycorr_curr_conf_[ 1 ] <<
483  " glycorr_curr_conf_[ 1 ] " << glycorr_curr_conf_[ 1 ] << std::endl;
484 */
485 }
486 
487 unsigned int
489 {
490 
491  unsigned int total = parent::count_dynamic_memory();
492  total += all_vs_bb_energies_[ 0 ].size() * sizeof( PackerEnergy );
493  total += all_vs_bb_energies_[ 1 ].size() * sizeof( PackerEnergy );
494  total += procorr_energies_[ 0 ].size() * sizeof( PackerEnergy );
495  total += procorr_energies_[ 1 ].size() * sizeof( PackerEnergy );
496  total += glycorr_energies_[ 0 ].size() * sizeof( PackerEnergy );
497  total += glycorr_energies_[ 1 ].size() * sizeof( PackerEnergy );
498  total += sr_aa_neighbors_.size() * sizeof( unsigned char );
499  return total;
500 }
501 
502 void
504  int node_not_necessarily_proline,
505  int state,
506  int other_bb,
507  PackerEnergy bb_nonprobb_E,
508  PackerEnergy bb_probb_E,
509  PackerEnergy sc_nonprobb_E,
510  PackerEnergy sc_probb_E
511 )
512 {
513  int const node = which_node( node_not_necessarily_proline );
514 
515  all_vs_bb_energies_[ node ]( state, compact_bbindex( other_bb ) ) = sc_nonprobb_E + 0.5 * bb_nonprobb_E;
516 
517  procorr_energies_[ node ]( state, compact_bbindex( other_bb ) ) =
518  sc_probb_E + 0.5 * bb_probb_E -
519  (sc_nonprobb_E + 0.5 * bb_nonprobb_E);
520 
521  /*if ( get_node_index(0) == 27 && get_node_index(1) == 28 ) {
522  std::cout << "SetProCorr: " << get_node_index(0) << " " << get_node_index(1) << " " << node << " " << state << " " << compact_bbindex( other_bb )
523  << " allvbb " << all_vs_bb_energies_[ node ]( state, compact_bbindex( other_bb ) ) << " "
524  << " procorr " << procorr_energies_[ node ]( state, compact_bbindex( other_bb ) ) << std::endl;
525  }*/
526 
527 
528 }
529 
530 void
532  int node_not_necessarily_glycine,
533  int state,
534  int other_bb,
535  PackerEnergy bb_nonglybb_E,
536  PackerEnergy bb_glybb_E,
537  PackerEnergy sc_nonglybb_E,
538  PackerEnergy sc_glybb_E
539 )
540 {
541  int const node = which_node( node_not_necessarily_glycine );
542 
543  /// Assume this has already been done when setting the glycine correction?
544  /// No. Proline might not be present. If both glycine and glycine are present
545  /// then this assignment is done twice; that's ok.
546  all_vs_bb_energies_[ node ]( state, compact_bbindex( other_bb ) ) = sc_nonglybb_E + 0.5 * bb_nonglybb_E;
547 
548  glycorr_energies_[ node ]( state, compact_bbindex( other_bb ) ) =
549  sc_glybb_E + 0.5 * bb_glybb_E -
550  (sc_nonglybb_E + 0.5 * bb_nonglybb_E);
551 
552  /*if ( get_node_index(0) == 27 && get_node_index(1) == 28 ) {
553  std::cout << "SetGlyCorr: " << get_node_index(0) << " " << get_node_index(1) << " " << node << " " << state << " " << compact_bbindex( other_bb )
554  << " allvbb " << all_vs_bb_energies_[ node ]( state, compact_bbindex( other_bb ) ) << " "
555  << " glycorr " << glycorr_energies_[ node ]( state, compact_bbindex( other_bb ) ) << std::endl;
556  }*/
557 
558 }
559 
560 
561 void
563 {
564  //std::cout << "OTFFlexbbEdge::prepare_for_simulated_annealing" << std::endl;
565 
566  /// compute sr_aa_neighbors_ table
567  using namespace core;
568 
569  Real const sfxn_reach = sfxn_->info()->max_atomic_interaction_distance();
570 
571  Size const naatypes = sr_aa_neighbors_.size1();
572  for ( int ii = 1; ii <= num_bb( 0 ); ++ii ) {
573  for ( int jj = 1, jje = compact_bbindex( num_bb( 1 ) ); jj <= jje; ++jj ) {
574  int const jjbb = get_nodes_from_same_flexseg() ? ii : jj;
575  for ( Size kk = 1; kk <= naatypes; ++kk ) {
576 
577  if ( get_otfflexbb_node( 0 )->num_states_for_aa_for_bb()( kk, ii ) == 0 ) continue;
578  int kkoffset = get_otfflexbb_node( 0 )->state_offsets_for_aa_for_bb()( kk, ii );
579  int kkrotno = 1 + kkoffset;
580  Residue const & kkrot = get_otfflexbb_node( 0 )->rotamer( kkrotno );
581  Vector const kkpos = kkrot.xyz( kkrot.nbr_atom() );
582  Real const kk_reach = get_otfflexbb_node( 0 )->bounding_radius_for_rotamers( kk, ii );
583 
584  for ( Size ll = 1; ll <= naatypes; ++ll ) {
585  if ( get_otfflexbb_node( 1 )->num_states_for_aa_for_bb()( ll, jjbb ) == 0 ) continue;
586 
587  int lloffset = get_otfflexbb_node( 1 )->state_offsets_for_aa_for_bb()( ll, jjbb );
588  int llrotno = 1 + lloffset;
589  Residue const & llrot = get_otfflexbb_node( 1 )->rotamer( llrotno );
590  Vector const llpos = llrot.xyz( llrot.nbr_atom() );
591  Real const ll_reach = get_otfflexbb_node( 1 )->bounding_radius_for_rotamers( ll, jjbb );
592 
593  // cast boolean d2 comparison to unsigned char -- also should test boolean lookup time
594  // as well as integer lookup time... reading boolean FArrays is usually very slow.
595  sr_aa_neighbors_( kk, ll, ii, jj ) = (unsigned char)
596  (kkpos.distance_squared( llpos ) < std::pow( kk_reach + sfxn_reach + ll_reach, 2 ));
597  //std::cout << "EDGE: " << get_node_index(0) << " " << get_node_index(0) << " " << ii << " ";
598  //std::cout << jj << " " << kkrot.aa() << " " << llrot.aa() << " " << (bool) sr_aa_neighbors_( kk, ll, ii, jj ) << std::endl;
599  }
600  }
601  }
602  }
603 }
604 
605 void
607 {
608  lr_energies_exist_ = true;
609 }
610 
611 inline
612 bool
614  return get_otfflexbb_node( which_node )->rotamer_is_proline( state );
615 }
616 
617 inline
618 bool
620  return get_otfflexbb_node( which_node )->rotamer_is_glycine( state );
621 }
622 
623 void
625 {
626 
627  parent::set_node_state_to_zero( which_node );
629  procorr_curr_conf_[ 0 ] = /*procorr_curr_conf_[ 0 ] =*/ 0.0; // Was procorr_curr_conf_[ 1 ] meant? ~Labonte
631 
633  procorr_alt_conf_[ 0 ] = /*procorr_alt_conf_[ 0 ] =*/ 0.0; // Was procorr_alt_conf_[ 1 ] meant? ~Labonte
635 
636 }
637 
638 void
640 {
641  std::cout << "OTFFlexbbEdge::print_alt_energies() " << get_node_index(0) << " " << get_node_index(1) << std::endl;
642  std::cout << "scsc_energy_alt_conf_ " << scsc_energy_alt_conf_ <<
643  " all_vs_bb_energy_alt_conf_[ 0 ] " << all_vs_bb_energy_alt_conf_[ 0 ] <<
644  " all_vs_bb_energy_alt_conf_[ 1 ] " << all_vs_bb_energy_alt_conf_[ 1 ] <<
645  " procorr_alt_conf_[ 0 ] " << procorr_alt_conf_[ 1 ] <<
646  " procorr_alt_conf_[ 1 ] " << procorr_alt_conf_[ 1 ] <<
647  " glycorr_alt_conf_[ 0 ] " << glycorr_alt_conf_[ 1 ] <<
648  " glycorr_alt_conf_[ 1 ] " << glycorr_alt_conf_[ 1 ] << std::endl;
649 
650  std::cout << "scsc_energy_curr_conf_ " << scsc_energy_curr_conf_ <<
651  " all_vs_bb_energy_curr_conf_[ 0 ] " << all_vs_bb_energy_curr_conf_[ 0 ] <<
652  " all_vs_bb_energy_curr_conf_[ 1 ] " << all_vs_bb_energy_curr_conf_[ 1 ] <<
653  " procorr_curr_conf_[ 0 ] " << procorr_curr_conf_[ 1 ] <<
654  " procorr_curr_conf_[ 1 ] " << procorr_curr_conf_[ 1 ] <<
655  " glycorr_curr_conf_[ 0 ] " << glycorr_curr_conf_[ 1 ] <<
656  " glycorr_curr_conf_[ 1 ] " << glycorr_curr_conf_[ 1 ] << std::endl;
657 }
658 
659 
660 /// GRAPH
661 
663  parent( num_nodes ),
664  current_pose_energy_( 0.0 ),
665  alternate_pose_energy_( 0.0 )
666 {}
667 
669 {}
670 
671 void
674 )
675 {
676  parent::initialize( rot_sets );
677 
678  assert( get_num_nodes() == (int) rot_sets.nmoltenres() );
679 
680  for ( int ii = 1; ii <= get_num_nodes(); ++ii ) {
681  int ii_rotoffset = rot_sets.nrotamer_offset_for_moltenres( ii );
682  for ( int jj = 1, jje = rot_sets.nrotamers_for_moltenres(ii);
683  jj <= jje; ++jj ) {
684  get_otfflexbb_node(ii)->set_rotamer( jj, rot_sets.rotamer( jj + ii_rotoffset ) );
685  }
687  }
688 
689 #ifdef DEBUG_OTF_FLEXBB_ENERGIES
690  for ( int ii = 1; ii <= get_num_nodes(); ++ii ) {
691  moltenres_2_resid_[ ii ] = rot_sets.moltenres_2_resid( ii );
693  }
694 #endif
695 
696 }
697 
698 void
700  int node1,
701  int node2,
702  int node_not_necessarily_proline,
703  int state,
704  int other_bb,
705  PackerEnergy bb_nonprobb_E,
706  PackerEnergy bb_probb_E,
707  PackerEnergy sc_nonprobb_E,
708  PackerEnergy sc_probb_E
709 )
710 {
712  node_not_necessarily_proline, state, other_bb,
713  bb_nonprobb_E, bb_probb_E, sc_nonprobb_E, sc_probb_E );
714 }
715 
716 void
718  int node1,
719  int node2,
720  int node_not_necessarily_glycine,
721  int state,
722  int other_bb,
723  PackerEnergy bb_nonglybb_E,
724  PackerEnergy bb_glybb_E,
725  PackerEnergy sc_nonglybb_E,
726  PackerEnergy sc_glybb_E
727 )
728 {
730  node_not_necessarily_glycine, state, other_bb,
731  bb_nonglybb_E, bb_glybb_E, sc_nonglybb_E, sc_glybb_E );
732 }
733 
734 
735 unsigned int
737 {
738  /// Note: no memory accounting code for Pose or ScoreFunction!
740 }
741 
742 void
744 {
745  assert( get_num_edges() == 0 );
746  pose_ = new Pose( pose );
747 
748 #ifdef DEBUG_OTF_FLEXBB_ENERGIES
749  current_pose_ = new Pose( pose );
750  alternate_pose_ = new Pose( pose );
751  resid_2_moltenres_.resize( pose.total_residue() );
752  moltenres_2_resid_.resize( get_num_nodes() );
753 #endif
754 
755 }
756 
757 
758 void
760 {
761  assert( get_num_edges() == 0 );
762  sfxn_ = new ScoreFunction( sfxn );
763 
764 #ifdef DEBUG_OTF_FLEXBB_ENERGIES
765  using namespace core::scoring;
766  assert( pose_ ); // context pose must be set before the score function.
767 
768  (*sfxn_)( *pose_ );
769 
771 
772  methods::EnergyMethodOptions opts = sfxn_->energy_method_options();
773  opts.decompose_bb_hb_into_pair_energies( true );
774  oc_sfxn_->set_energy_method_options( opts );
775 
776  for ( Size ii = 1; ii <= n_score_types; ++ii ) {
777  ScoreType iist = (ScoreType) ii;
778  if ( sfxn.weights()[ iist ] != 0.0 ) {
779  oc_sfxn_->set_weight( iist, sfxn.weights()[ iist ] );
780  }
781  }
782 
783 #endif
784 
785 
786 }
787 
790 {
791  assert( pose_ );
792  return pose_;
793 }
794 
797 {
798  assert( sfxn_ );
799  return sfxn_;
800 }
801 
802 void
804  int node1,
805  int node2
806 )
807 {
808  OTFFlexbbEdge * edge = find_otfflexbb_edge( node1, node2 );
809  if ( edge ) {
811  }
812 }
813 
814 
815 
816 void
818 {
819 #ifndef DEBUG_OTF_FLEXBB_ENERGIES
820  utility_exit_with_message( "Do not call OTFFlexbbInteractionGraph::debug_note_considered_substitution unless debugging" );
821 #endif
822 
823  //std::cout << "Replacing residue " << alt_rotamer.seqpos() << " moltenres: " << resid_2_moltenres_[alt_rotamer.seqpos() ] << std::endl;
824  alternate_pose_->replace_residue( alt_rotamer.seqpos(), alt_rotamer, false ); // PHIL PLEASE MAKE THIS O(1)!
825  changing_seqpos_.push_back( alt_rotamer.seqpos() );
826  alt_rots_.push_back( alt_rotamer.clone() );
827  alt_rot_inds_.push_back( index );
828 }
829 
830 void
832  PackerEnergy deltaE,
833  PackerEnergy node_totalE,
834  bool require_match
835 )
836 {
837 #ifndef DEBUG_OTF_FLEXBB_ENERGIES
838  utility_exit_with_message( "Do not call OTFFlexbbInteractionGraph::debug_note_projected_deltaE_of_considered_substitution unless debugging" );
839 #endif
840  Real alt_E_real = 0;// = (*sfxn_)(*alternate_pose_);
841  alternate_pose_energy_ = (*oc_sfxn_)( *alternate_pose_ );
842 
843  static int n_correct_since_last_problem = 0;
844 
846  Real delta_delta = std::abs( deltaE - real_deltaE );
847  bool large = std::abs(delta_delta) > 1e-4;
848  bool significant = large && std::abs( delta_delta / node_totalE ) > 1e-5 && std::abs( delta_delta / (deltaE + node_totalE )) > 1e-5 && std::abs( delta_delta / real_deltaE ) > 1e-5;
849 
850  if ( require_match && ! any_vertex_state_unassigned() && significant && large ) {
851 
852  std::cout << "Delta E: predicted -- " << deltaE << " real: "
853  << real_deltaE << " delta_delta: " << delta_delta << " sig: " << std::abs( delta_delta / node_totalE ) << " " << std::abs( delta_delta / (deltaE + node_totalE ))
854  << " (since last problem: " << n_correct_since_last_problem << " )"
855  << " ocE: " << alternate_pose_energy_ << " realE " << alt_E_real << " delta: " << alternate_pose_energy_ - alt_E_real << std::endl;
856  n_correct_since_last_problem = 0;
857  std::cout << "Changing nodes:";
858  for ( Size ii = 1; ii <= changing_seqpos_.size(); ++ii ) {
859  std::cout << " ( " << changing_seqpos_[ ii ] << " " << alt_rot_inds_[ ii ] << ")";
860  }
861  std::cout << std::endl;
862  for ( Size ii = 1; ii <= changing_seqpos_.size(); ++ii ) {
863  Size ii_resid = changing_seqpos_[ ii ];
864  Size ii_moltenresid = resid_2_moltenres_[ ii_resid ];
865  //std::cout << "Real energies: " << ii_moltenresid;
866  Real ii_total( 0.0 );
868  ir = alternate_pose_->energies().energy_graph().get_node(ii_resid)->edge_list_begin(),
869  ire = alternate_pose_->energies().energy_graph().get_node(ii_resid)->edge_list_end();
870  ir != ire; ++ir ) {
871  Size jj_resid = (*ir)->get_other_ind( ii_resid );
872  Size jj_moltenresid = resid_2_moltenres_[ jj_resid ];
873  if ( jj_moltenresid == 0 ) continue;
874 
875  Real ii_jj_energy = (static_cast< core::scoring::EnergyEdge const *> (*ir))->dot( oc_sfxn_->weights() );
876  ii_total += ii_jj_energy;
877 
878  //std::cout << "Two-Body Energy Real: " << ii_moltenresid << " " << jj_moltenresid << " " << ii_jj_energy << std::endl;
879 
880  OTFFlexbbEdge const * ii_jj_edge = find_otfflexbb_edge( ii_moltenresid, jj_moltenresid );
881  if ( !ii_jj_edge ) {
882  if ( ii_jj_energy != 0.0 ) std::cout << "EDGE MISSING FROM INTERACTION GRAPH: ( " << ii_moltenresid << " " << jj_moltenresid << " ) missing energy of " << ii_jj_energy << std::endl;
883  continue;
884  }
885 
886  Real delta = std::abs( ii_jj_edge->alt_energy() - ii_jj_energy );
887  if ( delta > 1e-5 ) {
888 
889  std::cout << "Two-Body Energy Error: " << ii_moltenresid << " " << jj_moltenresid << " real " << ii_jj_energy ;
890  std::cout << " predicted: " << ii_jj_edge->alt_energy() << " ";
891  std::cout << alternate_pose_->residue( ii_resid ).aa() << " " << alternate_pose_->residue( jj_resid ).aa() << std::endl;
892  std::cout << " bbbb: " << core::pack::rotamer_set::RotamerSets::get_bb_bbE(
893  *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) );
894  std::cout << " sc1bb2: " << core::pack::rotamer_set::RotamerSets::get_sc_bbE(
895  *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) );
896  std::cout << " bb1sc2: " << core::pack::rotamer_set::RotamerSets::get_sc_bbE(
897  *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( jj_resid ), alternate_pose_->residue( ii_resid ) );
898 
900  oc_sfxn_->eval_ci_2b_sc_sc( alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) , *alternate_pose_, tbemap );
901  oc_sfxn_->eval_cd_2b_sc_sc( alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) , *alternate_pose_, tbemap );
902  Real scsc_energy_alt_conf = oc_sfxn_->weights().dot( tbemap );
903  std::cout << " scsc: " << scsc_energy_alt_conf;
904 
905  std::cout << std::endl;
906  ii_jj_edge->print_alt_energies();
907 
908  }
909 
910  }
911  Real ii_one_body_energy = alternate_pose_->energies().onebody_energies( ii_resid ).dot( oc_sfxn_->weights() );
912  Real ii_one_body_and_background = ii_one_body_energy;
913  //std::cout << "Real one body energies: " << << std::endl;
914  //std::cout << "Real two body energy total: " << ii_total << std::endl;
915  //std::cout << std::endl;
916 
917 
918  //std::cout << "Real energies with background: " << ii_moltenresid;
919  ii_total = 0.0;
921  ir = alternate_pose_->energies().energy_graph().get_node(ii_resid)->edge_list_begin(),
922  ire = alternate_pose_->energies().energy_graph().get_node(ii_resid)->edge_list_end();
923  ir != ire; ++ir ) {
924  Size jj_resid = (*ir)->get_other_ind( ii_resid );
925  Size jj_moltenresid = resid_2_moltenres_[ jj_resid ];
926  if ( jj_moltenresid != 0 ) continue;
927  Real ii_jj_energy = (static_cast< core::scoring::EnergyEdge const *> (*ir))->dot(oc_sfxn_->weights());
928  ii_total += ii_jj_energy;
929  ii_one_body_and_background += ii_jj_energy;
930  //std::cout << " " << jj_resid << " " << ii_jj_energy ;
931 
932  //std::cout << " bbbb: " << core::pack::rotamer_set::RotamerSets::get_bb_bbE(
933  // *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) );
934  //std::cout << " sc1bb2: " << core::pack::rotamer_set::RotamerSets::get_sc_bbE(
935  // *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) );
936  //std::cout << " bb1sc2: " << core::pack::rotamer_set::RotamerSets::get_sc_bbE(
937  // *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( jj_resid ), alternate_pose_->residue( ii_resid ) );
938 
939  //core::scoring::EnergyMap tbemap;
940  //oc_sfxn_->eval_ci_2b_sc_sc( alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) , *alternate_pose_, tbemap );
941  //oc_sfxn_->eval_cd_2b_sc_sc( alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) , *alternate_pose_, tbemap );
942  //Real scsc_energy_alt_conf = oc_sfxn_->weights().dot( tbemap );
943  //std::cout << " scsc: " << scsc_energy_alt_conf;
944 
945  //std::cout << std::endl;
946 
947 
948  }
949 
950  //std::cout << "Real one body energies: " << alternate_pose_->energies().onebody_energies( ii_resid ).dot( oc_sfxn_->weights() ) << std::endl;
951  //std::cout << "Real two body background energy total: " << ii_total << std::endl;
952  //std::cout << "Real total energy: " << alternate_pose_->energies().residue_total_energies( ii_resid ).dot( oc_sfxn_->weights() ) << std::endl;
953  Real one_body_delta = std::abs( ii_one_body_and_background - get_otfflexbb_node( ii_moltenresid )->alternate_state_one_body_energy() );
954  if ( one_body_delta > 1e-5 && one_body_delta / ii_one_body_and_background > 1e-5) {
955  std::cout << "One body energy in error: molt: " << ii_moltenresid << " resid: " << ii_resid
956  << " rot: " << alt_rot_inds_[ ii ] << " " << alternate_pose_->residue( ii_resid ).aa()
957  << " real " << ii_one_body_and_background << " pred "
958  << get_otfflexbb_node( ii_moltenresid )->alternate_state_one_body_energy() << std::endl;
959  std::cout << "One body internal " << ii_one_body_energy << " ";
960  alternate_pose_->energies().onebody_energies( ii_resid ).show_weighted( std::cout, oc_sfxn_->weights() );
961  std::cout << std::endl;
962  /*for ( Size jj = 1; jj <= alt_rots_[ ii ]->mainchain_torsions().size(); ++jj ) {
963  std::cout << "bb angles: " << jj << " " <<
964  alternate_pose_->residue( ii_resid ).mainchain_torsions()[ jj ] << " vs " <<
965  alt_rots_[ ii ]->mainchain_torsions()[ jj ] << std::endl;
966  }
967  for ( Size jj = 1; jj <= alt_rots_[ ii ]->natoms(); ++jj ) {
968  std::cout << "coords: " << jj << " (" << alternate_pose_->residue( ii_resid ).xyz( jj ).x()
969  << " " << alternate_pose_->residue( ii_resid ).xyz( jj ).y()
970  << " " << alternate_pose_->residue( ii_resid ).xyz( jj ).z() << ") vs ("
971  << " " << alt_rots_[ ii ]->xyz( jj ).x()
972  << " " << alt_rots_[ ii ]->xyz( jj ).y()
973  << " " << alt_rots_[ ii ]->xyz( jj ).z()
974  << ")" << std::endl;
975  }*/
977  ir = alternate_pose_->energies().energy_graph().get_node(ii_resid)->edge_list_begin(),
978  ire = alternate_pose_->energies().energy_graph().get_node(ii_resid)->edge_list_end();
979  ir != ire; ++ir ) {
980  Size jj_resid = (*ir)->get_other_ind( ii_resid );
981  Size jj_moltenresid = resid_2_moltenres_[ jj_resid ];
982  if ( jj_moltenresid != 0 ) continue;
983  Real ii_jj_energy = (static_cast< core::scoring::EnergyEdge const *> (*ir))->dot( oc_sfxn_->weights() );
984  std::cout << ii_resid << " " << jj_resid << " " << ii_jj_energy << std::endl;;
985 
986  //std::cout << " bbbb: " << core::pack::rotamer_set::RotamerSets::get_bb_bbE(
987  // *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) );
988  //std::cout << " sc1bb2: " << core::pack::rotamer_set::RotamerSets::get_sc_bbE(
989  // *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) );
990  //std::cout << " bb1sc2: " << core::pack::rotamer_set::RotamerSets::get_sc_bbE(
991  // *alternate_pose_, *oc_sfxn_, alternate_pose_->residue( jj_resid ), alternate_pose_->residue( ii_resid ) );
992 
993  //core::scoring::EnergyMap tbemap;
994  //oc_sfxn_->eval_ci_2b_sc_sc( alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) , *alternate_pose_, tbemap );
995  //oc_sfxn_->eval_cd_2b_sc_sc( alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) , *alternate_pose_, tbemap );
996  //Real scsc_energy_alt_conf = oc_sfxn_->weights().dot( tbemap );
997  //std::cout << " scsc: " << scsc_energy_alt_conf;
998 
999  //std::cout << std::endl;
1000 
1001 
1002  }
1003 
1004  }
1005 
1006  }
1007 
1008 
1009  //for ( Size ii = 1; ii <= moltenres_2_resid_.size(); ++ii ) {
1010  //std::cout << "moltenres: " << ii << " " << moltenres_2_resid_[ ii ] << std::endl;
1011  //}
1012  static int count_bad( 0 );
1013  alternate_pose_->dump_pdb( "BadPredDeltaE_" + utility::to_string( ++count_bad ) + "_alternate.pdb" );
1014  current_pose_->dump_pdb( "BadPredDeltaE_" + utility::to_string( count_bad ) + "_current.pdb" );
1015  assert( ! require_match || any_vertex_state_unassigned() || ! ( significant && large) );
1016  utility_exit_with_message( "Bad predicted deltaE" );
1017  } else {
1018  ++n_correct_since_last_problem;
1019  }
1020 }
1021 
1022 void
1024 {
1025 #ifndef DEBUG_OTF_FLEXBB_ENERGIES
1026  utility_exit_with_message( "Do not call OTFFlexbbInteractionGraph::debug_note_accepted_substitution unless debugging" );
1027 #endif
1028  (*current_pose_) = (*alternate_pose_);
1030  changing_seqpos_.clear();
1031  alt_rots_.clear();
1032  alt_rot_inds_.clear();
1033  //std::cout << "ACCEPTED SUBSTITUTION" << std::endl;
1034 }
1035 
1036 void
1038 {
1039 #ifndef DEBUG_OTF_FLEXBB_ENERGIES
1040  utility_exit_with_message( "Do not call OTFFlexbbInteractionGraph::debug_note_rejected_substitution unless debugging" );
1041 #endif
1042  (*alternate_pose_) = (*current_pose_);
1043  changing_seqpos_.clear();
1044  alt_rots_.clear();
1045  alt_rot_inds_.clear();
1046  //std::cout << "REJECTED SUBSTITUTION" << std::endl;
1047 }
1048 
1049 
1050 
1051 }
1052 }
1053 }
1054 
1055