Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GaussianOverlapEnergy.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/GaussianOverlapEnergy.cc
11 /// @brief Gaussian Overlap Energy
12 /// @author Ben Borgo (bborgo@genetics.wustl.edu)
13 
14 
15 
17 #include <basic/database/open.hh>
18 #include <basic/options/option.hh>
19 #include <basic/options/keys/in.OptionKeys.gen.hh>
20 #include <core/pose/Pose.hh>
23 // AUTO-REMOVED #include <core/scoring/NeighborList.hh>
24 //#include <core/scoring/ScoringManager.hh>
26 #include <numeric/interpolation/spline/SplineGenerator.hh>
27 #include <numeric/NumericTraits.hh>
28 #include <utility/io/izstream.hh>
29 #include <sstream>
30 #include <core/chemical/AA.hh>
32 
34 
35 //Auto Headers
36 #include <core/id/AtomID.hh>
37 
38 
39 
40 #define DIST_TH 6.0
41 //#define TETHER_WT 10.0
42 
43 namespace core {
44 namespace scoring {
45 namespace methods {
46 
48 
49 
50 /// @details This must return a fresh instance of the GaussianOverlapEnergy class,
51 /// never an instance already in use
55 ) const {
56  return new GaussianOverlapEnergy;
57 }
58 
61  ScoreTypes sts;
62  sts.push_back( gauss );
63  return sts;
64 }
65 
66 
69 {
70 
71 /*
72 
73  utility::io::izstream izin;
74  basic::database::open( izin, basic::options::option[ basic::options::OptionKeys::in::file::native ]() );
75 
76  utility::vector1< utility::vector1< Real > > points;
77 
78  char s[999];
79  izin.getline(s,999); // read in and ignore header line
80  while( true ) {
81  izin.getline(s,999);
82  // std::cerr << "string: '" << s << "'" << std::endl;
83  std::istringstream iss(s);
84  core::Real tmp;
85  utility::vector1< Real > point;
86  if( !(iss >> tmp ) ) break; // if no line, done
87  point.push_back(tmp);
88  iss >> tmp;
89  point.push_back(tmp);
90  if( iss >> tmp ) point.push_back(tmp);
91  points.push_back(point);
92  }
93 
94  assert( points.size() >= 2 );
95 
96  // std::cerr << "printing points" << std::endl;
97  // for( Size i = 1; i <= points.size(); ++i ) {
98  // std::cerr << "point: ";
99  // for( Size j = 1; j <= points[i].size(); ++j ) {
100  // std::cerr << points[i][j] << ",";
101  // }
102  // std::cerr << std::endl;
103  // }
104 
105  using namespace numeric::interpolation::spline;
106  SplineGenerator sg( points[ 1 ][1], points[ 1 ][2], points[ 1 ][3],
107  points[points.size()][1], points[points.size()][2], points[points.size()][3] );
108 
109  for( Size i = 2; i < points.size(); ++i ) {
110  if( points[i].size() == 2 ) sg.add_known_value( points[i][1], points[i][2] );
111  if( points[i].size() == 3 ) sg.add_known_value( points[i][1], points[i][2], points[i][3] );
112  }
113 
114  interp_ = sg.get_interpolator();
115 
116  // core::Real x,y,dy;
117  // for( x = 0; x <= 6.0; x += 0.01 ) {
118  // interp_->interpolate(x,y,dy);
119  // std::cerr << "SUCKERE " << x << " " << y << " " << dy << std::endl;
120  // }
121 
122 */
123 }
124 
125 
126 /// clone
129 {
130  return new GaussianOverlapEnergy();
131 }
132 
133 
134 inline bool count_atom( int const & atype ) {
135  // return true;
136  return ( ( 1 <= atype && atype <= 6 ) // just carbons for now...
137  || ( 18 <= atype && atype <= 19 )
138  );
139 }
140 /////////////////////////////////////////////////////////////////////////////
141 // scoring
142 /////////////////////////////////////////////////////////////////////////////
143 
144 ///
145 void
147  conformation::Residue const & rsd1,
148  conformation::Residue const & rsd2,
149  pose::Pose const & /*pose*/,
150  ScoreFunction const &,
151  EnergyMap & emap
152 ) const
153 {
154 
155  using namespace core;
156  using namespace conformation;
157 
158  Real score(0.0);
159 
160  if ( rsd1.seqpos() == rsd2.seqpos() ) return;
161 // if ( rsd1.is_bonded( rsd2 ) ) return;
162 
163  chemical::AA const aa1( rsd1.aa() );
164  chemical::AA const aa2( rsd2.aa() );
165  if ( aa1 == chemical::aa_cys && aa2 == chemical::aa_cys &&
166  rsd1.is_bonded( rsd2 ) && rsd1.polymeric_sequence_distance( rsd2 ) > 1 &&
168  if ( aa1 == chemical::aa_pro && aa2 == chemical::aa_pro ) return;
169 
170  for ( Size i = 1, i_end = rsd1.nheavyatoms(); i <= i_end; ++i ) {
171  Vector const & i_xyz( rsd1.xyz(i) );
172  //Size const i_type( rsd1.atom_type_index(i) );
173  for ( Size j = 1, j_end = rsd2.nheavyatoms(); j <= j_end; ++j ) {
174  Vector const & j_xyz( rsd2.xyz(j) );
175  //Size const j_type( rsd2.atom_type_index(j) );
176 
177  Real const d2( i_xyz.distance_squared( j_xyz ) );
178 
179  if( d2 <= 150.0 ){
180  core::Real r1 = rsd1.atom_type(i).lj_radius();
181  core::Real r2 = rsd2.atom_type(j).lj_radius();
182 
183  r1 = .92*r1; r2 = .92*r2;
184  if( d2 <= .5*(r1+r2) ){
185  score = 1000;}
186  else if( d2 <= .8*(r1+r2) ){
187  score = (r1+r2)/(d2*d2*d2*d2*sqrt(d2));}
188  else{
189  score = ((sqrt(numeric::NumericTraits<Real>::pi())*r1*r2)/(sqrt(r1*r1+r2*r2)))*(exp(-d2/(r1*r1+r2*r2)));
190  emap[ gauss ] += score;}}
191  else{
192  emap[ gauss ] += 0.0;}
193 }}
194 }
195 
196 void
198  id::AtomID const & /*id*/,
199  pose::Pose const & /*pose*/,
200  kinematics::DomainMap const &, // domain_map,
201  ScoreFunction const &,
202  EnergyMap const &,
203  Vector & /*F1*/,
204  Vector & /*F2*/
205 ) const
206 {
207  using namespace numeric;
208 /*
209  // id is a SUCK atom
210  if( "SUCK" == pose.residue(id.rsd()).name() ) { // loop over atom neighbors and suck
211  // conformation::Residue const & sck( pose.residue(id.rsd()) );
212  assert( 1 <= id.atomno() && id.atomno() <= 3 );
213  if( id.atomno() > 1 ) return;
214  numeric::xyzVector<Real> suck_xyz( pose.xyz(id) );
215 
216  for( int ir = 1; ir <= (int)pose.total_residue(); ++ir ) {
217  conformation::Residue const & res( pose.residue(ir) );
218  if( "SUCK" == res.name() ) continue;
219 
220  for( int ia = 1; ia <= (int)res.nheavyatoms(); ++ia ) {
221  conformation::Atom const & atom( res.atom( ia ) );
222  if( !count_atom( atom.type() ) ) continue;
223 
224  xyzVector<Real> const & atom_xyz( atom.xyz() );
225 
226  Real const d = suck_xyz.distance(atom_xyz);
227  if( d > DIST_TH ) continue;
228 
229  // std::cerr << "DERIVATOMS " << res.seqpos() << " " << ia << " " << sck.seqpos() << " " << 1 << " " << d << " LPA " << id.rsd() << " " << id.atomno() << std::endl;
230 
231  // compute suck F1, F2
232  numeric::xyzVector<Real> const f1( suck_xyz.cross( atom_xyz ));
233  numeric::xyzVector<Real> const f2( suck_xyz - atom_xyz );
234  Real const dist( f2.length() );
235  Real deriv, dummy;
236  interp_->interpolate( dist, dummy, deriv );
237  // std::cerr << "sck_atm " << deriv << std::endl;
238  F1 += ( deriv / dist ) * weights[ suck ] * f1;
239  F2 += ( deriv / dist ) * weights[ suck ] * f2;
240 
241  }
242  }
243 
244  // // teathers, orig pos from pose data cache
245  // using namespace basic;
246  // CacheableData const & cd = pose.data().get(SUCKER_ORIG_POSITIONS);
247  // CacheableIntXyzVectorMap const & cxmap = dynamic_cast<CacheableIntXyzVectorMap const &>( cd );
248  // numeric::xyzVector<Real> const & orig_xyz = cxmap.map().find( id.rsd() )->second;
249  //
250  // numeric::xyzVector<Real> const f1( suck_xyz.cross( orig_xyz ));
251  // numeric::xyzVector<Real> const f2( suck_xyz - orig_xyz );
252  // std::cerr << "intrares dE " << distance(suck_xyz,orig_xyz) << " " << 2*TETHER_WT*distance(suck_xyz,orig_xyz) << std::endl;
253  // std::cerr << " SUCKER ORIG POS " << id.rsd() << " " << orig_xyz.x() << "," << orig_xyz.y() << "," << orig_xyz.z() << std::endl;
254  // std::cerr << " SUCKER POS " << id.rsd() << " " << suck_xyz.x() << "," << suck_xyz.y() << "," << suck_xyz.z() << std::endl;
255  // Real dist = distance( suck_xyz, orig_xyz );
256  // Real deriv = -dist * 2;
257  // F1 += ( deriv / dist ) * TETHER_WT * weights[ suck ] * f1;
258  // F2 += ( deriv / dist ) * TETHER_WT * weights[ suck ] * f2;
259 
260 
261  } else { // loop over suck residues and suck
262 
263  // heavy atoms only
264  if( id.atomno() > pose.residue(id.rsd()).nheavyatoms() ) return;
265  conformation::Atom const & atom( pose.residue(id.rsd()).atom(id.atomno()) );
266  if( !count_atom( atom.type() ) ) return;
267 
268  numeric::xyzVector<Real> atom_xyz( atom.xyz() );
269  // while( "SUCK" == pose.residue(i).name() ) {
270  for( Size i = 1; i <= pose.total_residue(); ++i ) {
271  if( "SUCK" != pose.residue(i).name() ) continue;
272 
273  conformation::Residue const & sck( pose.residue(i) );
274  numeric::xyzVector<Real> suck_xyz( sck.xyz(1) );
275  Real const d = suck_xyz.distance(atom_xyz);
276  if( d <= DIST_TH ) {
277 
278  // std::cerr << "DERIVATOMS " << id.rsd() << " " << id.atomno() << " " << sck.seqpos() << " " << 1 << " " << d << " LPB " << id.rsd() << " " << id.atomno() << std::endl;
279 
280  // compute suck F1, F2
281  numeric::xyzVector<Real> const f1( atom_xyz.cross( suck_xyz ));
282  numeric::xyzVector<Real> const f2( atom_xyz - suck_xyz );
283  Real const dist( f2.length() );
284  Real deriv, dummy;
285  interp_->interpolate( dist, dummy, deriv );
286  // std::cerr << "reg_atm " << deriv << std::endl;
287  F1 += ( deriv / dist ) * weights[ suck ] * f1;
288  F2 += ( deriv / dist ) * weights[ suck ] * f2;
289 
290  }
291  // --i;
292 
293  }
294 
295  }
296 */
297 
298 }
299 
300 void
302  conformation::Residue const & /*rsd*/,
303  pose::Pose const & /*pose*/,
304  ScoreFunction const & /*sfxn*/,
305  EnergyMap & /*emap*/
306 ) const {
307  // using namespace basic;
308  // if( "SUCK" == rsd.name() ) {
309  // CacheableData const & cd = pose.data().get(SUCKER_ORIG_POSITIONS);
310  // CacheableIntXyzVectorMap const & cxmap = dynamic_cast<CacheableIntXyzVectorMap const &>( cd );
311  // numeric::xyzVector<Real> const & orig_xyz = cxmap.map().find( rsd.seqpos() )->second;
312  // numeric::xyzVector<Real> const & curr_xyz( rsd.xyz(1) );
313  // Real const d2( distance_squared(orig_xyz,curr_xyz) );
314  // std::cerr << "intrareas E " << distance(curr_xyz,orig_xyz) << " " << TETHER_WT*d2 << std::endl;
315  // std::cerr << " SUCKER ORIG POS " << rsd.seqpos() << " " << orig_xyz.x() << "," << orig_xyz.y() << "," << orig_xyz.z() << std::endl;
316  // std::cerr << " SUCKER POS " << rsd.seqpos() << " " << curr_xyz.x() << "," << curr_xyz.y() << "," << curr_xyz.z() << std::endl;
317  // emap[ suck ] += TETHER_WT*d2;
318  // }
319 }
320 
321 
322 /// @brief GaussianOverlapEnergy distance cutoff set to the same cutoff used by EtableEnergy, for now
323 Distance
325 {
326  return interaction_cutoff();
327 }
328 
329 /// @details non-virtual accessor for speed; assumption: GaussianOverlapEnergy is not inherrited from.
330 Distance
332 {
333  return DIST_TH;
334 }
335 
336 /// @brief GaussianOverlapEnergy requires that Energies class maintains a TenANeighborGraph
337 void
339 {
340 }
343 {
344  return 1; // Initial versioning
345 }
346 
347 
348 }
349 }
350 }