Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CenHBPotential.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/scoring/methods/CenHBPotential.cc
11 /// @brief Smooth, differentiable version of centroid hbond term
12 /// @author Frank DiMaio
13 
14 
16 
17 // AUTO-REMOVED #include <core/scoring/Energies.hh>
18 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
19 
20 // AUTO-REMOVED #include <core/chemical/AA.hh>
21 // AUTO-REMOVED #include <core/chemical/VariantType.hh>
22 // AUTO-REMOVED #include <core/conformation/Residue.hh>
23 #include <basic/database/open.hh>
24 // AUTO-REMOVED #include <core/pose/Pose.hh>
25 // AUTO-REMOVED #include <core/pose/datacache/CacheableDataType.hh>
26 // AUTO-REMOVED #include <basic/datacache/BasicDataCache.hh>
27 // AUTO-REMOVED #include <basic/prof.hh>
28 #include <utility/io/izstream.hh>
29 
30 #include <utility/vector1.hh>
31 #include <boost/bind.hpp>
32 
33 
34 
35 namespace core {
36 namespace scoring {
37 
38 ///////////////////////////////////////////////////////////////////////////////////////////////
39 
40 Real CenHBPotential::func( Size seqsep, Real d, Real xd, Real xh ) const {
41  using numeric::constants::f::pi;
42 
43  utility::vector1< Real > const & As = (seqsep<=4) ? sr_As_ : lr_As_;
44  utility::vector1< Vector > const & mus = (seqsep<=4) ? sr_mus_ : lr_mus_;
45  utility::vector1< Vector > const & sigmas = (seqsep<=4) ? sr_sigmas_ : lr_sigmas_;
46 
47  Real y = 0;
48  for (Size i=1; i<=As.size(); ++i) {
49  y += As[i] * exp( -(d-mus[i][0])*(d-mus[i][0]) / (2*sigmas[i][0]*sigmas[i][0]) )
50  * ( exp( sigmas[i][1]*cos( pi/180*(xd-mus[i][1]) ) ) + exp( sigmas[i][1]*cos( pi/180*(xd+mus[i][1]) ) ) )
51  * ( exp( sigmas[i][2]*cos( pi/180*(xh-mus[i][2]) ) ) + exp( sigmas[i][2]*cos( pi/180*(xh+mus[i][2]) ) ) );
52  }
53  return y;
54 }
55 
56 
57 Vector CenHBPotential::dfunc( Size seqsep, Real d, Real xd, Real xh ) const {
58  using numeric::constants::f::pi;
59 
60  utility::vector1< Real > const & As = (seqsep<=4) ? sr_As_ : lr_As_;
61  utility::vector1< Vector > const & mus = (seqsep<=4) ? sr_mus_ : lr_mus_;
62  utility::vector1< Vector > const & sigmas = (seqsep<=4) ? sr_sigmas_ : lr_sigmas_;
63 
64  Vector dy = Vector(0,0,0);
65  for (Size i=1; i<=As.size(); ++i) {
66  Real s1 = exp( -(d-mus[i][0])*(d-mus[i][0]) / (2*sigmas[i][0]*sigmas[i][0]) );
67  Real s2a = exp( sigmas[i][1]*cos( pi/180*(xd-mus[i][1]) ) );
68  Real s2b = exp( sigmas[i][1]*cos( pi/180*(xd+mus[i][1]) ) );
69  Real s3a = exp( sigmas[i][2]*cos( pi/180*(xh-mus[i][2]) ) );
70  Real s3b = exp( sigmas[i][2]*cos( pi/180*(xh+mus[i][2]) ) );
71  Real s2 = s2a+s2b;
72  Real s3 = s3a+s3b;
73 
74  dy[0] += -As[i] * s1 * s2 * s3 * (d-mus[i][0]) / (sigmas[i][0]*sigmas[i][0]);
75  dy[1] += -As[i] * s1 * s3 * pi/180 * sigmas[i][1] * ( sin( pi/180*(xd-mus[i][1])) * s2a + sin( pi/180*(xd+mus[i][1])) * s2b );
76  dy[2] += -As[i] * s1 * s2 * pi/180 * sigmas[i][2] * ( sin( pi/180*(xh-mus[i][2])) * s3a + sin( pi/180*(xh+mus[i][2])) * s3b );
77  }
78  return dy;
79 }
80 
81 ///////////////////////////////////////////////////////////////////////////////////////////////
82 
84  // defaults
85  cutoff_sr_ = 6.0;
86  cutoff_lr_ = 6.0;
87 
88  // load the data
89  std::string tag,line;
90  utility::io::izstream stream;
91  basic::database::open( stream, "scoring/score_functions/centroid_smooth/cen_hb_params.txt");
92 
93  while ( getline( stream, line ) ) {
94  std::istringstream l(line);
95  l >> tag;
96  if (tag == "HBOND_BB_LR:") {
97  l >> tag;
98  if (tag == "CUTOFF") {
99  l >> cutoff_lr_;
100  } else if (tag == "GAUSSIAN3D") {
101  Size ngauss; l >> ngauss;
102  Real A;
103  numeric::xyzVector<Real> mu, sigma;
104  for (Size i=1; i<=ngauss; ++i) {
105  l >> A >> mu[0] >> mu[1] >> mu[2] >> sigma[0] >> sigma[1] >> sigma[2];
106  add_lr_gaussian(A,mu,sigma);
107  }
108  }
109  } else if (tag == "HBOND_BB_SR:") {
110  l >> tag;
111  if (tag == "CUTOFF") {
112  l >> cutoff_sr_;
113  } else if (tag == "GAUSSIAN3D") {
114  Size ngauss; l >> ngauss;
115  Real A;
116  numeric::xyzVector<Real> mu, sigma;
117  for (Size i=1; i<=ngauss; ++i) {
118  l >> A >> mu[0] >> mu[1] >> mu[2] >> sigma[0] >> sigma[1] >> sigma[2];
119  add_sr_gaussian(A,mu,sigma);
120  }
121  }
122  } else if (tag != "#") {
123  utility_exit_with_message("bad format for cen_smooth_params.txt");
124  }
125 
126  if ( l.fail() ) utility_exit_with_message("bad format for cen_smooth_params.txt");
127  }
128 }
129 
130 
131 
132 }
133 }