14 #ifndef INCLUDED_core_pack_interaction_graph_SurfaceInteractionGraph_hh
15 #define INCLUDED_core_pack_interaction_graph_SurfaceInteractionGraph_hh
32 #include <basic/Tracer.hh>
33 #include <utility/exit.hh>
36 #include <ObjexxFCL/FArray1D.hh>
43 #include <utility/vector1.hh>
47 static basic::Tracer
TR_NODE(
"core.pack.surfaceig.node");
48 static basic::Tracer
TR_EDGE(
"core.pack.surfaceig.edge");
49 static basic::Tracer
TR_BGNODE(
"core.pack.surfaceig.bgnode");
50 static basic::Tracer
TR_BGEDGE(
"core.pack.surfaceig.bgedge");
51 static basic::Tracer
TR_SIG(
"core.pack.surfaceig.sig");
52 static basic::Tracer
TR_STATS(
"core.pack.surfaceig.stats");
59 namespace interaction_graph {
61 template <
typename V,
typename E,
typename G >
class SurfaceNode;
63 template <
typename V,
typename E,
typename G >
class SurfaceEdge;
82 template <
typename V,
typename E,
typename G >
110 virtual void print()
const;
127 return get_surface_owner()->rotamer_sets().moltenres_2_resid( parent::get_node_index() );
235 template <
typename V,
typename E,
typename G >
249 int changing_nodes_curr_state,
int changing_nodes_alt_state );
331 template <
typename V,
typename E,
typename G >
412 template <
typename V,
typename E,
typename G >
489 template <
typename V,
typename E,
typename G >
511 using parent::set_errorfull_deltaE_threshold;
613 template <
typename V,
typename E,
typename G >
616 template <
typename V,
typename E,
typename G >
619 template <
typename V,
typename E,
typename G >
622 template <
typename V,
typename E,
typename G >
625 template <
typename V,
typename E,
typename G >
640 template <
typename V,
typename E,
typename G >
643 rotamers_vector_( num_states ),
644 calculated_surface_deltaE_( false ),
645 deltaE_for_substitution_( 0.0f ),
646 curr_state_total_hASA_( 0.0 ),
647 alt_state_total_hASA_( 0 ),
648 have_prepared_for_simA_( false ),
649 surface_score_min_last_100_( 0 ),
650 surface_score_min_recent_( 0 ),
651 num_substitutions_since_surface_min_update_( 0 ),
652 observed_sufficient_surface_E_to_predict_min_( false ),
653 surface_exposed_( false ),
654 is_below_buried_residue_no_hsasa_cutoff_( false ),
655 num_neighbors_counting_self_(-1)
672 template <
typename V,
typename E,
typename G >
685 template <
typename V,
typename E,
typename G >
690 V::prepare_for_simulated_annealing();
692 if ( ! parent::get_bg_edge_vector_up_to_date_() ) {
693 parent::update_bg_edge_vector();
696 have_prepared_for_simA_ =
true;
701 int this_nodes_index = parent::get_node_index();
703 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
704 int other_nodes_index = get_incident_surface_edge(ii)->get_other_ind( this_nodes_index );
706 if ( this->detect_neighborship_with_node( other_nodes_index,
true ) ) {
707 fc_neighbor_map[ std::pair<int,int>(this_nodes_index, other_nodes_index) ] = 1;
708 fc_neighbor_map[ std::pair<int,int>(other_nodes_index, this_nodes_index) ] = 1;
712 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
713 int bg_nodes_index = get_edge_to_surface_bg_node( ii )->get_other_ind(
this );
714 if ( this->detect_neighborship_with_node( bg_nodes_index,
false ) ) {
715 bg_neighbor_map[ std::pair<int,int>(this_nodes_index, bg_nodes_index) ] = 1;
716 bg_neighbor_map[ std::pair<int,int>(bg_nodes_index, this_nodes_index) ] = 1;
720 init_hASA_variables();
748 template <
typename V,
typename E,
typename G >
752 pose::Pose poseRef = get_surface_owner()->pose();
755 int fc_node_index = parent::get_node_index();
762 int other_node_resid;
764 other_node_resid = get_surface_owner()->rotamer_sets().moltenres_2_resid( node_index );
766 other_node_resid = get_surface_owner()->bg_node_2_resid( node_index );
787 if ( distanceBetweenAtoms <= INTERACTION_RADIUS ) {
816 template <
typename V,
typename E,
typename G >
827 parent::assign_zero_state();
831 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
832 get_incident_surface_edge( ii )->acknowledge_state_zeroed_surface( parent::get_node_index() );
835 parent::update_bg_edge_vector();
837 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
838 get_edge_to_surface_bg_node( ii )->acknowledge_state_change( 0 );
857 template <
typename V,
typename E,
typename G >
866 #ifdef DOUBLE_CHECK_COUNTS
867 Real previous_state_hASA = curr_state_total_hASA_;
871 curr_state_total_hASA_ = alt_state_total_hASA_;
873 #ifdef DOUBLE_CHECK_COUNTS
874 if ( std::fabs( curr_state_total_hASA_ - previous_state_hASA ) > 0.01 ) {
876 if ( parent::get_current_state() != 0 && is_surface_exposed() ) {
877 verify_patch_areas_correct( parent::get_node_index(), parent::get_current_state(), previous_state_hASA );
895 template <
typename V,
typename E,
typename G >
899 TR_NODE <<
"assign_state_surface(): node " << parent::get_node_index() <<
" being assigned state " << state << std::endl;
910 project_deltaE_for_substitution_surface( state, temp, -1.0f );
911 commit_considered_substitution_surface();
921 template <
typename V,
typename E,
typename G >
924 if ( !(this->is_surface_exposed()) ) {
929 if ( parent::get_current_state() == 0 ) {
933 if ( curr_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) {
934 return surface_energy_weight_ * MAX_SURFACE_ENERGY;
937 return surface_energy_weight_ * hASA_energy( curr_state_total_hASA_ );
982 template <
typename V,
typename E,
typename G >
984 int alternate_state,
core::PackerEnergy & prev_PDenergies_for_node,
float deltaE_thresh_for_avoiding_surface_calcs ) {
986 runtime_assert( alternate_state > 0 && alternate_state <= parent::get_num_states() );
988 ++num_state_substitutions_considered_;
989 calculated_surface_deltaE_ =
false;
991 prev_PDenergies_for_node = parent::get_curr_pd_energy_total();
997 parent::calc_deltaEpd( alternate_state );
999 deltaE_for_substitution_ = parent::get_alt_pd_energy_total() - parent::get_curr_pd_energy_total();
1001 if ( decide_procrastinate_surface_computations( deltaE_for_substitution_, deltaE_thresh_for_avoiding_surface_calcs ) ) {
1002 ++num_surface_comps_procrastinated_;
1005 TR_NODE <<
"deltaE for PD: " << deltaE_for_substitution_ << std::endl;
1007 deltaE_for_substitution_ += project_surface_deltaE();
1010 return deltaE_for_substitution_;
1021 template <
typename V,
typename E,
typename G >
1025 TR_NODE <<
"project_surface_deltaE(): current_state:" << parent::get_current_state();
1026 if ( parent::get_current_state() == 0 ) {
1027 TR_NODE <<
" (" << wt_residue_for_node().name3() <<
"-";
1028 if ( wt_residue_for_node().is_polar() ) {
TR_NODE <<
"P)"; }
else {
TR_NODE <<
"HP)"; }
1030 TR_NODE <<
" (" << get_rotamer( parent::get_current_state() )->name() <<
"-";
1031 if ( get_rotamer( parent::get_current_state() )->is_polar() ) {
TR_NODE <<
"P)"; }
else {
TR_NODE <<
"HP)"; }
1033 TR_NODE <<
", alternate_state: " << parent::get_alternate_state() <<
" (" << get_rotamer( parent::get_alternate_state() )->name() <<
"-";
1034 if ( get_rotamer( parent::get_alternate_state() )->is_polar() ) {
TR_NODE <<
"P)"; }
else {
TR_NODE <<
"HP)"; }
1046 if ( this->is_surface_exposed() ) {
1052 if ( parent::get_current_state() == 0 ) {
1055 chemical::AA alt_AA = get_rotamer( parent::get_alternate_state() )->aa();
1056 Size nbs = num_neighbors_counting_self();
1058 alt_state_total_hASA_ = curr_state_total_hASA_ - average_residue_hASA( curr_AA, nbs ) + average_residue_hASA( alt_AA, nbs );
1060 if ( alt_state_total_hASA_ < -0.001 ) {
1062 utility_exit_with_message(
"Nonsensical alt_state reached (alt state total hASA < 0). Exiting. " );
1067 chemical::AA curr_AA = get_rotamer( parent::get_current_state() )->aa();
1068 chemical::AA alt_AA = get_rotamer( parent::get_alternate_state() )->aa();
1069 Size nbs = num_neighbors_counting_self();
1071 alt_state_total_hASA_ = curr_state_total_hASA_ - average_residue_hASA( curr_AA, nbs ) + average_residue_hASA( alt_AA, nbs );
1078 Real surface_deltaE = 0;
1082 TR_NODE <<
"project_surface_deltaE(): calculating deltaE for " << parent::get_num_incident_edges() <<
" first class and "
1083 << parent::get_num_edges_to_background_nodes() <<
" background neighbors." << std::endl;
1085 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
1086 int other_nodes_index = get_incident_surface_edge(ii)->get_other_ind( parent::get_node_index() );
1088 if ( fc_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_nodes_index) ) != fc_neighbor_map.end() ) {
1089 surface_deltaE += get_incident_surface_edge(ii)->get_surface_deltaE_for_neighbor( parent::get_node_index(), parent::get_alternate_state() );
1093 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
1094 int other_nodes_index = get_edge_to_surface_bg_node(ii)->get_other_ind(
this );
1096 if ( bg_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_nodes_index) ) != bg_neighbor_map.end() ) {
1097 surface_deltaE += get_edge_to_surface_bg_node( ii )->get_surface_deltaE_for_substitution( parent::get_alternate_state() );
1101 calculated_surface_deltaE_ =
true;
1103 surface_deltaE += get_surface_score_difference();
1106 if ( get_surface_score_difference() != 0 ) {
1107 TR_NODE <<
"project_surface_deltaE(): curr state hASA: " << curr_state_total_hASA_ <<
", alt state hASA: " << alt_state_total_hASA_
1108 <<
", score difference: " << get_surface_score_difference() << std::endl;
1113 if ( surface_deltaE > 100000 || surface_deltaE < -100000 ) {
1114 std::cerr <<
"project_surface_deltaE(): deltaE for PD: " << deltaE_for_substitution_ << std::endl;
1115 std::cerr <<
"project_surface_deltaE(): deltaE for surfaceE: " << surface_deltaE << std::endl;
1117 std::cerr <<
"project_surface_deltaE(): current_state:" << parent::get_current_state();
1118 if ( parent::get_current_state() == 0 ) {
1119 std::cerr <<
" (" << wt_residue_for_node().name3() <<
"-";
1120 if ( wt_residue_for_node().is_polar() ) { std::cerr <<
"P)"; }
else { std::cerr <<
"HP)"; }
1122 std::cerr <<
" (" << get_rotamer( parent::get_current_state() )->name() <<
"-";
1123 if ( get_rotamer( parent::get_current_state() )->is_polar() ) { std::cerr <<
"P)"; }
else { std::cerr <<
"HP)"; }
1125 std::cerr <<
", alternate_state: " << parent::get_alternate_state() <<
" (" << get_rotamer( parent::get_alternate_state() )->name() <<
"-";
1126 if ( get_rotamer( parent::get_alternate_state() )->is_polar() ) { std::cerr <<
"P)"; }
else { std::cerr <<
"HP)"; }
1127 std::cerr << std::endl;
1129 get_surface_owner()->print();
1130 utility_exit_with_message(
"surface deltaE went crazy. Terminating." );
1135 if ( surface_deltaE != 0 ) {
1136 TR_NODE <<
"deltaE for surfaceE: " << surface_deltaE << std::endl;
1140 return surface_deltaE;
1155 template <
typename V,
typename E,
typename G >
1158 Real surface_deltaE_max = 0;
1160 if ( ! observed_sufficient_surface_E_to_predict_min_ )
1163 if ( threshold < 0 || pd_deltaE < 0 )
1166 for(
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii) {
1167 Real mag_deltaE = get_incident_surface_edge(ii)->get_max_surface_deltaE_guess( parent::get_node_index() );
1168 if ( mag_deltaE < 0.0f ) {
1171 surface_deltaE_max += mag_deltaE;
1174 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
1175 Real mag_deltaE = get_edge_to_surface_bg_node( ii )->get_max_surface_deltaE_guess();
1176 if ( mag_deltaE < 0.0f ) {
1179 surface_deltaE_max += mag_deltaE;
1182 surface_deltaE_max += (surface_energy_weight_ * hASA_energy( curr_state_total_hASA_ ) ) - surface_score_min_last_100_;
1187 TR_NODE <<
"decide_procrastinate_surface_computations(): pd_deltaE: " << pd_deltaE <<
", surface_deltaE_max: " << surface_deltaE_max
1188 <<
", threshold: " << threshold << std::endl;
1190 if ( (pd_deltaE - surface_deltaE_max) > threshold ) {
1237 template <
typename V,
typename E,
typename G >
1239 SurfaceNode<V,E,G>* node_considering_substitution,
int changing_nodes_curr_state,
int changing_nodes_alt_state ) {
1247 if ( !(this->is_surface_exposed()) ) {
1261 if ( changing_nodes_curr_state == 0 ) {
1267 alt_state_total_hASA_ = curr_state_total_hASA_ - average_residue_hASA( curr_AA, nbs ) + average_residue_hASA( alt_AA, nbs );
1269 if ( alt_state_total_hASA_ < -0.001 ) {
1271 utility_exit_with_message(
"Nonsensical alt_state reached (total hASA < 0). Exiting. " );
1280 alt_state_total_hASA_ = curr_state_total_hASA_ - average_residue_hASA( curr_AA, nbs ) + average_residue_hASA( alt_AA, nbs );
1285 if ( curr_state_total_hASA_ != alt_state_total_hASA_ ) {
1286 TR_NODE <<
"get_surface_deltaE_for_neighbors_state_substitution: node " << parent::get_node_index()
1287 <<
" calc. deltaE for changing node " << node_considering_substitution->get_node_index()
1288 <<
", curr hASA: " << curr_state_total_hASA_ <<
", alt hASA: " << alt_state_total_hASA_
1289 <<
", score_difference: " << get_surface_score_difference() << std::endl;
1293 return get_surface_score_difference();
1308 template <
typename V,
typename E,
typename G >
1311 if ( curr_state_total_hASA_ == alt_state_total_hASA_ ) {
return 0.0; }
1313 if ( curr_state_total_hASA_ < -0.001 ) {
1315 utility_exit_with_message(
"Nonsensical curr_state reached (total hASA < 0). Exiting. " );
1317 if ( alt_state_total_hASA_ < -0.001 ) {
1319 utility_exit_with_message(
"Nonsensical alt_state reached (total hASA < 0). Exiting. " );
1322 if ( ( curr_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) && ( alt_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) ) {
1328 if ( alt_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) {
1329 return surface_energy_weight_ * MAX_SURFACE_ENERGY;
1333 if ( curr_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) {
1335 return surface_energy_weight_ * -1 * MAX_SURFACE_ENERGY;
1338 return surface_energy_weight_ * ( hASA_energy(alt_state_total_hASA_) - hASA_energy(curr_state_total_hASA_) );
1371 template <
typename V,
typename E,
typename G >
1374 assert( parent::considering_alternate_state() );
1376 #ifdef DOUBLE_CHECK_COUNTS
1377 int previous_state = parent::get_current_state();
1378 Real previous_state_hASA = curr_state_total_hASA_;
1381 if ( ! calculated_surface_deltaE_ ) {
1382 ++num_surface_comps_later_made_;
1383 Real temp = project_surface_deltaE();
1384 deltaE_for_substitution_ = parent::get_alt_pd_energy_total() - parent::get_curr_pd_energy_total() + temp;
1388 parent::commit_considered_substitution();
1390 curr_state_total_hASA_ = alt_state_total_hASA_;
1393 #ifdef DOUBLE_CHECK_COUNTS
1394 if ( ( parent::get_current_state() != 0 ) && is_surface_exposed() ) {
1395 verify_patch_areas_correct( parent::get_node_index(), previous_state, previous_state_hASA );
1400 TR_NODE <<
"Committed substitution node " << parent::get_node_index() << std::endl;
1403 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
1404 get_incident_surface_edge(ii)->acknowledge_substitution_surface();
1406 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii) {
1407 get_edge_to_surface_bg_node(ii)->acknowledge_substitution_surface();
1410 track_surface_E_min();
1412 return deltaE_for_substitution_;
1424 template <
typename V,
typename E,
typename G >
1432 Real total_hASA = 0.0;
1433 if ( this->is_surface_exposed() ) {
1435 total_hASA += average_residue_hASA();
1436 TR_NODE <<
"verify_patch_areas_correct(): adding " << average_residue_hASA() <<
" to total_hASA for self; total_hASA: " << total_hASA << std::endl;
1461 pose::Pose poseRef = get_surface_owner()->pose();
1463 conformation::Residue const & rsd1 = poseRef.
residue( get_surface_owner()->rotamer_sets().moltenres_2_resid( parent::get_node_index() ) );
1464 Real distanceBetweenAtoms = 0.0;
1466 for (
Size rr = 1; rr <= get_surface_owner()->rotamer_sets().nmoltenres(); ++rr ) {
1468 if ( (
int)rr == parent::get_node_index() ) {
continue; }
1474 if ( distanceBetweenAtoms > INTERACTION_RADIUS ) {
1482 int other_node_index = rr;
1483 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
1485 if ( get_incident_surface_edge(ii)->get_other_ind( parent::get_node_index() ) == other_node_index ) {
1491 int edge_index = ( other_node_index == get_incident_surface_edge(ii)->get_surface_node(0)->get_node_index() ? 0 : 1 );
1496 if ( (get_incident_surface_edge(ii)->get_surface_node( edge_index ))->get_current_state() == 0 ) {
1499 total_hASA += (get_incident_surface_edge(ii)->get_surface_node( edge_index ))->average_residue_hASA();
1500 TR_NODE <<
"verify_patch_areas_correct(): adding " << (get_incident_surface_edge(ii)->get_surface_node( edge_index ))->average_residue_hASA()
1501 <<
" to total_hASA for incident edge " << ii <<
", total_hASA: " << total_hASA << std::endl;
1510 int nbackground = poseRef.
total_residue() - get_surface_owner()->rotamer_sets().nmoltenres();
1511 for (
int id = 1;
id <= nbackground; ++id ) {
1516 if ( distanceBetweenAtoms > INTERACTION_RADIUS ) {
1522 int other_node_index = id;
1523 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
1524 if ( get_edge_to_surface_bg_node(ii)->get_other_ind(
this ) == other_node_index ) {
1528 total_hASA += (get_edge_to_surface_bg_node(ii)->get_surface_bg_node())->average_residue_hASA();
1529 TR_NODE <<
"verify_patch_areas_correct(): adding " << (get_edge_to_surface_bg_node(ii)->get_surface_bg_node())->average_residue_hASA()
1530 <<
" to total_hASA for incident bg edge " << ii <<
", total_hASA: " << total_hASA << std::endl;
1537 if ( std::fabs( total_hASA - curr_state_total_hASA_ ) > 0.01 ) {
1539 TR_NODE <<
"verify_patch_areas_correct(): calling node " << node_id <<
"; this node current_state: " << parent::get_current_state();
1540 TR_NODE <<
" (" << get_rotamer( parent::get_current_state() )->name() <<
"-";
1541 if ( get_rotamer( parent::get_current_state() )->is_polar() ) {
TR_NODE <<
"P)"; }
else {
TR_NODE <<
"HP)"; }
1543 TR_NODE <<
", previous_state: " << previous_state;
1544 if ( previous_state != 0 ) {
1545 TR_NODE <<
" (" << get_rotamer( previous_state )->name() <<
"-";
1546 if ( get_rotamer( previous_state )->is_polar() ) {
TR_NODE <<
"P)"; }
else {
TR_NODE <<
"HP)"; }
1548 TR_NODE <<
", previous_state hASA: " << previous_state_hASA << std::endl;
1550 std::cout <<
"This node:" << std::endl;
1553 std::cout <<
"Neighboring nodes:" << std::endl;
1554 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
1555 int other_nodes_index = get_incident_surface_edge(ii)->get_other_ind( parent::get_node_index() );
1556 int edge_index = ( other_nodes_index == get_incident_surface_edge(ii)->get_surface_node(0)->get_node_index() ? 0 : 1 );
1558 if ( fc_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_nodes_index) ) != fc_neighbor_map.end() ) {
1560 if ( get_incident_surface_edge(ii)->get_surface_node( edge_index )->is_surface_exposed() ) {
1563 get_incident_surface_edge(ii)->get_surface_node( edge_index )->print();
1567 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
1568 int other_nodes_index = get_edge_to_surface_bg_node(ii)->get_other_ind(
this );
1570 if ( bg_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_nodes_index) ) != bg_neighbor_map.end() ) {
1571 if ( get_edge_to_surface_bg_node(ii)->get_surface_bg_node()->is_surface_exposed() ) {
1574 get_edge_to_surface_bg_node(ii)->get_surface_bg_node()->print();
1578 std::cout <<
"Nodes counted iterating over all residues:" << std::endl;
1581 for (
Size rr = 1; rr <= get_surface_owner()->rotamer_sets().nmoltenres(); ++rr ) {
1583 if ( (
int)rr == parent::get_node_index() ) {
continue; }
1589 if ( distanceBetweenAtoms > INTERACTION_RADIUS ) {
1597 int other_node_index = rr;
1598 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
1600 if ( get_incident_surface_edge(ii)->get_other_ind( parent::get_node_index() ) == other_node_index ) {
1606 int edge_index = ( other_node_index == get_incident_surface_edge(ii)->get_surface_node(0)->get_node_index() ? 0 : 1 );
1607 if ( get_incident_surface_edge(ii)->get_surface_node( edge_index )->is_surface_exposed() ) {
1610 get_incident_surface_edge(ii)->get_surface_node( edge_index )->print();
1618 int nbackground = poseRef.
total_residue() - get_surface_owner()->rotamer_sets().nmoltenres();
1619 for (
int id = 1;
id <= nbackground; ++id ) {
1624 if ( distanceBetweenAtoms > INTERACTION_RADIUS ) {
1630 int other_node_index = id;
1631 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
1632 if ( get_edge_to_surface_bg_node(ii)->get_other_ind(
this ) == other_node_index ) {
1633 if ( get_edge_to_surface_bg_node(ii)->get_surface_bg_node()->is_surface_exposed() ) {
1636 get_edge_to_surface_bg_node(ii)->get_surface_bg_node()->print();
1643 TR_NODE <<
"total_hASA: " << total_hASA <<
", curr_state_total_hASA_: " << curr_state_total_hASA_ << std::endl;
1644 utility_exit_with_message(
"total hASA values are out of sync. Something is wrong. Quitting." );
1655 template <
typename V,
typename E,
typename G >
1658 ++num_substitutions_since_surface_min_update_;
1660 Real alt_surfaceE = surface_energy_weight_ * hASA_energy( alt_state_total_hASA_ );
1662 if ( surface_score_min_recent_ > alt_surfaceE )
1663 surface_score_min_recent_ = alt_surfaceE;
1667 if ( num_substitutions_since_surface_min_update_ == 100 ) {
1668 surface_score_min_last_100_ = surface_score_min_recent_;
1669 Real curr_surfaceE = surface_energy_weight_ * hASA_energy( curr_state_total_hASA_ );
1670 if (curr_surfaceE < surface_score_min_last_100_ ) {
1671 surface_score_min_last_100_ = curr_surfaceE;
1673 observed_sufficient_surface_E_to_predict_min_ =
true;
1674 num_substitutions_since_surface_min_update_ = 0;
1686 template <
typename V,
typename E,
typename G >
1689 std::cout <<
"(node id:" << parent::get_node_index() <<
", current_state: " << parent::get_current_state();
1691 if ( parent::get_current_state() == 0 ) {
1692 std::cout <<
" (" << wt_residue_for_node().name3() <<
"-";
1693 if ( wt_residue_for_node().is_polar() ) { std::cout <<
"P)"; }
else { std::cout <<
"HP)"; }
1695 std::cout <<
" (" << get_rotamer( parent::get_current_state() )->name() <<
"-";
1696 if ( get_rotamer( parent::get_current_state() )->is_polar() ) { std::cout <<
"P)"; }
else { std::cout <<
"HP)"; }
1699 if ( parent::get_current_state() == 0 ) {
1700 std::cout <<
", hASA: " << average_residue_hASA( wt_residue_for_node().aa(), num_neighbors_counting_self() );
1702 std::cout <<
", hASA: " << average_residue_hASA();
1705 std::cout <<
", one body energy: " << parent::get_one_body_energy_current_state()
1706 <<
", curr: " << curr_state_total_hASA_ <<
", alt: " << alt_state_total_hASA_ <<
", surface energy: " << get_curr_state_surface_energy()
1707 <<
", se: " << surface_exposed_ << std::endl;
1722 template <
typename V,
typename E,
typename G >
1733 template <
typename V,
typename E,
typename G >
1736 unsigned int total_memory = parent::count_dynamic_memory();
1740 return total_memory;
1750 template <
typename V,
typename E,
typename G >
1762 template <
typename V,
typename E,
typename G >
1765 if (num_state_substitutions_considered_ == 0)
1768 TR_STATS <<
"SurfaceE Calculation Avoidance Statistics:" << std::endl;
1769 TR_STATS <<
"num state substitutions considered: " << num_state_substitutions_considered_ <<
", "
1770 <<
"num surface calcs procrastinated: " << num_surface_comps_procrastinated_ <<
", "
1771 <<
"num surface calcs later computed: " << num_surface_comps_later_made_ << std::endl;
1772 TR_STATS <<
"Percent Avoided: " << (double)(num_surface_comps_procrastinated_ - num_surface_comps_later_made_) / num_state_substitutions_considered_ <<
", ";
1774 if ( num_surface_comps_procrastinated_ != 0 ) {
1775 TR_STATS <<
"Percent Procrastinated worthwhile: " <<
1776 (double)(num_surface_comps_procrastinated_ - num_surface_comps_later_made_) / num_surface_comps_procrastinated_ << std::endl;
1778 TR_STATS <<
"Percent Procrastinated worthwhile: " <<
"N/A" << std::endl;
1791 template <
typename V,
typename E,
typename G >
1793 num_state_substitutions_considered_ = 0;
1794 num_surface_comps_procrastinated_ = 0;
1795 num_surface_comps_later_made_ = 0;
1805 template <
typename V,
typename E,
typename G >
1809 if ( rotamers->num_rotamers() != (
Size) parent::get_num_states() ) {
1810 utility_exit_with_message(
"Number of rotamers is not equal to parents number of states. Quitting.");
1814 TR_NODE <<
"set_rotamers: adding " << rotamers->num_rotamers() <<
" to local rotamers vector." << std::endl;
1817 for (
Size ii = 1; ii <= rotamers->num_rotamers(); ++ii ) {
1818 rotamers_vector_[ ii ] = rotamers->rotamer( ii );
1822 TR_NODE <<
"rotamers_vector_: [ ";
1823 for (
Size ii = 1; ii <= rotamers_vector_.size(); ++ii ) {
1824 TR_NODE << ii <<
":" << rotamers_vector_[ ii ]->name1() <<
"-" << rotamers_vector_[ ii ]->seqpos() <<
", ";
1837 template <
typename V,
typename E,
typename G >
1839 return rotamers_vector_[ state ];
1851 template <
typename V,
typename E,
typename G >
1853 return surface_exposed_;
1862 template <
typename V,
typename E,
typename G >
1864 surface_exposed_ = value;
1874 template <
typename V,
typename E,
typename G >
1876 return is_below_buried_residue_no_hsasa_cutoff_;
1885 template <
typename V,
typename E,
typename G >
1887 is_below_buried_residue_no_hsasa_cutoff_ = value;
1898 template <
typename V,
typename E,
typename G >
1904 if ( alt_state_total_hASA_ != curr_state_total_hASA_ ) {
1905 alt_state_total_hASA_ = curr_state_total_hASA_;
1907 TR_NODE <<
"reset_alt_state_total_hASA(): alt state total hASA was not equal to current state total hASA, but is now." << std::endl;
1932 template <
typename V,
typename E,
typename G >
1959 num_neighbors_counting_self_ =
1964 TR_NODE <<
"initialize_num_neighbors_counting_self(): fc node index " << parent::get_node_index() <<
" (PDB: "
1965 << wt_residue_for_node().seqpos() <<
"): " << num_neighbors_counting_self_ <<
" nbs" << std::endl;
1977 template <
typename V,
typename E,
typename G >
1980 if ( num_neighbors_counting_self_ == -1 ) {
1981 initialize_num_neighbors_counting_self();
1984 return num_neighbors_counting_self_;
1991 template <
typename V,
typename E,
typename G >
1993 curr_state_total_hASA_ = calculate_amount_total_hydrophobic_ASA();
1994 alt_state_total_hASA_ = curr_state_total_hASA_;
2022 template <
typename V,
typename E,
typename G >
2025 Real total_hASA = 0.0;
2028 TR_NODE <<
"calculate_amount_total_hydrophobic_ASA(): ";
2031 if ( num_neighbors_counting_self() <= SURFACE_EXPOSED_CUTOFF ) {
2032 total_hASA += average_residue_hASA( wt_residue_for_node().aa(), num_neighbors_counting_self() );
2037 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
2039 int other_node_index = get_incident_surface_edge(ii)->get_other_ind( parent::get_node_index() );
2042 if ( fc_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_node_index ) ) != fc_neighbor_map.end() ) {
2045 TR_NODE << other_node_index <<
"-";
2047 int edge_index = ( other_node_index == get_incident_surface_edge(ii)->get_surface_node(0)->get_node_index() ? 0 : 1 );
2048 chemical::AA other_nodes_type = (get_incident_surface_edge(ii)->get_surface_node( edge_index )->wt_residue_for_node()).aa();
2049 Size nbs = get_incident_surface_edge(ii)->get_surface_node( edge_index )->num_neighbors_counting_self();
2050 Real hASA = average_residue_hASA( other_nodes_type, nbs );
2062 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
2063 int other_node_index = get_edge_to_surface_bg_node(ii)->get_other_ind(
this );
2065 if ( bg_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_node_index) ) != bg_neighbor_map.end() ) {
2068 TR_NODE <<
"b" << other_node_index <<
"-";
2070 chemical::AA bg_nodes_type = (get_edge_to_surface_bg_node(ii)->get_surface_bg_node()->wt_residue_for_node()).aa();
2071 Size nbs = get_edge_to_surface_bg_node(ii)->get_surface_bg_node()->num_neighbors_counting_self();
2072 Real hASA = average_residue_hASA( bg_nodes_type, nbs );
2089 TR_NODE <<
"returning patch area of " << total_hASA <<
" for node index " << parent::get_node_index()
2090 <<
" (PDB: " << wt_residue_for_node().seqpos() <<
")" << std::endl;
2107 template <
typename V,
typename E,
typename G >
2109 return average_residue_hASA( get_rotamer( parent::get_current_state() )->aa(), num_neighbors_counting_self() );
2120 template <
typename V,
typename E,
typename G >
2122 if ( num_nbs > (
Size)BURIED_RESIDUE_NO_HSASA_CUTOFF )
return 0.00;
2135 template <
typename V,
typename E,
typename G >
2137 if ( patch_area > MAX_PATCH_SURFACE_AREA ) {
2138 return surface_energy_weight_ * MAX_SURFACE_ENERGY;
2140 if ( num_neighbors_counting_self() > SURFACE_EXPOSED_CUTOFF ) {
2153 template <
typename V,
typename E,
typename G >
2156 template <
typename V,
typename E,
typename G >
2170 template <
typename V,
typename E,
typename G >
2173 curr_state_total_hASA_( 0.0 ),
2174 alt_state_total_hASA_( 0.0 ),
2175 have_prepared_for_simA_( false ),
2176 surface_exposed_( false ),
2177 is_below_buried_residue_no_hsasa_cutoff_( false ),
2178 num_neighbors_counting_self_(-1)
2193 template <
typename V,
typename E,
typename G >
2205 template <
typename V,
typename E,
typename G >
2208 if ( ! parent::get_edge_vector_up_to_date() )
2209 parent::update_edge_vector();
2213 init_hASA_variables();
2215 have_prepared_for_simA_ =
true;
2230 template <
typename V,
typename E,
typename G >
2262 template <
typename V,
typename E,
typename G >
2264 SurfaceNode< V, E, G >* fc_node_changing,
int changing_nodes_curr_state,
int changing_nodes_alt_state ) {
2281 parent::update_edge_vector();
2284 if ( changing_nodes_alt_state == 0 ) {
2285 return MAX_SURFACE_ENERGY;
2289 if ( !(this->is_surface_exposed()) ) {
2297 if ( changing_nodes_curr_state == 0 ) {
2311 alt_state_total_hASA_ = curr_state_total_hASA_ - average_residue_hASA( curr_AA, nbs ) + average_residue_hASA( alt_AA, nbs );
2313 if ( alt_state_total_hASA_ < -0.001 ) {
2314 TR_BGNODE <<
"curr_state_total_hASA_: " << curr_state_total_hASA_ <<
", alt_state_total_hASA_: " << alt_state_total_hASA_
2315 <<
", curr_AA: " << curr_AA <<
", alt_AA: " << alt_AA << std::endl;
2317 utility_exit_with_message(
"Nonsensical alt_state reached (alt_state total hASA < 0). Exiting.");
2331 alt_state_total_hASA_ = curr_state_total_hASA_ - average_residue_hASA( curr_AA, nbs ) + average_residue_hASA( alt_AA, nbs );
2335 Real difference = 0.0;
2337 if ( curr_state_total_hASA_ == alt_state_total_hASA_ ) {
return 0.0; }
2339 if ( curr_state_total_hASA_ < -0.001 ) { this->print(); utility_exit_with_message(
"Nonsensical curr_state reached (curr_state total hASA < 0). Exiting." ); }
2340 if ( alt_state_total_hASA_ < -0.001 ) { this->print(); utility_exit_with_message(
"Nonsensical alt_state reached (alt_state total hASA < 0). Exiting." ); }
2342 if ( ( curr_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) && ( alt_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) ) {
2348 if ( alt_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) {
2349 difference = surface_energy_weight_ * MAX_SURFACE_ENERGY;
2351 TR_BGNODE <<
"project_surface_deltaE_for_substitution: bg node " << parent::get_node_index()
2352 <<
" calculated deltaE for changing surface resid " << fc_node_changing->
wt_seqpos_for_node() <<
"; "
2353 <<
"curr state hASA: " << curr_state_total_hASA_ <<
", alt hASA: " << alt_state_total_hASA_
2354 <<
", score difference: " << difference << std::endl;
2360 if ( curr_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) {
2362 difference = surface_energy_weight_ * -1 * MAX_SURFACE_ENERGY;
2364 TR_BGNODE <<
"project_surface_deltaE_for_substitution: bg node " << parent::get_node_index()
2365 <<
" calculated deltaE for changing surface resid " << fc_node_changing->
wt_seqpos_for_node() <<
"; "
2366 <<
"curr state hASA: " << curr_state_total_hASA_ <<
", alt hASA: " << alt_state_total_hASA_
2367 <<
", score difference: " << difference << std::endl;
2372 difference = surface_energy_weight_ * ( hASA_energy( alt_state_total_hASA_ ) - hASA_energy( curr_state_total_hASA_ ) );
2375 TR_BGNODE <<
"project_surface_deltaE_for_substitution: bg node " << parent::get_node_index()
2376 <<
" calculated deltaE for changing surface resid " << fc_node_changing->
wt_seqpos_for_node() <<
"; "
2377 <<
"curr state hASA: " << curr_state_total_hASA_ <<
", alt hASA: " << alt_state_total_hASA_
2378 <<
", score difference: " << difference << std::endl;
2392 template <
typename V,
typename E,
typename G >
2394 curr_state_total_hASA_ = alt_state_total_hASA_;
2404 template <
typename V,
typename E,
typename G >
2407 if ( !(this->is_surface_exposed()) ) {
2411 if ( curr_state_total_hASA_ > MAX_PATCH_SURFACE_AREA ) {
2412 return surface_energy_weight_ * MAX_SURFACE_ENERGY;
2415 return surface_energy_weight_ * hASA_energy( curr_state_total_hASA_ );
2425 template <
typename V,
typename E,
typename G >
2428 std::cout <<
"(bgnode id:" << parent::get_node_index() <<
", hASA: " << average_residue_hASA()
2429 <<
", curr: " << curr_state_total_hASA_ <<
", alt: " << alt_state_total_hASA_
2430 <<
", score: " << get_surface_score() <<
", se: " << surface_exposed_ << std::endl;
2436 template <
typename V,
typename E,
typename G >
2445 template <
typename V,
typename E,
typename G >
2447 unsigned int total_memory = parent::count_dynamic_memory();
2450 return total_memory;
2460 template <
typename V,
typename E,
typename G >
2462 return surface_exposed_;
2472 template <
typename V,
typename E,
typename G >
2474 surface_exposed_ = value;
2484 template <
typename V,
typename E,
typename G >
2486 return is_below_buried_residue_no_hsasa_cutoff_;
2495 template <
typename V,
typename E,
typename G >
2497 is_below_buried_residue_no_hsasa_cutoff_ = value;
2508 template <
typename V,
typename E,
typename G >
2511 if ( alt_state_total_hASA_ != curr_state_total_hASA_ ) {
2512 alt_state_total_hASA_ = curr_state_total_hASA_;
2514 TR_BGNODE <<
"reset_alt_state_total_hASA(): alt state total hASA was not equal to current state total hASA, but is now." << std::endl;
2531 template <
typename V,
typename E,
typename G >
2561 TR_BGNODE <<
"initialize_num_neighbors_counting_self(): bg node index " << parent::get_node_index() <<
" (PDB: "
2562 << get_surface_owner()->bg_node_2_resid( parent::get_node_index() )
2563 <<
"): " << num_neighbors_counting_self_ <<
" nbs" << std::endl;
2575 template <
typename V,
typename E,
typename G >
2578 if ( num_neighbors_counting_self_ == -1 ) {
2579 initialize_num_neighbors_counting_self();
2582 return num_neighbors_counting_self_;
2589 template <
typename V,
typename E,
typename G >
2591 curr_state_total_hASA_ = calculate_amount_total_hydrophobic_ASA();
2592 alt_state_total_hASA_ = curr_state_total_hASA_;
2603 template <
typename V,
typename E,
typename G >
2606 Real total_hASA = 0.0;
2609 TR_BGNODE <<
"calculate_amount_total_hydrophobic_ASA(): ";
2611 if ( num_neighbors_counting_self() <= SURFACE_EXPOSED_CUTOFF ) {
2612 total_hASA += average_residue_hASA( wt_residue_for_node().aa(), num_neighbors_counting_self() );
2618 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
2622 if ( get_surface_bg_edge(ii)->get_surface_node()->detect_neighborship_with_node( parent::get_node_index(),
false ) ) {
2625 int other_node_index = get_surface_bg_edge(ii)->get_other_ind(
this );
2628 chemical::AA fc_nodes_type = ( get_surface_bg_edge(ii)->get_surface_node()->wt_residue_for_node() ).aa();
2629 Size nbs = get_surface_bg_edge(ii)->get_surface_node()->num_neighbors_counting_self();
2630 Real hASA = average_residue_hASA( fc_nodes_type, nbs );
2649 TR_BGNODE <<
"returning patch area of " << total_hASA <<
" for bg node index " << parent::get_node_index()
2650 <<
" (PDB " << get_surface_owner()->bg_node_2_resid( parent::get_node_index() ) <<
")" << std::endl;
2669 template <
typename V,
typename E,
typename G >
2671 return average_residue_hASA( wt_residue_for_node().aa(), num_neighbors_counting_self() );
2682 template <
typename V,
typename E,
typename G >
2684 if ( num_nbs > (
Size)BURIED_RESIDUE_NO_HSASA_CUTOFF )
return 0.00;
2697 template <
typename V,
typename E,
typename G >
2699 if ( patch_area > MAX_PATCH_SURFACE_AREA ) {
2700 return surface_energy_weight_ * MAX_SURFACE_ENERGY;
2702 if ( num_neighbors_counting_self() > SURFACE_EXPOSED_CUTOFF ) {
2725 template <
typename V,
typename E,
typename G >
2728 node_changing_( -1 ),
2729 node_not_changing_( -1 )
2747 template <
typename V,
typename E,
typename G >
2758 template <
typename V,
typename E,
typename G >
2761 parent::prepare_for_simulated_annealing_no_deletion();
2763 if ( parent::pd_edge_table_all_zeros() ) {
2766 if ( !( get_surface_node(0)->detect_neighborship_with_node( parent::get_node_index(1),
true ) ) ) {
2788 template <
typename V,
typename E,
typename G >
2792 node_changing_ = ( node_that_changed == parent::get_node_index(0) ? 0 : 1 );
2793 node_not_changing_ = !node_changing_;
2795 nodes_curr_states_[ node_changing_ ] = 0;
2796 inform_non_changing_node_of_neighbors_change();
2812 template <
typename V,
typename E,
typename G >
2815 node_changing_ = ( node_considering_substitution == parent::get_node_index(0) ? 0 : 1 );
2816 node_not_changing_ = ! node_changing_;
2821 nodes_alt_states_[ node_changing_ ] = alt_state;
2822 nodes_alt_states_[ node_not_changing_ ] = nodes_curr_states_[ node_not_changing_ ];
2826 Real surface_deltaE = get_surface_node( node_not_changing_ )->get_surface_deltaE_for_neighbors_state_substitution(
2827 get_surface_node( node_changing_ ), nodes_curr_states_[ node_changing_ ], alt_state );
2829 magnitude_last_surface_deltaE_[ node_changing_ ] = std::abs( surface_deltaE );
2837 return surface_deltaE;
2848 template <
typename V,
typename E,
typename G >
2851 inform_non_changing_node_of_neighbors_change();
2853 nodes_curr_states_[ node_changing_ ] = nodes_alt_states_[ node_changing_ ];
2855 track_max_magnitude_surface_deltaE();
2867 template <
typename V,
typename E,
typename G >
2870 get_surface_node( node_not_changing_ )->acknowledge_neighbors_substitution_surface();
2881 template <
typename V,
typename E,
typename G >
2884 ++num_surface_deltaE_observations_since_update_[ node_changing_ ];
2889 if ( magnitude_last_surface_deltaE_[ node_changing_ ] > max_surface_deltaE_recent_50_commits_[ node_changing_ ] ) {
2890 max_surface_deltaE_recent_50_commits_[ node_changing_ ] = magnitude_last_surface_deltaE_[ node_changing_ ];
2893 if ( num_surface_deltaE_observations_since_update_[ node_changing_] == 50 ) {
2896 max_surface_deltaE_last_50_commits_[ node_changing_ ] = max_surface_deltaE_recent_50_commits_[ node_changing_ ];
2897 num_surface_deltaE_observations_since_update_[ node_changing_] = 0;
2898 max_surface_deltaE_recent_50_commits_[ node_changing_ ] = -1.0f;
2919 template <
typename V,
typename E,
typename G >
2921 parent::declare_energies_final_no_deletion();
2928 template <
typename V,
typename E,
typename G >
2930 return max_surface_deltaE_last_50_commits_[ node_changing_ ];
2940 template <
typename V,
typename E,
typename G >
2949 template <
typename V,
typename E,
typename G >
2958 template <
typename V,
typename E,
typename G >
2961 unsigned int total_memory = parent::count_dynamic_memory();
2964 return total_memory;
2984 template <
typename V,
typename E,
typename G >
2988 fc_node_curr_state_( 0 ),
2989 fc_node_alt_state_( 0 )
2991 max_surface_deltaE_last_50_commits_ = -1.0f;
2992 max_surface_deltaE_recent_50_commits_ = -1.0f;
2993 magnitude_last_surface_deltaE_ = -1.0f;
2994 num_surface_deltaE_observations_since_update_ = 0;
3003 template <
typename V,
typename E,
typename G >
3020 template <
typename V,
typename E,
typename G >
3034 template <
typename V,
typename E,
typename G >
3037 if ( new_state == fc_node_curr_state_ )
3040 get_surface_deltaE_for_substitution( new_state );
3041 acknowledge_substitution_surface();
3061 template <
typename V,
typename E,
typename G >
3065 fc_node_alt_state_ = alt_state;
3072 Real const surface_deltaE = get_surface_bg_node()->project_surface_deltaE_for_substitution(
3073 get_surface_node(), fc_node_curr_state_, fc_node_alt_state_ );
3075 magnitude_last_surface_deltaE_ = std::abs( surface_deltaE );
3077 return surface_deltaE;
3088 template <
typename V,
typename E,
typename G >
3091 fc_node_curr_state_ = fc_node_alt_state_;
3093 get_surface_bg_node()->acknowledge_substitution_surface();
3095 track_max_magnitude_surface_deltaE();
3106 template <
typename V,
typename E,
typename G >
3109 ++num_surface_deltaE_observations_since_update_;
3111 if ( magnitude_last_surface_deltaE_ > max_surface_deltaE_recent_50_commits_) {
3112 max_surface_deltaE_recent_50_commits_ = magnitude_last_surface_deltaE_;
3115 if ( num_surface_deltaE_observations_since_update_ == 1000 ) {
3116 max_surface_deltaE_last_50_commits_ = max_surface_deltaE_recent_50_commits_;
3117 num_surface_deltaE_observations_since_update_= 0;
3118 max_surface_deltaE_recent_50_commits_ = -1.0f;
3129 template <
typename V,
typename E,
typename G >
3131 return max_surface_deltaE_last_50_commits_;
3138 template <
typename V,
typename E,
typename G >
3147 template <
typename V,
typename E,
typename G >
3150 unsigned int total_memory = parent::count_dynamic_memory();
3151 return total_memory;
3171 template <
typename V,
typename E,
typename G >
3174 num_total_residues_( 0 ),
3175 num_residues_assigned_as_background_( 0 ),
3176 num_commits_since_last_update_( 0 ),
3177 total_energy_current_state_assignment_( 0 ),
3178 total_energy_alternate_state_assignment_( 0 ),
3179 node_considering_alt_state_( 0 ),
3180 deltaE_threshold_for_avoiding_surface_calcs_( -1.0f ),
3181 prepared_for_simulated_annealing_( false ),
3182 surface_score_weight_( 1 )
3189 template <
typename V,
typename E,
typename G >
3263 template <
typename V,
typename E,
typename G >
3276 TR_SIG <<
"initialize() called" << std::endl;
3277 TR_SIG <<
"calling set_rotamers on " << rotamer_sets().nmoltenres() <<
" molten residues." << std::endl;
3282 G::initialize( rot_sets );
3285 for (
Size ii = 1; ii <= rotamer_sets().nmoltenres(); ++ii ) {
3286 get_surface_node( ii )->set_rotamers( rotamer_sets().rotamer_set_for_moltenresidue( ii ) );
3290 set_num_residues_in_protein( pose().total_residue() );
3303 int nbackground = pose().total_residue() - rot_sets.
nmoltenres();
3304 set_num_background_residues( nbackground );
3306 for (
Size ii = 1; ii <= pose().total_residue(); ++ii) {
3315 if ( packer_task().being_packed(ii) || packer_task().being_designed(ii) ) {
3320 set_residue_as_background_residue( ii );
3328 Size node_num_nbs = 0;
3329 for (
int ii = 1; ii <= parent::get_num_nodes(); ++ii) {
3330 node_num_nbs = get_surface_node( ii )->num_neighbors_counting_self();
3335 if ( node_num_nbs <= (
Size)SURFACE_EXPOSED_CUTOFF ) {
3338 get_surface_node( ii )->surface_exposed(
true );
3339 get_surface_node( ii )->is_below_buried_residue_no_hsasa_cutoff(
true );
3341 TR_SIG <<
"initialize_surface_ig: setting surface_exposed and is_below_buried_residue_no_hsasa_cutoff bools to true for FC node " << ii << std::endl;
3343 }
else if ( node_num_nbs > (
Size)SURFACE_EXPOSED_CUTOFF && node_num_nbs <= (
Size)BURIED_RESIDUE_NO_HSASA_CUTOFF ) {
3344 get_surface_node( ii )->is_below_buried_residue_no_hsasa_cutoff(
true );
3346 TR_SIG <<
"initialize_surface_ig: setting is_below_buried_residue_no_hsasa_cutoff bool to true for FC node " << ii << std::endl;
3352 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
3353 node_num_nbs = get_surface_bg_node( ii )->num_neighbors_counting_self();
3354 if ( node_num_nbs <= (
Size)SURFACE_EXPOSED_CUTOFF ) {
3356 get_surface_bg_node( ii )->surface_exposed(
true );
3357 get_surface_bg_node( ii )->is_below_buried_residue_no_hsasa_cutoff(
true );
3359 TR_SIG <<
"initialize_surface_ig: setting surface_exposed and is_below_buried_residue_no_hsasa_cutoff bools to true for BG node " << ii << std::endl;
3361 }
else if ( node_num_nbs > (
Size)SURFACE_EXPOSED_CUTOFF && node_num_nbs <= (
Size)BURIED_RESIDUE_NO_HSASA_CUTOFF ) {
3362 get_surface_node( ii )->is_below_buried_residue_no_hsasa_cutoff(
true );
3364 TR_SIG <<
"initialize_surface_ig: setting is_below_buried_residue_no_hsasa_cutoff bool to true for BG node " << ii << std::endl;
3371 TR_SIG <<
"initialize_surface_ig: DONE with initialization.\n---" << std::endl;
3397 template <
typename V,
typename E,
typename G >
3400 num_total_residues_ = num_res;
3401 resid_2_bgenumeration_.resize( num_total_residues_ );
3402 for (
int ii = 1; ii <= num_total_residues_; ++ii) {
3403 resid_2_bgenumeration_[ii] = 0;
3422 template <
typename V,
typename E,
typename G >
3426 TR_SIG <<
"set_num_background_residues: setting num background residues to " << num_background_residues << std::endl;
3429 parent::set_num_background_nodes( num_background_residues );
3430 if ( parent::get_num_background_nodes() == 0 )
3433 bgenumeration_2_resid_.resize( parent::get_num_background_nodes() );
3434 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
3435 bgenumeration_2_resid_[ii] = 0;
3452 template <
typename V,
typename E,
typename G >
3455 assert( resid_2_bgenumeration_[ residue ] == 0 );
3458 TR_SIG <<
"set_residue_as_background_residue: setting residue " << pose().residue( residue ).name3() <<
" " << residue <<
" as background node." << std::endl;
3461 ++num_residues_assigned_as_background_;
3462 resid_2_bgenumeration_[ residue ] = num_residues_assigned_as_background_;
3463 bgenumeration_2_resid_[ num_residues_assigned_as_background_ ] = residue;
3477 template <
typename V,
typename E,
typename G >
3480 if ( node_index > num_residues_assigned_as_background_ ) {
3481 utility_exit_with_message(
"Out of bounds array index passed to bg_node_2_resid. Quitting." );
3483 return bgenumeration_2_resid_[ node_index ];
3505 template <
typename V,
typename E,
typename G >
3508 if ( prepared_for_simulated_annealing_ ) {
3516 for (
int ii = 1; ii <= parent::get_num_nodes(); ++ii)
3517 get_surface_node( ii )->init_hASA_variables();
3518 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii)
3519 get_surface_bg_node( ii )->init_hASA_variables();
3527 detect_background_residue_and_first_class_residue_neighbors();
3531 G::prepare_for_simulated_annealing();
3534 parent::prepare_for_simulated_annealing();
3536 prepared_for_simulated_annealing_ =
true;
3539 TR_SIG <<
"prepare_for_simulated_annealing: number edges in graph: " << parent::get_num_edges() << std::endl;
3552 template <
typename V,
typename E,
typename G >
3555 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
3558 TR_SIG <<
"detect_bg_and_fc_residue_neighbors: checking for neighbors of background residue " << pose().residue( bgenumeration_2_resid_[ ii ] ).name3()
3559 <<
" " << pose().residue( bgenumeration_2_resid_[ ii ] ).seqpos() << std::endl;
3562 for (
int jj = 1; jj <= parent::get_num_nodes(); ++jj) {
3567 if ( get_surface_bg_node( ii )->detect_neighborship( get_surface_node( jj ) ) ) {
3569 TR_SIG <<
"detect_bg_and_fc_residue_neighbors: --- adding FC/BG edge: fc node id:" << pose().residue(jj).seqpos()
3570 <<
" / bg resid:" << bgenumeration_2_resid_[ ii ] << std::endl;
3572 parent::add_background_edge( jj, ii );
3578 TR_SIG <<
"DONE detecting background and first class neighbors.\n---" << std::endl;
3591 template <
typename V,
typename E,
typename G >
3595 TR_SIG <<
"blanket_assign_state_0() called" << std::endl;
3597 for (
int ii = 1; ii <= parent::get_num_nodes(); ++ii) {
3598 get_surface_node( ii )->assign_zero_state();
3600 update_internal_energy_totals_surface();
3612 template <
typename V,
typename E,
typename G >
3616 TR_SIG <<
"update_internal_energy_totals_surface" << std::endl;
3621 parent::update_internal_energy_totals();
3622 total_energy_current_state_assignment_ = parent::get_energy_PD_current_state_assignment();
3624 for (
int ii = 1; ii <= parent::get_num_nodes(); ++ii) {
3625 Real fc_surface = get_surface_node( ii )->get_curr_state_surface_energy();
3626 total_energy_current_state_assignment_ += fc_surface;
3629 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
3630 Real bg_surface = get_surface_bg_node( ii )->get_surface_score();
3631 total_energy_current_state_assignment_ += bg_surface;
3634 num_commits_since_last_update_ = 0;
3653 template <
typename V,
typename E,
typename G >
3657 TR_SIG <<
"set_errorfull_deltaE_threshold: setting threshold to " << deltaE << std::endl;
3663 deltaE_threshold_for_avoiding_surface_calcs_ = deltaE;
3688 template <
typename V,
typename E,
typename G >
3691 blanket_reset_alt_state_total_hASAs();
3694 TR_SIG <<
"---" << std::endl;
3695 TR_SIG <<
"consider_substitution(): trying new state " << new_state <<
" ("
3696 << get_surface_node( node_ind )->get_rotamer( new_state )->name() <<
") on node/molten res " << node_ind <<
" (wt: "
3697 << pose().residue( rotamer_sets().moltenres_2_resid( node_ind ) ).name3() <<
" " << rotamer_sets().moltenres_2_resid( node_ind ) <<
") " << std::endl;
3700 node_considering_alt_state_ = node_ind;
3702 delta_energy = get_surface_node( node_ind )->project_deltaE_for_substitution_surface(
3703 new_state, prev_energy_for_node, deltaE_threshold_for_avoiding_surface_calcs_ );
3706 TR_SIG <<
"consider_substitution: delta_energy: " << delta_energy << std::endl;
3708 total_energy_alternate_state_assignment_ = delta_energy + total_energy_current_state_assignment_;
3730 template <
typename V,
typename E,
typename G >
3734 TR_SIG <<
"blanket_reset_alt_state_total_hASAs: calling reset_alt_state_total_hASA on all FC nodes." << std::endl;
3736 for (
int ii = 1; ii <= parent::get_num_nodes(); ++ii) {
3737 get_surface_node( ii )->reset_alt_state_total_hASA();
3741 TR_SIG <<
"blanket_reset_alt_state_total_hASAs: calling reset_alt_state_total_hASA on all BG nodes." << std::endl;
3743 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
3744 get_surface_bg_node( ii )->reset_alt_state_total_hASA();
3756 template <
typename V,
typename E,
typename G >
3760 TR_SIG <<
"commit_considered_substitution(): committing sub on node " << node_considering_alt_state_ << std::endl;
3762 core::PackerEnergy deltaE = get_surface_node( node_considering_alt_state_ )->commit_considered_substitution_surface();
3764 total_energy_current_state_assignment_ = total_energy_current_state_assignment_ + deltaE;
3766 node_considering_alt_state_ = -1;
3767 ++num_commits_since_last_update_;
3768 if ( num_commits_since_last_update_ == COMMIT_LIMIT_BETWEEN_UPDATES ) {
3769 update_internal_energy_totals_surface();
3772 return total_energy_current_state_assignment_;
3791 template <
typename V,
typename E,
typename G >
3795 TR_SIG <<
"set_network_state() called with states: " << node_states << std::endl;
3798 blanket_reset_alt_state_total_hASAs();
3800 for (
int ii = 1; ii <= parent::get_num_nodes(); ++ii) {
3801 get_surface_node( ii )->assign_state_surface( node_states(ii) );
3803 update_internal_energy_totals_surface();
3805 return total_energy_current_state_assignment_;
3819 template <
typename V,
typename E,
typename G >
3822 get_surface_node( node_ind )->assign_state_surface( new_state );
3824 update_internal_energy_totals_surface();
3825 return total_energy_current_state_assignment_;
3836 template <
typename V,
typename E,
typename G >
3838 return total_energy_current_state_assignment_;
3856 template <
typename V,
typename E,
typename G >
3860 TR_SIG <<
"create_new_node called with node_index " << node_index <<
" and num_states " << num_states << std::endl;
3877 template <
typename V,
typename E,
typename G >
3881 TR_SIG <<
"create_new_edge() called for indices " << index1 <<
" and " << index2 << std::endl;
3897 template <
typename V,
typename E,
typename G >
3900 TR_SIG <<
"create_background_node() called for index " << node_index << std::endl;
3920 template <
typename V,
typename E,
typename G >
3932 template <
typename V,
typename E,
typename G >
3936 TR_SIG <<
"internal energies: " << std::endl;
3937 for (
int ii = 1; ii <= parent::get_num_nodes(); ++ii) {
3938 Real one_body = get_surface_node( ii )->get_curr_state_one_body_energy();
3939 TR_SIG <<
"node " << ii <<
" 1b: " << one_body;
3941 Real surface = get_surface_node( ii )->get_curr_state_surface_energy();
3952 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
3954 Real bg_surface = get_surface_bg_node( ii )->get_surface_score();
3955 TR_SIG <<
"bg res: " << bgenumeration_2_resid_[ ii ] <<
" surface: " << bg_surface << std::endl;
3959 int count_edges = 0;
3960 for (std::list< core::pack::interaction_graph::EdgeBase*>::const_iterator iter = parent::get_edge_list_begin(); iter != parent::get_edge_list_end(); ++iter) {
3962 TR_SIG <<
"edge: " << edge_energy <<
" ";
3964 if ( count_edges % 5 == 0)
3978 template <
typename V,
typename E,
typename G >
3987 template <
typename V,
typename E,
typename G >
3996 template <
typename V,
typename E,
typename G >
3999 unsigned int total_memory = parent::count_dynamic_memory();
4000 total_memory += resid_2_bgenumeration_.size() *
sizeof (
int );
4001 total_memory += bgenumeration_2_resid_.size() *
sizeof (
int );
4003 return total_memory;
4010 template <
typename V,
typename E,
typename G >
4015 TR_SIG <<
"set_pose() called: typeid() of base class G returned: " <<
typeid(
G).name() << std::endl;
4035 template <
typename V,
typename E,
typename G >
4038 packer_task_ = the_task.
clone();
4045 template <
typename V,
typename E,
typename G >
4058 template<
typename V,
typename E,
typename G >
4062 std::cout <<
"Surface Interaction Graph state: " << std::endl;
4063 std::cout <<
"nodes: " << std::endl;
4064 for (
int jj = 1; jj <= parent::get_num_nodes(); ++jj) {
4065 get_surface_node( jj )->print();
4068 std::cout <<
"bgnodes: " << std::endl;
4069 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
4070 get_surface_bg_node( ii )->print();
4086 template<
typename V,
typename E,
typename G >
4088 observed_sufficient_surface_E_to_predict_min_ =
true;
4090 for(
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii)
4091 get_incident_surface_edge(ii)->set_max_surface_deltaE();
4093 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii )
4094 get_edge_to_surface_bg_node(ii)->set_max_surface_deltaE();
4106 template<
typename V,
typename E,
typename G >
4109 std::vector<Real> hASA_vector;
4110 hASA_vector.push_back( curr_state_total_hASA_ );
4112 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
4113 int other_nodes_index = get_incident_surface_edge(ii)->get_other_ind( parent::get_node_index() );
4114 int edge_index = ( other_nodes_index == get_incident_surface_edge(ii)->get_surface_node(0)->get_node_index() ? 0 : 1 );
4116 if ( fc_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_nodes_index) ) != fc_neighbor_map.end() ) {
4118 hASA_vector.push_back( get_incident_surface_edge(ii)->get_surface_node( edge_index )->get_current_hASA() );
4122 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
4123 int other_nodes_index = get_edge_to_surface_bg_node(ii)->get_other_ind(
this );
4125 if ( bg_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_nodes_index) ) != bg_neighbor_map.end() ) {
4127 hASA_vector.push_back( get_edge_to_surface_bg_node(ii)->get_surface_bg_node()->get_current_hASA() );
4139 template<
typename V,
typename E,
typename G >
4147 template<
typename V,
typename E,
typename G >
4160 template<
typename V,
typename E,
typename G >
4163 std::vector< Real > alt_state_hASA_vector;
4164 alt_state_hASA_vector.push_back( alt_state_total_hASA_ );
4166 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
4167 int other_nodes_index = get_incident_surface_edge(ii)->get_other_ind( parent::get_node_index() );
4168 int edge_index = ( other_nodes_index == get_incident_surface_edge(ii)->get_surface_node(0)->get_node_index() ? 0 : 1 );
4170 if ( fc_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_nodes_index) ) != fc_neighbor_map.end() ) {
4172 alt_state_hASA_vector.push_back( get_incident_surface_edge(ii)->get_surface_node( edge_index )->get_alt_hASA() );
4176 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii ) {
4177 int other_nodes_index = get_edge_to_surface_bg_node(ii)->get_other_ind(
this );
4179 if ( bg_neighbor_map.find( std::pair<int,int>( parent::get_node_index(), other_nodes_index) ) != bg_neighbor_map.end() ) {
4181 alt_state_hASA_vector.push_back( get_edge_to_surface_bg_node(ii)->get_surface_bg_node()->get_alt_hASA() );
4185 return alt_state_hASA_vector;
4194 template<
typename V,
typename E,
typename G >
4202 template<
typename V,
typename E,
typename G >
4212 template<
typename V,
typename E,
typename G >
4215 std::vector< int > networkstate;
4216 for (
int jj = 1; jj <= parent::get_num_nodes(); ++jj) {
4217 networkstate.push_back( get_surface_node(jj)->get_current_state() );
4219 return networkstate;
4228 template<
typename V,
typename E,
typename G >
4230 return get_surface_node( index )->get_hASA_for_node_and_nbs();
4240 template<
typename V,
typename E,
typename G >
4242 return get_surface_node( index )->get_alt_state_hASA_for_node_and_nbs();
4252 template<
typename V,
typename E,
typename G >
4254 for (
int jj = 1; jj <= parent::get_num_nodes(); ++jj) {
4255 get_surface_node(jj)->set_observed_sufficient_boolean_true();