Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Align_RotamerEvaluator.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 Align_RotamerEvaluator
11 /// @author James Thompson
12 
14 
16 #include <core/pose/Pose.hh>
17 
18 #include <basic/Tracer.hh>
19 // AUTO-REMOVED #include <core/sequence/util.hh>
23 
24 // AUTO-REMOVED #include <core/conformation/Residue.hh>
27 
28 #include <ObjexxFCL/string.functions.hh>
29 #include <numeric/angle.functions.hh>
30 
32 #include <utility/vector1.hh>
33 
34 
35 static basic::Tracer tr("protocols.comparative_modeling.Align_RotamerEvaluator");
36 
37 namespace protocols {
38 namespace comparative_modeling {
39 
41 
43  core::pose::PoseCOP native_pose,
44  std::string tag,
45  core::Real const chi_dev,
47 ) :
48  AlignEvaluator( native_pose, tag, true, aln ),
49  chi_dev_(chi_dev)
50 {}
51 
54  core::pose::Pose const & pose
55 ) {
56  using namespace core::pack::dunbrack;
57  using utility::vector1;
58 
60  for ( core::Size ii = 1; ii <= pose.total_residue(); ++ii ) {
61  RotVector rot;
62  rotamer_from_chi( pose.residue(ii), rot );
63  rots.push_back( rot );
64  }
65  return rots;
66 }
67 
70  core::pose::Pose const & pose
71 ) {
72  using core::Size;
73  using core::Real;
74  using utility::vector1;
75 
77  for ( Size ii = 1; ii <= pose.total_residue(); ++ii ) {
78  vector1< Real > chi_vec;
79  core::Size const n_chi( pose.residue_type(ii).nchi() );
80  for ( Size jj = 1; jj <= n_chi; ++jj ) {
81  chi_vec.push_back( pose.chi(jj,ii) );
82  }
83  chis.push_back( chi_vec );
84  }
85  return chis;
86 }
87 
88 void
90  core::pose::Pose & pose,
91  std::string /*tag*/,
93 ) const {
94  using core::Real;
95  using core::Size;
96  using utility::vector1;
98  using namespace core::pack::dunbrack;
99 
100  SequenceMapping mapping( get_alignment(pose)->sequence_mapping(1,2) );
101 
102  tr.flush_all_channels();
103  static Size const MAX_N_CHI (4); // hacky
104  vector1< Size > n_rots_equiv( MAX_N_CHI, 0 );
105  vector1< Size > n_chis_equiv( MAX_N_CHI, 0 );
106 
107  Size n_ali(0);
108  Real const max_dev( chi_dev() );
109  for ( Size ii = 1; ii <= pose.total_residue(); ++ii ) {
110  Size const native_ii( mapping[ii] );
111  bool skip(
112  native_ii == 0 ||
113  native_ii > native_pose()->total_residue()
114  );
115  if ( !skip ) {
116  ++n_ali;
117  RotVector model_rots, native_rots;
118  rotamer_from_chi( pose.residue(ii), model_rots );
119  rotamer_from_chi( native_pose()->residue(native_ii), native_rots );
120  if ( model_rots.size() == native_rots.size() ) {
121  for ( Size chi_idx = 1; chi_idx <= model_rots.size(); ++chi_idx ) {
122  // rotamer equivalence
123  if ( model_rots[chi_idx] == native_rots[chi_idx] ) {
124  n_rots_equiv[chi_idx]++;
125  }
126 
127  // chi deviation
128  //Real const model_chi ( pose.chi(ii,chi_idx) );
129  //Real const native_chi( native_pose()->chi(native_ii,chi_idx) );
130  Real const model_chi ( pose.chi(chi_idx,ii) );
131  Real const native_chi( native_pose()->chi(chi_idx,native_ii) );
132  using numeric::nearest_angle_degrees;
133  if ( nearest_angle_degrees(model_chi,native_chi) <= max_dev ) {
134  n_chis_equiv[chi_idx]++;
135  }
136  }
137  }
138  } // residue is aligned
139  } // for residues
140 
141  Real const coverage(
142  (Real) (n_ali) / (Real) (native_pose()->total_residue())
143  );
144  Size const native_nres( native_pose()->total_residue() );
145  for ( Size ii = 1; ii <= n_chis_equiv.size(); ++ii ) {
146  using std::string;
147  using ObjexxFCL::string_of;
148 
149  string const chi_tag( "chi" + string_of(ii) + "_equiv_" + tag() );
150  Real const chi_equiv( coverage * (Real) n_chis_equiv[ii] / (Real) native_nres );
151  ss.add_energy( chi_tag, chi_equiv );
152 
153  string const rot_tag( "rot" + string_of(ii) + "_equiv_" + tag() );
154  Real const rot_equiv( coverage * (Real) n_rots_equiv[ii] / (Real) native_nres );
155  ss.add_energy( rot_tag, rot_equiv );
156  }
157 } // apply
158 
160  return chi_dev_;
161 }
162 
163 } // comparative_modeling
164 } // protocols