34 #include <utility/string_util.hh>
36 #include <utility/vector1.hh>
37 #include <utility/options/IntegerVectorOption.hh>
42 namespace interaction_graph {
49 parent( owner, node_id, num_states ),
50 rotamers_( num_states ),
51 rotamer_is_proline_( num_states, (unsigned char) 0 ),
52 rotamer_is_glycine_( num_states, (unsigned char) 0 )
95 Real bounding_square_radius( 0.0 );
100 if ( kk == 1 ) { nbatm = kkrot.
xyz( kkrot.
nbr_atom() ); }
104 if ( bounding_square_radius < lldis2 ) {
105 bounding_square_radius = lldis2;
132 parent( owner, node1, node2 ),
133 compute_bbbb_and_scbb_otf_( false ),
134 lr_energies_exist_( false ),
135 pose_( get_otfflexbbig_owner()->get_pose() ),
136 sfxn_( get_otfflexbbig_owner()->get_scorefxn() )
195 using namespace core::scoring;
240 iter_end =
sfxn_->long_range_energies_end();
241 iter != iter_end; ++iter ) {
252 #ifdef DEBUG_OTF_FLEXBB_ENERGIES_VERBOSE
288 using namespace core::scoring;
332 iter_end =
sfxn_->long_range_energies_end();
333 iter != iter_end; ++iter ) {
344 #ifdef DEBUG_OTF_FLEXBB_ENERGIES_VERBOSE
380 using namespace core::scoring;
421 iter_end =
sfxn_->long_range_energies_end();
422 iter != iter_end; ++iter ) {
433 #ifdef DEBUG_OTF_FLEXBB_ENERGIES_VERBOSE
504 int node_not_necessarily_proline,
513 int const node =
which_node( node_not_necessarily_proline );
518 sc_probb_E + 0.5 * bb_probb_E -
519 (sc_nonprobb_E + 0.5 * bb_nonprobb_E);
532 int node_not_necessarily_glycine,
541 int const node =
which_node( node_not_necessarily_glycine );
549 sc_glybb_E + 0.5 * bb_glybb_E -
550 (sc_nonglybb_E + 0.5 * bb_nonglybb_E);
567 using namespace core;
569 Real const sfxn_reach =
sfxn_->info()->max_atomic_interaction_distance();
572 for (
int ii = 1; ii <=
num_bb( 0 ); ++ii ) {
575 for (
Size kk = 1; kk <= naatypes; ++kk ) {
579 int kkrotno = 1 + kkoffset;
584 for (
Size ll = 1; ll <= naatypes; ++ll ) {
588 int llrotno = 1 + lloffset;
596 (kkpos.distance_squared( llpos ) < std::pow( kk_reach + sfxn_reach + ll_reach, 2 ));
664 current_pose_energy_( 0.0 ),
665 alternate_pose_energy_( 0.0 )
689 #ifdef DEBUG_OTF_FLEXBB_ENERGIES
702 int node_not_necessarily_proline,
712 node_not_necessarily_proline, state, other_bb,
713 bb_nonprobb_E, bb_probb_E, sc_nonprobb_E, sc_probb_E );
720 int node_not_necessarily_glycine,
730 node_not_necessarily_glycine, state, other_bb,
731 bb_nonglybb_E, bb_glybb_E, sc_nonglybb_E, sc_glybb_E );
748 #ifdef DEBUG_OTF_FLEXBB_ENERGIES
764 #ifdef DEBUG_OTF_FLEXBB_ENERGIES
765 using namespace core::scoring;
773 opts.decompose_bb_hb_into_pair_energies(
true );
774 oc_sfxn_->set_energy_method_options( opts );
778 if ( sfxn.
weights()[ iist ] != 0.0 ) {
819 #ifndef DEBUG_OTF_FLEXBB_ENERGIES
820 utility_exit_with_message(
"Do not call OTFFlexbbInteractionGraph::debug_note_considered_substitution unless debugging" );
837 #ifndef DEBUG_OTF_FLEXBB_ENERGIES
838 utility_exit_with_message(
"Do not call OTFFlexbbInteractionGraph::debug_note_projected_deltaE_of_considered_substitution unless debugging" );
843 static int n_correct_since_last_problem = 0;
846 Real delta_delta = std::abs( deltaE - real_deltaE );
847 bool large = std::abs(delta_delta) > 1e-4;
848 bool significant = large && std::abs( delta_delta / node_totalE ) > 1e-5 && std::abs( delta_delta / (deltaE + node_totalE )) > 1e-5 && std::abs( delta_delta / real_deltaE ) > 1e-5;
852 std::cout <<
"Delta E: predicted -- " << deltaE <<
" real: "
853 << real_deltaE <<
" delta_delta: " << delta_delta <<
" sig: " << std::abs( delta_delta / node_totalE ) <<
" " << std::abs( delta_delta / (deltaE + node_totalE ))
854 <<
" (since last problem: " << n_correct_since_last_problem <<
" )"
856 n_correct_since_last_problem = 0;
857 std::cout <<
"Changing nodes:";
861 std::cout << std::endl;
866 Real ii_total( 0.0 );
871 Size jj_resid = (*ir)->get_other_ind( ii_resid );
873 if ( jj_moltenresid == 0 )
continue;
876 ii_total += ii_jj_energy;
882 if ( ii_jj_energy != 0.0 ) std::cout <<
"EDGE MISSING FROM INTERACTION GRAPH: ( " << ii_moltenresid <<
" " << jj_moltenresid <<
" ) missing energy of " << ii_jj_energy << std::endl;
887 if ( delta > 1e-5 ) {
889 std::cout <<
"Two-Body Energy Error: " << ii_moltenresid <<
" " << jj_moltenresid <<
" real " << ii_jj_energy ;
890 std::cout <<
" predicted: " << ii_jj_edge->
alt_energy() <<
" ";
891 std::cout << alternate_pose_->residue( ii_resid ).aa() <<
" " << alternate_pose_->residue( jj_resid ).aa() << std::endl;
893 *alternate_pose_, *
oc_sfxn_, alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) );
895 *alternate_pose_, *
oc_sfxn_, alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) );
897 *alternate_pose_, *
oc_sfxn_, alternate_pose_->residue( jj_resid ), alternate_pose_->residue( ii_resid ) );
900 oc_sfxn_->eval_ci_2b_sc_sc( alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) , *
alternate_pose_, tbemap );
901 oc_sfxn_->eval_cd_2b_sc_sc( alternate_pose_->residue( ii_resid ), alternate_pose_->residue( jj_resid ) , *
alternate_pose_, tbemap );
902 Real scsc_energy_alt_conf =
oc_sfxn_->weights().dot( tbemap );
903 std::cout <<
" scsc: " << scsc_energy_alt_conf;
905 std::cout << std::endl;
911 Real ii_one_body_energy = alternate_pose_->energies().onebody_energies( ii_resid ).dot(
oc_sfxn_->weights() );
912 Real ii_one_body_and_background = ii_one_body_energy;
924 Size jj_resid = (*ir)->get_other_ind( ii_resid );
926 if ( jj_moltenresid != 0 )
continue;
928 ii_total += ii_jj_energy;
929 ii_one_body_and_background += ii_jj_energy;
953 Real one_body_delta = std::abs( ii_one_body_and_background -
get_otfflexbb_node( ii_moltenresid )->alternate_state_one_body_energy() );
954 if ( one_body_delta > 1e-5 && one_body_delta / ii_one_body_and_background > 1e-5) {
955 std::cout <<
"One body energy in error: molt: " << ii_moltenresid <<
" resid: " << ii_resid
956 <<
" rot: " <<
alt_rot_inds_[ ii ] <<
" " << alternate_pose_->residue( ii_resid ).aa()
957 <<
" real " << ii_one_body_and_background <<
" pred "
959 std::cout <<
"One body internal " << ii_one_body_energy <<
" ";
960 alternate_pose_->energies().onebody_energies( ii_resid ).show_weighted( std::cout,
oc_sfxn_->weights() );
961 std::cout << std::endl;
980 Size jj_resid = (*ir)->get_other_ind( ii_resid );
982 if ( jj_moltenresid != 0 )
continue;
984 std::cout << ii_resid <<
" " << jj_resid <<
" " << ii_jj_energy << std::endl;;
1012 static int count_bad( 0 );
1013 alternate_pose_->dump_pdb(
"BadPredDeltaE_" + utility::to_string( ++count_bad ) +
"_alternate.pdb" );
1014 current_pose_->dump_pdb(
"BadPredDeltaE_" + utility::to_string( count_bad ) +
"_current.pdb" );
1016 utility_exit_with_message(
"Bad predicted deltaE" );
1018 ++n_correct_since_last_problem;
1025 #ifndef DEBUG_OTF_FLEXBB_ENERGIES
1026 utility_exit_with_message(
"Do not call OTFFlexbbInteractionGraph::debug_note_accepted_substitution unless debugging" );
1028 (*current_pose_) = (*alternate_pose_);
1039 #ifndef DEBUG_OTF_FLEXBB_ENERGIES
1040 utility_exit_with_message(
"Do not call OTFFlexbbInteractionGraph::debug_note_rejected_substitution unless debugging" );
1042 (*alternate_pose_) = (*current_pose_);