Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FullatomDisulfidePotential.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/disulfides/FullatomDisulfidePotential.cc
11 /// @brief Fullatom Disulfide potential class definition
12 /// @author Bill Schief
13 /// @author blindly ported by Andrew Leaver-Fay
14 /// @author rewritten by Robert Vernon
15 
16 // Unit Headers
18 
19 // Package Headers
21 // AUTO-REMOVED #include <core/scoring/EnergyMap.hh>
24 // AUTO-REMOVED #include <core/scoring/constraints/CircularHarmonicFunc.hh>
28 #include <basic/database/open.hh>
29 
30 // Project Headers
31 // AUTO-REMOVED #include <core/pose/Pose.hh>
32 
33 // Utility Headers
34 #include <numeric/xyz.functions.hh>
35 #include <utility/exit.hh>
36 
37 // Numeric headers
38 #include <numeric/constants.hh>
39 #include <numeric/interpolation/Histogram.hh>
40 
41 #include <basic/Tracer.hh>
42 
43 #include <utility/vector1.hh>
44 
45 
46 using basic::T;
47 using basic::Error;
48 using basic::Warning;
49 
50 static basic::Tracer TR("core.scoring.disulfides.FullatomDisulfidePotential");
51 
52 namespace core {
53 namespace scoring {
54 namespace disulfides {
55 
56 using namespace core;
57 
58 //-----------------------------------------
59 // physical parameters of disulfide bonds
60 //-----------------------------------------
61 //
62 // (Computed from disulfide containing proteins in the 2008 Vall database)
63 //
64 // CB--SG--SG angle (gaussian)
65 // CBSGSG MEAN: 1.819120 SDEV: 0.104496
66 //
67 // CB--SG--SG--CB dihedral angle (bimodal gaussian)
68 // posCBSGSGCB MEAN: 1.641427 SDEV: 0.247741
69 // negCBSGSGCB MEAN: -1.517302 SDEV: 0.203992
70 //
71 // CA--CB--SG--SG dihedral angles (coarse bimodal gaussian)
72 // posCACBSGSG MEAN: 1.709486 SDEV: 0.660339
73 // negCACBSGSG MEAN: -1.471579 SDEV: 0.604909
74 //
75 // Notes:
76 // CBSGSG fits well to a gaussian curve
77 //
78 // CBSGSGCB is sharply bimodal across a ~180 degree angle difference
79 // with a negative angle peak that's ~24% larger than the positive angle peak.
80 // We may actually want to upweight the larger peak, but the 'true difference' between
81 // the peaks correlates with a ton of other angles and energies so for now they can compete equally
82 //
83 // CACBSGSG is coarsely bimodal and not a true gaussian.
84 // There are peaks ~140 degrees removed from each other on either side of zero,
85 // but the two regions between the peaks differ in behavior
86 // (specifically: spanning zero is forbidden, spanning -180/180 is allowed)
87 // For now the score ignores that and treats them as two gaussians with large standard deviations.
88 //
89 //
90 // These angles are specific to the following functions:
91 //
92 // CACBSGSG Dihedral = cbsg_dihedral_func_( new CBSG_Dihedral_Func ) = dslf_ss_dih
93 // CBSGSGCB Dihedral = sgsg_dihedral_func_( new SGSG_Dihedral_Func ) = dslf_ca_dih
94 // CBSGSG Aangle = cb_angle_func_( new CB_Angle_Func ) = dslf_cs_ang
95 //
96 // SG--SG Distances are done by the following rosetta++ antique, which uses a fitted histogram
97 //
98 // sg_dist_func_( new SG_Dist_Func )
99 //
100 // -Robert Vernon (March 2010)
101 
102 
103 
104 //
105 // core::Real const ideal_ss_dist_in_disulfide = { 2.02 };
106 // // mean sulfur-sulfur distance in natives // angstroms
107 //
108 // core::Real const disulf_ss_dist_stdev = { 0.35 };
109 // // standard dev. of s-s dist in natives // degrees 0.35
110 //
111 // core::Real const ideal_cs_angle_in_disulfide = { 103.4 };
112 // // mean cbeta-sulfur-sulfur angle in natives // degrees
113 //
114 // core::Real const disulf_cs_angle_stdev = { 5.0 };
115 // // standard dev. of cbeta-s-s angle in natives // degrees 2.6
116 //
117 // core::Real const mean_pos_dihedral_in_disulf = { 87.9 };
118 // // mean positive cbeta-sulfur-sulfur-cbeta dihedral angle // degrees
119 //
120 // core::Real const disulf_pos_dihedral_stdev = { 21.8 };
121 // // standard dev. of pos. dihedral angle in natives // degrees
122 //
123 // core::Real const mean_pos_dihedral_gauss1 = { 87.4 };
124 // // mean positive cbeta-sulfur-sulfur-cbeta dihedral angle // degrees
125 //
126 // core::Real const stdev_pos_dihedral_gauss1 = { 20.9 };
127 // // standard dev. of pos. dihedral angle in natives // degrees
128 //
129 // core::Real const mean_pos_dihedral_gauss2 = { 95.6 };
130 // // mean positive cbeta-sulfur-sulfur-cbeta dihedral angle // degrees
131 //
132 // core::Real const stdev_pos_dihedral_gauss2 = { 3.0 };
133 // // standard dev. of pos. dihedral angle in natives // degrees
134 //
135 // core::Real const mean_neg_dihedral_in_disulf = { -86.2 };
136 // // mean negative cbeta-sulfur-sulfur-cbeta dihedral angle // degrees
137 //
138 // core::Real const disulf_neg_dihedral_stdev = { 11.1 };
139 // // standard dev. of neg. dihedral angle in natives // degrees
140 //
141 // core::Real const ideal_ca_dihedral_in_disulf = { 74.0 };
142 // // ideal calpha-cbeta-sulfur-sulfur dihedral (abs val) // degrees
143 
144 
146  parent(),
147  disulf_ssdist_cutoff_( 3.0 ),
148  cbsg_dihedral_func_( new CBSG_Dihedral_Func ),
149  sgsg_dihedral_func_( new SGSG_Dihedral_Func ),
150  cb_angle_func_( new CB_Angle_Func ),
151  sg_dist_func_( new SG_Dist_Func )
152 {}
153 
155 
156 void
158 {
159  using namespace numeric::constants::d;
160  for (Real angle = -360.0; angle <= 360.0; angle = angle + 0.1) {
161 
162  std::cout << "ANGLE: " << angle
163  << " CBSGSG " << cb_angle_func_->func(angle*degrees_to_radians)
164  << " CBSGSGCB " << sgsg_dihedral_func_->func(angle*degrees_to_radians)
165  << " CACBSGSG " << cbsg_dihedral_func_->func(angle*degrees_to_radians)
166  << std::endl;
167  }
168 
169  for (Real distance = 0.0; distance <= 10; distance = distance + 0.01) {
170  std::cout << "DISTANCE: " << distance << " SCORE: " << sg_dist_func_->func(distance) << std::endl;
171  }
172 }
173 
174 /**
175  * @brief Calculated scores for a disulfide bond between two residues
176  *
177  * @param[in] res1 The lower residue of the disulfide
178  * @param[in] res2 The upper residue of the disulfide. Assumed to be bonded to res1
179  * @param[out] distance_score_this_disulfide A score based on S-S distance
180  * @param[out] csangles_score_this_disulfide A score based on the Cb-S angles
181  * @param[out] dihedral_score_this_disulfide A score based on the S-S dihedral
182  * @param[out] ca_dihedral_sc_this_disulf A score based on the Cb-S dihedrals
183  * @param[out] truefalse_fa_disulf True if these residues should be disulfide bonded
184  *
185  * @details Scores are interpolated from the histograms created by the
186  * farlx_*_initializer methods.
187  * The distance score has such a histogram as its core with two linear
188  * functions at either side so that the score increases to infinity
189  */
190 void
192  conformation::Residue const & res1,
193  conformation::Residue const & res2,
194  DisulfideAtomIndices const & res1_atom_indices,
195  DisulfideAtomIndices const & res2_atom_indices,
196  Energy & distance_score_this_disulfide,
197  Energy & csangles_score_this_disulfide,
198  Energy & dihedral_score_this_disulfide,
199  Energy & ca_dihedral_sc_this_disulf,
200  bool & truefalse_fa_disulf
201  ) const
202 {
203  // Allocate memory for disulf params. Values are set by get_disulfide_params
204  // dist between cys sulfurs
205  Real ssdist(-1);
206  // Cb-S-S bond angles
207  Real csang_1(-1),csang_2(-1);
208  // dihedral (torsion) angle, cbeta1-s1-s2-cbeta2
209  Real dihed(360);
210  // dihedral (torsion) angle, calpha1-cbeta1-s1-s2
211  Real disulf_ca_dihedral_angle_1(360);
212  // dihedral (torsion) angle, calpha2-cbeta2-s2-s1
213  Real disulf_ca_dihedral_angle_2(360);
214 
215  //Assume res1 and res2 are bonded and score them
216  get_disulfide_params(res1,res2,res1_atom_indices,res2_atom_indices,
217  ssdist,csang_1,csang_2,dihed,disulf_ca_dihedral_angle_1,disulf_ca_dihedral_angle_2);
218 
219  distance_score_this_disulfide = 0;
220  csangles_score_this_disulfide = 0;
221  dihedral_score_this_disulfide = 0;
222  ca_dihedral_sc_this_disulf = 0;
223  truefalse_fa_disulf = false;
224 
225  // ssdist score:
226 
227  distance_score_this_disulfide = sg_dist_func_->func(ssdist);
228 
229  // csangle score:
230 
231  //Check that csang is in the right domain
232  runtime_assert_msg( ! ( csang_1 > 180. || csang_2 > 180. ) , "Error csang > 180" );
233 
234  using namespace numeric::constants::d;
235  Energy csang_1_score = cb_angle_func_->func(csang_1*degrees_to_radians);
236  Energy csang_2_score = cb_angle_func_->func(csang_2*degrees_to_radians);
237  csangles_score_this_disulfide = (csang_1_score+csang_2_score)*0.5;
238 
239  // dihedral score:
240 
241  dihedral_score_this_disulfide = sgsg_dihedral_func_->func(dihed*degrees_to_radians);
242 
243  // ca_dihedral score: (this is just the chi_2 angle, rotation about cbeta-sulfur)
244 
245  // chi_2 of cys_1
246 
247  ca_dihedral_sc_this_disulf = cbsg_dihedral_func_->func(disulf_ca_dihedral_angle_1*degrees_to_radians);
248  ca_dihedral_sc_this_disulf += cbsg_dihedral_func_->func(disulf_ca_dihedral_angle_2*degrees_to_radians);
249  //Compensate for adding the scores together
250  ca_dihedral_sc_this_disulf *= .5 ;
251 
252 
253  //std::cout << "DUMP_CA_DIH " << disulf_ca_dihedral_angle_1 << " " << cbsg_dihedral_func_->func(disulf_ca_dihedral_angle_1*degrees_to_radians) << std::endl;
254  //std::cout << "DUMP_CA_DIH " << disulf_ca_dihedral_angle_2 << " " << cbsg_dihedral_func_->func(disulf_ca_dihedral_angle_2*degrees_to_radians) << std::endl;
255 
256  //std::cout << "DUMP_SS_DIH " << dihed << " " << sgsg_dihedral_func_->func(dihed*degrees_to_radians) << std::endl;
257 
258  //std::cout << "DUMP_ANG " << csang_1 << " " << cb_angle_func_->func(csang_1*degrees_to_radians) << std::endl;
259  // std::cout << "DUMP_ANG " << csang_2 << " " << cb_angle_func_->func(csang_2*degrees_to_radians) << std::endl;
260 
261  //std::cout << "DUMP_DIST " << ssdist << " " << sg_dist_func_->func(ssdist) << std::endl;
262 
263  // Call it a disulfide or not!
264  if ( ssdist < disulf_ssdist_cutoff_ ) {
265  truefalse_fa_disulf = true;
266  }
267 }
268 
269 
270 void
272  conformation::Residue const & res1,
273  conformation::Residue const & res2,
274  DisulfideAtomIndices const & res1_atom_indices,
275  DisulfideAtomIndices const & res2_atom_indices,
276  Size const at1,
277  EnergyMap const & weights,
278  Vector & F1,
279  Vector & F2
280 ) const
281 {
282  using namespace id;
283  using namespace constraints;
284 
285  ResiduePairXYZ respairxyz( res1, res2 );
286  Vector f1( 0.0 ), f2( 0.0 );
287  if ( res1_atom_indices.derivative_atom( at1 ) == CYS_C_ALPHA ) {
288 
289  f1 = f2 = 0;
290  DihedralConstraint dihedral_ang_cst = DihedralConstraint(
291  AtomID( at1, res1.seqpos() ),
292  AtomID( res1_atom_indices.c_beta_index(), res1.seqpos() ),
293  AtomID( res1_atom_indices.disulf_atom_index(), res1.seqpos() ),
294  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
296  dihedral_ang_cst.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
297  F1 += 0.5 * f1;
298  F2 += 0.5 * f2;
299 
300  } else if ( res1_atom_indices.derivative_atom( at1 ) == CYS_C_BETA ) {
301 
302  f1 = f2 = 0;
304  AtomID( at1, res1.seqpos() ),
305  AtomID( res1_atom_indices.disulf_atom_index(), res1.seqpos() ),
306  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
308  ang_cst.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
309  F1 += 0.5 * f1;
310  F2 += 0.5 * f2;
311 
312  f1 = f2 = 0;
313  DihedralConstraint dihedral_ang_cst = DihedralConstraint(
314  AtomID( res1_atom_indices.c_alpha_index(), res1.seqpos() ),
315  AtomID( at1, res1.seqpos() ),
316  AtomID( res1_atom_indices.disulf_atom_index(), res1.seqpos() ),
317  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
319  dihedral_ang_cst.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
320  F1 += 0.5 * f1;
321  F2 += 0.5 * f2;
322 
323  f1 = f2 = 0;
324  DihedralConstraint ss_dihedral_ang_cst = DihedralConstraint(
325  AtomID( at1, res1.seqpos() ),
326  AtomID( res1_atom_indices.disulf_atom_index(), res1.seqpos() ),
327  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
328  AtomID( res2_atom_indices.c_beta_index(), res2.seqpos() ),
330  ss_dihedral_ang_cst.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
331  F1 += f1;
332  F2 += f2;
333 
334  } else if ( res1_atom_indices.derivative_atom( at1 ) == CYS_S_GAMMA ) {
335 
336  AtomPairConstraint apc( AtomID( at1, res1.seqpos() ), AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ), sg_dist_func_, dslf_ss_dst );
337  apc.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
338  F1 += f1;
339  F2 += f2;
340 
341  f1 = f2 = 0;
342  AngleConstraint ang_cst1 = AngleConstraint(
343  AtomID( res1_atom_indices.c_beta_index(), res1.seqpos() ),
344  AtomID( at1, res1.seqpos() ),
345  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
347  ang_cst1.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
348  F1 += 0.5 * f1;
349  F2 += 0.5 * f2;
350 
351  f1 = f2 = 0;
352  AngleConstraint ang_cst2 = AngleConstraint(
353  AtomID( at1, res1.seqpos() ),
354  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
355  AtomID( res2_atom_indices.c_beta_index(), res2.seqpos() ),
357  ang_cst2.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
358  F1 += 0.5 * f1;
359  F2 += 0.5 * f2;
360 
361  f1 = f2 = 0;
362  DihedralConstraint dihedral_ang_cst1 = DihedralConstraint(
363  AtomID( res1_atom_indices.c_alpha_index(), res1.seqpos() ),
364  AtomID( res1_atom_indices.c_beta_index(), res1.seqpos() ),
365  AtomID( at1, res1.seqpos() ),
366  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
368  dihedral_ang_cst1.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
369  F1 += 0.5 * f1;
370  F2 += 0.5 * f2;
371 
372  f1 = f2 = 0;
373  DihedralConstraint dihedral_ang_cst2 = DihedralConstraint(
374  AtomID( res2.atom_index("CA"), res2.seqpos() ),
375  AtomID( res2_atom_indices.c_beta_index(), res2.seqpos() ),
376  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
377  AtomID( at1, res1.seqpos() ),
379  dihedral_ang_cst2.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
380  F1 += 0.5 * f1;
381  F2 += 0.5 * f2;
382 
383  f1 = f2 = 0;
384  DihedralConstraint ss_dihedral_ang_cst = DihedralConstraint(
385  AtomID( res1_atom_indices.c_beta_index(), res1.seqpos() ),
386  AtomID( at1, res1.seqpos() ),
387  AtomID( res2_atom_indices.disulf_atom_index(), res2.seqpos() ),
388  AtomID( res2_atom_indices.c_beta_index(), res2.seqpos() ),
390  ss_dihedral_ang_cst.fill_f1_f2( AtomID( at1, res1.seqpos() ), respairxyz, f1, f2, weights );
391  F1 += f1;
392  F2 += f2;
393 
394  }
395 }
396 
397 ///////////////////////////////////////////
398 /// Private: Methods, Data Initializers ///
399 ///////////////////////////////////////////
400 
401 
402 ////////////////////////////////////////////////////////////////////////////////
403 /// @brief Calculates several geometrical parameters of a fullatom disulfide bond
404 /// @details
405 /// given residue num for 2 cys involved in disulfide bond, returns
406 /// four quantities:
407 /// sulf-sulf dist, 2 carb-sulf bond angles, and a 4-atom dihedral angle.
408 /// Angles are returned in degrees.
409 ///
410 /// @param[in] coord1 - in - fullatom coords of cys 1
411 /// @param[in] coord2 - in - fullatom coords of cys 2
412 /// @param[out] dist_between_sulfurs - out - s1-s2 distance
413 /// @param[out] cs_bond_angle_1 - out - cb1-s1-s2 bond angle
414 /// @param[out] cs_bond_angle_2 - out - cb2-s1-s2 bond angle
415 /// @param[out] disulf_dihedral_angle - out - cb1-s1-s2-cb2 dihedral
416 /// @param[out] disulf_ca_dihedral_angle_1 - out - ca1-cb1-s1-s2 dihedral
417 /// @param[out] disulf_ca_dihedral_angle_2 - out - ca2-cb2-s2-s1 dihedral
418 ///
419 /// @author Bill Schief
420 /////////////////////////////////////////////////////////////////////////////////
421 void
423  conformation::Residue const & res1,
424  conformation::Residue const & res2,
425  DisulfideAtomIndices const & res1_atom_indices,
426  DisulfideAtomIndices const & res2_atom_indices,
427  Distance & dist_between_sulfurs, // dist between cys sulfurs
428  Real & cs_bond_angle_1,
429  Real & cs_bond_angle_2,
430  Real & disulf_dihedral_angle, // dihedral (torsion) angle, cbeta-s-s-cbeta
431  Real & disulf_ca_dihedral_angle_1,
432  // dihedral (torsion) angle, calpha1-cbeta1-s1-s2
433  Real & disulf_ca_dihedral_angle_2 // dihedral (torsion) angle, calpha2-cbeta2-s2-s1
434 ) const
435 {
436  using namespace numeric::constants::d;
437 
438  Vector calpha_1( res1.atom( res1_atom_indices.c_alpha_index() ).xyz() );
439  Vector cbeta_1 ( res1.atom( res1_atom_indices.c_beta_index( ) ).xyz() );
440  Vector sulfur_1( res1.atom( res1_atom_indices.disulf_atom_index() ).xyz() );
441  Vector calpha_2( res2.atom( res2_atom_indices.c_alpha_index() ).xyz() );
442  Vector cbeta_2 ( res2.atom( res2_atom_indices.c_beta_index( ) ).xyz() );
443  Vector sulfur_2( res2.atom( res2_atom_indices.disulf_atom_index() ).xyz() );
444 
445  dist_between_sulfurs = sulfur_1.distance( sulfur_2 );
446  cs_bond_angle_1 = angle_of( cbeta_1, sulfur_1, sulfur_2);
447  cs_bond_angle_2 = angle_of( cbeta_2, sulfur_2, sulfur_1);
448  cs_bond_angle_1 *= radians_to_degrees; // convert
449  cs_bond_angle_2 *= radians_to_degrees; // convert
450  disulf_dihedral_angle = dihedral_degrees(cbeta_1,sulfur_1,sulfur_2,cbeta_2);
451  disulf_ca_dihedral_angle_1 = dihedral_degrees(calpha_1,cbeta_1,sulfur_1,sulfur_2);
452  disulf_ca_dihedral_angle_2 = dihedral_degrees(calpha_2,cbeta_2,sulfur_2,sulfur_1);
453 }
454 
455 
456 //------------------------------------------------------------------------------
457 
459  //cbsg_pos_peak_( 86.0 ),
460  //cbsg_pos_sd_( 72.0 ),
461  //cbsg_neg_peak_( -74.0 ),
462  //cbsg_neg_sd_( 39.0 )
463 
464  //csf_cbang1a_(0.1,0.9,10,0.0),
465  //csf_cbang1b_(0.1,0.9,10,0.0)
466 
467  csf_cbang1_(0.1,0.9,10,0.0),
468  csf_cbang2_(1.35,1.1,-5,0.0),
469  csf_cbang3_(-1.25,1.5,-5,0.0)
470 {}
471 
473 
474 /// @param ang[in] Dihedral angle in radians
475 /// @note This function is not continuous across 0 or 180 degrees. This is bad,
476 /// and is only acceptable because it occurs at the maximums so we minimize
477 /// away from the discontinuity. -Spencer
478 Real
479 CBSG_Dihedral_Func::func( Real const ang ) const
480 {
481 // using namespace numeric::constants::d;
482 
483 // Real ang_deg = ang * radians_to_degrees;
484 // Real const ang_peak = ang_deg > 0.0 ? cbsg_pos_peak_ : cbsg_neg_peak_;
485 // Real const ang_sd = ang_deg > 0.0 ? cbsg_pos_sd_ : cbsg_neg_sd_;
486 // Real const delta_ang = ang_deg - ang_peak;
487 // Real const ang_frac = delta_ang / ang_sd;
488 // return -std::exp(-(ang_frac*ang_frac));
489  //return csf_cbang1a_.func(ang) + csf_cbang1b_.func(ang);
490 
491  return csf_cbang1_.func(ang) + (csf_cbang2_.func(ang))/10 + (csf_cbang3_.func(ang))/10 + 0.095;
492 }
493 
494 /// @param ang[in] Dihedral angle in radians
495 Real
496 CBSG_Dihedral_Func::dfunc( Real const ang ) const {
497 // using namespace numeric::constants::d;
498 
499 // Real ang_deg = ang * radians_to_degrees;
500 // Real const ang_peak = ang_deg > 0.0 ? cbsg_pos_peak_ : cbsg_neg_peak_;
501 // Real const ang_sd = ang_deg > 0.0 ? cbsg_pos_sd_ : cbsg_neg_sd_;
502 // Real const delta_ang = ang_deg - ang_peak;
503 // Real const ang_frac = delta_ang / ang_sd;
504 
505 // return radians_to_degrees * std::exp(-(ang_frac*ang_frac)) * ( 2*ang_deg - 2*ang_peak ) / ( ang_sd * ang_sd );
506  return csf_cbang1_.dfunc(ang) + (csf_cbang2_.dfunc(ang))/10 + (csf_cbang3_.dfunc(ang))/10;
507 }
508 
509 ///////////////
510 
511 // CB--SG--SG--CB dihedral angle (bimodal gaussian)
512 // posCBSGSGCB MEAN: 1.641427 SDEV: 0.247741
513 // negCBSGSGCB MEAN: -1.517302 SDEV: 0.203992
514 
516  //csf_cbang1a_( 1.641426, 0.25, -2, 0.0),
517  //csf_cbang2a_( 1.641426, 0.7, -40, 0.0),
518  //csf_cbang1b_(-1.517302, 0.25, -2, 0.0),
519  //csf_cbang2b_(-1.517302, 0.7, -40, 0.0)
520 csf_cbang1a_( 1.641426, 0.25, -2.3, 0.0),
521 csf_cbang2a_( 1.641426, 0.9, -20, 0.0),
522 csf_cbang1b_(-1.517302, 0.25, -2.3, 0.0),
523 csf_cbang2b_(-1.517302, 0.9, -20, 0.0)
524  {}
525 
527 
528 /// @param ang[in] Dihedral angle in radians
529 Real
531 {
532 // using namespace numeric::constants::d;
533 
534 // Real ang_deg = ang * radians_to_degrees;
535 // Real score(0);
536 // fa_sgsg_dihedral_scores()->interpolate(ang_deg,score);
537 // return score;
538 
539  //std::cout << "SGSG " << ang << " " << csf_cbang1a_.func(ang) << " " << csf_cbang2a_.func(ang) << " " << csf_cbang1b_.func(ang) << " " << csf_cbang2b_.func(ang) << " " << 2*csf_cbang1a_.func(ang) + csf_cbang2a_.func(ang) + 2*csf_cbang1b_.func(ang) + csf_cbang2b_.func(ang) << std::endl;
540 
541  //return 2*csf_cbang1a_.func(ang) + csf_cbang2a_.func(ang) + 2*csf_cbang1b_.func(ang) + csf_cbang2b_.func(ang) + 0.6602761;
542 
543  //return 10*csf_cbang1a_.func(ang) + csf_cbang2a_.func(ang) + 10*csf_cbang1b_.func(ang) + csf_cbang2b_.func(ang);
544  return 25*csf_cbang1a_.func(ang) + csf_cbang2a_.func(ang) + 25*csf_cbang1b_.func(ang) + csf_cbang2b_.func(ang) + 4.58;
545 }
546 
547 /// @param ang[in] Dihedral angle in radians
548 Real
549 SGSG_Dihedral_Func::dfunc( Real const ang ) const
550 {
551 // using namespace numeric::constants::d;
552 
553 // Real ang_deg = ang * radians_to_degrees;
554 // Real deriv;
555 // fa_sgsg_dihedral_scores()->derivative(ang_deg, deriv); // units/degree
556 // return deriv*radians_to_degrees; // return units/radian
557 
558 // return 10*csf_cbang1a_.dfunc(ang) + csf_cbang2a_.dfunc(ang) + 10*csf_cbang1b_.dfunc(ang) + csf_cbang2b_.dfunc(ang);
559  return 25*csf_cbang1a_.dfunc(ang) + csf_cbang2a_.dfunc(ang) + 25*csf_cbang1b_.dfunc(ang) + csf_cbang2b_.dfunc(ang);
560 }
561 
562 /// Access the histogram for this Func (in degrees)
563 // numeric::interpolation::HistogramCOP<core::Real,core::Real>::Type
564 // SGSG_Dihedral_Func::fa_sgsg_dihedral_scores()
565 // {
566 // using namespace numeric::interpolation;
567 // static HistogramCOP<Real,Real>::Type scores(0);
568 // if(scores == 0) {
569 // utility::io::izstream scores_stream;
570 // basic::database::open( scores_stream, "scoring/score_functions/disulfides/fa_CbSSCb_dihedral_score");
571 // scores = new Histogram<Real,Real>( scores_stream() );
572 // scores_stream.close();
573 // }
574 // return scores;
575 // }
576 
577 ///////////////
578 
580  //chf_cbang_( 1.819120, 0.104496 )
581  //chf_cbang_( 1.819120, 0.4 ),
582 
583  //onno
584  //csf_cbang_( 1.819120, 0.1, -10, 0.0)
585  //ommo
586 
587  //CHECKIN
588  //csf_cbang_( 1.819120, 0.104496, -200, 0.0)
589 
590  csf_cbang1_( 1.819120, 0.208961, -200, 0.0),
591  csf_cbang2_( 1.819120, 0.208961, -50, 0.0)
592 
593 //csf_cbang1_( 1.819120, 0.3, -2, 0.0),
594  //csf_cbang2_( 1.819120, 0.1, -10, 0.0)
595  //2c
596  //csf_cbang1_( 1.819120, 0.104496, -7, 0.0),
597  //csf_cbang2_( 1.819120, 0.104496, -0.5, 0.0)
598  //csf_cbang1_( 1.819120, 0.104496, -200 ),
599  //csf_cbang2_( 1.819120, 0.2, -20 ),
600  //csf_cbang3_( 1.819120, 0.2, -5, 0.0)
601 {}
602 
604 
605 /// @param csang[in] Dihedral angle in radians
606 Real
607 CB_Angle_Func::func( Real const ang) const
608 {
609 // using namespace numeric::constants::d;
610 
611 // Real ang_deg = ang*radians_to_degrees;
612 // //Check that csang is in the right domain
613 // runtime_assert_msg( 0 <= ang_deg && ang_deg <= 180., "Error csang > 180" );
614 
615 // Real score(0);
616 // // Will be out of the histogram's range sometimes, but we like the default
617 // // behavior of using the boundary scores for extreme ang_deg
618 // CB_Angle_Func::fa_csang_scores()->interpolate(ang_deg,score);
619 // return score;
620 
621  //std::cout << "CBANG " << ang << " " << csf_cbang1_.func(ang) << " " << csf_cbang2_.func(ang) << " " << csf_cbang3_.func(ang) << " " << (0.2*chf_cbang_.func(ang)) + csf_cbang1_.func(ang) + csf_cbang2_.func(ang) + csf_cbang3_.func(ang) << std::endl;
622 
623  //return (0.2*chf_cbang_.func(ang)) + csf_cbang1_.func(ang) + csf_cbang2_.func(ang) + csf_cbang3_.func(ang);
624 
625  //std::cout << "CBANG " << ang << " " << csf_cbang1_.func(ang) << " " << csf_cbang2_.func(ang) << " " << (50*csf_cbang1_.func(ang)) + (1000.0*csf_cbang2_.func(ang)) << std::endl;
626 
627 
628  //return (csf_cbang1_.func(ang)) + (20.0*csf_cbang2_.func(ang)) - 0.393803696;
629  //return (csf_cbang1_.func(ang)) + (csf_cbang2_.func(ang)) - 0.393803696;
630  //return (csf_cbang1_.func(ang)) + (csf_cbang2_.func(ang)) - 0.393803696;
631 
632  //onno
633  //return 10*(csf_cbang_.func(ang)) + std::abs(ang - 1.819120) + 2.44918662;
634 
635  //CHECKIN
636  //return 2*(csf_cbang_.func(ang)) + std::abs(ang - 1.819120) + 2.0;
637 
638  return (csf_cbang1_.func(ang)) + (csf_cbang2_.func(ang)) + 4*(std::abs(ang - 1.819120)) + 2.0;
639 }
640 
641 /// @param ang[in] Dihedral angle in radians
642 Real
643 CB_Angle_Func::dfunc( Real const ang ) const
644 {
645 // using namespace numeric::constants::d;
646 // Real ang_deg = ang * radians_to_degrees;
647 // //std::cout << "ang_deg: " << ang_deg << std::endl;
648 
649 // Real d_csang_score_dang( 0.0 );
650 // // Should be zero when ang_deg is not in the hist range
651 // CB_Angle_Func::fa_csang_scores()->derivative(ang_deg,d_csang_score_dang);
652 // return d_csang_score_dang * radians_to_degrees;
653 // return (0.2*chf_cbang_.dfunc(ang)) + csf_cbang1_.dfunc(ang) + csf_cbang2_.dfunc(ang) + csf_cbang3_.dfunc(ang);
654 
655  //return (csf_cbang1_.dfunc(ang)) + (20.0*csf_cbang2_.dfunc(ang));
656 
657  //onno
658  //return 10*(csf_cbang_.dfunc(ang)) + (ang - 1.819120)/std::abs(ang - 1.819120);
659 
660  //CHECKIN
661  //return 2*(csf_cbang_.dfunc(ang)) + (ang - 1.819120)/std::abs(ang - 1.819120);
662 
663  return (csf_cbang1_.dfunc(ang)) + (csf_cbang2_.dfunc(ang)) + 4*((ang - 1.819120)/std::abs(ang - 1.819120));
664 }
665 
666 /// Access the histogram for this Func (in degrees)
667 // numeric::interpolation::HistogramCOP<core::Real,core::Real>::Type
668 // CB_Angle_Func::fa_csang_scores()
669 // {
670 // using namespace numeric::interpolation;
671 // static HistogramCOP<Real,Real>::Type scores(0);
672 // if(scores == 0) {
673 // utility::io::izstream scores_stream;
674 // basic::database::open( scores_stream, "scoring/score_functions/disulfides/fa_CaCbS_angle_score");
675 // scores = new Histogram<Real,Real>( scores_stream() );
676 // scores_stream.close();
677 // }
678 // return scores;
679 // }
680 
681 //////////////////
682 
684 
686 
687 /// @param ssdist[in] S-S distance, in Angstroms
688 Real
689 SG_Dist_Func::func( Real const ssdist ) const
690 {
691  Real distance_score_this_disulfide( 0.0 );
692 
693  numeric::interpolation::HistogramCOP<Real,Real>::Type scores =
695  Real ssdist_min_range( scores->minimum() );
696  Real ssdist_max_range( scores->maximum() );
697 
698  if ( ssdist >= ssdist_max_range ) { // max tail
699  Real ssdist_score_at_max(0);
700  scores->interpolate(ssdist_max_range,ssdist_score_at_max);
701  Real ssdist_max_tail_slope(0);
702  scores->derivative(ssdist_max_range-scores->step_size(),ssdist_max_tail_slope);
703 
704  distance_score_this_disulfide = ssdist_score_at_max + ( ssdist - ssdist_max_range ) * ssdist_max_tail_slope;
705  } else if ( ssdist <= ssdist_min_range ) { // min tail
706  Real ssdist_score_at_min(0);
707  scores->interpolate(ssdist_min_range,ssdist_score_at_min);
708  Real ssdist_min_tail_slope(0);
709  scores->derivative(ssdist_min_range,ssdist_min_tail_slope);
710 
711  distance_score_this_disulfide = ssdist_score_at_min + ( ssdist - ssdist_min_range ) * ssdist_min_tail_slope;
712  } else {
713  SG_Dist_Func::fa_ssdist_scores()->interpolate(ssdist, distance_score_this_disulfide);
714  }
715 
716  return distance_score_this_disulfide;
717 }
718 
719 /// @param ssdist[in] S-S distance, in Angstroms
720 Real
721 SG_Dist_Func::dfunc( Real const ssdist ) const {
722  Real d_distance_score_this_disulfide_ddis( 0.0 );
723 
724  numeric::interpolation::HistogramCOP<Real,Real>::Type scores =
726  Real ssdist_min_range( scores->minimum() );
727  Real ssdist_max_range( scores->maximum() );
728  if ( ssdist >= ssdist_max_range ) { // max tail
729  scores->derivative(ssdist_max_range-scores->step_size(),d_distance_score_this_disulfide_ddis);
730  } else if ( ssdist <= ssdist_min_range ) { // min tail
731  scores->derivative(ssdist_min_range,d_distance_score_this_disulfide_ddis);
732  } else {
733  SG_Dist_Func::fa_ssdist_scores()->derivative(ssdist, d_distance_score_this_disulfide_ddis);
734  }
735  return d_distance_score_this_disulfide_ddis;
736 }
737 
738 /// Access the histogram for this Func
739 numeric::interpolation::HistogramCOP<core::Real,core::Real>::Type
741 {
742  using namespace numeric::interpolation;
743  static HistogramCOP<Real,Real>::Type scores(0);
744  if(scores == 0) {
745  utility::io::izstream scores_stream;
746  basic::database::open( scores_stream, "scoring/score_functions/disulfides/fa_SS_distance_score");
747  scores = new Histogram<Real,Real>( scores_stream() );
748  scores_stream.close();
749  }
750  return scores;
751 }
752 
753 }
754 }
755 }
756