19 #include <basic/Tracer.hh>
47 #include <ObjexxFCL/format.hh>
50 #include <numeric/numeric.functions.hh>
53 #include <utility/exit.hh>
54 #include <utility/string_util.hh>
57 #include <utility/vector1.hh>
66 static basic::Tracer
tr(
"core.scoring.Energies");
68 using namespace ObjexxFCL::fmt;
74 : utility::pointer::ReferenceCount(),
81 max_context_neighbor_cutoff_( 0.0 ),
84 use_nblist_auto_update_(false),
85 minimization_graph_( 0 ),
86 residue_total_energies_uptodate_( false ),
87 residue_total_energy_uptodate_( false ),
101 : utility::pointer::ReferenceCount(),
102 size_( other.size_ ),
104 energy_graph_( new
EnergyGraph( *other.energy_graph_ ) ),
106 externally_required_context_graphs_( other.externally_required_context_graphs_ ),
107 required_context_graphs_( other.required_context_graphs_ ),
108 max_context_neighbor_cutoff_( other.max_context_neighbor_cutoff_ ),
110 use_nblist_( other.use_nblist_ ),
111 use_nblist_auto_update_( other.use_nblist_auto_update_ ),
112 minimization_graph_( other.minimization_graph_ ? new
MinimizationGraph( * other.minimization_graph_ ) : 0 ),
113 onebody_energies_( other.onebody_energies_ ),
114 residue_total_energies_uptodate_( false ),
115 residue_total_energies_( size_ ),
116 residue_total_energy_uptodate_( false ),
117 residue_total_energy_( size_, 0.0 ),
118 total_energies_( other.total_energies_ ),
119 total_energy_( other.total_energy_ ),
120 finalized_energies_( other.finalized_energies_ ),
122 scorefxn_weights_( other.scorefxn_weights_ ),
123 domain_map_( other.domain_map_ ),
124 scoring_( other.scoring_ ),
125 energy_state_( other.energy_state_ ),
126 graph_state_( other.graph_state_ ),
127 data_cache_( other.data_cache_ ),
139 if (
this == &rhs )
return *
this;
208 }
else if (
owner_ != 0 ) {
209 utility_exit_with_message(
"Attempted to set the owner twice, once with " + utility::to_string(
owner_ ) +
" and now with " + utility::to_string( owner ) );
281 assert( dynamic_cast< TenANeighborGraph const * > (
context_graphs_[ ten_A_neighbor_graph ].
get()) );
298 assert( dynamic_cast< TenANeighborGraph const * > (
context_graphs_[ ten_A_neighbor_graph ].
get()) );
317 assert( dynamic_cast< TwelveANeighborGraph const * > (
context_graphs_[ twelve_A_neighbor_graph ].
get()) );
335 assert( dynamic_cast< TwelveANeighborGraph const * > (
context_graphs_[ twelve_A_neighbor_graph ].
get()) );
371 utility_exit_with_message(
372 "Energies:: operation NOT permitted during scoring." );
501 using namespace graph;
508 int const n1( (*iter)->get_first_node_ind() ), n2( (*iter)->get_second_node_ind() );
525 rni = lrec->upper_neighbor_iterator_begin( ii ),
526 rniend = lrec->upper_neighbor_iterator_end( ii );
527 (*rni) != (*rniend); ++(*rni) ) {
528 if ( iimap == 0 || iimap !=
domain_map_( rni->upper_neighbor_id() ) ) {
529 rni->mark_energy_uncomputed();
558 return *(
nblist_.find( type )->second );
633 out <<
"E(i)" << I(4,i);
674 out <<
"E(i)" << I(4,res);
688 out <<
"The pose must be scored first to generate an energy table." << std::endl;
692 out <<
A( 4,
"res" );
696 it_end = temp_emap.end(); it != it_end; ++it ) {
703 for (
Size i=1; i <= e.
size(); ++i ) {
707 it_end = emap.end(); it != it_end; ++it ) {
708 if (temp_emap[
ScoreType( it - emap.begin() + 1) ]) out << F( 15, 3, *it );
714 out <<
A( 4,
"tot" );
733 utility_exit_with_message(
"No structure mods allowed during scoring!");
744 if ( nres !=
size_ ) {
774 out << F( 15,3, *it );
823 if (
size_ == new_size ) {
921 for (
uint ii = 1, ii_end =
size_; ii <= ii_end; ++ii ) {
967 all_score_types.push_back( (
ScoreType) ii );
981 iru =
energy_graph_->get_node(i)->const_upper_edge_list_begin(),
982 irue =
energy_graph_->get_node(i)->const_upper_edge_list_end();
983 iru != irue; ++iru ) {
985 EnergyEdge const & edge( static_cast< EnergyEdge const & > (**iru) );
990 for (
Size ii = 1; ii <= twobody_score_types.size(); ++ii ) {
1000 if ( lrec == 0 )
continue;
1001 if ( lrec->empty() )
continue;
1006 rni = lrec->const_upper_neighbor_iterator_begin( i ),
1007 rniend = lrec->const_upper_neighbor_iterator_end( i );
1008 (*rni) != (*rniend); ++(*rni) ) {
1009 Size j = rni->upper_neighbor_id();
1011 rni->retrieve_energy( emap );
1034 twobody_score_types.push_back( (
ScoreType) ii );
1038 for (
Size ii = 1; ii <=
size_; ++ii ) {
1042 for (
Size ii = 1; ii <=
size_; ++ii ) {
1046 iru =
energy_graph_->get_node(ii)->const_upper_edge_list_begin(),
1047 irue =
energy_graph_->get_node(ii)->const_upper_edge_list_end();
1048 iru != irue; ++iru ) {
1049 EnergyEdge const & edge( static_cast< EnergyEdge const & > (**iru) );
1061 if ( lrec == 0 )
continue;
1062 if ( lrec->empty() )
continue;
1065 for (
Size ii = 1; ii <=
size_; ++ii ) {
1067 rni = lrec->const_upper_neighbor_iterator_begin( ii ),
1068 rniend = lrec->const_upper_neighbor_iterator_end( ii );
1069 (*rni) != (*rniend); ++(*rni) ) {
1070 Size jj = rni->upper_neighbor_id();
1072 rni->retrieve_energy( emap );
1092 bool deleted_a_graph(
false );
1104 deleted_a_graph =
true;
1117 if ( deleted_a_graph ) {
1133 if ( info->scores_present()[ (
ScoreType) ii ] != 0.0 ) {
1156 using namespace graph;
1182 bool const ii_moved( ii_map == 0 || all_moved );
1185 Distance const ii_intxn_radius( iiradius +
1189 ii_iter =
point_graph_->get_vertex( ii ).upper_edge_list_begin(),
1190 ii_end_iter =
point_graph_->get_vertex( ii ).upper_edge_list_end();
1191 ii_iter != ii_end_iter; ++ii_iter ) {
1192 uint const jj = ii_iter->upper_vertex();
1193 if ( (
domain_map_(jj) != ii_map ) || ii_moved ) {
1200 if ( ii_intxn_radius + jjradius > 0 ) {
1201 if ( square_distance < (ii_intxn_radius + jjradius )*(ii_intxn_radius + jjradius )) {
1204 for (
uint kk = 1; kk <= context_graphs_present.size(); ++kk ) {
1205 context_graphs_present[ kk ]->conditionally_add_edge( ii, jj, square_distance );
1221 Distance const energy_neighbor_cutoff = 2 * max_pair_radius +
scorefxn_info_->max_atomic_interaction_distance();
1225 Distance const neighbor_cutoff = numeric::max( energy_neighbor_cutoff, context_cutoff );
1228 core::conformation::find_neighbors<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>( pg, neighbor_cutoff );
1233 for ( std::map< EnergiesCacheableDataType::Enum, scoring::NeighborListOP >::const_iterator
1234 other_nblist_iter = other.
nblist_.begin(),
1235 other_nblist_end = other.
nblist_.end();
1236 other_nblist_iter != other_nblist_end; ++other_nblist_iter ) {
1237 nblist_[ other_nblist_iter->first ] = other_nblist_iter->second->clone();
1277 utility_exit_with_message(
"Error: Null returned from ContextGraphFactory::create_context_graph( " + utility::to_string( type ) +
")" );
1288 using namespace graph;
1292 for (
uint ii = 1, ii_end =
size_; ii <= ii_end; ++ii ) {
1293 Distance const iiradius(
owner_->residue_type( ii ).nbr_radius() );
1294 Distance const ii_intxn_radius( iiradius +
1297 ii_iter =
point_graph->get_vertex( ii ).upper_edge_list_begin(),
1298 ii_end_iter =
point_graph->get_vertex( ii ).upper_edge_list_end();
1299 ii_iter != ii_end_iter; ++ii_iter ) {
1300 uint const jj = ii_iter->upper_vertex();
1301 Distance const jjradius(
owner_->residue_type( jj ).nbr_radius() );
1304 if ( ii_intxn_radius + jjradius > 0 ) {
1306 context_graphs_[ type ]->conditionally_add_edge( ii, jj, square_distance );
1341 bool scorefunction_changed(
false );
1347 scorefunction_changed =
true;
1352 for ( Size ii = 1; ii <= n_shortranged_2b_score_types; ++ii ) {
1353 if ( scorefxn_weights_[ (ScoreType) ii ] != sfxn.weights()[ (ScoreType) ii ] ) {
1354 energy_state_ = BAD;
1356 scorefunction_changed = true;
1375 if ( scorefunction_changed ) {