Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Membrane_FAPotential.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 // This file is made available under the Rosetta Commons license.
5 // See http://www.rosettacommons.org/license
6 // (C) 199x-2007 University of Washington
7 // (C) 199x-2007 University of California Santa Cruz
8 // (C) 199x-2007 University of California San Francisco
9 // (C) 199x-2007 Johns Hopkins University
10 // (C) 199x-2007 University of North Carolina, Chapel Hill
11 // (C) 199x-2007 Vanderbilt University
12 
13 /// @file core/scoring/methods/EnvPairPotential.cc
14 /// @brief Membrane FA Potential
15 /// @author Patrick Barth
16 ///
17 
18 
19 // Unit headers
23 // AUTO-REMOVED #include <core/scoring/MembraneTopology.hh>
24 
25 // Package headers
26 
27 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
29 
30 // Project headers
31 #include <core/chemical/AA.hh>
32 // AUTO-REMOVED #include <core/chemical/VariantType.hh>
34 // AUTO-REMOVED #include <basic/database/open.hh>
35 #include <core/pose/Pose.hh>
37 #include <basic/datacache/BasicDataCache.hh>
38 
39 #include <basic/options/option.hh>
40 // AUTO-REMOVED #include <basic/options/after_opts.hh>
41 #include <basic/options/keys/membrane.OptionKeys.gen.hh>
42 
43 // Utility headers
44 // AUTO-REMOVED #include <utility/io/izstream.hh>
45 // AUTO-REMOVED #include <utility/utility.functions.hh>
46 #include <core/types.hh>
47 
48 
49 #include <utility/vector1.hh>
50 #include <numeric/xyzVector.hh>
51 // AUTO-REMOVED #include <numeric/xyz.functions.hh>
52 // AUTO-REMOVED #include <numeric/random/random.hh>
53 // AUTO-REMOVED #include <numeric/conversions.hh>
54 
55 #include <ObjexxFCL/FArray1D.hh>
56 #include <ObjexxFCL/FArray2D.hh>
57 
58 
59 
60 // just for debugging
61 //#include <ObjexxFCL/formatted.o.hh>
62 
63 // C++
64 
65 
66 namespace core {
67 namespace scoring {
68 //static numeric::random::RandomGenerator RG(280628); // <- Magic number, do not change it!
69 
70 
71 //pba
72 
74  CacheableData()
75 {
76  fa_center_ = src.fa_center_;
77  fa_proj_ = src.fa_proj_;
80  fa_depth_ = src.fa_depth_;
83 }
84 
85 void
87 {
88  thickness_=15.0;
89  steepness_=10.0;
90  Fa_Membed_update_=basic::options::option[ basic::options::OptionKeys::membrane::Fa_Membed_update ]();
92 }
93 
94 void
96 {
97  fa_center_ = 0.0;
98  Size const nres( pose.total_residue() );
99  fa_proj_.resize( nres );
100  fa_proj_coord_.resize( nres );
101  fa_proj_deriv_.resize( nres );
102  fa_depth_.resize( nres );
103 
104  // Tryptophan is the largest...
105  static Size const MAX_AMINOACID_SIZE = 15; ///Todo Fix this Hack. Membrane Design failed because these vectors are presized assuming residue atom count remains constant
106  for ( Size i = 1; i <= nres; ++i ) {
107  Size const max_size = std::max( MAX_AMINOACID_SIZE, pose.residue( i ).nheavyatoms() ); // in case of ligands or NCAAs
108  fa_proj_[i].resize( max_size );
109  fa_proj_coord_[i].resize( max_size );
110  fa_proj_deriv_[i].resize( max_size );
111  fa_depth_[i].resize( max_size);
112  for ( Size j = 1; j <= max_size; ++j ) {
113  fa_proj_[i][j] = 0.0;
114  fa_proj_coord_[i][j].assign(0.0,0.0,0.0);
115  fa_proj_deriv_[i][j] = 0.0;
116  fa_depth_[i][j] = 0.0;
117  }
118  }
119 }
120 
121 void
123 {
124  CenListInfo & cenlist( nonconst_cenlist_from_pose( pose ));
125  cenlist.calculated() = true; //pba
127  membrane_embed.calculated() = false; //pba 112209
128  Membrane_FAEmbed & membrane_faembed( nonconst_Membrane_FAEmbed_from_pose( pose ));
129  membrane_faembed.calculated() = false; //pba
130 }
131 
132 void
134 {
135 
137  Membrane_FAEmbed & membrane_faembed(nonconst_Membrane_FAEmbed_from_pose( pose ));
138 
139  membrane_faembed.initialize(pose);
140 
141  if (membrane_faembed.Fa_Membed_update()) membrane_embed.calculated() = false;
143 
144  Vector const normal(MembraneEmbed_from_pose( pose ).normal());
145  Vector const center(MembraneEmbed_from_pose( pose ).center());
146  Real const penalty(MembraneEmbed_from_pose( pose ).penalty());
147  Real const thickness(Membrane_FAEmbed_from_pose( pose ).thickness());
148  Real const steepness(Membrane_FAEmbed_from_pose( pose ).steepness());
149 
150  fa_projection(pose,normal,center,thickness,steepness,penalty);
151 }
152 
153 void
155  pose::Pose & pose,
156  Vector const & normal,
157  Vector const & center,
158  Real const & thickness,
159  Real const & steepness,
160  Real const & penalty
161 ) const
162 {
163  // mjo commenting out 'topology' because it is unused and causes a warning
164  //core::scoring::MembraneTopology const & topology( core::scoring::MembraneTopology_from_pose(pose) );
165  Membrane_FAEmbed & membrane_faembed(nonconst_Membrane_FAEmbed_from_pose( pose ));
166 
167  Size nres=pose.total_residue();
168  Real internal_product(0), z(0), zn(0), znm1(0);
169 
170  membrane_faembed.fa_center() = std::abs(dot(center, normal));
171  membrane_faembed.fa_penalty() = penalty;
172 
173  //pbadebug
174  if(!membrane_faembed.calculated()) {
175  // USE TRACER OUTPUT ! ! !
176 // std::cout << "CENTER " << center.x() << " " << center.y() << " " << center.z() << "\n";
177 // std::cout << "NORMAL " << normal.x() << " " << normal.y() << " " << normal.z() << "\n";
178 // std::cout << "thickness steepness " << thickness << " " << steepness << "\n";
179 // std::cout << "fa_center " << membrane_faembed.fa_center() << "\n";
180  // std::cout << "fa_penalty " << membrane_faembed.fa_penalty() << "\n";
181  }
182 
183  for ( Size i = 1; i <= nres; ++i ) {
184  for ( Size j = 1, j_end = pose.residue( i ).nheavyatoms(); j <= j_end; ++j ) {
185  Vector const xyz( pose.residue( i ).xyz( j ) );
186  membrane_faembed.fa_depth( i, j ) = dot(xyz-center, normal);
187 
188  internal_product = std::abs(membrane_faembed.fa_depth( i, j ));
189  z = internal_product;
190  z /= thickness;
191  zn = std::pow( z, steepness );
192  membrane_faembed.fa_proj( i, j ) = zn/(1 + zn);
193 
194  //deriv
195  znm1 = std::pow( z, (steepness-1) );
196  membrane_faembed.fa_proj_deriv( i, j ) = steepness * znm1 * std::pow((1 + zn),-2);
197  membrane_faembed.fa_proj_deriv( i, j ) /= thickness;
198 
199  Vector proj_i = center + membrane_faembed.fa_depth(i,j)*normal;
200  Vector i_ip = proj_i - xyz;
201  Vector proj_center = center - i_ip;
202  membrane_faembed.fa_proj_coord(i,j) = proj_center;
203  }
204  }
205  membrane_faembed.calculated() = true;
206 }
207 
208 
209 Membrane_FAEmbed const &
211 {
212  // ////using core::pose::datacache::CacheableDataType::MEMBRANE_FAEMBED;
213  return *( static_cast< Membrane_FAEmbed const * >( pose.data().get_const_ptr( core::pose::datacache::CacheableDataType::MEMBRANE_FAEMBED )() ));
214 }
215 
216 /// @details Either returns a non-const reference to the cenlist object already stored
217 /// in the pose, or creates a new cenist object, places it in the pose, and returns
218 /// a non-const reference to it.
221 {
222  // ////using core::pose::datacache::CacheableDataType::MEMBRANE_FAEMBED;
223 
225  return *( static_cast< Membrane_FAEmbed * >( pose.data().get_ptr( core::pose::datacache::CacheableDataType::MEMBRANE_FAEMBED )() ));
226  }
227  // else
228  Membrane_FAEmbedOP membrane_faembed = new Membrane_FAEmbed;
230  return *membrane_faembed;
231 }
232 
233 }
234 }