Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_O2StarMover.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_O2StarMover
11 /// @brief O2Stars an RNA residue from a chain terminus.
12 /// @detailed
13 /// @author Rhiju Das
14 
17 
18 // libRosetta headers
19 #include <core/types.hh>
20 #include <core/pose/Pose.hh>
22 #include <core/id/TorsionID.hh>
23 #include <core/pose/util.hh>
24 #include <core/scoring/Energies.hh>
27 #include <basic/Tracer.hh>
28 
29 #include <numeric/random/random.hh>
30 
31 
32 static numeric::random::RandomGenerator RG(845099111); // <- Magic number, do not change it!
33 
34 using namespace core;
35 using core::Real;
36 
37 //////////////////////////////////////////////////////////////////////////
38 // Removes one residue from a 5' or 3' chain terminus, and appropriately
39 // updates the pose sub_to_full_info object.
40 //////////////////////////////////////////////////////////////////////////
41 
42 static basic::Tracer TR( "protocols.swa.monte_carlo.o2star_mover" ) ;
43 
44 namespace protocols {
45 namespace swa {
46 namespace monte_carlo {
47 
48 
49  //////////////////////////////////////////////////////////////////////////
50  //constructor!
51  RNA_O2StarMover::RNA_O2StarMover( scoring::ScoreFunctionOP scorefxn ,
52  bool const sample_all_o2star,
53  Real const sample_range_small,
54  Real const sample_range_large ):
55  scorefxn_( scorefxn ),
56  sample_all_o2star_( sample_all_o2star ),
57  sample_range_small_( sample_range_small ),
58  sample_range_large_( sample_range_large )
59  {}
60 
61  //////////////////////////////////////////////////////////////////////////
62  //destructor
64  {}
65 
66  //////////////////////////////////////////////////////////////////////////
67  void
69  {
70  std::string move_type = "";
71  apply( pose, move_type );
72  }
73 
74  //////////////////////////////////////////////////////////////////////
75  void
77  {
78 
79  Size o2star_res( 0 );
80 
81  SubToFullInfo & sub_to_full_info = nonconst_sub_to_full_info_from_pose( pose );
82  utility::vector1< Size > moving_res_list = sub_to_full_info.moving_res_list();
83 
84  if ( sample_all_o2star_ ){
85  o2star_res = get_random_o2star_residue( pose );
86  } else {
87  // warning -- following might lead to weird 'hysteresis' effects since it picks
88  // o2star to sample based on what's near moving residue.
89  ( *scorefxn_ )( pose ); //score it first to get energy graph.
90  o2star_res = get_random_o2star_residue_near_moving_residue( pose, moving_res_list );
91  }
92 
93  if ( o2star_res > 0 ) {
94  Real const random_number2 = RG.uniform();
95  if ( random_number2 < 0.5 ){
96  move_type = "sml-o2star";
98  } else {
99  move_type = "lrg-o2star";
101  }
102  }
103 
104  }
105 
106  //////////////////////////////////////////////////////////////////////////////////////
109  return "RNA_O2StarMover";
110  }
111 
112 
113  //////////////////////////////////////////////////////////////////////////////////////
114  void
115  RNA_O2StarMover::sample_near_o2star_torsion( pose::Pose & pose, Size const moving_res, Real const sample_range){
116  id::TorsionID o2star_torsion_id( moving_res, id::CHI, 4 );
117  Real o2star_torsion = pose.torsion( o2star_torsion_id ); //get
118  o2star_torsion += RG.gaussian() * sample_range; //sample_near
119  pose.set_torsion( o2star_torsion_id, o2star_torsion ); // apply
120  }
121 
122  //////////////////////////////////////////////////////////////////////////////////////
123  Size
125  // pick at random from whole pose -- a quick initial stab.
126  Size const o2star_num = int( pose.total_residue() * RG.uniform() ) + 1;
127  return o2star_num;
128  }
129 
130  //////////////////////////////////////////////////////////////////////////////////////
131  // This could be made smarter -- could go over nucleoside *and* suite.
132  Size
134 
135  // should be better -- actually look at o2star's that might be engaged in interactions with moving nucleoside
136 
137  // Following requires that pose is already scored once before entering the mover.
138  // Is there a way to avoid this? just ensure energy_graph is filled?
139  utility::vector1< bool > residues_allowed_to_be_packed( pose.total_residue(), false );
140  scoring::EnergyGraph const & energy_graph( pose.energies().energy_graph() );
141 
142  Distance DIST_CUTOFF( 4.0 );
143 
144  for (Size k = 1; k <= moving_res_list.size(); k++ ){
145  Size const i = moving_res_list[ k ];
146 
148  iter = energy_graph.get_node( i )->const_edge_list_begin();
149  iter != energy_graph.get_node( i )->const_edge_list_end();
150  ++iter ){
151 
152  Size j( (*iter)->get_other_ind( i ) );
153 
154  // check for potential interaction of o2* of this new residue and any atom in moving residue.
155  Vector const & o2star_other = pose.residue( j ).xyz( " O2*" );
156  for ( Size n = 1; n <= pose.residue( i ).natoms(); n++ ){
157  if ( ( pose.residue( i ).xyz( n ) - o2star_other ).length() < DIST_CUTOFF ) {
158  residues_allowed_to_be_packed[ j ] = true;
159  break;
160  }
161  }
162 
163  // check for potential interaction of o2* of moving residue and any atom in this new residue
164  if (residues_allowed_to_be_packed[ i ]) continue;
165 
166  Vector const & o2star_i = pose.residue( i ).xyz( " O2*" );
167  for ( Size n = 1; n <= pose.residue( j ).natoms(); n++ ){
168  if ( ( pose.residue( j ).xyz( n ) - o2star_i ).length() < DIST_CUTOFF ) {
169  residues_allowed_to_be_packed[ i ] = true;
170  break;
171  }
172  }
173 
174  }
175  }
176 
177  utility::vector1< Size > res_list;
178  for ( Size n = 1; n <= pose.total_residue(); n++ ) {
179  if ( residues_allowed_to_be_packed[ n ] ) {
180  res_list.push_back( n );
181  }
182  }
183  if (res_list.size()==0) return 0; //nothing to move!
184 
185  Size const o2star_idx_within_res_list = int( res_list.size() * RG.uniform() ) + 1;
186  Size const o2star_num = res_list[ o2star_idx_within_res_list ];
187  return o2star_num;
188  }
189 
190 }
191 }
192 }