Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RRComparer.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 src/protocols/rotamer_recovery/RRComparer.cc
11 /// @author Matthew O'Meara (mattjomeara@gmail.com)
12 /// Adapted from:
13 /// protocols::optimize_weights::IterativeOptEDriver::measure_rotamer_recovery()
14 /// and apps::pilot::doug::rotamer_prediction_benchmark()
15 
16 
17 // Unit Headers
19 
20 // Project Headers
24 #include <basic/Tracer.hh>
25 
26 // C++ Headers
27 #include <string>
28 
29 #include <utility/vector1.hh>
30 
31 
32 using std::string;
33 using std::endl;
34 using core::Size;
35 using core::Real;
38 using core::pose::Pose;
41 using basic::Tracer;
42 
43 namespace protocols {
44 namespace rotamer_recovery {
45 
46 /// @details Auto-generated virtual destructor
48 
49 static Tracer TR("protocol.moves.RRComparer");
50 
52  recovery_threshold_(0)
53 {}
54 
56  RRComparer(),
57  recovery_threshold_(src.recovery_threshold_)
58 {}
59 
61 
62 void
64  Real const recovery_threshold
65 ) {
66  recovery_threshold_ = recovery_threshold;
67 }
68 
69 /// @details measure the rotamer recovery by comparing rotamer bins
70 /// @return true, if the measurement was successful, false otherwise
71 bool
73  Pose const & /* pose1 */,
74  Pose const & /* pose2 */,
75  Residue const & res1,
76  Residue const & res2,
77  Real & score,
78  bool & recovered
79 ) {
80 
81 
82  if( res1.aa() != res2.aa() ) {
83  TR << "Cannot measure rotamer recovery because" << endl;
84  TR << "residue 1 has type '" << res1.type().name() << "'" << endl;
85  TR << "residue 2 has type '" << res2.type().name() << "'" << endl;
86  TR << "Make sure the protocol to generate the conformations did not 'design' the sequence identity too." << endl;
87  utility_exit();
88  }
89 
90  if( res1.aa() > num_canonical_aas ){
91  TR << "WARNING: trying to compare rotamer bins for non-canonical amino acid '" << res1.name() << "'" << endl;
92  return false;
93  }
94 
95  RotVector res1_rotbins, res2_rotbins;
96  rotamer_from_chi( res1, res1_rotbins );
97  rotamer_from_chi( res2, res2_rotbins );
98 
99  Size chi_match(0);
100  for ( Size chi_index=1; chi_index <= res1_rotbins.size(); ++chi_index ){
101  if ( res1_rotbins[ chi_index ] == res2_rotbins[ chi_index ] ) {
102  chi_match++;
103  }
104  }
105  score = res1_rotbins.size() - chi_match;
106  recovered = (score <= recovery_threshold_);
107  return true;
108 }
109 
110 string
112  return "RRComparerRotBins";
113 }
114 
115 string
117  return "";
118 }
119 
120 
121 RRComparerChiDiff::RRComparerChiDiff() : tolerance_( 20.0 ) {}
122 
124  RRComparer(),
125  tolerance_( src.tolerance_ )
126 {}
127 
129 
130 void
132 
133 /// @details measure the rotamer recovery by comparing rotamer bins
134 /// @return true, if the measurement was successful, false otherwise
135 bool
137  Pose const & /* pose1 */,
138  Pose const & /* pose2 */,
139  Residue const & res1,
140  Residue const & res2,
141  Real & score,
142  bool & recovered
143 ) {
144 
146 
147  if( res1.aa() != res2.aa() ) {
148  TR << "Cannot measure rotamer recovery because" << endl;
149  TR << "residue 1 has type '" << res1.type().name() << "'" << endl;
150  TR << "residue 2 has type '" << res2.type().name() << "'" << endl;
151  TR << "Make sure the protocol to generate the conformations did not 'design' the sequence identity too." << endl;
152  utility_exit();
153  }
154 
155  if( res1.aa() > num_canonical_aas ){
156  TR << "WARNING: trying to compare rotamer bins for non-canonical amino acid '" << res1.name() << "'" << endl;
157  return false;
158  }
159 
160  score = 0;
161  recovered=true;
162  for ( Size chi_index=1; chi_index <= res1.nchi(); ++chi_index ){
163  if ( res1.type().chi_2_proton_chi( chi_index ) == 0 ) { // ignore proton chi (tyr,ser,thr)
164  Real chidiff = std::abs( subtract_chi_angles( res1.chi(chi_index), res2.chi(chi_index), res1.aa(), chi_index ));
165  if ( score < chidiff ) { score = chidiff; }
166  if ( chidiff > tolerance_ ) { recovered = false; }
167  }
168  }
169 
170  return true;
171 }
172 
173 string
175  return "RRComparerChiDiff";
176 }
177 
178 string
180  return "";
181 }
182 
183 } // rotamer_recovery
184 } // protocols