Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_Relaxer.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 relax_protocols
11 /// @brief protocols that are specific to RNA_Relaxer
12 /// @detailed
13 /// @author Rhiju Das
14 
15 
21 // AUTO-REMOVED #include <core/conformation/Residue.hh>
22 #include <core/scoring/rms_util.hh>
27 // AUTO-REMOVED #include <core/kinematics/AtomTree.hh>
28 #include <core/pose/Pose.hh>
29 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
30 
32 // AUTO-REMOVED #include <core/scoring/constraints/CoordinateConstraint.hh>
33 
34 #include <basic/options/option.hh>
35 // AUTO-REMOVED #include <basic/options/util.hh>
36 
37 
38 //Relaxer stuff
39 
40 // ObjexxFCL Headers
41 // AUTO-REMOVED #include <ObjexxFCL/FArray1D.hh>
42 
43 #include <core/types.hh>
44 #include <basic/Tracer.hh>
45 
46 #include <numeric/random/random.hh>
47 // AUTO-REMOVED #include <numeric/conversions.hh>
48 
49 // External library headers
50 
51 
52 //C++ headers
53 #include <vector>
54 #include <string>
55 #include <sstream>
56 // AUTO-REMOVED #include <fstream>
57 
58 #if defined(WIN32) || defined(__CYGWIN__)
59  #include <ctime>
60 #endif
61 
62 // option key includes
63 
64 #include <basic/options/keys/score.OptionKeys.gen.hh>
65 
66 #include <core/kinematics/Jump.hh>
67 #include <utility/vector1.hh>
68 #include <ObjexxFCL/format.hh>
69 
70 //Auto using namespaces
71 namespace ObjexxFCL { namespace fmt { } } using namespace ObjexxFCL::fmt; // AUTO USING NS
72 //Auto using namespaces end
73 
74 
75 
76 using namespace core;
77 using basic::T;
78 
79 static numeric::random::RandomGenerator RG(19920); // <- Magic number, do not change it!
80 
81 static basic::Tracer TR( "protocols.rna.rna_relaxer" ) ;
82 
83 namespace protocols {
84 namespace rna {
85 
86  /////////////////////////////////////////////////////
87  // BASIC IDEA -- relax consists of fragment moves
88  // that aren't too perturbing, followed by minimization
89  // So we need a fragment mover and a minimizer.
90 
91 RNA_Relaxer::RNA_Relaxer( RNA_FragmentMoverOP & rna_fragment_mover, RNA_MinimizerOP & rna_minimizer ):
92  Mover(),
93  rna_fragment_mover_( rna_fragment_mover ),
94  rna_minimizer_( rna_minimizer ),
95  relax_cycles_( 50 ),
96  max_frag_size_( 3 ),
97  num_find_fragment_tries_( 100 ),
98  rmsd_min_cutoff_( 1.0 ),
99  rmsd_max_cutoff_( 3.5 ),
100  simple_rmsd_cutoff_relax_( false )
101 {
102  Mover::type("RNA_Relaxer");
103 }
104 
106 {
107 }
108 
109 /// @details Apply the RNA full atom relaxer.
110 ///
112 {
113 
114  using namespace core::scoring;
115  using namespace core::kinematics;
116  using namespace basic::options;
117  using namespace basic::options::OptionKeys;
118 
119 
120  //COMMENT THIS OUT!!!
121  // rna_minimizer_->use_coordinate_constraints( false );
122  //rna_minimizer_->skip_o2star_trials( true );
123 
124  time_t pdb_start_time = time(NULL);
125 
126  ScoreFunctionOP scorefxn;
127 
128  if ( option[ score::weights ].user() ) {
129  scorefxn = ScoreFunctionFactory::create_score_function( option[ score::weights ]() );
130  } else {
132  }
133 
134  if (pose.constraint_set()->has_constraints() ){
135  scorefxn->set_weight( atom_pair_constraint, 1.0 );
136  scorefxn->set_weight( angle_constraint, 1.0 );
137  }
138 
139  protocols::moves::MonteCarloOP monte_carlo_( new protocols::moves::MonteCarlo( pose, *scorefxn, 2.0 ) );
140 
141  for (Size r = 1; r <= relax_cycles_; r++ ) {
142 
143  TR << "RNA relaxer ROUND " << r << " of " << relax_cycles_ << std::endl;
144 
145  make_fragment_moves( pose );
146 
147  //Minimize it.
148  rna_minimizer_->apply( pose );
149  monte_carlo_->boltzmann( pose, "relax" );
150 
151  }
152 
153  monte_carlo_->show_counters();
154 
155  pose = monte_carlo_->lowest_score_pose();
156 
157  time_t pdb_end_time = time(NULL);
158 
159  scorefxn->show( std::cout, pose );
160 
161  TR << "RNA relaxer finished in " << (long)(pdb_end_time - pdb_start_time) << " seconds." << std::endl;
162 
163 }
164 
167  return "RNA_Relaxer";
168 }
169 
170 ///////////////////////////////////////////////////////////////////////////////////////////
171 void
173 {
176  } else { //default
177  lores_monte_carlo( pose );
178  }
179 }
180 
181 ///////////////////////////////////////////////////////////////////////////////////////////
182 void
184 {
185  //Find a fragment to try... don't want to deviate too much from the input pose.
186  pose::Pose start_pose = pose;
187 
188  Size const frag_size = static_cast <int> ( RG.uniform() * max_frag_size_ ) + 1;
189 
190  for (Size n = 1; n <= num_find_fragment_tries_ ; n++ ) {
191 
192  pose = start_pose;
193 
194  rna_fragment_mover_->random_fragment_insertion( pose, frag_size );
195 
196  Real const rmsd_to_start = scoring::all_atom_rmsd( pose, start_pose );
197  TR << "Testing fragment insertion --> Length: " << frag_size << " rmsd: " << rmsd_to_start << std::endl;
198  if ( rmsd_to_start > rmsd_min_cutoff_ && rmsd_to_start < rmsd_max_cutoff_ ) break;
199 
200  }
201 
202 }
203 
204 ///////////////////////////////////////////////////////////////////////////////////////////
205 void
207 {
208 
209  using namespace core::scoring;
210 
211  pose::Pose start_pose = pose;
212 
214  if (pose.constraint_set()->has_constraints() ){
215  lores_scorefxn->set_weight( atom_pair_constraint, 1.0 );
216  lores_scorefxn->set_weight( angle_constraint, 1.0 );
217  }
218 
219  Size const lores_monte_carlo_rounds( 1000 );
220  protocols::moves::MonteCarloOP lores_monte_carlo_( new protocols::moves::MonteCarlo( pose, *lores_scorefxn, 2.0 ) );
221 
222  for( Size i=1; i <= lores_monte_carlo_rounds ; ++i ) {
223 
224  Size const frag_size = static_cast <int> ( RG.uniform() * max_frag_size_ ) + 1;
225  rna_fragment_mover_->random_fragment_insertion( pose, frag_size );
226  lores_monte_carlo_->boltzmann( pose, "frag" + SS(frag_size) );
227 
228  }
229 
230  lores_monte_carlo_->show_counters();
231 
232  // Want some variety? Don't use the lowest score pose...
233  // pose = lores_monte_carlo_->lowest_score_pose();
234 
235  Real const rmsd_to_start = scoring::all_atom_rmsd( pose, start_pose );
236  TR << " LoRes MonteCarlo --> rmsd: " << rmsd_to_start << std::endl;
237 
238 }
239 
240 
241 } // namespace rna
242 } // namespace protocols