Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SymAtomTreeMultifunc.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/optimization/SymAtomTreeMultifunc.hh
11 /// @brief
12 /// @author
13 
14 /// Unit headers
16 
17 /// Package headers
18 // AUTO-REMOVED #include <core/optimization/MinimizerMap.hh>
21 
22 /// Project headers
23 // AUTO-REMOVED #include <core/conformation/Residue.hh>
24 // AUTO-REMOVED #include <core/pose/symmetry/util.hh>
25 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
26 
27 // AUTO-REMOVED #include <core/conformation/symmetry/SymmetryInfo.hh>
28 // AUTO-REMOVED #include <core/conformation/symmetry/SymmetricConformation.hh>
29 
30 #include <core/scoring/Energies.hh>
35 // AUTO-REMOVED #include <core/scoring/symmetry/SymmetricEnergies.hh>
36 
37 #include <core/pose/Pose.hh>
39 
40 /// Utility headers
41 #include <basic/prof.hh>
42 
43 /// Numeric headers
44 // AUTO-REMOVED #include <numeric/xyz.functions.hh>
45 
46 #include <utility/vector1.hh>
47 
48 //Auto Headers
49 #include <utility/string_util.hh>
50 
51 
52 
53 namespace core {
54 namespace optimization {
55 namespace symmetry {
56 
57 bool debug_inaccurateG = false;
60 bool check_rama = false;
61 bool check_hbonds = false;
62 
63 /// @details Useful debugging code that can be re-enabled by changing the boolean
64 /// variables at the top of this file.
65 void
66 SymAtomTreeMultifunc::dump( Multivec const & vars, Multivec const & /*vars2*/ ) const
67 {
68  if ( ! debug_inaccurateG ) return;
69 
70  static int count_dumped( 0 );
71  static bool after( true ); // dump two poses, a before and an after. Note, dumping poses as pdbs is often useless.
72 
73  if ( after ) { ++count_dumped; after = false; }
74  else { after = true; }
75 
77 
78  std::string which = ( after ? "after_" : "before_" );
79  pose_.dump_pdb( "atomtree_multifunc_error_pose_" + which + utility::to_string( count_dumped ) + ".pdb" );
82  std::cerr << std::endl;
83  using namespace scoring;
84 
85  if ( check_score_components ) {
86  // slow! Iterate through all the components and check their derivatives one by one.
87  const_cast< bool & > (deriv_check_) = true;
89  const_cast< bool & > (deriv_check_verbose_) = true;
90  }
91  Multivec dvars( vars );
92  scoring::EnergyMap orig_weights( score_function_.weights() );
93  for ( Size ii = 1; ii <= scoring::n_score_types; ++ii ) {
94  using namespace scoring;
95 
96  if ( score_function_.weights()[ (ScoreType ) ii ] == 0.0 ) continue;
97 
98  for ( Size jj = 1; jj <= scoring::n_score_types; ++jj ) {
99  if ( jj == ii ) {
100  const_cast< scoring::ScoreFunction & > (score_function_).set_weight( (scoring::ScoreType) jj, orig_weights[ (scoring::ScoreType) jj ]);
101  } else if ( score_function_.weights()[ (scoring::ScoreType ) jj ] != 0.0 ) {
102  const_cast< scoring::ScoreFunction & > (score_function_).set_weight( (scoring::ScoreType) jj, 1e-9 );
103  }
104  }
105  std::cout << "Checking score type: " << scoring::ScoreType( ii ) << std::endl;
106  dfunc( vars, dvars ); // invokes numeric derivative checker.
107  }
108  for ( Size ii = 1; ii <= scoring::n_score_types; ++ii ) {
109  if ( orig_weights[ scoring::ScoreType( ii ) ] != 0 ) {
110  const_cast< scoring::ScoreFunction & > (score_function_).set_weight( (scoring::ScoreType)ii, orig_weights[ (scoring::ScoreType) ii ]);
111  }
112  }
113  const_cast< bool & > (deriv_check_) = false;
114  const_cast< bool & > (deriv_check_verbose_) = false;
115  }
116 
117  if ( check_rama ) {
118  // useful if rama seems to be the culprit. This is the only piece of code
119  // that invokes eval_rama_score_all, so that function may be hacked to provide
120  // clearer debugging output.
122  }
123 
124  if ( check_hbonds ) {
125  scoring::hbonds::HBondSet const & hbond_set
126  ( static_cast< scoring::hbonds::HBondSet const & >
128 
129  for ( Size ii = 1; ii <= hbond_set.nhbonds(); ++ii ) {
130  scoring::hbonds::HBond const & iihbond = hbond_set.hbond( ii );
131  std::cerr << "Hbond " << ii <<
132  " d: " << iihbond.don_res() << " " << iihbond.don_hatm() <<
133  " a: " << iihbond.acc_res() << " " << iihbond.acc_atm() <<
134  " e: " << iihbond.energy() << " " << iihbond.weight() <<
135  " good? " << hbond_set.allow_hbond( iihbond ) << std::endl;
136  }
137  }
138 }
139 
140 
141 Real
143 {
144  PROF_START( basic::FUNC );
146  Real const score( score_function_( pose_ ) );
147  PROF_STOP( basic::FUNC );
148  return score;
149 }
150 
151 void
153  Multivec const & vars,
154  Multivec & dE_dvars
155 ) const {
156  PROF_START( basic::DFUNC );
157 
158  // in atom_tree_minimize.cc
159  atom_tree_dfunc( pose_, symm_min_map_, score_function_, vars, dE_dvars );
160  // optional derivative checking
161  if ( deriv_check_ ) {
163  }
164  PROF_STOP( basic::DFUNC );
165 }
166 
167 } // namespace symmetry
168 } // namespace optimization
169 } // namespace core
170