15 #ifndef INCLUDED_core_pack_interaction_graph_HPatchInteractionGraph_hh
16 #define INCLUDED_core_pack_interaction_graph_HPatchInteractionGraph_hh
45 #include <basic/Tracer.hh>
49 #include <utility/vector1.hh>
51 #include <utility/exit.hh>
55 #include <ObjexxFCL/FArray1D.hh>
68 namespace interaction_graph {
75 node_index_( node_ind ),
76 exhphobe_index_( exhphobe_ind )
85 static basic::Tracer
TR_NODE(
"core.pack.hpatchig.node");
86 static basic::Tracer
TR_EDGE(
"core.pack.hpatchig.edge");
87 static basic::Tracer
TR_BGNODE(
"core.pack.hpatchig.bgnode");
88 static basic::Tracer
TR_BGEDGE(
"core.pack.hpatchig.bgedge");
89 static basic::Tracer
TR_HIG(
"core.pack.hpatchig.ig");
90 static basic::Tracer
TR_STATS(
"core.pack.hpatchig.stats");
93 template <
typename V,
typename E,
typename G >
class HPatchNode;
95 template <
typename V,
typename E,
typename G >
class HPatchEdge;
114 template <
typename V,
typename E,
typename G >
122 HPatchNode(
G* owner,
int node_index,
int num_states );
144 std::vector< RotamerDotsCache > &
overlap,
166 return get_hpatch_owner()->rotamer_sets().moltenres_2_resid( parent::get_node_index() );
191 virtual void print()
const;
296 template <
typename V,
typename E,
typename G >
337 virtual void print()
const;
412 template <
typename V,
typename E,
typename G >
427 int node_considering_substitution,
494 template <
typename V,
typename E,
typename G >
572 template <
typename V,
typename E,
typename G >
622 Size residue_djs_offset,
653 using parent::get_energy_sum_for_vertex_group;
712 #ifdef DOUBLE_CHECK_COUNTS
713 void verify_sasas_correct();
805 template <
typename V,
typename E,
typename G >
808 current_state_rotamer_dots_(),
809 alt_state_rotamer_dots_(),
810 alt_state_dots_matches_current_state_dots_( true )
824 template <
typename V,
typename E,
typename G >
836 template <
typename V,
typename E,
typename G >
840 if ( rotamers->num_rotamers() != (
Size) parent::get_num_states() ) {
841 utility_exit_with_message(
"Number of rotamers is not equal to parents number of states. Quitting.");
845 TR_NODE <<
"set_rotamers: adding " << rotamers->num_rotamers() <<
" to local rotamers vector." << std::endl;
848 for (
Size ii = 1; ii <= rotamers->num_rotamers(); ++ii ) {
849 rotamers_vector_[ ii ] = rotamers->rotamer( ii );
850 restype_group_for_rotamers_[ ii ] = rotamers->get_residue_group_index_for_rotamer( ii );
863 hphobe_ats_for_restype_group_.resize( restype_group_for_rotamers_[ rotamers->num_rotamers() ] );
864 for (
Size ii = 1; ii <= hphobe_ats_for_restype_group_.size(); ++ii ) {
865 chemical::ResidueType const & ii_restype = rotamers_vector_[ rotamers->get_residue_type_begin( ii ) ]->type();
872 if ( max_hphobes_ < count_cs ) {
873 max_hphobes_ = count_cs;
875 hphobe_ats_for_restype_group_[ ii ].reserve( count_cs );
878 hphobe_ats_for_restype_group_[ ii ].push_back( jj );
884 curr_state_exp_hphobes_.reserve( max_hphobes_ );
885 alt_state_exp_hphobes_.reserve( max_hphobes_ );
906 template <
typename V,
typename E,
typename G >
909 return rotamers_vector_[ state ];
927 template <
typename V,
typename E,
typename G >
929 assert( state > 0 && state <= (
Size)parent::get_num_states() );
930 self_and_bg_dots_for_states_[ state ] = rd;
948 template <
typename V,
typename E,
typename G >
952 bool found_overlap =
false;
957 for (
Size ii = 1; ii <= (
Size)parent::get_num_states(); ++ii ) {
959 for (
Size jj = 1; jj <= (
Size)neighbor->get_num_states(); ++jj ) {
961 found_overlap =
true;
972 return found_overlap;
984 template <
typename V,
typename E,
typename G >
988 for (
Size ii = 1; ii <= (
Size)parent::get_num_states(); ++ii ) {
990 if ( self_and_bg_dots_for_states_[ ii ].overlaps( bg_dots ) ) {
1005 template <
typename V,
typename E,
typename G >
1010 TR_NODE <<
"prepare_for_simulated_annealing(): calling V::prep for simA for node " << parent::get_node_index() << std::endl;
1017 V::prepare_for_simulated_annealing();
1019 if ( ! parent::get_bg_edge_vector_up_to_date_() ) {
1021 TR_NODE <<
"prepare_for_simulated_annealing(): bg edge vector not up to date, calling parent::update_bg_edge_vector()" << std::endl;
1023 parent::update_bg_edge_vector();
1027 TR_NODE <<
"prepare_for_simulated_annealing(): calling initialize_self_overlap()" << std::endl;
1029 initialize_self_overlap();
1031 TR_NODE <<
"prepare_for_simulated_annealing(): ... done incrementing self overlap for all states" << std::endl;
1034 initialize_atom_atom_overlap_cache();
1045 template <
typename V,
typename E,
typename G >
1048 for (
Size ii=1; ii <= (
Size)parent::get_num_states(); ++ii ) {
1050 self_and_bg_dots_for_states_[ ii ].increment_self_overlap();
1068 template <
typename V,
typename E,
typename G >
1072 self_atom_atom_overlaps_.resize( (
Size)parent::get_num_states() );
1074 for (
Size state = 1; state <= (
Size)parent::get_num_states(); ++state ) {
1079 self_atom_atom_overlaps_[ state ].resize( rotamer_->nheavyatoms(),
utility::vector1< bool >( rotamer_->nheavyatoms(), false ) );
1083 Real const probe_radius = 1.4;
1085 RotamerDots const & rd = self_and_bg_dots_for_states_[ state ];
1087 for (
Size iia=1; iia <= rotamer_->nheavyatoms(); ++iia ) {
1089 if ( rotamer_->atom_type( iia ).element() != carbon_atom && rotamer_->atom_type( iia ).element() != sulfur_atom )
1095 for (
Size jja = iia + 1; jja <= rotamer_->nheavyatoms(); ++jja ) {
1096 if ( rotamer_->atom_type( jja ).element() != carbon_atom && rotamer_->atom_type( jja ).element() != sulfur_atom )
1102 Vector const & iia_atom_xyz = rotamer_->atom( iia ).xyz();
1103 Vector const & jja_atom_xyz = rotamer_->atom( jja ).xyz();
1108 if ( distance_squared <= (iia_atom_radius + jja_atom_radius) * (iia_atom_radius + jja_atom_radius) ) {
1110 Real const distance_ijxyz = std::sqrt( distance_squared );
1111 int degree_of_overlap;
1113 if ( degree_of_overlap >= 15 ) {
1115 self_atom_atom_overlaps_[ state ][ iia ][ jja ] =
true;
1165 template <
typename V,
typename E,
typename G >
1168 std::vector< RotamerDotsCache > & node_states_coverage_of_bg_res_,
1172 std::vector< RotamerDotsCache* > v_dots_for_bg_res( (
Size)parent::get_num_states() + 1, static_cast< RotamerDotsCache* >(0) );
1176 states_atom_atom_overlap_on_bg_res[ 0 ] = zero_vector;
1180 for (
Size ii = 1; ii <= (
Size)parent::get_num_states(); ++ii ) {
1183 Size ii_state_num_atoms = self_and_bg_dots_for_states_[ ii ].get_num_atoms();
1187 if ( self_and_bg_dots_for_states_[ ii ].overlaps( bg_rotamer_dots ) ) {
1193 self_and_bg_dots_for_states_[ ii ].increment_this_and_cache( bg_rotamer_dots, *v_dots_for_bg_res[ ii ], temp_atat_overlap );
1197 for (
Size kk = 1; kk <= ii_state_num_atoms; ++kk ) {
1198 states_atom_atom_overlap_on_bg_res[ ii ][ kk ][ jj ] = temp_atat_overlap[ jj ][ kk ];
1203 node_states_coverage_of_bg_res_[ ii ] = *(v_dots_for_bg_res[ ii ]);
1207 delete v_dots_for_bg_res[ ii ];
1226 template <
typename V,
typename E,
typename G >
1233 parent::assign_zero_state();
1237 TR_NODE <<
"assign_zero_state(): calling acknowledge_state_zeroed() on all incident edges." << std::endl;
1239 for (
Size ii = 1; ii <= (
Size)parent::get_num_incident_edges(); ++ii ) {
1240 get_incident_hpatch_edge( ii )->acknowledge_state_zeroed( parent::get_node_index() );
1243 parent::update_bg_edge_vector();
1246 TR_NODE <<
"assign_zero_state(): calling acknowledge_state_change() on all incident bg edges." << std::endl;
1248 for (
Size ii = 1; ii <= (
Size)parent::get_num_edges_to_background_nodes(); ++ii ) {
1249 get_edge_to_hpatch_bg_node( ii )->acknowledge_state_change( 0 );
1253 current_state_rotamer_dots_ = rd;
1254 alt_state_rotamer_dots_ = rd;
1255 alt_state_dots_matches_current_state_dots_ =
true;
1260 get_hpatch_owner()->register_fc_node_in_state0();
1278 template <
typename V,
typename E,
typename G >
1289 current_state_rotamer_dots_ = alt_state_rotamer_dots_;
1290 curr_state_inv_dots_ = alt_state_inv_dots_;
1291 curr_state_exp_hphobes_ = alt_state_exp_hphobes_;
1292 alt_state_dots_matches_current_state_dots_ =
true;
1306 template <
typename V,
typename E,
typename G >
1308 return current_state_rotamer_dots_.get_sasa();
1318 template <
typename V,
typename E,
typename G >
1320 return current_state_rotamer_dots_.get_atom_sasa( atom_index );
1330 template <
typename V,
typename E,
typename G >
1332 return alt_state_rotamer_dots_.get_atom_sasa( atom_index );
1342 template <
typename V,
typename E,
typename G >
1345 return self_atom_atom_overlaps_[ state ];
1358 template <
typename V,
typename E,
typename G >
1361 assert( alternate_state > 0 && alternate_state <= parent::get_num_states() );
1363 prev_PDenergies_for_node = parent::get_curr_pd_energy_total();
1369 parent::calc_deltaEpd( alternate_state );
1371 return get_pd_energy_delta();
1383 template <
typename V,
typename E,
typename G >
1385 return ( parent::get_alt_pd_energy_total() - parent::get_curr_pd_energy_total() );
1396 template <
typename V,
typename E,
typename G >
1399 get_hpatch_owner()->register_fc_node_affected_by_rotsub( parent::get_node_index() );
1402 TR_NODE <<
"consider_alternate_state(): current_state:" << parent::get_current_state();
1403 if ( parent::get_current_state() == 0 ) {
1404 TR_NODE <<
" (" << wt_residue_for_node().name3() <<
"-";
1405 if ( wt_residue_for_node().is_polar() ) {
TR_NODE <<
"P)"; }
else {
TR_NODE <<
"HP)"; }
1407 TR_NODE <<
" (" << get_rotamer( parent::get_current_state() )->name() <<
"-";
1408 if ( get_rotamer( parent::get_current_state() )->is_polar() ) {
TR_NODE <<
"P)"; }
else {
TR_NODE <<
"HP)"; }
1410 TR_NODE <<
", alternate_state: " << parent::get_alternate_state() <<
" (" << get_rotamer( parent::get_alternate_state() )->name() <<
"-";
1411 if ( get_rotamer( parent::get_alternate_state() )->is_polar() ) {
TR_NODE <<
"P)"; }
else {
TR_NODE <<
"HP)"; }
1417 assert( alt_state_dots_matches_current_state_dots_ );
1418 alt_state_dots_matches_current_state_dots_ =
false;
1420 alt_state_rotamer_dots_ = self_and_bg_dots_for_states_[ parent::get_alternate_state() ];
1422 Real delta_sasa = 0;
1423 for (
Size ii = 1; ii <= (
Size)parent::get_num_incident_edges(); ++ii ) {
1424 delta_sasa += get_incident_hpatch_edge(ii)->update_state_at_neighbor( parent::get_node_index(), parent::get_alternate_state(), alt_state_rotamer_dots_ );
1426 for (
Size ii = 1; ii <= (
Size)parent::get_num_edges_to_background_nodes(); ++ii ) {
1427 delta_sasa += get_edge_to_hpatch_bg_node( ii )->update_state_at_neighbor( parent::get_alternate_state() );
1430 update_alt_state_exphphobes();
1433 alt_state_inv_dots_.setup_from_rotamer_dots( alt_state_rotamer_dots_, alt_state_exp_hphobes_ );
1436 if ( get_sasa_difference() != 0 ) {
1437 TR_NODE <<
"consider_alternate_state(): curr state dots: " << current_state_rotamer_dots_.get_sasa()
1438 <<
", alt state dots: " << alt_state_rotamer_dots_.get_sasa()
1439 <<
", sasa difference: " << get_sasa_difference() << std::endl;
1442 delta_sasa += get_sasa_difference();
1454 template <
typename V,
typename E,
typename G >
1457 alt_state_exp_hphobes_.clear();
1458 for (
Size ii = 1; ii <= alt_hphobes.size(); ++ii ) {
1459 Size const ii_atom = alt_hphobes[ ii ];
1460 if ( alt_state_rotamer_dots_.get_atom_sasa( ii_atom ) > 0.0 ) {
1461 alt_state_exp_hphobes_.push_back( ii_atom );
1509 template <
typename V,
typename E,
typename G >
1519 get_hpatch_owner()->register_fc_node_affected_by_rotsub( parent::get_node_index() );
1520 parent::set_alternate_state( parent::get_current_state() );
1524 if ( current_state_rotamer_dots_.state_unassigned() ) {
1526 TR_NODE <<
"update_state_for_neighbors_substitution(): node " << parent::get_node_index() <<
" in unassigned state. skipping sasa calculations." << std::endl;
1537 assert( alt_state_dots_matches_current_state_dots_ );
1540 alt_state_dots_matches_current_state_dots_ =
false;
1552 if ( node_considering_substitution->get_current_state() != 0 ) {
1554 alt_state_rotamer_dots_.decrement_from_cached( neighbors_curr_state_overlap_with_this );
1564 alt_state_rotamer_dots_.increment_both_and_cache( neighbors_alternate_state, this_overlap_with_neighbors_alternate,
1565 neighbors_alternate_overlap_with_this, atom_atom_overlaps_cache );
1567 update_alt_state_exphphobes();
1568 alt_state_inv_dots_.setup_from_rotamer_dots( alt_state_rotamer_dots_, alt_state_exp_hphobes_ );
1577 if ( current_state_rotamer_dots_ != alt_state_rotamer_dots_ ) {
1578 TR_NODE <<
"update_state_for_neighbors_substitution(): node " << parent::get_node_index()
1579 <<
" calc. deltaE for changing node " << node_considering_substitution->get_node_index()
1580 <<
", curr state sasa: " << current_state_rotamer_dots_.get_sasa() <<
", alt state sasa: " << alt_state_rotamer_dots_.get_sasa()
1581 <<
", sasa difference: " << get_sasa_difference() << std::endl;
1585 return get_sasa_difference();
1603 template <
typename V,
typename E,
typename G >
1606 if ( parent::get_current_state() == 0 && parent::get_alternate_state() == 0 )
1608 else if ( parent::get_current_state() != 0 && parent::get_alternate_state() == 0 )
1609 return -1 * current_state_rotamer_dots_.get_sasa();
1610 else if ( parent::get_current_state() == 0 && parent::get_alternate_state() != 0 )
1611 return alt_state_rotamer_dots_.get_sasa();
1614 return alt_state_rotamer_dots_.get_sasa() - current_state_rotamer_dots_.get_sasa();
1625 template <
typename V,
typename E,
typename G >
1628 if ( alt_state_rotamer_dots_.state_unassigned() && current_state_rotamer_dots_.state_unassigned() )
return;
1633 if ( ! alt_state_dots_matches_current_state_dots_ ) {
1634 alt_state_rotamer_dots_ = current_state_rotamer_dots_;
1635 alt_state_inv_dots_ = curr_state_inv_dots_;
1636 alt_state_exp_hphobes_ = curr_state_exp_hphobes_;
1637 alt_state_dots_matches_current_state_dots_ =
true;
1639 TR_NODE <<
"reset_alt_state_dots(): alt state dots set equal to current state dots." << std::endl;
1676 template <
typename V,
typename E,
typename G >
1679 assert( parent::considering_alternate_state() );
1681 if ( parent::get_alternate_state() == 0 ) {
1682 assign_zero_state();
1687 parent::commit_considered_substitution();
1689 current_state_rotamer_dots_ = alt_state_rotamer_dots_;
1690 curr_state_inv_dots_ = alt_state_inv_dots_;
1691 curr_state_exp_hphobes_ = alt_state_exp_hphobes_;
1692 alt_state_dots_matches_current_state_dots_ =
true;
1694 TR_NODE <<
"Committed substitution node " << parent::get_node_index() << std::endl;
1698 for (
int ii = 1; ii <= parent::get_num_incident_edges(); ++ii ) {
1699 get_incident_hpatch_edge(ii)->acknowledge_substitution();
1701 for (
int ii = 1; ii <= parent::get_num_edges_to_background_nodes(); ++ii) {
1702 get_edge_to_hpatch_bg_node( ii )->acknowledge_substitution();
1714 template <
typename V,
typename E,
typename G >
1725 template <
typename V,
typename E,
typename G >
1736 template <
typename V,
typename E,
typename G >
1738 unsigned int total_memory = parent::count_dynamic_memory();
1741 total_memory += self_and_bg_dots_for_states_.size() *
sizeof(
RotamerDots );
1743 return total_memory;
1765 template <
typename V,
typename E,
typename G >
1767 TR_NODE <<
"node " << parent::get_node_index() <<
", current_state: " << parent::get_current_state()
1768 <<
", one body energy: " << parent::get_one_body_energy_current_state() << std::endl;
1769 current_state_rotamer_dots_.print( std::cout );
1770 alt_state_rotamer_dots_.print( std::cout );
1784 template <
typename V,
typename E,
typename G >
1787 prepared_for_simA_( false ),
1788 current_state_rotamer_dots_(),
1789 alt_state_rotamer_dots_(),
1790 alt_state_dots_matches_current_state_dots_( true )
1797 template <
typename V,
typename E,
typename G >
1809 template <
typename V,
typename E,
typename G >
1821 hphobe_ats_.reserve( n_hphobes_ );
1824 hphobe_ats_.push_back( ii );
1828 curr_state_exp_hphobes_.reserve( n_hphobes_ );
1829 alt_state_exp_hphobes_.reserve( n_hphobes_ );
1842 template <
typename V,
typename E,
typename G >
1854 template <
typename V,
typename E,
typename G >
1856 current_state_rotamer_dots_ = bg_rd;
1857 alt_state_dots_matches_current_state_dots_ =
false;
1871 template <
typename V,
typename E,
typename G >
1888 template <
typename V,
typename E,
typename G >
1891 if ( ! prepared_for_simA_ ) {
1892 if ( ! parent::get_edge_vector_up_to_date() )
1893 parent::update_edge_vector();
1895 prepared_for_simA_ =
true;
1900 current_state_rotamer_dots_.zero();
1901 alt_state_dots_matches_current_state_dots_ =
false;
1903 initialize_self_overlap();
1904 initialize_atom_atom_overlaps();
1908 for (
Size ii = 1; ii <= (
Size)parent::get_num_incident_edges(); ++ii ) {
1909 get_hpatch_bg_edge( ii )->initialize_overlap_cache( current_state_rotamer_dots_ );
1921 template <
typename V,
typename E,
typename G >
1930 alt_state_dots_matches_current_state_dots_ =
false;
1931 current_state_rotamer_dots_.increment_self_overlap();
1949 template <
typename V,
typename E,
typename G >
1952 self_atom_atom_overlaps_.resize( rotamer_->nheavyatoms(),
utility::vector1< bool >( rotamer_->nheavyatoms(), false ) );
1956 Real const probe_radius = 1.4;
1958 for (
Size iia=1; iia <= rotamer_->nheavyatoms(); ++iia ) {
1960 if ( rotamer_->atom_type( iia ).element() != carbon_atom && rotamer_->atom_type( iia ).element() != sulfur_atom )
1963 Real const iia_atom_radius = current_state_rotamer_dots_.get_atom_radius( iia ) + probe_radius;
1966 for (
Size jja = iia + 1; jja <= rotamer_->nheavyatoms(); ++jja ) {
1967 if ( rotamer_->atom_type( jja ).element() != carbon_atom && rotamer_->atom_type( jja ).element() != sulfur_atom )
1970 Real const jja_atom_radius = current_state_rotamer_dots_.get_atom_radius( jja ) + probe_radius;
1973 Vector const & iia_atom_xyz = rotamer_->atom( iia ).xyz();
1974 Vector const & jja_atom_xyz = rotamer_->atom( jja ).xyz();
1978 if ( distance_squared <= (iia_atom_radius + jja_atom_radius) * (iia_atom_radius + jja_atom_radius) ) {
1980 Real const distance_ijxyz = std::sqrt( distance_squared );
1981 int degree_of_overlap;
1983 if ( degree_of_overlap >= 15 ) {
1989 self_atom_atom_overlaps_[ iia ][ jja ] =
true;
2019 template <
typename V,
typename E,
typename G >
2022 alt_state_dots_matches_current_state_dots_ =
false;
2041 template <
typename V,
typename E,
typename G >
2045 get_hpatch_owner()->register_bg_node_affected_by_rotsub( parent::get_node_index() );
2051 if ( ! alt_state_dots_matches_current_state_dots_ ) {
2052 alt_state_rotamer_dots_ = current_state_rotamer_dots_;
2054 alt_state_dots_matches_current_state_dots_ =
false;
2063 alt_state_rotamer_dots_.decrement_from_cached( nodes_curr_overlap_with_bg_res );
2070 alt_state_rotamer_dots_.increment_from_cached( nodes_alt_overlap_with_bg_res );
2072 update_alt_state_exphphobes();
2073 alt_state_inv_dots_.setup_from_rotamer_dots( alt_state_rotamer_dots_, alt_state_exp_hphobes_ );
2079 Real sasa_difference = alt_state_rotamer_dots_.get_sasa() - current_state_rotamer_dots_.get_sasa();
2083 TR_BGNODE <<
"update_state_for_substitution: bg node " << parent::get_node_index()
2084 <<
" calculated deltaE for changing hpatch resid " << fc_node_resid <<
"; "
2085 <<
"curr state sasa: " << current_state_rotamer_dots_.get_sasa() <<
", alt state sasa: " << alt_state_rotamer_dots_.get_sasa()
2086 <<
", sasa difference: " << sasa_difference << std::endl;
2089 return sasa_difference;
2100 template <
typename V,
typename E,
typename G >
2104 if ( ! alt_state_dots_matches_current_state_dots_ ) {
2105 alt_state_rotamer_dots_ = current_state_rotamer_dots_;
2106 alt_state_inv_dots_ = curr_state_inv_dots_;
2107 alt_state_exp_hphobes_ = curr_state_exp_hphobes_;
2108 alt_state_dots_matches_current_state_dots_ =
true;
2110 TR_BGNODE <<
"reset_alt_state_dots(): alt state rotamer dots set equal to current state rotamer dots." << std::endl;
2123 template <
typename V,
typename E,
typename G >
2125 current_state_rotamer_dots_ = alt_state_rotamer_dots_;
2126 curr_state_inv_dots_ = alt_state_inv_dots_;
2127 curr_state_exp_hphobes_ = alt_state_exp_hphobes_;
2128 alt_state_dots_matches_current_state_dots_ =
true;
2138 template <
typename V,
typename E,
typename G >
2140 alt_state_exp_hphobes_.clear();
2141 for (
Size ii = 1; ii <= hphobe_ats_.size(); ++ii ) {
2142 Size const ii_atom = hphobe_ats_[ ii ];
2143 if ( alt_state_rotamer_dots_.get_atom_sasa( ii_atom ) > 0.0 ) {
2144 alt_state_exp_hphobes_.push_back( ii_atom );
2156 template <
typename V,
typename E,
typename G >
2158 return current_state_rotamer_dots_.get_sasa();
2168 template <
typename V,
typename E,
typename G >
2171 return current_state_rotamer_dots_.get_atom_sasa( atom_index );
2181 template <
typename V,
typename E,
typename G >
2184 return alt_state_rotamer_dots_.get_sasa();
2194 template <
typename V,
typename E,
typename G >
2197 return alt_state_rotamer_dots_.get_atom_sasa( atom_index );
2207 template <
typename V,
typename E,
typename G >
2209 return self_atom_atom_overlaps_;
2216 template <
typename V,
typename E,
typename G >
2224 template <
typename V,
typename E,
typename G >
2226 unsigned int total_memory = parent::count_dynamic_memory();
2228 return total_memory;
2247 template <
typename V,
typename E,
typename G >
2249 TR_BGNODE <<
"bgnode " << parent::get_node_index() <<
", current state sasa: " << current_state_rotamer_dots_.get_sasa()
2250 <<
", alt state sasa: " << alt_state_rotamer_dots_.get_sasa() << std::endl;
2251 current_state_rotamer_dots_.print( std::cout );
2271 template <
typename V,
typename E,
typename G >
2274 node_changing_( -1 ),
2275 node_not_changing_( -1 )
2290 template <
typename V,
typename E,
typename G >
2303 template <
typename V,
typename E,
typename G >
2307 TR_EDGE <<
"prepare_for_simulated_annealing called on edge e(" << parent::get_node_index( 0 ) <<
"," << parent::get_node_index( 1 ) <<
")" << std::endl;
2310 parent::prepare_for_simulated_annealing_no_deletion();
2312 if ( parent::pd_edge_table_all_zeros() ) {
2313 if ( ! (get_hpatch_node(0)->overlaps( get_hpatch_node(1)) ) ) {
2315 TR_EDGE <<
"prepare_for_simulated_annealing - dropping edge e(" << parent::get_node_index( 0 )
2316 <<
"," << parent::get_node_index( 1 ) <<
")" << std::endl;
2333 template <
typename V,
typename E,
typename G >
2338 node_changing_ = ( node_that_changed == parent::get_node_index(0) ? 0 : 1 );
2339 node_not_changing_ = ! node_changing_;
2341 nodes_curr_states_[ node_changing_ ] = 0;
2343 nodes_curr_pair_dot_counts_[ node_changing_ ].resize( 0 );
2344 nodes_curr_pair_dot_counts_[ node_not_changing_ ].resize( 0 );
2346 nodes_alt_pair_dot_counts_[ node_changing_ ].resize( 0 );
2347 nodes_alt_pair_dot_counts_[ node_not_changing_ ].resize( 0 );
2355 inform_non_changing_node_of_neighbors_change();
2365 template <
typename V,
typename E,
typename G >
2368 get_hpatch_node( node_not_changing_ )->acknowledge_neighbors_substitution();
2390 template <
typename V,
typename E,
typename G >
2393 using namespace utility;
2395 node_changing_ = ( node_considering_substitution == parent::get_node_index(0) ? 0 : 1 );
2396 node_not_changing_ = ! node_changing_;
2398 nodes_alt_states_[ node_changing_ ] = alt_state;
2399 nodes_alt_states_[ node_not_changing_ ] = nodes_curr_states_[ node_not_changing_ ];
2402 nodes_alt_pair_dot_counts_[ node_not_changing_ ].zero();
2406 nodes_alt_pair_dot_counts_[ node_changing_ ] = nodes_curr_pair_dot_counts_[ node_changing_ ];
2409 nodes_alt_pair_dot_counts_[ node_changing_ ].zero();
2424 nodes_alt_pair_dot_counts_[ node_changing_ ].resize( changing_node_alt_state_dots.
get_num_atoms() );
2426 nodes_alt_pair_dot_counts_[ node_not_changing_ ].resize( get_hpatch_node( node_not_changing_ )->get_current_state_num_atoms() );
2435 Size const node_not_changing_num_atoms = get_hpatch_node( node_not_changing_ )->get_current_state_num_atoms();
2436 Size const node_changing_alt_state_num_atoms = changing_node_alt_state_dots.
get_num_atoms();
2440 if ( alt_state_atom_atom_overlaps_.size() < node_changing_alt_state_num_atoms ) {
2441 alt_state_atom_atom_overlaps_.resize( node_changing_alt_state_num_atoms,
utility::vector1< bool >( node_not_changing_num_atoms,
false ) );
2444 for (
Size ii = 1; ii <= node_changing_alt_state_num_atoms; ++ii ) {
2445 if ( alt_state_atom_atom_overlaps_[ii].
size() < node_not_changing_num_atoms ) {
2446 alt_state_atom_atom_overlaps_[ii].resize( node_not_changing_num_atoms,
false );
2448 for (
Size jj = 1; jj <= node_not_changing_num_atoms; ++jj ) {
2449 alt_state_atom_atom_overlaps_[ ii ][ jj ] =
false;
2453 Real const delta_sasa = get_hpatch_node( node_not_changing_ )->update_state_for_neighbors_substitution(
2454 get_hpatch_node( node_changing_ ), changing_node_alt_state_dots,
2455 nodes_curr_pair_dot_counts_[ node_not_changing_ ],
2456 nodes_alt_pair_dot_counts_[ node_changing_ ],
2457 nodes_alt_pair_dot_counts_[ node_not_changing_ ],
2458 alt_state_atom_atom_overlaps_ );
2480 template <
typename V,
typename E,
typename G >
2483 inform_non_changing_node_of_neighbors_change();
2485 nodes_curr_states_[ node_changing_ ] = nodes_alt_states_[ node_changing_ ];
2487 nodes_curr_pair_dot_counts_[0] = nodes_alt_pair_dot_counts_[0];
2488 nodes_curr_pair_dot_counts_[1] = nodes_alt_pair_dot_counts_[1];
2491 if ( node_changing_ == 0 ) {
2492 if ( current_state_atom_atom_overlaps_.size() < alt_state_atom_atom_overlaps_.size() ) {
2493 current_state_atom_atom_overlaps_.resize( alt_state_atom_atom_overlaps_.size() );
2495 for (
Size ii = 1; ii <= alt_state_atom_atom_overlaps_.size(); ++ii ) {
2496 if ( current_state_atom_atom_overlaps_[ii].
size() < alt_state_atom_atom_overlaps_[ii].size() ) {
2497 current_state_atom_atom_overlaps_[ii].resize( alt_state_atom_atom_overlaps_[ii].
size() );
2499 current_state_atom_atom_overlaps_[ii] = alt_state_atom_atom_overlaps_[ii];
2507 if ( alt_state_atom_atom_overlaps_.size() == 0 ) {
2508 current_state_atom_atom_overlaps_ = alt_state_atom_atom_overlaps_;
2513 assert( get_hpatch_node( node_changing_ )->get_alt_state_num_atoms() <= alt_state_atom_atom_overlaps_.size() );
2514 assert( get_hpatch_node( node_not_changing_ )->get_current_state_num_atoms() <= alt_state_atom_atom_overlaps_[1].
size() );
2516 if ( current_state_atom_atom_overlaps_.size() < alt_state_atom_atom_overlaps_[1].size() ) {
2517 current_state_atom_atom_overlaps_.resize( alt_state_atom_atom_overlaps_[1].
size() );
2520 for (
Size ii=1; ii <= alt_state_atom_atom_overlaps_[1].size(); ++ii ) {
2521 if ( current_state_atom_atom_overlaps_[ii].
size() < alt_state_atom_atom_overlaps_.size() ){
2522 current_state_atom_atom_overlaps_[ii].resize( alt_state_atom_atom_overlaps_.size() );
2526 for (
Size ii=1; ii <= alt_state_atom_atom_overlaps_.size(); ++ii ) {
2528 assert( alt_state_atom_atom_overlaps_[ ii ].
size() <= alt_state_atom_atom_overlaps_[ 1 ].
size() );
2529 assert( ii > get_hpatch_node( node_changing_ )->get_alt_state_num_atoms() ||
2530 get_hpatch_node( node_not_changing_ )->get_current_state_num_atoms() <= alt_state_atom_atom_overlaps_[ii].
size() );
2531 for (
Size jj = 1; jj <= alt_state_atom_atom_overlaps_[ ii ].size(); ++jj ) {
2532 current_state_atom_atom_overlaps_[ jj ][ ii ] = alt_state_atom_atom_overlaps_[ ii ][ jj ];
2548 template <
typename V,
typename E,
typename G >
2551 return current_state_atom_atom_overlaps_;
2562 template <
typename V,
typename E,
typename G >
2565 return alt_state_atom_atom_overlaps_;
2585 template <
typename V,
typename E,
typename G >
2587 parent::declare_energies_final_no_deletion();
2597 template <
typename V,
typename E,
typename G >
2606 template <
typename V,
typename E,
typename G >
2614 template <
typename V,
typename E,
typename G >
2617 unsigned int total_memory = parent::count_dynamic_memory();
2621 for (
Size ii = 1; ii <= alt_state_atom_atom_overlaps_.size(); ++ii ) {
2622 total_memory +=
sizeof(
bool ) * alt_state_atom_atom_overlaps_[ii].
size();
2625 for (
Size ii = 1; ii <= current_state_atom_atom_overlaps_.size(); ++ii ) {
2626 total_memory +=
sizeof(
bool ) * current_state_atom_atom_overlaps_[ii].
size();
2629 return total_memory;
2644 template <
typename V,
typename E,
typename G >
2647 prepared_for_simA_( false ),
2648 node_states_coverage_of_bg_res_(),
2649 nodes_curr_state_( 0 ),
2650 nodes_alt_state_( 0 ),
2651 node_states_overlap_with_bg_res_()
2660 template <
typename V,
typename E,
typename G >
2678 template <
typename V,
typename E,
typename G >
2692 template <
typename V,
typename E,
typename G >
2699 if ( ! prepared_for_simA_ ) {
2704 node_states_coverage_of_bg_res_.resize( (
Size)(get_hpatch_node()->get_num_states() + 1),
RotamerDotsCache( bg_res_num_atoms_ ) );
2708 node_states_overlap_with_bg_res_.resize( (
Size)(get_hpatch_node()->get_num_states() + 1) );
2710 get_hpatch_node()->initialize_overlap_with_background( bg_residue_dots, node_states_coverage_of_bg_res_, node_states_overlap_with_bg_res_ );
2712 prepared_for_simA_ =
true;
2716 curr_dots_cache_.resize( bg_res_num_atoms_ );
2717 alt_dots_cache_.resize( bg_res_num_atoms_ );
2734 template <
typename V,
typename E,
typename G >
2737 if ( new_state == nodes_curr_state_ )
2740 update_state_at_neighbor( new_state );
2741 acknowledge_substitution();
2753 template <
typename V,
typename E,
typename G >
2766 alt_dots_cache_.zero();
2767 alt_dots_cache_ = node_states_coverage_of_bg_res_[ alt_state ];
2769 nodes_alt_state_ = alt_state;
2776 Real const delta_sasa = get_hpatch_bg_node()->update_state_for_substitution( get_hpatch_node(), curr_dots_cache_, alt_dots_cache_ );
2788 template <
typename V,
typename E,
typename G >
2791 get_hpatch_bg_node()->acknowledge_substitution();
2793 nodes_curr_state_ = nodes_alt_state_;
2794 curr_dots_cache_ = alt_dots_cache_;
2806 template <
typename V,
typename E,
typename G >
2809 assert( state <= node_states_overlap_with_bg_res_.size() );
2810 return node_states_overlap_with_bg_res_[ state ];
2817 template <
typename V,
typename E,
typename G >
2825 template <
typename V,
typename E,
typename G >
2828 unsigned int total_memory = parent::count_dynamic_memory();
2829 total_memory += node_states_coverage_of_bg_res_.size() *
sizeof (
RotamerDotsCache );
2830 total_memory += node_states_overlap_with_bg_res_.size() *
sizeof(
bool );
2831 return total_memory;
2840 template <
typename V,
typename E,
typename G >
2843 template <
typename V,
typename E,
typename G >
2846 template <
typename V,
typename E,
typename G >
2849 template <
typename V,
typename E,
typename G >
2852 template <
typename V,
typename E,
typename G >
2855 template <
typename V,
typename E,
typename G >
2858 template <
typename V,
typename E,
typename G >
2867 template <
typename V,
typename E,
typename G >
2870 hpatch_score_weight_( 1.0 ),
2871 num_total_residues_( 0 ),
2872 num_residues_assigned_as_background_( 0 ),
2873 some_node_in_state_0_( true ),
2874 fc_nodes_near_rotsub_( num_nodes, 0 ),
2875 fc_nodes_near_rotsub_bool_( num_nodes, true ),
2876 fc_exp_hphobe_djs_offsets_( num_nodes, 0 ),
2877 fc_n_exp_hphobes_( num_nodes, 0 ),
2878 prepared_for_simulated_annealing_( false ),
2879 observed_sufficient_hpatch_E_to_predict_min_( false ),
2880 hpatch_score_min_last_100_( 0 ),
2881 hpatch_score_min_recent_( 0 ),
2882 num_substitutions_since_hpatch_min_update_( 0 ),
2883 calculated_hpatch_deltaE_( false ),
2884 deltaE_for_substitution_( 0.0f ),
2885 node_considering_alt_state_( 0 ),
2886 alt_state_being_considered_( 0 ),
2887 total_energy_current_state_assignment_( 0 ),
2888 total_energy_alternate_state_assignment_( 0 ),
2889 hpatch_energy_current_state_assignment_( 0 ),
2890 hpatch_energy_alternate_state_assignment_( 0 ),
2891 num_commits_since_last_update_( 0 ),
2892 deltaE_threshold_for_avoiding_hpatch_calcs_( -1.0f )
2902 template <
typename V,
typename E,
typename G >
2916 template <
typename V,
typename E,
typename G >
2921 TR_HIG <<
"set_pose() called: typeid() of base class G returned: " <<
typeid(
G).name() << std::endl;
2941 template <
typename V,
typename E,
typename G >
2944 packer_task_ = the_task.
clone();
2955 template <
typename V,
typename E,
typename G >
3029 template <
typename V,
typename E,
typename G >
3042 TR_HIG <<
"initialize() called" << std::endl;
3043 TR_HIG <<
"calling set_rotamers on " << rotamer_sets().nmoltenres() <<
" molten residues." << std::endl;
3048 G::initialize( rot_sets );
3051 for (
Size ii = 1; ii <= rotamer_sets().nmoltenres(); ++ii ) {
3052 get_hpatch_node( ii )->set_rotamers( rotamer_sets().rotamer_set_for_moltenresidue( ii ) );
3056 set_num_residues_in_protein( pose().total_residue() );
3058 int nbackground = pose().total_residue() - rot_sets.
nmoltenres();
3059 set_num_background_residues( nbackground );
3061 for (
Size ii = 1; ii <= pose().total_residue(); ++ii) {
3064 if ( packer_task().being_packed(ii) || packer_task().being_designed(ii) ) {
3069 set_residue_as_background_residue( ii );
3072 set_background_residue_rotamer_dots( ii, pose().residue(ii) );
3076 for (
Size ii = 1; ii <= rotamer_sets().nmoltenres(); ++ii ) {
3081 TR_HIG <<
"initialize: calling set_rotamer_dots_for_node_state for node " << ii <<
" with rotamers [";
3083 for (
Size jj = 1; jj <= rsop->num_rotamers(); ++jj ) {
3084 set_rotamer_dots_for_node_state( ii, jj, *(rsop->rotamer( jj )) );
3087 TR_HIG <<
"] " << std::endl;
3094 init_SASA_radii_from_database();
3097 TR_HIG <<
"initialize_hpatch_ig: DONE with initialization.\n---" << std::endl;
3109 template <
typename V,
typename E,
typename G >
3112 TR_HIG <<
"create_new_node called with node_index " << node_index <<
" and num_states " << num_states << std::endl;
3124 template <
typename V,
typename E,
typename G >
3127 TR_HIG <<
"create_new_edge() called for indices " << index1 <<
" and " << index2 << std::endl;
3139 template <
typename V,
typename E,
typename G >
3142 TR_HIG <<
"create_background_node() called for index " << node_index << std::endl;
3154 template <
typename V,
typename E,
typename G >
3157 TR_HIG <<
"create_background_edge() called for indices " << fc_node_index <<
" and " << bg_node_index << std::endl;
3174 template <
typename V,
typename E,
typename G >
3177 num_total_residues_ = num_res;
3178 resid_2_bgenumeration_.resize( num_total_residues_ );
3180 for (
Size ii = 1; ii <= num_total_residues_; ++ii ) {
3181 resid_2_bgenumeration_[ii] = 0;
3197 template <
typename V,
typename E,
typename G >
3201 TR_HIG <<
"set_num_background_residues: setting num background residues to " << num_background_residues << std::endl;
3204 parent::set_num_background_nodes( num_background_residues );
3205 if ( parent::get_num_background_nodes() == 0)
3208 bgenumeration_2_resid_.resize( parent::get_num_background_nodes() );
3209 bg_nodes_near_rotsub_.resize( parent::get_num_background_nodes() );
3210 for (
Size ii = 1; ii <= bg_nodes_near_rotsub_.size(); ++ii ) { bg_nodes_near_rotsub_[ ii ] = ii; }
3211 bg_nodes_near_rotsub_bool_.resize( parent::get_num_background_nodes(),
true );
3212 bg_exp_hphobe_djs_offsets_.resize( parent::get_num_background_nodes(), 0 );
3213 bg_n_exp_hphobes_.resize( parent::get_num_background_nodes(), 0 );
3214 for (
Size ii = 1; ii <= (
Size)parent::get_num_background_nodes(); ++ii ) {
3215 bgenumeration_2_resid_[ii] = 0;
3226 template <
typename V,
typename E,
typename G >
3229 assert( resid_2_bgenumeration_[ residue ] == 0 );
3231 ++num_residues_assigned_as_background_;
3232 resid_2_bgenumeration_[ residue ] = num_residues_assigned_as_background_;
3233 bgenumeration_2_resid_[ num_residues_assigned_as_background_ ] = residue;
3236 TR_HIG <<
"set_residue_as_background_residue: set residue " << pose().residue( residue ).name3() <<
" "
3237 << residue <<
" as background node " << num_residues_assigned_as_background_ <<
". bgenumeration_2_resid_: [ ";
3238 for (
Size ii=1; ii <= bgenumeration_2_resid_.size(); ++ii ) {
3239 TR_HIG << bgenumeration_2_resid_[ ii ] <<
", ";
3241 TR_HIG <<
" ]" << std::endl;
3253 template <
typename V,
typename E,
typename G >
3256 Size bgid = resid_2_bgenumeration_[ residue ];
3260 get_hpatch_bg_node( bgid )->set_rotamer( rotamer_op );
3262 bool exclude_hydrogens =
true;
3263 bool use_expanded_polar_atom_radii =
true;
3264 RotamerDots rd( rotamer_op, exclude_hydrogens, use_expanded_polar_atom_radii );
3265 get_hpatch_bg_node( bgid )->set_rotamer_dots( rd );
3276 template <
typename V,
typename E,
typename G >
3280 bool exclude_hydrogens =
true;
3281 bool use_expanded_polar_atom_radii =
true;
3282 RotamerDots rd( rotamer_op, exclude_hydrogens, use_expanded_polar_atom_radii );
3286 get_hpatch_node( node_index )->set_rotamer_dots_for_state( state, rd );
3308 template <
typename V,
typename E,
typename G >
3311 if ( prepared_for_simulated_annealing_ ) {
3332 parent::prepare_for_simulated_annealing();
3335 initialize_bg_bg_overlaps();
3340 detect_background_residue_and_first_class_residue_overlap();
3344 G::prepare_for_simulated_annealing();
3347 parent::prepare_for_simulated_annealing();
3350 TR_HIG <<
"prepare_for_simulated_annealing(): initializing background-background overlap" << std::endl;
3353 initialize_bg_bg_overlaps();
3354 initialize_bg_bg_atom_atom_overlaps();
3356 prepared_for_simulated_annealing_ =
true;
3359 TR_HIG <<
"prepare_for_simulated_annealing: number edges in graph: " << parent::get_num_edges() << std::endl;
3372 template <
typename V,
typename E,
typename G >
3375 for (
Size ii = 1; ii <= (
Size)parent::get_num_background_nodes(); ++ii ) {
3378 TR_HIG <<
"detect_bg_and_fc_residue_neighbors: checking for neighbors of background residue " << pose().residue( bgenumeration_2_resid_[ ii ] ).name3()
3379 <<
" " << pose().residue( bgenumeration_2_resid_[ ii ] ).seqpos() << std::endl;
3382 for (
Size jj = 1; jj <= (
Size)parent::get_num_nodes(); ++jj ) {
3387 if ( get_hpatch_bg_node( ii )->detect_overlap( get_hpatch_node( jj ) ) ) {
3389 TR_HIG <<
"detect_bg_residue_and_fc_residue_overlap: --- adding FC/BG edge: fc node id:" << jj
3390 <<
" / bg node: " << ii <<
", bg resid:" << bgenumeration_2_resid_[ ii ] << std::endl;
3392 parent::add_background_edge( jj, ii );
3398 TR_HIG <<
"DONE detecting background and first class overlap.\n---" << std::endl;
3410 template <
typename V,
typename E,
typename G >
3413 for (
Size ii = 1; ii <= (
Size)parent::get_num_background_nodes(); ++ii ) {
3414 for (
Size jj = ii + 1; jj <= (
Size)parent::get_num_background_nodes(); ++jj ) {
3416 get_hpatch_bg_node( ii )->initialize_bg_bg_overlap( *get_hpatch_bg_node( jj ) );
3427 template <
typename V,
typename E,
typename G >
3432 assert( node1_index < node2_index );
3434 return bg_bg_atom_atom_overlaps_[ node1_index ][ node2_index ];
3463 template <
typename V,
typename E,
typename G >
3466 Real const probe_radius = 1.4;
3468 bg_bg_respairs_w_hphobe_olap_.resize( (
Size) parent::get_num_background_nodes() );
3469 bg_bg_atom_atom_overlaps_.resize( (
Size) parent::get_num_background_nodes() );
3470 curr_bg_bg_exhpobeolap_.resize( (
Size) parent::get_num_background_nodes() );
3471 alt_bg_bg_exhpobeolap_.resize( (
Size) parent::get_num_background_nodes() );
3473 for (
Size bgnode_ii = 1; bgnode_ii <= (
Size)parent::get_num_background_nodes(); ++bgnode_ii ) {
3476 Size const ii_natoms = bgnode_ii_rotamer->nheavyatoms();
3479 for (
Size bgnode_jj = bgnode_ii + 1; bgnode_jj <= (
Size)parent::get_num_background_nodes(); ++bgnode_jj ) {
3482 Size const jj_natoms = bgnode_jj_rotamer->nheavyatoms();
3487 bool any_hphobe_olap =
false;
3488 for (
Size ii=1; ii <= ii_hphobes.size(); ++ii ) {
3489 Size const iia = ii_hphobes[ ii ];
3493 Real const iia_atom_radius = atom_radii[ iia_atom.type() ] + probe_radius;
3495 for (
Size jj=1; jj <= jj_hphobes.size(); ++jj ) {
3496 Size const jja = jj_hphobes[ jj ];
3499 Real const jja_atom_radius = atom_radii[ jja_atom.type() ] + probe_radius;
3502 Vector const & iia_atom_xyz = bgnode_ii_rotamer->atom( iia ).xyz();
3503 Vector const & jja_atom_xyz = bgnode_jj_rotamer->atom( jja ).xyz();
3507 if ( distance_squared <= (iia_atom_radius + jja_atom_radius) * (iia_atom_radius + jja_atom_radius) ) {
3509 Real const distance_ijxyz = std::sqrt( distance_squared );
3510 int degree_of_overlap;
3512 if ( degree_of_overlap >= 15 ) {
3519 ii_jj_overlap[ iia ][ jja ] =
true;
3520 any_hphobe_olap =
true;
3526 if ( any_hphobe_olap ) {
3527 bg_bg_respairs_w_hphobe_olap_[ bgnode_ii ].push_back( bgnode_jj );
3528 bg_bg_atom_atom_overlaps_[ bgnode_ii ].push_back( ii_jj_overlap );
3530 curr_bg_bg_exhpobeolap_[ bgnode_ii ].push_back( ii_jj_overlap );
3531 alt_bg_bg_exhpobeolap_[ bgnode_ii ].push_back( ii_jj_overlap );
3575 template <
typename V,
typename E,
typename G >
3578 for (
Size ii = 1; ii <= (
Size)parent::get_num_nodes(); ++ii ) {
3580 TR_HIG <<
"blanket_assign_state_0() calling assign_zero_state() on node " << ii << std::endl;
3582 get_hpatch_node( ii )->assign_zero_state();
3591 total_energy_current_state_assignment_ = 0.0;
3592 hpatch_energy_current_state_assignment_ = hpatch_energy_alternate_state_assignment_ = 0.0;
3595 some_node_in_state_0_ =
true;
3596 for (
Size ii = 1; ii <= fc_nodes_near_rotsub_.size(); ++ii ) { fc_nodes_near_rotsub_[ ii ] = ii; }
3597 std::fill( fc_nodes_near_rotsub_bool_.begin(), fc_nodes_near_rotsub_bool_.end(), true );
3598 for (
Size ii = 1; ii <= bg_nodes_near_rotsub_.size(); ++ii ) { bg_nodes_near_rotsub_[ ii ] = ii; }
3599 std::fill( bg_nodes_near_rotsub_bool_.begin(), bg_nodes_near_rotsub_bool_.end(), true );
3618 template <
typename V,
typename E,
typename G >
3623 parent::update_internal_energy_totals();
3624 total_energy_current_state_assignment_ = parent::get_energy_PD_current_state_assignment() + hpatch_energy_current_state_assignment_;
3626 num_commits_since_last_update_ = 0;
3628 #ifdef DOUBLE_CHECK_COUNTS
3629 verify_sasas_correct();
3635 #ifdef DOUBLE_CHECK_COUNTS
3647 template <
typename V,
typename E,
typename G >
3650 using namespace ObjexxFCL::fmt;
3656 for (
Size ii=1; ii <= (
Size)parent::get_num_nodes(); ++ii ) {
3657 node_sasas[ ii ] = (get_hpatch_node(ii)->get_current_state_rotamer_dots()).get_sasa();
3663 for (
Size ii=1; ii <= (
Size)parent::get_num_background_nodes(); ++ii ) {
3664 bgnode_sasas[ ii ] = (get_hpatch_bg_node(ii)->get_current_state_rotamer_dots()).get_sasa();
3673 for (
core::uint ii = 1; ii <= rotamer_sets().nmoltenres(); ++ii ) {
3674 core::uint iiresid = rotamer_sets().moltenres_2_resid( ii );
3675 core::uint iicurrrot = get_hpatch_node(ii)->get_current_state();
3679 pose_copy.replace_residue( iiresid, *newresidue,
false );
3682 Real total_sasa = 0.0;
3683 id::AtomID_Map< Real > atom_sasa;
3685 Real probe_radius = 1.4;
3688 id::AtomID_Map< bool > atom_subset;
3689 atom_subset.resize( pose_copy.n_residue() );
3691 for (
Size ii=1; ii <= pose_copy.n_residue(); ++ii ) {
3692 atom_subset.resize( ii, pose_copy.residue_type(ii).natoms(), false );
3693 for (
Size jj = 1; jj <= pose_copy.residue_type(ii).nheavyatoms(); ++jj ) {
3694 atom_subset[ ii ][ jj ] =
true;
3700 bool incorrect_sasa_found =
false;
3703 for (
Size ii=1; ii <= node_sasas.size(); ++ii ) {
3705 if ( fabs( node_sasas[ ii ] - rsd_sasa[ rotamer_sets().moltenres_2_resid( ii ) ] ) > 0.1 )
3706 incorrect_sasa_found =
true;
3712 for (
Size ii=1; ii <= bgnode_sasas.size(); ++ii ) {
3714 if ( fabs( bgnode_sasas[ ii ] - rsd_sasa[ bg_node_2_resid( ii ) ] ) > 0.1 )
3715 incorrect_sasa_found =
true;
3719 if ( incorrect_sasa_found )
3720 utility_exit_with_message(
"SASA values are out of sync. Something is wrong. Quitting." );
3722 TR_HIG <<
"verify_sasas_correct() called. and checked out" << std::endl;
3740 template <
typename V,
typename E,
typename G >
3744 TR_HIG <<
"set_errorfull_deltaE_threshold: setting threshold to " << deltaE << std::endl;
3751 deltaE_threshold_for_avoiding_hpatch_calcs_ = deltaE;
3762 template <
typename V,
typename E,
typename G >
3765 if ( num_state_substitutions_considered_ == 0 )
3768 TR_STATS <<
"num state substitutions considered: " << num_state_substitutions_considered_ <<
", "
3769 <<
"num hpatch calcs procrastinated: " << num_hpatch_comps_procrastinated_ <<
", "
3770 <<
"num hpatch calcs later computed: " << num_hpatch_comps_later_made_ << std::endl;
3771 TR_STATS <<
"Percent Avoided: " << (double) (num_hpatch_comps_procrastinated_ - num_hpatch_comps_later_made_) / num_state_substitutions_considered_ <<
", ";
3773 if ( num_hpatch_comps_procrastinated_ != 0 ) {
3774 TR_STATS <<
"Worthwhile Procrastination: " << (double) (num_hpatch_comps_procrastinated_ - num_hpatch_comps_later_made_) / num_hpatch_comps_procrastinated_ << std::endl;
3776 TR_STATS <<
"Worthwhile Procrastination: " <<
"N/A" << std::endl;
3787 template <
typename V,
typename E,
typename G >
3789 num_state_substitutions_considered_ = 0;
3790 num_hpatch_comps_procrastinated_ = 0;
3791 num_hpatch_comps_later_made_ = 0;
3824 template <
typename V,
typename E,
typename G >
3829 reset_from_previous_deltaHpatch_comp();
3832 TR_HIG <<
"---" << std::endl;
3833 TR_HIG <<
"consider_substitution(): trying new state " << new_state <<
" ("
3834 << get_hpatch_node( node_ind )->get_rotamer( new_state )->name() <<
") on node/molten res " << node_ind <<
" (wt: "
3835 << pose().residue( rotamer_sets().moltenres_2_resid( node_ind ) ).name3() <<
" " << rotamer_sets().moltenres_2_resid( node_ind ) <<
") " << std::endl;
3838 ++num_state_substitutions_considered_;
3840 node_considering_alt_state_ = node_ind;
3841 alt_state_being_considered_ = new_state;
3844 core::PackerEnergy deltaE = get_hpatch_node( node_ind )->calculate_PD_deltaE_for_substitution( new_state, prev_energy_for_node );
3846 calculated_hpatch_deltaE_ =
false;
3848 if ( decide_procrastinate_hpatch_computations( deltaE, deltaE_threshold_for_avoiding_hpatch_calcs_ ) ) {
3850 ++num_hpatch_comps_procrastinated_;
3853 TR_HIG <<
"deltaE for PD: " << deltaE << std::endl;
3855 deltaE += calculate_hpatch_deltaE();
3856 calculated_hpatch_deltaE_ =
true;;
3859 delta_energy = deltaE;
3860 total_energy_alternate_state_assignment_ = deltaE + total_energy_current_state_assignment_;
3863 TR_HIG <<
"total deltaE for substitution: " << delta_energy << std::endl;
3875 template <
typename V,
typename E,
typename G >
3880 get_hpatch_node( node_considering_alt_state_ )->consider_alternate_state();
3882 Real delta_sasa = get_hpatch_node( node_considering_alt_state_ )->consider_alternate_state();
3883 if ( delta_sasa != 0.0 ) {
3884 TR_HIG <<
"delta sasa: " << delta_sasa << std::endl;
3889 hpatch_energy_alternate_state_assignment_ = calculate_alt_state_hpatch_score();
3890 core::PackerEnergy hpatch_deltaE = hpatch_energy_alternate_state_assignment_ - hpatch_energy_current_state_assignment_;
3892 TR_HIG <<
"hpatchE current state: " << hpatch_energy_current_state_assignment_
3893 <<
", alt state: " << hpatch_energy_alternate_state_assignment_ <<
", hpatch deltaE: " << hpatch_deltaE << std::endl;
3896 return hpatch_deltaE;
3899 template <
typename V,
typename E,
typename G >
3902 some_node_in_state_0_ =
true;
3913 template <
typename V,
typename E,
typename G >
3915 if ( ! fc_nodes_near_rotsub_bool_[ fc_node_ind ] ) {
3916 fc_nodes_near_rotsub_.push_back( fc_node_ind );
3917 fc_nodes_near_rotsub_bool_[ fc_node_ind ] =
true;
3921 template <
typename V,
typename E,
typename G >
3923 if ( ! bg_nodes_near_rotsub_bool_[ bg_node_ind ] ) {
3924 bg_nodes_near_rotsub_.push_back( bg_node_ind );
3925 bg_nodes_near_rotsub_bool_[ bg_node_ind ] =
true;
3936 template <
typename V,
typename E,
typename G >
3940 radii_.resize( atom_type_set.
n_atomtypes(), 0.0 );
3943 for (
core::Size ii=1; ii <= radii_.size(); ++ii ) {
3944 radii_[ii] = atom_type_set[ii].extra_parameter( SASA_RADIUS_INDEX );
3947 initialized_SASA_radii =
true;
3959 template <
typename V,
typename E,
typename G >
3964 Size residue_djs_offset,
3969 for (
Size ii=1, iiend = exp_hphobes.size(); ii <= iiend; ++ii ) {
3971 Size const iia = exp_hphobes[ii];
3972 Size const ii_djs_id = residue_djs_offset + ii;
3976 for (
Size jj = ii + 1; jj <= iiend; ++jj ) {
3977 Size const jja( exp_hphobes[jj] );
3978 Size const jj_djs_id = residue_djs_offset + jj;
3980 if ( atom_atom_overlaps[ iia ][ jja ] ) {
3995 if ( ds.
ds_find( ii_djs_id ) == ds.
ds_find( jj_djs_id ) )
continue;
3997 ds.
ds_union( ii_djs_id, jj_djs_id);
4012 template <
typename V,
typename E,
typename G >
4027 for (
Size ii=1, iiend = exp_hphobes1.size(), jjend = exp_hphobes2.size(); ii <= iiend; ++ii ) {
4028 Size const iia = exp_hphobes1[ ii ];
4029 Size const ii_djs_index = djs_offset_1 + ii;
4034 for (
Size jj = 1; jj <= jjend; ++jj ) {
4035 Size const jja = exp_hphobes2[ jj ];
4036 Size const jj_djs_index = djs_offset_2 + jj;
4039 if ( atom_atom_overlaps[ iia ][ jja ] ) {
4068 if ( ds.
ds_find( ii_djs_index ) == ds.
ds_find( jj_djs_index ) )
continue;
4070 ds.
ds_union( ii_djs_index, jj_djs_index );
4090 template <
typename V,
typename E,
typename G >
4095 if ( some_node_in_state_0_ && parent::any_vertex_state_unassigned() )
4098 some_node_in_state_0_ =
false;
4100 if ( !initialized_SASA_radii ) {
4105 init_SASA_radii_from_database();
4113 Size tot_exp_hphobes( 0 );
4114 djs_id_2_hphobe_index_.clear();
4116 for (
Size ii = 1; ii <= (
Size) parent::get_num_nodes(); ++ii ) {
4117 fc_exp_hphobe_djs_offsets_[ ii ] = tot_exp_hphobes;
4120 Size ii_n_exhphobes( fc_nodes_near_rotsub_bool_[ ii ] ? get_hpatch_node( ii )->n_alt_state_exp_hphobes() : get_hpatch_node( ii )->n_curr_state_exp_hphobes() );
4121 fc_n_exp_hphobes_[ ii ] = ii_n_exhphobes;
4123 tot_exp_hphobes += ii_n_exhphobes;
4124 for (
Size jj = 1; jj <= ii_n_exhphobes; ++jj ) {
4130 for (
Size ii = 1; ii <= (
Size) parent::get_num_background_nodes(); ++ii ) {
4131 bg_exp_hphobe_djs_offsets_[ ii ] = tot_exp_hphobes;
4134 Size ii_n_exhphobes( bg_nodes_near_rotsub_bool_[ ii ] ? get_hpatch_bg_node( ii )->n_alt_state_exp_hphobes() : get_hpatch_bg_node( ii )->n_curr_state_exp_hphobes() );
4135 bg_n_exp_hphobes_[ ii ] = ii_n_exhphobes;
4137 tot_exp_hphobes += ii_n_exhphobes;
4138 for (
Size jj = 1; jj <= ii_n_exhphobes; ++jj ) {
4145 ep_sasa_for_djs_node_.resize( tot_exp_hphobes );
4150 for (
Size ii = 1; ii <= (
Size) parent::get_num_nodes(); ++ii ) {
4151 Size const ii_offset = fc_exp_hphobe_djs_offsets_[ ii ];
4152 Size const ii_n_exhphobes( fc_n_exp_hphobes_[ ii ] );
4153 utility::vector1< Size > const & ii_exhphobes( fc_nodes_near_rotsub_bool_[ ii ] ? get_hpatch_node( ii )->alt_state_exp_hphobes() : get_hpatch_node( ii )->curr_state_exp_hphobes() );
4157 for (
Size jj = 1; jj <= ii_n_exhphobes; ++jj ) {
4158 Size const jj_atom = ii_exhphobes[ jj ];
4159 Size const jj_djs_node_id = ii_offset + jj;
4161 ep_sasa_for_djs_node_[ jj_djs_node_id ] = get_hpatch_node( ii )->get_alt_state_rotamer_dots().get_atom_sasa( jj_atom );
4165 for (
Size ii = 1; ii <= (
Size) parent::get_num_background_nodes(); ++ii ) {
4166 Size const ii_offset = bg_exp_hphobe_djs_offsets_[ ii ];
4167 Size const ii_n_exhphobes( bg_n_exp_hphobes_[ ii ] );
4168 utility::vector1< Size > const & ii_exhphobes( bg_nodes_near_rotsub_bool_[ ii ] ? get_hpatch_bg_node( ii )->alt_state_exp_hphobes() : get_hpatch_bg_node( ii )->curr_state_exp_hphobes() );
4170 for (
Size jj = 1; jj <= ii_n_exhphobes; ++jj ) {
4171 Size const jj_atom = ii_exhphobes[ jj ];
4172 Size const jj_djs_node_id = ii_offset + jj;
4174 ep_sasa_for_djs_node_[ jj_djs_node_id ] = get_hpatch_bg_node( ii )->get_alt_state_rotamer_dots().get_atom_sasa( jj_atom );
4182 for (
Size ii = 1; ii <= (
Size)parent::get_num_nodes(); ++ii ) {
4183 if ( fc_n_exp_hphobes_[ ii ] == 0 )
continue;
4185 conformation::ResidueCOP rsd( ii == node_considering_alt_state_ ? get_hpatch_node( ii )->curr_state_rotamer() : get_hpatch_node( ii )->alt_state_rotamer() );
4186 Size const ii_state = ( ii == node_considering_alt_state_ ? alt_state_being_considered_ : get_hpatch_node( ii )->get_current_state() );
4188 utility::vector1< Size > const & ii_exhphobes( fc_nodes_near_rotsub_bool_[ ii ] ? get_hpatch_node( ii )->alt_state_exp_hphobes() : get_hpatch_node( ii )->curr_state_exp_hphobes() );
4190 update_disjoint_sets_using_cache( *rsd, get_hpatch_node( ii )->alt_state_inv_dots(), ii_exhphobes, fc_exp_hphobe_djs_offsets_[ ii ], atom_atom_self_overlaps, ds );
4193 for (
Size ii = 1; ii <= (
Size) parent::get_num_background_nodes(); ++ii ) {
4194 if ( bg_n_exp_hphobes_[ ii ] == 0 )
continue;
4200 update_disjoint_sets_using_cache( ii_rsd, get_hpatch_bg_node( ii )->alt_state_inv_dots(), ii_exp_hphobes, bg_exp_hphobe_djs_offsets_[ ii ], atom_atom_self_overlaps, ds );
4211 for (
Size ii = 1; ii <= (
Size) parent::get_num_background_nodes(); ++ii ) {
4212 if ( bg_n_exp_hphobes_[ ii ] == 0 )
continue;
4213 if ( bg_bg_respairs_w_hphobe_olap_[ ii ].
size() == 0 )
continue;
4215 Size const ii_djs_offset = bg_exp_hphobe_djs_offsets_[ ii ];
4222 for (
Size jj = 1; jj <= bg_bg_respairs_w_hphobe_olap_[ ii ].size(); ++jj ) {
4226 Size jj_bg_node_ind = bg_bg_respairs_w_hphobe_olap_[ ii ][ jj ];
4231 if ( bg_n_exp_hphobes_[ jj_bg_node_ind ] == 0 )
continue;
4234 Size const jj_djs_offset = bg_exp_hphobe_djs_offsets_[ jj_bg_node_ind ];
4271 update_disjoint_sets_using_cache( ii_rsd, get_hpatch_bg_node( ii )->alt_state_inv_dots(), ii_exp_hphobes, ii_djs_offset,
4272 jj_rsd, get_hpatch_bg_node( jj_bg_node_ind )->alt_state_inv_dots(), jj_exp_hphobes, jj_djs_offset, atom_atom_overlaps, ds );
4277 TR_HIG <<
"calculate_alt_state_hpatch_score(): iterating over first-class edges" << std::endl;
4291 for ( std::list<EdgeBase*>::iterator iter = parent::get_edge_list_begin(); iter != parent::get_edge_list_end(); ++iter ) {
4299 if ( fc_n_exp_hphobes_[ node0_index ] == 0 || fc_n_exp_hphobes_[ node1_index ] == 0 )
continue;
4302 get_hpatch_node( node0_index )->get_rotamer( alt_state_being_considered_ ) :
4303 get_hpatch_node( node0_index )->get_rotamer( get_hpatch_node( node0_index )->get_current_state() ) );
4306 Size const ii_djs_offset = fc_exp_hphobe_djs_offsets_[ node0_index ];
4315 get_hpatch_node( node1_index )->get_rotamer( alt_state_being_considered_ ) :
4316 get_hpatch_node( node1_index )->get_rotamer( get_hpatch_node( node1_index )->get_current_state() ) );
4319 Size const jj_djs_offset = fc_exp_hphobe_djs_offsets_[ node1_index ];
4329 if ( node0_index == node_considering_alt_state_ || node1_index == node_considering_alt_state_ ) {
4331 if ( node0_index == node_considering_alt_state_ ) {
4333 update_disjoint_sets_using_cache(
4334 *ii_rsd, get_hpatch_node( node0_index )->alt_state_inv_dots(), ii_exp_hphobes, ii_djs_offset,
4335 *jj_rsd, get_hpatch_node( node1_index )->alt_state_inv_dots(), jj_exp_hphobes, jj_djs_offset,
4336 atom_atom_overlaps, ds );
4339 update_disjoint_sets_using_cache(
4340 *jj_rsd, get_hpatch_node( node1_index )->alt_state_inv_dots(), jj_exp_hphobes, jj_djs_offset,
4341 *ii_rsd, get_hpatch_node( node0_index )->alt_state_inv_dots(), ii_exp_hphobes, ii_djs_offset,
4342 atom_atom_overlaps, ds );
4348 update_disjoint_sets_using_cache(
4349 *ii_rsd, get_hpatch_node( node0_index )->alt_state_inv_dots(), ii_exp_hphobes, ii_djs_offset,
4350 *jj_rsd, get_hpatch_node( node1_index )->alt_state_inv_dots(), jj_exp_hphobes, jj_djs_offset,
4351 atom_atom_overlaps, ds );
4357 TR_HIG <<
"calculate_alt_state_hpatch_score(): iterating over background edges" << std::endl;
4369 typename std::list< core::pack::interaction_graph::BackgroundToFirstClassEdge< V, E, G >* >::const_iterator iter;
4370 for ( iter = parent::get_bg_edge_list_begin(); iter != parent::get_bg_edge_list_end(); ++iter ) {
4374 if ( fc_n_exp_hphobes_[ fc_node_index ] == 0 || bg_n_exp_hphobes_[ bg_node_index ] == 0 )
continue;
4376 Size fc_node_current_state = get_hpatch_node( fc_node_index )->get_current_state();
4379 get_hpatch_node( fc_node_index )->get_rotamer( alt_state_being_considered_ ) :
4380 get_hpatch_node( fc_node_index )->get_rotamer( fc_node_current_state ) );
4383 Size const fc_djs_offset = fc_exp_hphobe_djs_offsets_[ fc_node_index ];
4391 Size const bg_djs_offset = bg_exp_hphobe_djs_offsets_[ bg_node_index ];
4400 fc_node_index == node_considering_alt_state_ ?
4404 update_disjoint_sets_using_cache(
4405 *ii_rsd, get_hpatch_node( fc_node_index )->alt_state_inv_dots(), fc_exp_hphobes, fc_djs_offset,
4406 *jj_rsd, get_hpatch_bg_node( bg_node_index )->alt_state_inv_dots(), bg_exp_hphobes, bg_djs_offset,
4407 atom_atom_overlaps, ds );
4417 Size const largest_set_size_index = utility::arg_max( set_sizes );
4418 TR_HIG <<
"num atoms in largest patch: : " << set_sizes[ largest_set_size_index ] << std::endl;
4422 reps_for_nonzero_rank_ccs_.resize( 0 );
4423 djs_rep_node_index_2_cc_index_.resize( tot_exp_hphobes, 0 );
4424 sasa_for_cc_.resize( 0 );
4426 for (
Size ii = 1; ii <= tot_exp_hphobes; ++ii ) {
4428 if ( ds.
node( ii_rep ).
rank == 0 )
continue;
4429 Size ii_cc = djs_rep_node_index_2_cc_index_[ ii_rep ];
4432 reps_for_nonzero_rank_ccs_.push_back( ii_rep );
4433 sasa_for_cc_.push_back( 0.0 );
4434 djs_rep_node_index_2_cc_index_[ ii_rep ] = n_ccs;
4437 sasa_for_cc_[ ii_cc ] += ep_sasa_for_djs_node_[ ii ];
4440 core::Real total_alt_state_hpatch_score = 0.0;
4441 for (
Size ii = 1; ii <= sasa_for_cc_.size(); ++ii ) {
4443 Real const patch_area = sasa_for_cc_[ ii ];
4451 total_alt_state_hpatch_score += score;
4456 for (
Size ii = 1; ii <= reps_for_nonzero_rank_ccs_.size(); ++ii ) {
4457 djs_rep_node_index_2_cc_index_[ reps_for_nonzero_rank_ccs_[ ii ]] = 0;
4462 std::map< Size, utility::vector1< Size > > sets = ds.
sets();
4463 std::map< Size, utility::vector1< Size > >::iterator it;
4466 for ( it = sets.begin() ; it != sets.end(); it++ ) {
4467 if ( (*it).second.size() < 2 )
continue;
4469 TR_HIG <<
"atoms in patch: [ ";
4482 for (
Size ii = 1; ii <= (*it).second.size(); ++ii ) {
4483 Size const node_index = djs_id_2_hphobe_index_[ (*it).second[ ii ] ].node_index_;
4484 Size const exphobe_index = djs_id_2_hphobe_index_[ (*it).second[ ii ] ].exhphobe_index_;
4487 if ( djs_id_2_hphobe_index_[ (*it).second[ ii ] ].fc_bg_ == 1 ) {
4489 *get_hpatch_node( node_index )->get_rotamer( alt_state_being_considered_ ) :
4490 *get_hpatch_node( node_index )->get_rotamer( get_hpatch_node( node_index )->get_current_state() ) );
4497 get_hpatch_node( node_index )->alt_state_exp_hphobes() : get_hpatch_node( node_index )->curr_state_exp_hphobes() );
4502 if ( exphobe_index > exhphobes.size() ) {
4503 std::cout <<
"node_considering_alt_state_: " << node_considering_alt_state_ << std::endl;
4504 std::cout <<
"node_considering_alt_state_ == node_index: " << ( node_considering_alt_state_ == node_index ?
"yes" :
"no" ) << std::endl;
4505 std::cout <<
"fc_nodes_near_rotsub_bool_[ ii ]: " << fc_nodes_near_rotsub_bool_[ node_index ] << std::endl;
4507 get_hpatch_node( node_index )->print();
4510 std::cout <<
"curr state exp hphobes: [ ";
4511 for (
Size aa=1; aa <= curr_state_exhphobes.size(); ++aa ) { std::cout << curr_state_exhphobes[ aa ] <<
", "; }
4514 std::cout <<
"alt state exp hphobes: [ ";
4515 for (
Size aa=1; aa <= alt_state_exhphobes.size(); ++aa ) { std::cout << alt_state_exhphobes[ aa ] <<
", "; }
4516 std::cout <<
"]" << std::endl;
4519 Size atom_index = exhphobes[ exphobe_index ];
4522 TR_HIG << rotamer_sets().moltenres_2_resid( node_index ) <<
"/" << utility::trim( rsd.
atom_name( atom_index ) ) <<
" + ";
4523 patch_area += ep_sasa_for_djs_node_[ (*it).second[ ii ] ];
4536 Size atom_index = exhphobes[ exphobe_index ];
4539 TR_HIG << bgenumeration_2_resid_[ node_index ] <<
"/" << utility::trim( rsd.
atom_name( atom_index ) ) <<
" + ";
4540 patch_area += ep_sasa_for_djs_node_[ (*it).second[ ii ] ];
4545 if ( patch_area > scoring::SurfacePotential::MAX_HPATCH_AREA ) {
4546 score = hpatch_score_weight_ * scoring::SurfacePotential::MAX_HPATCH_SCORE;
4548 score = hpatch_score_weight_ * scoring::SurfacePotential::get_instance()->hpatch_score( patch_area );
4550 TR_HIG <<
"], patch_area: " << patch_area <<
", score: " << score << std::endl;
4556 return total_alt_state_hpatch_score;
4571 template <
typename V,
typename E,
typename G >
4574 Real hpatch_deltaE_max = 0;
4576 if ( ! observed_sufficient_hpatch_E_to_predict_min_ )
4579 if ( threshold < 0 || pd_deltaE < 0 )
4582 hpatch_deltaE_max += hpatch_energy_current_state_assignment_ - hpatch_score_min_last_100_;
4587 TR_HIG <<
"decide_procrastinate_hpatch_computations(): pd_deltaE: " << pd_deltaE <<
", hpatch_deltaE_max: " << hpatch_deltaE_max
4588 <<
", threshold: " << threshold << std::endl;
4590 if ( (pd_deltaE - hpatch_deltaE_max) > threshold ) {
4614 template <
typename V,
typename E,
typename G >
4621 TR_HIG <<
"reset_from_previous_deltaHpatch_comp: calling reset_alt_state_dots on all FC nodes." << std::endl;
4623 for (
Size ii = 1; ii <= fc_nodes_near_rotsub_.size(); ++ii ) {
4624 Size const ii_fc_node = fc_nodes_near_rotsub_[ ii ];
4625 assert( fc_nodes_near_rotsub_bool_[ ii_fc_node ] );
4626 get_hpatch_node( ii_fc_node )->reset_alt_state_dots();
4628 if ( ! some_node_in_state_0_ ) {
4629 for (
Size ii = 1; ii <= fc_nodes_near_rotsub_.size(); ++ii ) {
4630 Size const ii_fc_node = fc_nodes_near_rotsub_[ ii ];
4631 fc_nodes_near_rotsub_bool_[ ii_fc_node ] =
false;
4633 fc_nodes_near_rotsub_.clear();
4637 TR_HIG <<
"reset_from_previous_deltaHpatch_comp: calling reset_alt_state_dots on all BG nodes." << std::endl;
4639 for (
Size ii = 1; ii <= bg_nodes_near_rotsub_.size(); ++ii ) {
4640 Size const ii_bg_node = bg_nodes_near_rotsub_[ ii ];
4641 assert( bg_nodes_near_rotsub_bool_[ ii_bg_node ] );
4642 get_hpatch_bg_node( ii_bg_node )->reset_alt_state_dots();
4644 if ( ! some_node_in_state_0_ ) {
4645 for (
Size ii = 1; ii <= bg_nodes_near_rotsub_.size(); ++ii ) {
4646 Size const ii_bg_node = bg_nodes_near_rotsub_[ ii ];
4647 bg_nodes_near_rotsub_bool_[ ii_bg_node ] =
false;
4649 bg_nodes_near_rotsub_.clear();
4660 template <
typename V,
typename E,
typename G >
4666 TR_HIG <<
"commit_considered_substitution(): committing sub on node " << node_considering_alt_state_ << std::endl;
4670 if ( ! calculated_hpatch_deltaE_ ) {
4671 hpatch_deltaE = calculate_hpatch_deltaE();
4672 ++num_hpatch_comps_later_made_;
4678 deltaE_for_substitution_ = get_hpatch_node( node_considering_alt_state_ )->get_pd_energy_delta() + hpatch_deltaE;
4681 get_hpatch_node( node_considering_alt_state_ )->commit_considered_substitution();
4683 total_energy_current_state_assignment_ = total_energy_current_state_assignment_ + deltaE_for_substitution_;
4684 hpatch_energy_current_state_assignment_ = hpatch_energy_alternate_state_assignment_;
4686 node_considering_alt_state_ = -1;
4687 ++num_commits_since_last_update_;
4689 if ( num_commits_since_last_update_ == COMMIT_LIMIT_BETWEEN_UPDATES ) {
4690 update_internal_energy_totals_hpatch();
4693 track_hpatch_E_min();
4695 return total_energy_current_state_assignment_;
4705 template <
typename V,
typename E,
typename G >
4708 ++num_substitutions_since_hpatch_min_update_;
4710 Real alt_hpatchE = hpatch_energy_current_state_assignment_;
4712 if ( hpatch_score_min_recent_ > alt_hpatchE )
4713 hpatch_score_min_recent_ = alt_hpatchE;
4715 if ( num_substitutions_since_hpatch_min_update_ == 100 ) {
4716 hpatch_score_min_last_100_ = hpatch_score_min_recent_;
4717 if ( hpatch_energy_current_state_assignment_ < hpatch_score_min_last_100_ )
4718 hpatch_score_min_last_100_ = hpatch_energy_current_state_assignment_;
4719 observed_sufficient_hpatch_E_to_predict_min_ =
true;
4720 num_substitutions_since_hpatch_min_update_ = 0;
4736 template <
typename V,
typename E,
typename G >
4740 TR_HIG <<
"set_network_state() called with states: " << node_states << std::endl;
4742 for (
Size ii = 1; ii <= (
Size)parent::get_num_nodes(); ++ii ) {
4745 consider_substitution( ii, node_states( ii ), deltaE, previousE );
4746 commit_considered_substitution();
4753 return total_energy_current_state_assignment_;
4765 template <
typename V,
typename E,
typename G >
4767 return total_energy_current_state_assignment_;
4823 template <
typename V,
typename E,
typename G >
4832 template <
typename V,
typename E,
typename G >
4841 template <
typename V,
typename E,
typename G >
4843 unsigned int total_memory = parent::count_dynamic_memory();
4845 total_memory += resid_2_bgenumeration_.size() *
sizeof(
Size );
4846 total_memory += bgenumeration_2_resid_.size() *
sizeof(
Size );
4848 return total_memory;
4859 template <
typename V,
typename E,
typename G >
4869 template <
typename V,
typename E,
typename G >
4873 TR_HIG <<
"internal energies: " << std::endl;
4874 for (
Size ii = 1; ii <= parent::get_num_nodes(); ++ii ) {
4875 Real one_body = get_hpatch_node( ii )->get_curr_state_one_body_energy();
4876 TR_HIG <<
"node " << ii <<
" 1b: " << one_body;
4877 Real sasa = get_hpatch_node( ii )->get_current_state_sasa();
4878 TR_HIG <<
", sasa = " << sasa;
4887 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
4888 Real bg_sasa = get_hpatch_bg_node( ii )->get_current_sasa();
4889 TR_HIG <<
"bg res: " << bgenumeration_2_resid_[ ii ] <<
" sasa: " << bg_sasa << std::endl;
4893 int count_edges = 0;
4894 for (std::list< core::pack::interaction_graph::EdgeBase*>::const_iterator iter = parent::get_edge_list_begin(); iter != parent::get_edge_list_end(); ++iter) {
4896 TR_HIG <<
"edge: " << edge_energy <<
" ";
4898 if ( count_edges % 5 == 0)
4932 template<
typename V,
typename E,
typename G >
4936 std::cout <<
"HPatch Interaction Graph state: " << std::endl;
4937 std::cout <<
"nodes: " << std::endl;
4938 for (
int jj = 1; jj <= parent::get_num_nodes(); ++jj) {
4939 get_hpatch_node( jj )->print();
4942 std::cout <<
"bgnodes: " << std::endl;
4943 for (
int ii = 1; ii <= parent::get_num_background_nodes(); ++ii) {
4944 get_hpatch_bg_node( ii )->print();
4958 template<
typename V,
typename E,
typename G >
4966 template<
typename V,
typename E,
typename G >
4975 template<
typename V,
typename E,
typename G >
4984 template<
typename V,
typename E,
typename G >
4994 template<
typename V,
typename E,
typename G >
4997 std::vector< int > networkstate;
4998 for (
int jj = 1; jj <= parent::get_num_nodes(); ++jj ) {
4999 networkstate.push_back( get_hpatch_node(jj)->get_current_state() );
5001 return networkstate;
5011 template<
typename V,
typename E,
typename G >
5013 observed_sufficient_hpatch_E_to_predict_min_ =
true;
5024 template <
typename V,
typename E,
typename G >
5027 for (
Size ii=1; ii <= (
Size)parent::get_num_nodes(); ++ii ) {
5028 node_sasas[ ii ] = ((get_hpatch_node(ii))->get_current_state_rotamer_dots()).get_sasa();
5031 for (
Size ii=1; ii <= (
Size)parent::get_num_background_nodes(); ++ii ) {
5032 bgnode_sasas[ ii ] = ((get_hpatch_bg_node(ii))->get_current_state_rotamer_dots()).get_sasa();
5044 template <
typename V,
typename E,
typename G >
5047 if ( node_index > num_residues_assigned_as_background_ ) {
5048 utility_exit_with_message(
"Out of bounds array index passed to bg_node_2_resid. Quitting." );
5050 return bgenumeration_2_resid_[ node_index ];
5060 template < typename V, typename E, typename G >
5061 utility::vector1< Size > const & HPatchInteractionGraph< V, E, G >::get_fc_nodes_near_rotsub() {
5062 return fc_nodes_near_rotsub_;
5071 template < typename V, typename E, typename G >
5072 utility::vector1< bool > const & HPatchInteractionGraph< V, E, G >::get_fc_nodes_near_rotsub_bool() {
5073 return fc_nodes_near_rotsub_bool_;
5082 template < typename V, typename E, typename G >
5083 utility::vector1< Size > const & HPatchInteractionGraph< V, E, G >::get_bg_nodes_near_rotsub() {
5084 return bg_nodes_near_rotsub_;
5093 template < typename V, typename E, typename G >
5094 utility::vector1< bool > const & HPatchInteractionGraph< V, E, G >::get_bg_nodes_near_rotsub_bool() {
5095 return bg_nodes_near_rotsub_bool_;
5105 template < typename V, typename E, typename G >
5106 utility::vector1< Size > const & HPatchInteractionGraph< V, E, G >::get_fc_exp_hphobe_djs_offsets() {
5107 return fc_exp_hphobe_djs_offsets_;
5117 template < typename V, typename E, typename G >
5118 utility::vector1< Size > const & HPatchInteractionGraph< V, E, G >::get_bg_exp_hphobe_djs_offsets() {
5119 return bg_exp_hphobe_djs_offsets_;
5129 template < typename V, typename E, typename G >
5130 utility::vector1< Size > const & HPatchInteractionGraph< V, E, G >::get_fc_n_exp_hphobes() {
5131 return fc_n_exp_hphobes_;
5140 template < typename V, typename E, typename G >
5141 utility::vector1< Size > const & HPatchInteractionGraph< V, E, G >::get_bg_n_exp_hphobes() {
5142 return bg_n_exp_hphobes_;