Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FACTSPotential.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:f;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 // (c) Copyright Rosetta Commons Member Institutions.
4 // (c) This file is part of the Rosetta software suite and is made available under license.
5 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
6 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
7 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
8 
9 // @file: core/scoring/facts/FACTSPotential.hh
10 // @brief: Header-file for 3 class declartions for the FACTS algorithm
11 // FACTS: Fast Analytical Continuum Treatment of Solvation by URS HABERTHUR and AMEDEO CAFLISCH
12 // @author: Massih Khorvash (massih.khorvash@gmail.com)
13 // @author: Hahnbeom Park
14 
15 #ifndef INCLUDED_core_scoring_FACTSPotential_hh
16 #define INCLUDED_core_scoring_FACTSPotential_hh
17 
18 // Unit headers
20 
21 // Project headers
22 #include <core/types.hh>
24 #include <core/pose/Pose.fwd.hh>
25 //#include <core/pack/task/PackerTask.fwd.hh>
27 #include <core/id/AtomID.fwd.hh>
30 
31 #include <basic/datacache/CacheableData.hh>
32 
33 // Utility headers
34 #include <utility/vector1.hh>
35 #include <utility/pointer/owning_ptr.hh>
36 #include <utility/pointer/ReferenceCount.hh>
37 #include <iostream>
38 
39 using namespace std;
40 
41 namespace core {
42 namespace scoring {
43 
44  /**************************************************************************************************/
45  /* */
46  /* @brief: The FACTSResidueInfo class provides all the functions, constants and parameters */
47  /* for different atoms, which are required to calculate the solvation free energy of */
48  /* of a molecule embedded in a continuum solvent using FACTS method */
49  /* */
50  /**************************************************************************************************/
51 
52  // Structure for storing Self-Neighbor(not GB-Neighbor) info
53  struct SelfNeighInfo {
57  };
58 
59  //This class provides the information that is specific for each atoms of a residue in FACTS algorithm
60  // (such as van der waals radii, Ai_i, Bi_i, lookup_on_radius_, esolvE_i, sasa, ...)
62 
63  public:
65 
66  public:
67  //The function clone creates an exact copy of the FACTSResidueInfo object.
68  //It returns a pointer that points to the new object
70  return new FACTSResidueInfo( *this );
71  }
72 
73  //The constructor with a residue as its input parameter.
74  FACTSResidueInfo(Residue const & rsd){
75  initialize(rsd);
76  }
77 
78  //This function initializes all the private and public variables of the class FACTSResidueInfo
79  void initialize(Residue const & rsd);
80 
81  // Accessors
82  Size natoms() const{ return natoms_; }
83  Real q( Size const atm ) const{ return q_[ atm ]; }
84 
85  Real a0(Size const atm) const{ return a0_[atm]; }
86  Real a1(Size const atm) const{ return a1_[atm]; }
87  Real a2(Size const atm) const{ return a2_[atm]; }
88  Real a3(Size const atm) const{ return a3_[atm]; }
89  Real b1(Size const atm) const{ return b1_[atm]; }
90  Real b2(Size const atm) const{ return b2_[atm]; }
91  Real c0(Size const atm) const{ return c0_[atm]; }
92  Real c1(Size const atm) const{ return c1_[atm]; }
93  Real c2(Size const atm) const{ return c2_[atm]; }
94  Real c3(Size const atm) const{ return c3_[atm]; }
95  Real d1(Size const atm) const{ return d1_[atm]; }
96  Real d2(Size const atm) const{ return d2_[atm]; }
97 
98  //Real COradius(int atm_look_up_indx) const{ return COradius_[atm_look_up_indx]; }
99  //Real volume(Size const atm_look_up_indx) const{ return volume_[atm_look_up_indx]; }
100  Real COradius(Size const atm ) const{ return COradius_[atm]; }
101  Real volume(Size const atm ) const{ return volume_[atm]; }
102  bool flag_for_calculation( Size const atm ) const { return flag_for_calculation_[atm]; }
103  bool not_using( Size const atm ) const {return not_using_[atm]; }
104 
105  Real Ai( Size const atm ) const { return Ai_[atm]; }
106  Real Bi( Size const atm ) const { return Bi_[atm]; }
107  Real Ci( Size const atm ) const { return Ci_[atm]; }
108  Real Di( Size const atm ) const { return Di_[atm]; }
109  Real Ei( Size const atm ) const { return Ei_[atm]; }
110 
111  utility::vector1< Real > Ai() const { return Ai_; }
112  utility::vector1< Vector > nmtr() const { return nmtr_; }
113  utility::vector1< Real > dnmtr() const { return dnmtr_; }
114 
115  Real esolvE( Size const atm ) const { return esolvE_[atm]; }
116  Vector nmtr( Size const atm ) const { return nmtr_[atm]; }
117  Real dnmtr( Size const atm ) const { return dnmtr_[atm]; }
118  Real sasa( Size const atm ) const { return sasa_[atm]; }
119  Real alpha( Size const atm ) const { return alpha_[atm]; }
120  Real BR( Size const atm ) const { return BR_[atm]; }
121  Real GBpair( Size const res ) const { return GBpair_[res]; }
122 
123  SelfNeighInfo selfneigh( Size const atm ) const { return selfneigh_[atm]; }
124  Real dG_dCi( Size const atm ) const { return dG_dCi_[atm]; }
125  Real dSA_dDi( Size const atm ) const { return dSA_dDi_[atm]; }
126  Real dE_dBR( Size const atm ) const { return dE_dBR_[atm]; }
127  Vector dE_drij2( Size const atm ) const { return dE_drij2_[atm]; }
128  Vector polarF2d( Size const atm ) const { return polarF2d_[atm]; }
129  Vector polarF2BR( Size const atm ) const { return polarF2BR_[atm]; }
130  Vector nonpolarF2( Size const atm ) const { return nonpolarF2_[atm]; }
131 
132  private: //helper functions
133  //This function initializes the value of natoms to the number of atoms in the residue
134  void initialize_number_of_atoms( Residue const & rsd );
135 
136  //This function initializes the vector q to charges of each atom
137  void initialize_charge( Residue const & rsd );
138 
139  void initialize_parameters( Residue const & rsd );
140 
141  //This function initializes the constants used for calculating the energy
142  void initialize_constants();
143 
144  void modify_volume( conformation::Residue const & rsd, Size i );
145 
146  public:
147  const static Size MAXNEIGH = 300;
148  //const static Real max_selfdcut2 = 100.0;
149 
150  utility::vector1<Real> esolvE_; // DeltaGi (equation 7 on page 704 of FACTS paper)
151  utility::vector1<Real> sasa_; // atomic SASA (equation 11 on page 706 of FACTS paper)
152  utility::vector1<Real> Ai_; // Ai (equation 3 on page 704 of FACTS paper)
153  utility::vector1<Real> Bi_; // Bi (equation 4 on page 704 of FACTS paper)
154  utility::vector1<Real> Ci_; // Ci (equation 6 on page 704 of FACTS paper)
155  utility::vector1<Real> Di_; // Di (equation 10 on page 706 of FACTS paper)
157  utility::vector1<Real> alpha_;// Gamma used in equation 12 on page 706 of FACTS paper
158  utility::vector1<bool> flag_for_calculation_;// this variable is used in res_res_burial and
159  // evaluate_all_self_electrostatic_energies_and_SASA
160  utility::vector1<Vector> nmtr_; // nmtr of Bi (equation 4 on page 704 of FACTS paper)
161  utility::vector1<Real> dnmtr_; // dnmtr of Bi (equation 4 on page 704 of FACTS paper)
162  utility::vector1<Real> BR_; // effective Born Radius
164 
173 
174  private: //variables and vectors
175 
178  utility::vector1<Real> q_; //list of charges of each atom
179  utility::vector1<Real> COradius_; //list of cut off radius (R^sphere_i) for calculating theta for self-energy
180  utility::vector1<Real> volume_; //The volume for atoms with native van der waals
181 
182  //For evaluating Ci for each atom (see equation 6 on page 704 of FACTS paper)
185 
186  //For evaluating esolvE_i for each atom (see equation 7 on page 704 of FACTS paper)
191 
192  //The constant for evaluating Di for each atom (see equation 10 on page 706 of FACTS paper)
195 
196  //The constant for evaluating sasa for each atom (see equation 11 on page 706 of FACTS paper)
201 
202  };
203 
204  ////////////////////////////////////////////////////////////////////////////////////////////////////
205  class FACTSPoseInfo : public basic::datacache::CacheableData {
206 
207  public:
210 
211  public:
212 
214 
215  FACTSPoseInfo( FACTSPoseInfo const & src );
216 
217  basic::datacache::CacheableDataOP
218  clone() const
219  {
220  return new FACTSPoseInfo( *this );
221  }
222 
223  Size size() const
224  {
225  return residue_info_.size();
226  }
227 
229  {
230  return *residue_info_[i];
231  }
232 
233  FACTSResidueInfo const & residue_info( Size const i ) const
234  {
235  return *residue_info_[i];
236  }
237 
238  bool being_packed( Size const seqpos ) const
239  {
240  return being_packed_[ seqpos ];
241  }
242 
243  void set_placeholder( Size const i, ResidueOP rsd, FACTSResidueInfoOP info );
244 
245  FACTSResidueInfo const & placeholder_info( Size const seqpos ) const
246  {
247  assert( placeholder_info_[ seqpos ] );
248  return *placeholder_info_[ seqpos ];
249  }
250 
251  Residue const & placeholder_residue( Size const seqpos ) const
252  {
253  assert( placeholder_residue_[ seqpos ] );
254  return *placeholder_residue_[ seqpos ];
255  }
256 
257  void initialize( pose::Pose const & pose );
258 
259  void set_repack_list( utility::vector1< bool > const & repacking_residues );
260 
261  public:
262  utility::vector1< FACTSResidueInfoOP > residue_info_; // these are allocated in initialize
265  utility::vector1< bool > being_packed_; // stores info from the packertask when setup_for_packing calls set_repack_list
266  };
267 
268  ////////////////////////////////////////////////////////////////////////////////////////////////////
269  class FACTSRotamerSetInfo : public basic::datacache::CacheableData {
270 
271  public:
275 
276  public:
277 
278  ///
280  CacheableData()
281  {
282  residue_info_.resize( src.size() );
283  for ( Size i=1; i<= src.size(); ++i ) {
284  residue_info_[i] = src.residue_info_[i]->clone();
285  }
286  }
287 
288  basic::datacache::CacheableDataOP clone() const
289  {
290  return new FACTSRotamerSetInfo( *this );
291  }
292 
293  Size size() const
294  {
295  return residue_info_.size();
296  }
297 
299  {
300  return *residue_info_[i];
301  }
302 
303  FACTSResidueInfo const & residue_info( Size const i ) const
304  {
305  return *residue_info_[i];
306  }
307 
308  FACTSRotamerSetInfo( RotamerSet const & rotamer_set )
309  {
310  initialize( rotamer_set );
311  }
312 
313  /// dont forget to 0 the born_radii
314  void initialize( RotamerSet const & rotamer_set );
315 
316  private:
318  };
319 
320  /**************************************************************************************************/
321  /* */
322  /* @brief: The FACTSPotential class provides all the functions, constants, and parameters */
323  /* common to all atoms required to calculate the free energy of solvation of a */
324  /* (macro)molecule embedded in a continuum solvent using FACTS method */
325  /* */
326  /**************************************************************************************************/
327 
329 
330  public:
332 
333  public:
334 
335  FACTSPotential();
336 
337  void setup_for_scoring(pose::Pose & pose) const;
338 
339  void setup_for_derivatives(pose::Pose & pose) const;
340 
341  void setup_for_packing(
342  pose::Pose & pose,
343  utility::vector1< bool > const & repacking_residues ) const;
344  // Undefinded, commenting out to fix PyRosetta build void setup_for_packing(pose::Pose & pose, pack::task::PackerTask const & task ) const;
345 
346  void update_residue_for_packing( pose::Pose & pose,
347  Size const seqpos
348  ) const;
349 
350  void get_rotamers_born_radii(pose::Pose const & pose, conformation::RotamerSetBase & rotamer_set) const;
351 
352  Real evaluate_polar_energy( Residue const & rsd1,
353  FACTSResidueInfo const & facts1,
354  Residue const & rsd2
355  ) const;
356 
357  Real evaluate_nonpolar_energy( Residue const & rsd1,
358  FACTSResidueInfo const & facts1,
359  Residue const & rsd2
360  ) const;
361 
362  void evaluate_context_change_for_packing(
363  Residue const & rsd1_ref,
364  Residue const & rsd1,
365  FACTSResidueInfo const & facts1,
366  Residue const & rsd2_ref,
367  Residue const & rsd2,
368  FACTSResidueInfo const & facts2,
369  utility::vector1< Real > & dBRi1,
370  utility::vector1< Real > & dBRi2,
371  utility::vector1< Real > & dSAi1,
373  ) const;
374 
375  Real evaluate_polar_otf_energy(Residue const & rsd1,
376  FACTSResidueInfo const & facts1,
377  Residue const & rsd2,
378  FACTSResidueInfo const & facts2,
379  utility::vector1< Real > const & dBRi1,
380  utility::vector1< Real > const & dBRi2,
381  bool do_correction
382  ) const;
383 
384  void eval_atom_polar_derivative(
385  id::AtomID const & id,
386  Real const weight,
387  pose::Pose const & pose,
388  kinematics::DomainMap const & domain_map,
389  bool const exclude_DNA_DNA,
390  Vector & F1,
391  Vector & F2
392  ) const;
393 
394  void eval_atom_nonpolar_derivative(
395  id::AtomID const & id,
396  Real const weight,
397  pose::Pose const & pose,
398  kinematics::DomainMap const & domain_map,
399  bool const exclude_DNA_DNA,
400  Vector & F1,
401  Vector & F2
402  ) const;
403 
404  void get_single_rotamer_born_radii(
405  Residue const & rsd1,
406  pose::Pose const & pose,
407  FACTSPoseInfo const & gb_info,
408  FACTSResidueInfo & gb1
409  ) const;
410 
411  Real polar_energy_pack_corrector(
412  Residue const & ref_rsd,
413  Residue const & rsd,
414  FACTSResidueInfo const & facts_info
415  ) const;
416 
417  private:
418  void res_res_burial(
419  Residue const & rsd1,
420  FACTSResidueInfo & gb1,
421  Residue const & rsd2,
422  FACTSResidueInfo const & gb2
423  ) const;
424 
425  void res_res_burial_for_scoring(
426  Residue const & rsd1,
427  FACTSResidueInfo & gb1,
428  Residue const & rsd2,
429  FACTSResidueInfo & gb2
430  ) const;
431 
432  void get_self_terms(
433  FACTSResidueInfo & facts1
434  ) const;
435 
436  void calculate_GBpair_apprx(
437  Residue const & rsd1,
438  Residue const & rsd2,
439  FACTSResidueInfo & facts1,
440  FACTSResidueInfo & facts2
441  ) const;
442 
443  void calculate_GBpair_exact(
444  Residue const & rsd1,
445  Residue const & rsd2,
446  FACTSResidueInfo & facts1,
447  FACTSResidueInfo & facts2
448  ) const;
449 
450  void get_template_born_radii(
451  pose::Pose const & pose,
452  FACTSPoseInfo & gb_info
453  ) const;
454 
455  void build_placeholders(
456  pose::Pose const & pose,
457  FACTSPoseInfo & facts_info
458  ) const;
459 
460  // Accessors
461  Real Tau() const{ return Tau_; }
462  Real Kappa() const { return Kappa_; }
463  Real MultiplicitiveFactor() const { return MultiplicitiveFactor_; };
464  Real GBPair_cut() const { return GBpair_cut_; };
465 
466  private: //list of private variables and parameters for the FACTS method common to all atoms
467 
468  //This variable contains the solvation free energy of the macromolecule
469  //which is the sum of FACTSResidueInfo::sasa and FACTSResidueInfo::esolvE_i
470  //solvation_free_energy corresponds to deltaG(FACTS) = deltaG(el,FACTS) + Gamma * sigma(Si(FACTS)) i.e. equation 12 on page 706 of FACTS paper
471 
472  bool options_registered_;
477  bool do_apprx;
478 
479  // Below are not being used
480  Real cut_off_born_radius_; //The cut off used for calculating born radius
485  Real dummy_distance_; // also implicitly defined by the gb placeholder params file
486 
487  };
488 } // scoring
489 } // core
490 
491 #endif