Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_PairwiseLowResolutionEnergy.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/rna/RNA_PairwiseLowResolutionEnergy.cc
11 /// @brief Statistically derived rotamer pair potential class implementation
12 /// @author Phil Bradley
13 /// @author Andrew Leaver-Fay
14 /// @author Rhiju Das
15 
16 
17 // Unit headers
20 
21 // Package headers
28 #include <core/scoring/Energies.hh>
32 
33 // Project headers
35 #include <core/pose/Pose.hh>
36 
37 #include <utility/vector1.hh>
38 
39 
40 // Utility headers
41 
42 
43 // C++
44 
45 namespace core {
46 namespace scoring {
47 namespace rna {
48 
49 
50 /// @details This must return a fresh instance of the RNA_PairwiseLowResolutionEnergy class,
51 /// never an instance already in use
55 ) const {
57 }
58 
61  ScoreTypes sts;
62  sts.push_back( rna_base_pair );
63  sts.push_back( rna_base_axis );
64  sts.push_back( rna_base_stagger );
65  sts.push_back( rna_base_stack );
66  sts.push_back( rna_base_stack_axis );
67  sts.push_back( rna_base_pair_pairwise );
68  sts.push_back( rna_base_axis_pairwise );
69  sts.push_back( rna_base_stagger_pairwise );
70  sts.push_back( rna_base_stack_pairwise );
71  sts.push_back( rna_base_stack_axis_pairwise );
72  sts.push_back( rna_base_backbone );
73  sts.push_back( rna_backbone_backbone );
74  sts.push_back( rna_repulsive );
75  sts.push_back( rna_data_base );
76  return sts;
77 }
78 
79 
81 
82 //////////////////////////////////////////////////////////////////////////////
83 //////////////////////////////////////////////////////////////////////////////
84 // Note -- this is not ready for the packer.
85 // To do:
86 // * Have each residue carry with it a virtual centroid, and three virtual atoms
87 // that define the base coordinate system (for SPEED)
88 // • Actually have the energy calculated in residue_pair_energy rather
89 // then the pre-cached values.
90 //
91 
92 /// c-tor
95  rna_low_resolution_potential_( ScoringManager::get_instance()->get_RNA_LowResolutionPotential() )
96 {}
97 
98 //clone
101 {
103 }
104 
105 
106 /////////////////////////////////////////////////////////////////////////////
107 // scoring
108 /////////////////////////////////////////////////////////////////////////////
109 
110 
111 ///
112 void
114 {
115 
118 
121 
122  // Use mini's residue_pair_energy to keep track of the book-keeping, instead of this...
123  //rna_low_resolution_potential_.update_rna_base_base_interactions( pose );
124 
125  might_be_designing_ = false;
126 
127 }
128 
129 ///
130 void
132 {
135 
138 
139  // Just make sure that everything has been calculated. This doesn't use residue_pair_energy for bookkeeping,
140  // it just chugs through all the residue pairs.
142 
143  might_be_designing_ = false;
144 
145 }
146 
147  /////////////////////////////////////////////////////////////////
148 void
150  pose::Pose & pose,
151  utility::vector1< bool > const & ,
152  utility::vector1< bool > const & designing_residues
153 ) const
154 {
157 
160 
161  might_be_designing_ = false;
162  for ( Size ii = 1; ii <= designing_residues.size(); ++ii ) {
163  if ( designing_residues[ ii ] ) {
164  might_be_designing_ = true;
165  break;
166  }
167  }
168 
169 }
170 
171 
172 
173 //////////////////////////////////////////////////////////////////////////////////////////
174 //
175 //
176 //
177 void
179  conformation::Residue const & rsd1,
180  conformation::Residue const & rsd2,
181  pose::Pose const & pose,
182  ScoreFunction const &,
183  EnergyMap & emap
184 ) const
185 {
186 
187  Vector centroid1, centroid2;
188  kinematics::Stub stub1, stub2;
189  get_centroid_information( rsd1, rsd2, pose, centroid1, centroid2, stub1, stub2 );
190 
191  rna_low_resolution_potential_.eval_rna_base_pair_energy( *rna_raw_base_base_info_, rsd1, rsd2, pose, centroid1, centroid2, stub1, stub2 );
192 
193  // Note that following are used in packing/designing, although for full de novo modeling
194  // there's a score that filters out base pairings that oversubscribe any one base edge.
200 
201  ////////////////////////////////////////////////////////////////////////////////
203  centroid1, centroid2, stub1, stub2);
204 
205  ////////////////////////////////////////////////////////////////////////////////
208 
209 
210 }
211 
212 ///////////////////////////////////////////////////////////////
213 void
215  conformation::Residue const & rsd1,
216  conformation::Residue const & rsd2,
217  pose::Pose const & pose,
218  Vector & centroid1,
219  Vector & centroid2,
220  kinematics::Stub & stub1,
221  kinematics::Stub & stub2 ) const
222 {
223 
224  // This is not very elegant -- should we consider making the
225  // centroid a virtual atom on the residue, and stubs defined by
226  // three more virtual atoms?
227  rna::RNA_ScoringInfo const & rna_scoring_info( rna::rna_scoring_info_from_pose( pose ) );
228  rna::RNA_CentroidInfo const & rna_centroid_info( rna_scoring_info.rna_centroid_info() );
229  if ( might_be_designing_ ) {
230  //Recalculate from scratch.
231  centroid1 = rna_centroid_info.get_base_centroid( rsd1 );
232  centroid2 = rna_centroid_info.get_base_centroid( rsd2 );
233  stub1 = rna_centroid_info.get_base_coordinate_system( rsd1, centroid1 );
234  stub2 = rna_centroid_info.get_base_coordinate_system( rsd2, centroid2 );
235  } else {
236  //Use centroid informtion already calculated in setup_for_scoring.
237  centroid1 = rna_centroid_info.base_centroids()[ rsd1.seqpos() ];
238  centroid2 = rna_centroid_info.base_centroids()[ rsd2.seqpos() ];
239  stub1 = rna_centroid_info.base_stubs()[ rsd1.seqpos() ];
240  stub2 = rna_centroid_info.base_stubs()[ rsd2.seqpos() ];
241  }
242 
243 }
244 
245 
246 ////////////////////////////////////////////////////////////////////////////////////////////
247 ////////////////////////////////////////////////////////////////////////////////////////////
248 Real
250  conformation::Residue const & rsd1,
251  conformation::Residue const & rsd2
252 ) const
253 {
254  ObjexxFCL::FArray3D< Real > const & base_pair_array ( rna_raw_base_base_info_->base_pair_array() );
255  Real score( 0.0 );
256  for (Size i = 1; i <= rna::NUM_EDGES; i++ ){
257  score += base_pair_array( rsd1.seqpos(), rsd2.seqpos(), i );
258  score += base_pair_array( rsd2.seqpos(), rsd1.seqpos(), i );
259  }
260  return score;
261 }
262 
263 /////////////////////////////////////////////////////////////////////////////////
264 Real
266  conformation::Residue const & rsd1,
267  conformation::Residue const & rsd2
268 ) const
269 {
270  ObjexxFCL::FArray3D< Real > const & base_axis_array ( rna_raw_base_base_info_->base_axis_array() );
271  Real score( 0.0 );
272  for (Size i = 1; i <= rna::NUM_EDGES; i++ ){
273  score += base_axis_array( rsd1.seqpos(), rsd2.seqpos(), i );
274  score += base_axis_array( rsd2.seqpos(), rsd1.seqpos(), i );
275  }
276  return score;
277 }
278 
279 /////////////////////////////////////////////////////////////////////////////////
280 Real
282  conformation::Residue const & rsd1,
283  conformation::Residue const & rsd2
284 ) const
285 {
286  ObjexxFCL::FArray3D< Real > const & base_stagger_array ( rna_raw_base_base_info_->base_stagger_array() );
287  Real score( 0.0 );
288  for (Size i = 1; i <= rna::NUM_EDGES; i++ ){
289  score += base_stagger_array( rsd1.seqpos(), rsd2.seqpos(), i );
290  score += base_stagger_array( rsd2.seqpos(), rsd1.seqpos(), i );
291  }
292  return score;
293 }
294 
295 /////////////////////////////////////////////////////////////////////////////////
296 Real
298  conformation::Residue const & rsd1,
299  conformation::Residue const & rsd2
300 ) const
301 {
302  ObjexxFCL::FArray2D< Real > const & stack_array ( rna_raw_base_base_info_->base_stack_array() );
303  return stack_array( rsd1.seqpos(), rsd2.seqpos() );
304 }
305 
306 /////////////////////////////////////////////////////////////////////////////////
307 Real
309  conformation::Residue const & rsd1,
310  conformation::Residue const & rsd2
311 ) const
312 {
313  ObjexxFCL::FArray2D< Real > const & stack_axis_array ( rna_raw_base_base_info_->base_stack_axis_array() );
314  return stack_axis_array( rsd1.seqpos(), rsd2.seqpos() );
315 }
316 
317 
318 ////////////////////////////////////////////////////////////////////////////////////////////
319 void
321  pose::Pose & pose,
322  ScoreFunction const & sfxn,
323  EnergyMap & totals
324 ) const
325 {
326 
328  rna::RNA_RawBaseBaseInfo & raw_base_base_info( rna_scoring_info.rna_raw_base_base_info() );
329  clean_up_rna_two_body_energy_tables( raw_base_base_info, pose );
330 
331  //This needs to take care of a bunch of base pair book-keeping.
332  // Get Pose cached pairwise "raw" base-base info. This was
333  // updated above.
334  if ( sfxn.has_nonzero_weight( rna_base_pair ) ||
339  {
340 
341  // Create Pose cached non-pairwise, "filtered" base-base info.
342  // This forces each base edge to have only one pairing partner.
343  rna::RNA_FilteredBaseBaseInfo & rna_filtered_base_base_info( rna_scoring_info.rna_filtered_base_base_info() );
344 
345  // Maybe we should put an if statement.
346  rna_filtered_base_base_info.carry_out_filtering( raw_base_base_info );
347 
348  // From filtered base-base info, pull out total scores.
349  totals[ rna_base_pair ] = rna_filtered_base_base_info.get_total_base_pair_score();
350  totals[ rna_base_axis ] = rna_filtered_base_base_info.get_total_base_axis_score();
351  totals[ rna_base_stagger ] = rna_filtered_base_base_info.get_total_base_stagger_score();
352  totals[ rna_base_stack ] = rna_filtered_base_base_info.get_total_base_stack_score();
353  totals[ rna_base_stack_axis ] = rna_filtered_base_base_info.get_total_base_stack_axis_score();
354 
355  // rna_filtered_base_base_info.set_calculated( false );
356  rna::RNA_DataInfo const & rna_data_info( rna_scoring_info.rna_data_info() );
357  totals[ rna_data_base ] += rna_filtered_base_base_info.get_data_score( rna_data_info );
358 
359  }
360 
361  // rna_low_resolution_potential_.finalize( pose );
362  // std::cout << "DONE SCORING " << std::endl;
363 
364 }
365 
366 ////////////////////////////////////////////////////////////////////////////////////////////
367 // Hey, if we use the domain_map, can save some computation!!!
368 void
370  id::AtomID const & atom_id,
371  pose::Pose const & pose,
372  kinematics::DomainMap const & /*domain_map*/,
373  ScoreFunction const &,
374  EnergyMap const & weights,
375  Vector & F1,
376  Vector & F2
377  ) const
378 {
379 
380  // NOTE -- currently have not put in derivatives for pairwise terms!!!! Would not be too hard actually!
381 
382  Vector f1( 0.0 ), f2( 0.0 );
383 
384  if ( weights[ rna_base_backbone ] != 0.0 ) {
386  F1 += weights[ rna_base_backbone ] * f1;
387  F2 += weights[ rna_base_backbone ] * f2;
388  }
389 
390  if ( weights[ rna_repulsive ] != 0.0 ) {
392  F1 += weights[ rna_repulsive ] * f1;
393  F2 += weights[ rna_repulsive ] * f2;
394  }
395 
396  if ( weights[ rna_backbone_backbone ] != 0.0 ) {
398  F1 += weights[ rna_backbone_backbone ] * f1;
399  F2 += weights[ rna_backbone_backbone ] * f2;
400  }
401 
402  // Non-pairwise terms.
403  // updated above, in setup_for_scoring
404  rna_low_resolution_potential_.eval_atom_derivative_base_base( atom_id, pose, weights, F1, F2 );
405 
406 }
407 
408 void
410  scoring::rna::RNA_RawBaseBaseInfo & raw_base_base_info,
411  pose::Pose & pose ) const
412 {
413 
414  //Make sure to zero out any of the base pair, base stack, etc. energies
415  // in our special RNA cached energies that are not between neighbors,
416  // and were therefore never calculated in residue_pair_energy().
417  scoring::rna::RNA_RawBaseBaseInfo raw_base_base_info_save( raw_base_base_info );
418  raw_base_base_info.zero();
419 
420  scoring::EnergyGraph & energy_graph( pose.energies().energy_graph() );
421 
422  for (Size i = 1; i <= pose.total_residue(); i++ ) {
423 
425  iru = energy_graph.get_node(i)->upper_edge_list_begin(),
426  irue = energy_graph.get_node(i)->upper_edge_list_end();
427  iru != irue; ++iru ) {
428  Size const j( (*iru)->get_second_node_ind() );
429 
430  raw_base_base_info.copy_values( raw_base_base_info_save, i, j );
431  raw_base_base_info.copy_values( raw_base_base_info_save, j, i );
432  }
433 
434  }
435 
436 }
437 
438 /// @brief RNA_PairwiseLowResolutionEnergy distance cutoff
439 Distance
441 {
442  return 0.0; /// Uh, I don't know.
443 }
446 {
447  return 1; // Initial versioning
448 }
449 
450 }
451 }
452 }