Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GunnCost.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 /// @brief Cost computation for Gunn Moves
11 /// @author Oliver Lange
12 
13 // Unit Headers
15 
16 // Project Headers
17 #include <core/pose/Pose.hh>
19 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
20 #include <core/types.hh>
22 #include <basic/Tracer.hh>
23 
24 // Numeric Headers
25 #include <numeric/constants.hh>
26 
27 // Utility headers
28 #include <utility/vector1.fwd.hh>
29 #include <numeric/numeric.functions.hh>
30 
31 //// C++ headers
32 #include <cstdlib>
33 #include <string>
34 
35 #include <core/id/AtomID.hh>
36 #include <utility/vector1.hh>
37 
38 namespace protocols {
39 namespace frag_picker {
40 namespace scores {
41 
42 using namespace core;
43 
44 static basic::Tracer trGunnCost("core.fragment.GunnCost");
45 
47 
48  if ( begin == end ) return; // can't compute gunn for 1-residue fragments...
49 
50  PointPosition p1,p2,p3,temp;
51  Vector x1,y1,z1; //res j
52  Vector x2,y2,z2; //res k
53  Vector R; // connection resj -> resk
54 
55  // setup coordinate system around res j
56  chemical::ResidueType const& rtj ( pose.residue_type ( begin ) );
57  id::AtomID Nj( rtj.atom_index ("N") , begin );
58  id::AtomID CAj( rtj.atom_index ("CA") , begin );
59  id::AtomID Cj( rtj.atom_index ("C") , begin );
60  p1 = pose.xyz ( Nj );
61  p2 = pose.xyz ( CAj );
62  p3 = pose.xyz ( Cj );
63  /*{
64  Vector d1,d2,d3;
65  d1 = p1-p2;
66  d2 = p1-p3;
67  d3 = p2-p3;
68  trGunnCost.Trace << "N-CA " << d1.length() << " N-C" << d2.length() << " CA-C " << d3.length()<< std::endl;
69  trGunnCost.Trace << p1[0] << " " << p1[1] << " " << p1[2] << std::endl;
70  trGunnCost.Trace << p2[0] << " " << p2[1] << " " << p2[2] << std::endl;
71  trGunnCost.Trace << p3[0] << " " << p3[1] << " " << p3[2] << std::endl;
72  }*/
73  x1 = p1 - p2;
74  x1.normalize();
75 
76  cross( x1, p3 - p2, z1 );
77  z1.normalize();
78 
79  cross( z1, x1, y1);
80 
81  // setup coordinate system around res k
82  chemical::ResidueType const& rtk ( pose.residue_type ( end ) );
83  id::AtomID Nk( rtk.atom_index ("N") , end );
84  id::AtomID Ck( rtk.atom_index ("C") , end );
85  id::AtomID CAk( rtk.atom_index ("CA") , end );
86 
87  p1 = pose.xyz ( Nk );
88  p2 = pose.xyz ( CAk );
89  p3 = pose.xyz ( Ck );
90  /*
91  trGunnCost.Trace << p1[0] << " " << p1[1] << " " << p1[2] << std::endl;
92  trGunnCost.Trace << p2[0] << " " << p2[1] << " " << p2[2] << std::endl;
93  trGunnCost.Trace << p3[0] << " " << p3[1] << " " << p3[2] << std::endl;
94  */
95  x2 = p1 - p2;
96  x2.normalize();
97 
98  cross( x2, p3 - p2, z2 );
99  z2.normalize();
100 
101  cross( z2, x2, y2 );
102 
103  // compute inter residue vector
104  R = pose.xyz( CAk ) - pose.xyz( CAj );
105  /* trGunnCost.Trace << R[0] << " " << R[1] << " " << R[2] << std::endl; */
106  // compute gunn quantities
107 
108  data.q6 = R.length();
109  R.normalize();
110 
111  data.q1 = dot_product( x1, R );
112  data.q2 = dot_product( x2, R );
113  data.q3 = dot_product( x1, x2) - data.q1 * data.q2;
114  data.q3 /= ( std::sqrt( (1-data.q1*data.q1) * (1-data.q2*data.q2) ) + .0001 );
115  data.q3 = std::acos( numeric::sin_cos_range( data.q3 ) );
116  data.q4 = std::acos( numeric::sin_cos_range( dot_product( y1, R ) / ( std::sqrt( 1-data.q1 * data.q1 ) + .0001 ) ) );
117  data.q5 = std::acos( numeric::sin_cos_range( dot_product( y2, R ) / ( std::sqrt( 1-data.q2 * data.q2 ) + .0001 ) ) );
118 
119 }
120 
122  using numeric::constants::d::pi_over_2;
123  using numeric::constants::d::pi;
124  Real c1,c2,c3,c4;
125  c1 = 2.035; //magic weights
126  c2 = 0.346;
127  c3 = 5.72;
128  c4 = 3.84;
129 
130  Real d3 ( std::abs( g1.q3 - g2.q3 ) );
131  if ( d3 > pi_over_2 ) d3 = pi - d3;
132  Real d4 ( std::abs( g1.q4 - g2.q4 ) );
133  if ( d4 > pi_over_2 ) d4 = pi - d4;
134  Real d5 ( std::abs( g1.q5 - g2.q5 ) );
135  if ( d5 > pi_over_2 ) d5 = pi - d5;
136 
137  Real cost = 2.92 +
138  c3 * std::log( 1.0 + ( std::abs( g1.q1 - g2.q1 ) + std::abs( g1.q2 - g2.q2 ) ) ) +
139  c2 * std::log( 1.0 + std::abs( g1.q6 - g2.q6 ) ) +
140  c1 * std::log( 1.0 + d3 ) +
141  c4 * std::log( 1.0 + d4 + d5 );
142  if ( cost < 2.95 ) cost = 100; // too similar
143  return cost;
144 }
145 
146 } // scores
147 } // frag_picker
148 } // protocols
149