Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RG_Energy_RNA.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/RG_Energy_RNA.cc
11 /// @brief Radius of gyration energy function definition.
12 /// @author James Thompson
13 
14 
15 // Unit headers
18 
19 // Package headers
23 // AUTO-REMOVED #include <core/scoring/ScoringManager.hh>
24 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
25 
26 // Project headers
27 #include <core/pose/Pose.hh>
30 
31 
32 // Utility headers
33 // AUTO-REMOVED #include <basic/prof.hh>
34 
35 #include <core/id/AtomID.hh>
37 #include <utility/vector1.hh>
38 
39 
40 
41 // C++
42 
43 
44 namespace core {
45 namespace scoring {
46 namespace rna {
47 
48 
49 /// @details This must return a fresh instance of the RG_Energy_RNA class,
50 /// never an instance already in use
54 ) const {
55  return new RG_Energy_RNA;
56 }
57 
60  ScoreTypes sts;
61  sts.push_back( rna_rg );
62  return sts;
63 }
64 
65 
66 /// c-tor
69 {}
70 
71 /// clone
74 {
75  return new RG_Energy_RNA;
76 }
77 
78 
79 /////////////////////////////////////////////////////////////////////////////
80 // scoring
81 /////////////////////////////////////////////////////////////////////////////
82 
83 ///
84 void
86 {
87 
89  rna::RNA_CentroidInfo & rna_centroid_info( rna_scoring_info.rna_centroid_info() );
90  //Doesn't recalculate stuff if already updated:
91  rna_centroid_info.update( pose );
92 
93  utility::vector1< Vector > const & base_centroids( rna_centroid_info.base_centroids() );
94  Size const nres( pose.total_residue() );
95 
96  // calculate center of mass -- mutable.
97 
98  center_of_mass_ = 0.0;
99  for ( Size i = 1; i <= nres; ++i ) {
100  conformation::Residue const & rsd( pose.residue( i ) );
101  if ( !rsd.is_RNA() ) continue;
102  Vector const v( base_centroids[i] );
103  center_of_mass_ += v;
104  }
105  center_of_mass_ /= nres;
106 
107  ///////////////////////////////////////
108  //
109  // RG SCORE
110  // calculate RG based on distance from center of mass
111  Real rg_squared = 0;
112  for ( Size i = 1; i <= nres; ++i ) {
113  conformation::Residue const & rsd( pose.residue( i ) );
114  if ( !rsd.is_RNA() ) continue;
115  Vector const v( base_centroids[i] );
116  rg_squared += ( v - center_of_mass_ ).length_squared();
117  }
118 
119  // This definition of rg differs with the conventional definition which
120  // divides by nres and not by nres-1. For the sake of matching r++, it's
121  // being left at nres-1 for now, but is a candidate for change in the near
122  // future.
123  rg_squared /= (nres - 1);
124  rg_ = sqrt( rg_squared ); //Save in this class
125 
126 
127 
128 }
129 
130 
131 /////////////////////////////////////////////////////////////////////////////
132 void
134 {
135 
136  //score the pose.... that should generate the center_of_mass position, and the Rg.
137  setup_for_scoring( pose, scorefxn );
138 
139 }
140 
141 
142 ///////////////////////////////////////////////////////////////////////////////
143 void
145  pose::Pose & pose,
146  ScoreFunction const &,
147  EnergyMap & totals
148 ) const {
149  using namespace conformation;
150 
151 
152  totals[ rna_rg ] = rg_;
153 
155  rna::RNA_CentroidInfo & rna_centroid_info( rna_scoring_info.rna_centroid_info() );
156  rna_centroid_info.set_calculated( false );
157 
158 } // finalize_total_energy
159 
160 
161 ///////////////////////////////////////////////////////////////////////////////
162 // Following makes the approximation that center of mass of the RNA
163 // will stay fixed during minimimize!
164 void
166  id::AtomID const & atom_id,
167  pose::Pose const & pose,
168  kinematics::DomainMap const &,
169  ScoreFunction const &,
170  EnergyMap const & weights,
171  Vector & F1,
172  Vector & F2
173  ) const
174 {
175 
176  using namespace conformation;
177 
178  Size const i ( atom_id.rsd() );
179  Size const atom_num_i ( atom_id.atomno() );
180 
181  conformation::Residue const & rsd( pose.residue( i ) );
182  if ( !rsd.is_RNA() ) return;
183 
184  rna::RNA_ScoringInfo const & rna_scoring_info( rna::rna_scoring_info_from_pose( pose ) );
185  rna::RNA_CentroidInfo const & rna_centroid_info( rna_scoring_info.rna_centroid_info() );
186  utility::vector1< Vector > const & base_centroids( rna_centroid_info.base_centroids() );
187 
188 
189  Size const nres( pose.total_residue() );
190 
191  //Apply force at base sidechain atom?
192  //
193  // Alternatively spread over all atoms in base. That's perhaps more kosher, but
194  // equivalent if base is rigid.
195  //
196  // Or alternatively, if I set up a base centroid virtual atom with a fixed
197  // geometry relative to the base first sidechain atom -- apply it there.
198  //
199 
200  if ( atom_num_i == rna::first_base_atom_index( rsd ) ) {
201 
202  Vector const v( base_centroids[i] );
203  Vector f2 = ( v - center_of_mass_ )/ ( (nres - 1 ) * rg_ );
204  Vector f1 = cross( f2, v );
205 
206  F1 += weights[ rna_rg ] * f1;
207  F2 += weights[ rna_rg ] * f2;
208  }
209 
210 } // eval atom derivative
213 {
214  return 1; // Initial versioning
215 }
216 
217 
218 
219 } // rna
220 } // scoring
221 } // core