Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CoarseEtableEnergy.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/CoarseEtableEnergy.hh
11 /// @brief Energy method for coarse grained residue representation class header
12 /// @author Oliver
13 
14 
15 // Unit headers
18 
19 // Package headers
28 
29 // Project headers
31 #include <core/pose/Pose.hh>
32 
33 #include <ObjexxFCL/FArray3D.hh>
34 
35 //Auto Headers
42 
43 
44 namespace core {
45 namespace scoring {
46 namespace etable {
47 
48 
49 /// @details This must return a fresh instance of the CoarseEtableEnergy class,
50 /// never an instance already in use
53  methods::EnergyMethodOptions const & options
54 ) const {
55  return new CoarseEtableEnergy( *( ScoringManager::get_instance()->etable( options.etable_type() )),
56  options,
58 }
59 
62  ScoreTypes sts;
63  sts.push_back( coarse_fa_atr );
64  sts.push_back( coarse_fa_rep );
65  sts.push_back( coarse_fa_sol );
66  return sts;
67 }
68 
69 
70 ///
71 
73  Etable const & etable_in,
74  methods::EnergyMethodOptions const & options,
75  coarse::CoarseEtableCAP coarse_etable_in
76 ) :
79  etable_in, options,
81  coarse_etable_( coarse_etable_in )
82 {
83  if ( coarse_etable_in ) {
84  coarse_etable_in->check_atomset_compatibility( etable_in.atom_set() );
85  } else {
86  utility_exit_with_message("coarse etable not present ");
87  }
88 }
89 
90 
91 void
93  Size const res1,
94  Size const res2,
95  pose::Pose const & pose
96 ) const {
97  coarse_etable_->set_residue_pair( pose.residue( res1 ), pose.residue( res2 ) );
98 }
99 
100 
101 
102 void
104  pose::Pose const & pose,
105  scoring::ScoreFunction const &
106 ) const {
107  if (pose.total_residue()) {
108  if ( pose.residue(1).type().atom_type_set_ptr() != coarse_etable_->atom_set() ) {
109  utility_exit_with_message( "Illegal attempt to score with non-identical atom set between pose and etable " );
110  }
111  }
112 }
113 
114 
115 /*
116  //clone
117  EnergyMethodOP
118  clone() const {
119  return new CoarseEtableEnergy( *this );
120  }
121 
122 
123  void
124  derived_prepare_for_residue_pair(
125  Size const res1,
126  Size const res2,
127  pose::Pose const & pose
128  ) const {
129  coarse_etable_->set_residue_pair( pose.residue( res1 ), pose.residue( res2 ) );
130  }
131 
132  void indicate_required_context_graphs( utility::vector1< bool > & context_graphs_required ) const
133  {
134  context_graphs_required[ ten_A_neighbor_graph ] = true;
135  }
136 
137  //
138  void
139  setup_for_scoring_(pose::Pose const& pose, scoring::ScoreFunction const&) const {
140  if (pose.total_residue()) {
141  if ( pose.residue(1).type().atom_type_set_ptr() != coarse_etable_->atom_set() ) {
142  utility_exit_with_message( "Illegal attempt to score with non-identical atom set between pose and etable " );
143  }
144  }
145  }
146 
147 
148 public:
149  // implementation for quasi-virtual functions
150  inline
151  void
152  atom_pair_energy_(
153  conformation::Atom const & atom1,
154  conformation::Atom const & atom2,
155  Real const weight,
156  Energy &atr,
157  Energy &rep,
158  Energy &solv,
159  Energy &bb,
160  Real & dsq
161  ) const;
162 
163  //
164  inline
165  void
166  pair_energy_H_(
167  conformation::Atom const & atom1,
168  conformation::Atom const & atom2,
169  Real weight,
170  Energy &atr,
171  Energy &rep,
172  Energy &solv,
173  Energy &bb
174  ) const;
175 
176 
177  ///
178  inline
179  Real
180  eval_dE_dR_over_r_(
181  conformation::Atom const & atom1,
182  conformation::Atom const & atom2,
183  EnergyMap const & weights,
184  Vector & f1,
185  Vector & f2
186  ) const;
187 
188  virtual
189  bool
190  defines_intrares_energy( EnergyMap const & weights ) const
191  {
192  return false;
193  }
194 
195  virtual
196  void
197  eval_intrares_energy(
198  conformation::Residue const &,
199  pose::Pose const &,
200  ScoreFunction const &,
201  EnergyMap &
202  ) const {}
203 
204 private:
205  coarse::CoarseEtableCAP coarse_etable_;
206 
207 };
208 
209  //inline methods
210 
211 inline
212 void
213 CoarseEtableEnergy::atom_pair_energy_(
214  conformation::Atom const & atom1,
215  conformation::Atom const & atom2,
216  Real const weight,
217  Energy &atr,
218  Energy &rep,
219  Energy &solv,
220  Energy &bb,
221  Real & d2
222 ) const {
223  // std::cerr << __FILE__<< ' ' << __LINE__ << std::endl;
224  if ( coarse_etable_->handles( atom1, atom2 ) ) {
225  int disbin;
226  Real frac;
227  if (interpolate_bins( atom1, atom2, d2, disbin, frac )) {
228  coarse_etable_->atom_pair_energy( disbin, frac, atom1, atom2, bb);
229  atr = rep = solv = 0.0;
230  }
231  } else {
232  parent::atom_pair_energy_( atom1, atom2, weight, atr, rep, solv, bb, d2);
233  }
234 }
235 ///////////////////////////////////////////////////////////////////////////////
236 
237 /// How does the coarse_etable_ know which residue pair this is?
238 /// when is coarse_etable_->set_residue_pair( rsd1, rsd2 ); called?
239 inline
240 Real
241 CoarseEtableEnergy::eval_dE_dR_over_r_(
242  conformation::Atom const & atom1,
243  conformation::Atom const & atom2,
244  EnergyMap const & weights,
245  Vector & f1,
246  Vector & f2
247 ) const
248 {
249  if ( coarse_etable_->handles(atom1,atom2) ) {
250  f1 = atom1.xyz().cross( atom2.xyz() );
251  f2 = atom1.xyz() - atom2.xyz();
252  Real d2,frac;
253  int disbin;
254  if (interpolate_bins(atom1,atom2,d2,disbin,frac)) {
255  return coarse_etable_->eval_dE_dR(disbin,frac,atom1,atom2,weights);
256  } else {
257  return 0.0;
258  }
259  } else {
260  return parent::eval_dE_dR_over_r_(atom1,atom2,weights,f1,f2);
261  }
262 }
263 
264 
265 ///////////////////////////////////////////////////////////////////////////////
266 
267 inline
268 void
269 CoarseEtableEnergy::pair_energy_H_(
270  conformation::Atom const & atom1,
271  conformation::Atom const & atom2,
272  Real weight,
273  Energy &atr,
274  Energy &rep,
275  Energy &solv,
276  Energy &bb
277 ) const
278 {
279 
280  if ( coarse_etable_->handles( atom1, atom2) ) {
281  Real d2,frac; int disbin;
282  if ( interpolate_bins( atom1, atom2, d2, disbin, frac) ) {
283  coarse_etable_->atom_pair_energy( disbin, frac, atom1, atom2, bb);
284  atr = rep = solv = 0.0;
285  }
286  } else {
287  parent::pair_energy_H_( atom1, atom2, weight, atr, rep, solv, bb );
288  }
289 }
290 
291 */
292 
293 }
294 }
295 }
296