Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_TorsionMover.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 RNA_DeleteMover
11 /// @brief Torsions an RNA residue from a chain terminus.
12 /// @detailed
13 /// @author Rhiju Das
14 
19 
20 // libRosetta headers
21 #include <core/types.hh>
25 #include <core/id/TorsionID.hh>
26 #include <core/pose/Pose.hh>
27 #include <core/pose/util.hh>
29 
31 
32 #include <numeric/random/random.hh>
33 
34 #include <basic/Tracer.hh>
35 
36 #include <map>
37 
38 
39 static numeric::random::RandomGenerator RG(245099111); // <- Magic number, do not change it!
40 
41 using namespace core;
42 using core::Real;
43 
44 //////////////////////////////////////////////////////////////////////////
45 // Removes one residue from a 5' or 3' chain terminus, and appropriately
46 // updates the pose sub_to_full_info object.
47 //////////////////////////////////////////////////////////////////////////
48 
49 static basic::Tracer TR( "protocols.swa.monte_carlo.rna_torsion_mover" ) ;
50 
51 namespace protocols {
52 namespace swa {
53 namespace monte_carlo {
54 
55 
56  //////////////////////////////////////////////////////////////////////////
57  //constructor!
58  // RNA_TorsionMover::RNA_TorsionMover():
59  // Mover(),
60  // default_sample_range_( 10.0 )
61  // {}
62 
63  //////////////////////////////////////////////////////////////////////////
64  //destructor
65  RNA_TorsionMover::~RNA_TorsionMover()
66  {}
67 
68  //////////////////////////////////////////////////////////////////////
69  void
70  RNA_TorsionMover::apply( core::pose::Pose & pose )
71  {
72  std::string move_type = "";
73  default_sample_range_ = 10.0; //not very elegant.
74  apply( pose, move_type, default_sample_range_ );
75  }
76 
77  //////////////////////////////////////////////////////////////////////
78  void
79  RNA_TorsionMover::apply( core::pose::Pose & pose, std::string & move_type, Real const & sample_range )
80  {
81  SubToFullInfo & sub_to_full_info = nonconst_sub_to_full_info_from_pose( pose );
82  utility::vector1< Size > const & moving_res_list = sub_to_full_info.moving_res_list();
83  random_torsion_move( pose, moving_res_list, move_type, sample_range );
84  }
85 
86  //////////////////////////////////////////////////////////////////////
87  void
88  RNA_TorsionMover::random_torsion_move( pose::Pose & pose,
89  utility::vector1< Size > const & moving_res_list,
90  std::string & move_type,
91  Real const & sample_range ){
92 
93  Size const random_idx = int( RG.uniform() * moving_res_list.size() ) + 1;
94  Size const i = moving_res_list[ random_idx ];
95 
96  MovingResidueCase moving_residue_case = get_moving_residue_case( pose, i );
97 
98  if ( moving_residue_case == CHAIN_TERMINUS_3PRIME || moving_residue_case == CHAIN_TERMINUS_5PRIME ){
99 
100  // an edge residue -- change both its nucleoside & suite -- can go crazy.
101  Size const nucleoside_num = i;
102  sample_near_nucleoside_torsion( pose, nucleoside_num, sample_range);
103 
104  Size suite_num( 0 );
105  if ( moving_residue_case == CHAIN_TERMINUS_3PRIME ) suite_num = i-1;
106  else suite_num = i;
107 
108  if ( RG.uniform() < 0.5) {
109  sample_near_suite_torsion( pose, suite_num, sample_range);
110  move_type += "-nuc-suite";
111  } else {
112  crankshaft_alpha_gamma( pose, suite_num, sample_range);
113  move_type += "-nuc-crank";
114  }
115 
116  } else {
117  runtime_assert( moving_residue_case == INTERNAL ); // cannot handle floating base yet.
118 
119  // don't do anything super-crazy -- either do previous suite, current nucleoside, or next suite.
120  Real const random_number = RG.uniform();
121 
122  if ( random_number < 0.6 ){
123 
124  Size suite_num( 0 );
125  if ( RG.uniform() < 0.5) {
126  suite_num= i-1;
127  } else {
128  suite_num= i;
129  }
130 
131  if ( RG.uniform() < 0.5) {
132  sample_near_suite_torsion( pose, suite_num, sample_range);
133  //move_type += "-suite" + string_of(suite_num);
134  move_type += "-suite";
135  } else {
136  crankshaft_alpha_gamma( pose, suite_num, sample_range);
137  //move_type += "-suite" + string_of(suite_num);
138  move_type += "-crank";
139  }
140  } else {
141  Size const nucleoside_num = i;
142  sample_near_nucleoside_torsion( pose, nucleoside_num, sample_range);
143  //move_type += "-nuc" + string_of(nucleoside_num);
144  move_type += "-nuc";
145  }
146 
147  }
148 
149  }
150 
151 
152 //////////////////////////////////////////////////
154  RNA_TorsionMover::get_name() const {
155  return "RNA_TorsionMover";
156  }
157 
158 
159 //////////////////////////////////////////////////
160 void
161 RNA_TorsionMover::sample_near_suite_torsion(utility::vector1< Real > & torsion_list, Real const stddev) {
162  // static const Real delta_north = rna_fitted_torsion_info_.ideal_delta_north();
163  // static const Real delta_south = rna_fitted_torsion_info_.ideal_delta_south();
164 
165  torsion_list[1] += RG.gaussian() * stddev;
166  torsion_list[2] += RG.gaussian() * stddev;
167  torsion_list[3] += RG.gaussian() * stddev;
168  torsion_list[4] += RG.gaussian() * stddev;
169  torsion_list[5] += RG.gaussian() * stddev;
170 
171 }
172 
173 
174 //////////////////////////////////////////////////
175 // copied from fang's turner_test_one_chain.cc
176 // why not use principal_value [-180 to 180]?
177 void
178 RNA_TorsionMover::sample_near_nucleoside_torsion(utility::vector1< Real > & torsion_list, Real const stddev) {
179  static const Real delta_north = rna_fitted_torsion_info_.ideal_delta_north();
180  static const Real delta_south = rna_fitted_torsion_info_.ideal_delta_south();
181 
182  if (RG.uniform() < 0.2) {
183  torsion_list[1] = (RG.uniform() < 0.5) ? delta_south : delta_north;
184  }
185 
186  torsion_list[2] += RG.gaussian() * stddev;
187  if (torsion_list[2] > 360) {
188  torsion_list[2] -= 360;
189  } else if (torsion_list[2] <= 0) {
190  torsion_list[2] += 360;
191  }
192 
193 }
194 
195 //////////////////////////////////
196 void
197 RNA_TorsionMover::apply_nucleoside_torsion( utility::vector1< Real > const & torsion_set,
198  pose::Pose & pose,
199  Size const moving_res){
200 
201  using namespace id;
202  using namespace scoring::rna;
203 
204  Real delta, nu2, nu1;
205  if (torsion_set[1] < 115) { //North pucker, [6] is delta angle (only pick one of the two states)
206  delta = rna_fitted_torsion_info_.ideal_delta_north();
207  nu2 = rna_fitted_torsion_info_.ideal_nu2_north();
208  nu1 = rna_fitted_torsion_info_.ideal_nu1_north();
209  } else { //South pucker
210  delta = rna_fitted_torsion_info_.ideal_delta_south();
211  nu2 = rna_fitted_torsion_info_.ideal_nu2_south();
212  nu1 = rna_fitted_torsion_info_.ideal_nu1_south();
213  }
214 
215  pose.set_torsion( TorsionID( moving_res, id::BB, 4 ), delta );
216  pose.set_torsion( TorsionID( moving_res, id::CHI, 2 ), nu2 );
217  pose.set_torsion( TorsionID( moving_res, id::CHI, 3 ), nu1 );
218  pose.set_torsion( TorsionID( moving_res, id::CHI, 1 ), torsion_set[2] );
219 }
220 
221 //////////////////////////////////
222 void
223 RNA_TorsionMover::apply_suite_torsion( utility::vector1< Real > const & torsion_set,
224  pose::Pose & pose,
225  Size const moving_suite ){
226 
227  using namespace id;
228  using namespace scoring::rna;
229 
230  pose.set_torsion( TorsionID( moving_suite, id::BB, 5 ), torsion_set[1] ); //epsilon
231  pose.set_torsion( TorsionID( moving_suite, id::BB, 6 ), torsion_set[2] ); //zeta
232  pose.set_torsion( TorsionID( moving_suite+1, id::BB, 1 ), torsion_set[3] ); //alpha
233  pose.set_torsion( TorsionID( moving_suite+1, id::BB, 2 ), torsion_set[4] ); //beta
234  pose.set_torsion( TorsionID( moving_suite+1, id::BB, 3 ), torsion_set[5] ); //gamma
235 
236 }
237 
238 
239 //////////////////////////////////
240 void
241 RNA_TorsionMover::apply_random_nucleoside_torsion( pose::Pose & pose,
242  Size const moving_res ){
243 
244  utility::vector1< Real > torsion_set;
245 
246  bool north_pucker = (RG.uniform() < 0.5) ? true : false;
247 
248  Size chi_rotamer = 1;
249  // could be syn if purine.
250  if ( scoring::rna::is_purine( pose.residue( moving_res ) ) && RG.uniform() < 0.5 ) chi_rotamer = 2;
251 
252  if ( north_pucker ){
253  torsion_set.push_back( rna_fitted_torsion_info_.ideal_delta_north() );
254  torsion_set.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_chi_north()[chi_rotamer].center );
255  } else {
256  torsion_set.push_back( rna_fitted_torsion_info_.ideal_delta_south() );
257  torsion_set.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_chi_south()[chi_rotamer].center );
258  }
259 
260  apply_nucleoside_torsion( torsion_set, pose, moving_res );
261 }
262 
263 
264 //////////////////////////////////
265 void
266 RNA_TorsionMover::apply_random_suite_torsion( pose::Pose & pose,
267  Size const moving_suite ){
268 
269  utility::vector1< Real > torsion_set;
270 
271  bool north_pucker = ( pose.delta( moving_suite ) < 115 );
272  Real const epsilon = ( north_pucker ) ? rna_fitted_torsion_info_.gaussian_parameter_set_epsilon_north()[1].center : rna_fitted_torsion_info_.gaussian_parameter_set_epsilon_south()[1].center;
273  torsion_set.push_back( epsilon );
274 
275  Size const alpha_rotamer = int( 3 * RG.uniform() ) + 1;
276  Real const alpha = rna_fitted_torsion_info_.gaussian_parameter_set_alpha()[ alpha_rotamer ].center;
277 
278  Size const zeta_rotamer = int( 2 * RG.uniform() ) + 1;
279  Real zeta;
280  if ( alpha_rotamer == 1 ){
281  zeta = rna_fitted_torsion_info_.gaussian_parameter_set_zeta_alpha_sc_minus()[ zeta_rotamer ].center;
282  } else if ( alpha_rotamer == 2 ){
283  zeta = rna_fitted_torsion_info_.gaussian_parameter_set_zeta_alpha_sc_plus()[ zeta_rotamer ].center;
284  } else {
285  zeta = rna_fitted_torsion_info_.gaussian_parameter_set_zeta_alpha_ap()[ zeta_rotamer ].center;
286  }
287 
288  torsion_set.push_back( zeta );
289  torsion_set.push_back( alpha );
290  torsion_set.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_beta()[1].center );
291 
292  Size const gamma_rotamer = int( 3 * RG.uniform() ) + 1;
293  torsion_set.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_gamma()[gamma_rotamer].center );
294 
295  apply_suite_torsion( torsion_set, pose, moving_suite );
296 
297 }
298 
299 
300 //////////////////////////////////
301 void
302 RNA_TorsionMover::apply_nucleoside_torsion_Aform(
303  pose::Pose & pose,
304  Size const moving_res ){
305 
306  utility::vector1< Real > ideal_A_form_torsions;
307  ideal_A_form_torsions.push_back( rna_fitted_torsion_info_.ideal_delta_north() );
308  ideal_A_form_torsions.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_chi_north()[1].center );
309  apply_nucleoside_torsion( ideal_A_form_torsions, pose, moving_res );
310 }
311 
312 
313 //////////////////////////////////
314 void
315 RNA_TorsionMover::apply_suite_torsion_Aform(
316  pose::Pose & pose,
317  Size const moving_suite ){
318 
319  utility::vector1< Real > ideal_A_form_torsions;
320  ideal_A_form_torsions.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_epsilon_north()[1].center );
321  ideal_A_form_torsions.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_zeta_alpha_sc_minus()[1].center );
322  ideal_A_form_torsions.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_alpha()[1].center );
323  ideal_A_form_torsions.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_beta()[1].center );
324  ideal_A_form_torsions.push_back( rna_fitted_torsion_info_.gaussian_parameter_set_gamma()[1].center );
325  apply_suite_torsion( ideal_A_form_torsions, pose, moving_suite );
326 }
327 
328 
329 ///////////////////////////////////////////////////
331 RNA_TorsionMover::get_suite_torsion( pose::Pose const & pose, Size const moving_suite ){
332 
333  using namespace id;
334 
335  utility::vector1< Real > torsion_set;
336  torsion_set.push_back( pose.torsion( TorsionID( moving_suite, id::BB, 5 ) ) ); //epsilon
337  torsion_set.push_back( pose.torsion( TorsionID( moving_suite, id::BB, 6 ) ) ); //zeta
338  torsion_set.push_back( pose.torsion( TorsionID( moving_suite+1, id::BB, 1 ) ) ); //alpha
339  torsion_set.push_back( pose.torsion( TorsionID( moving_suite+1, id::BB, 2 ) ) ); //beta
340  torsion_set.push_back( pose.torsion( TorsionID( moving_suite+1, id::BB, 3 ) ) ); //gamma
341 
342  return torsion_set;
343 }
344 
345 ///////////////////////////////////////////////////
347 RNA_TorsionMover::get_nucleoside_torsion( pose::Pose const & pose, Size const moving_nucleoside ){
348 
349  using namespace id;
350 
351  utility::vector1< Real > torsion_set;
352  torsion_set.push_back( pose.torsion( TorsionID( moving_nucleoside, id::BB, 4 ) ) ); //delta
353  torsion_set.push_back( pose.torsion( TorsionID( moving_nucleoside, id::CHI, 1 ) ) ); //chi
354 
355  return torsion_set;
356 }
357 
358 ///////////////////////////////////////////////////
359 void
360 RNA_TorsionMover::sample_near_suite_torsion( pose::Pose & pose, Size const moving_suite, Real const sample_range){
361  utility::vector1< Real> torsion_set = get_suite_torsion( pose, moving_suite );
362  sample_near_suite_torsion( torsion_set, sample_range );
363  apply_suite_torsion( torsion_set, pose, moving_suite );
364 }
365 
366 ///////////////////////////////////////////////////
367 void
368 RNA_TorsionMover::sample_near_nucleoside_torsion( pose::Pose & pose, Size const moving_res, Real const sample_range){
369  utility::vector1< Real> torsion_set = get_nucleoside_torsion( pose, moving_res );
370  sample_near_nucleoside_torsion( torsion_set, sample_range);
371  apply_nucleoside_torsion( torsion_set, pose, moving_res );
372 }
373 ///////////////////////////////////////////////////
374 void
375 RNA_TorsionMover::crankshaft_alpha_gamma( pose::Pose & pose, Size const moving_suite, Real const sample_range){
376 
377  using namespace id;
378 
379  TorsionID alpha_torsion_id( moving_suite+1, id::BB, 1 );
380  TorsionID gamma_torsion_id( moving_suite+1, id::BB, 3 );
381 
382  Real alpha = pose.torsion( alpha_torsion_id );
383  Real gamma = pose.torsion( gamma_torsion_id );
384  Real const perturb = RG.gaussian() * sample_range;
385 
386  alpha += perturb;
387  gamma -= perturb;
388 
389  pose.set_torsion( alpha_torsion_id, alpha );
390  pose.set_torsion( gamma_torsion_id, gamma );
391 
392 }
393 
394 
395 }
396 }
397 }