Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StepWiseRNA_Minimizer.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 StepWiseRNA_Minimizer
11 /// @brief Not particularly fancy, just minimizes a list of poses.
12 /// @detailed
13 /// @author Parin Sripakdeevong (sripakpa@stanford.edu), Rhiju Das (rhiju@stanford.edu)
14 
15 
16 //////////////////////////////////
18 #include <protocols/swa/rna/StepWiseRNA_OutputData.hh> //Sept 26, 2011
25 
26 //////////////////////////////////
27 #include <core/types.hh>
28 #include <core/id/AtomID.hh>
29 #include <core/pose/Pose.hh>
30 #include <core/pose/util.hh>
37 #include <basic/Tracer.hh>
41 
43 #include <core/scoring/Energies.hh>
46 
47 #include <core/id/TorsionID.hh>
49 #include <core/chemical/util.hh>
50 #include <core/chemical/AtomType.hh> //Need this to prevent the compiling error: invalid use of incomplete type 'const struct core::chemical::AtomType Oct 14, 2009
53 
56 
57 
58 #include <ObjexxFCL/format.hh>
59 #include <ObjexxFCL/string.functions.hh>
60 
61 #include <utility/exit.hh>
62 #include <utility/file/file_sys_util.hh>
63 
64 #include <time.h>
65 
66 #include <string>
67 #include <fstream>
68 #include <iostream>
69 #include <sstream>
70 #include <map>
71 
72 
73 using namespace core;
74 using core::Real;
75 
76 //////////////////////////////////////////////////////////////////////////
77 //////////////////////////////////////////////////////////////////////////
78 // Core routine for stepwise sampling of proteins (and probably other
79 // biopolymers soon). Take a starting pose and a list of residues to sample,
80 // and comprehensively sample all backbone torsion angles by recursion.
81 //////////////////////////////////////////////////////////////////////////
82 //////////////////////////////////////////////////////////////////////////
83 //////////////////////////////////////////////////////////////////////////
84 
85 static basic::Tracer TR( "protocols.swa.rna_stepwise_rna_minimizer" ) ;
86 
87 namespace protocols {
88 namespace swa {
89 namespace rna {
90 
91  //////////////////////////////////////////////////////////////////////////
92  //constructor!
93  StepWiseRNA_Minimizer::StepWiseRNA_Minimizer(
94  utility::vector1 <pose_data_struct2> const & pose_data_list,
95  StepWiseRNA_JobParametersCOP & job_parameters ):
96  pose_data_list_( pose_data_list ),
97  job_parameters_( job_parameters ),
98  silent_file_( "silent_file.txt" ),
99  verbose_(false),
100  native_screen_(false),
101  native_screen_rmsd_cutoff_(3.0),
102  perform_electron_density_screen_(false),
103  rm_virt_phosphate_(false),
104  native_edensity_score_cutoff_(-1.0),
105  centroid_screen_(true),
106  perform_o2star_pack_(true),
107  output_before_o2star_pack_(false),
108  perform_minimize_(true),
109  num_pose_minimize_(999999), //Feb 02, 2012
110  minimize_and_score_sugar_(true),
111  rename_tag_(true),
112  base_centroid_screener_( 0 ) //Owning-pointer.
113  {
114  set_native_pose( job_parameters_->working_native_pose() );
115  }
116 
117  //////////////////////////////////////////////////////////////////////////
118  //destructor
120  {}
121 
122  /////////////////////
125  return "StepWiseRNA_Minimizer";
126  }
127 
128  //////////////////////////////////////////////////////////////////////////
129  bool
131  return (pose_data_1.score < pose_data_2.score);
132  }
133  //////////////////////////////////////////////////////////////////////////
134 
135 
136  void
138 
139  using namespace core::scoring;
140  using namespace core::pose;
141  using namespace core::io::silent;
142  using namespace protocols::rna;
143  using namespace core::optimization;
144 
145  Output_title_text("Enter StepWiseRNA_Minimizer::apply");
146 
147  Output_boolean(" verbose_=", verbose_ ); std::cout << std::endl;
148  Output_boolean(" native_screen_=", native_screen_ ); std::cout << std::endl;
149  std::cout << " native_screen_rmsd_cutoff_=" << native_screen_rmsd_cutoff_ << std::endl;
150  Output_boolean(" perform_electron_density_screen_=", perform_electron_density_screen_ ); std::cout << std::endl;
151  Output_boolean(" rm_virt_phosphate_=", rm_virt_phosphate_ ); std::cout << std::endl;
152  std::cout << " native_edensity_score_cutoff_=" << native_edensity_score_cutoff_ << std::endl;
153  Output_boolean(" centroid_screen_=", centroid_screen_ ); std::cout << std::endl;
154  Output_boolean(" perform_o2star_pack_=", perform_o2star_pack_); std::cout << std::endl;
155  Output_boolean(" output_before_o2star_pack_=", output_before_o2star_pack_ ); std::cout << std::endl;
156  std::cout << " (Upper_limit) num_pose_minimize_=" << num_pose_minimize_<< " pose_data_list.size()= " << pose_data_list_.size() << std::endl;
157  Output_boolean(" minimize_and_score_sugar_=", minimize_and_score_sugar_ ); std::cout << std::endl;
158  Output_boolean(" user_inputted_VDW_bin_screener_=", user_input_VDW_bin_screener_->user_inputted_VDW_screen_pose() ); std::cout << std::endl;
159  Output_seq_num_list(" working_global_sample_res_list=", job_parameters_->working_global_sample_res_list() );
160  Output_boolean(" perform_minimize_=", perform_minimize_); std::cout << std::endl;
161  Output_boolean(" rename_tag_=", rename_tag_); std::cout << std::endl;
162 
163  clock_t const time_start( clock() );
164 
165  Size const gap_size( job_parameters_->gap_size() );
166 
167  RNA_LoopCloser rna_loop_closer;
168 
170 
171  AtomTreeMinimizer minimizer;
172  float const dummy_tol( 0.00000025);
173  bool const use_nblist( true );
174  MinimizerOptions options( "dfpmin", dummy_tol, use_nblist, false, false );
175  options.nblist_auto_update( true );
176 
177  /////////////////////////////////////////////////////////
178 
179  if(pose_data_list_.size()==0){
180  std::cout << "pose_data_list_.size()==0, early exit from StepWiseRNA_Minimizer::apply" << std::endl;
182  return;
183  }
184 
185  pose::Pose dummy_pose = (*pose_data_list_[1].pose_OP);
186  Size const nres = dummy_pose.total_residue();
187  //////////////////////////////May 30 2010//////////////////////////////////////////////////////////////
188  utility::vector1< core::Size > const & working_fixed_res= job_parameters_->working_fixed_res();
189  utility::vector1< core::Size > working_minimize_res;
190  bool o2star_pack_verbose=true;
191 
192  for(Size seq_num=1; seq_num<=pose.total_residue(); seq_num++ ){
193  if(Contain_seq_num(seq_num, working_fixed_res)) continue;
194  working_minimize_res.push_back(seq_num);
195  }
196  ///////////////////////////////////////////////////////////////////////////////////////////////////////
197 
198  //Check scorefxn
199  std::cout << "check scorefxn" << std::endl;
200  scorefxn_->show( std::cout, dummy_pose );
201 
202  if( move_map_list_.size()==0 ) move_map_list_=Get_default_movemap( dummy_pose );
203 
204  if(minimize_and_score_sugar_==false){
205  std::cout << "WARNING: minimize_and_score_sugar_ is FALSE, freezing all DELTA, NU_1 and NU_2 torsions." << std::endl;
206  for(Size n=1; n<=move_map_list_.size(); n++){
208  }
209  }
210 
211  for(Size n=1; n<=move_map_list_.size(); n++){
212  std::cout << "OUTPUT move_map_list[" << n << "]:" << std::endl;
213  Output_movemap(move_map_list_[n], dummy_pose);
214  }
215 
216 
217  utility::vector1 <pose_data_struct2> minimized_pose_data_list;
218 
219  for(Size pose_ID=1; pose_ID<=pose_data_list_.size(); pose_ID++){
220 
221  if(pose_ID>num_pose_minimize_){
222 
223  if(minimized_pose_data_list.size()==0){
224  utility_exit_with_message("pose_ID>num_pose_minimize_ BUT minimized_pose_data_list.size()==0! This will lead to problem in SWA_sampling_post_process.py!");
225  }
226  std::cout << "WARNING MAX num_pose_minimize_(" << num_pose_minimize_ << ") EXCEEDED, EARLY BREAK." << std::endl;
227  break;
228  }
229 
230  std::cout << "Minimizing pose_ID= " << pose_ID << std::endl;
231 
232  std::string tag=pose_data_list_[pose_ID].tag;
233  pose=(*pose_data_list_[pose_ID].pose_OP); //This actually create a hard copy.....need this to get the graphic working..
234 
235  Size const five_prime_chain_break_res = figure_out_actual_five_prime_chain_break_res(pose);
236 
237  if(rm_virt_phosphate_){ //Fang's electron density code
238  for (Size ii = 1; ii <= pose.total_residue(); ++ii) {
239  pose::remove_variant_type_from_pose_residue(pose, "VIRTUAL_PHOSPHATE", ii);
240  }
241  }
242 
243  if(verbose_ && output_before_o2star_pack_) output_pose_data_wrapper(tag, 'B', pose, silent_file_data, silent_file_ + "_before_o2star_pack");
244 
246 
247  if(perform_o2star_pack_) o2star_minimize(pose, scorefxn_, get_surrounding_O2star_hydrogen(pose, working_minimize_res, o2star_pack_verbose) );
248 
249  if(verbose_ && !output_before_o2star_pack_) output_pose_data_wrapper(tag, 'B', pose, silent_file_data, silent_file_ + "_before_minimize");
250 
251  ///////Minimization/////////////////////////////////////////////////////////////////////////////
252  if (gap_size == 0){
253  rna_loop_closer.apply( pose, five_prime_chain_break_res ); //This doesn't do anything if rna_loop_closer was already applied during sampling stage...May 10,2010
254 
255  if(verbose_) output_pose_data_wrapper(tag, 'C', pose, silent_file_data, silent_file_ + "_after_loop_closure_before_minimize");
256  }
257 
258  for(Size round=1; round<=move_map_list_.size(); round++){
260 
261  if(perform_minimize_) minimizer.run( pose, mm, *(scorefxn_), options );
262  if(perform_o2star_pack_) o2star_minimize(pose, scorefxn_, get_surrounding_O2star_hydrogen(pose, working_minimize_res, o2star_pack_verbose) );
263 
264  if( gap_size == 0 ){
265  Real mean_dist_err = rna_loop_closer.apply( pose, five_prime_chain_break_res );
266  std::cout << "mean_dist_err (round= " << round << " ) = " << mean_dist_err << std::endl;
267 
268  if(perform_o2star_pack_) o2star_minimize(pose, scorefxn_, get_surrounding_O2star_hydrogen(pose, working_minimize_res, o2star_pack_verbose) );
269  if(perform_minimize_) minimizer.run( pose, mm, *(scorefxn_), options );
270 
271  }
272 
273  }
274 
275  ////////////////////////////////Final screening //////////////////////////////////////////////
276  if( pass_all_pose_screens(pose, tag, silent_file_data)==false ) continue;
277 
278  //////////////////////////////////////////////////////////////////////////////////////////////
279  pose_data_struct2 pose_data;
280  pose_data.tag=tag;
281  pose_data.score=(*scorefxn_)(pose);
282  pose_data.pose_OP=new pose::Pose;
283  (*pose_data.pose_OP)=pose;
284  minimized_pose_data_list.push_back(pose_data);
285 
286  std::cout << "SO FAR: pose_ID= " << pose_ID << " | minimized_pose_data_list.size()= " << minimized_pose_data_list.size();
287  std::cout << " | time taken= " << static_cast<Real>( clock() - time_start ) / CLOCKS_PER_SEC << std::endl;
288  std::cout << "-------------------------------------------------------------------------------------------------" << std::endl;
289  std::cout << "-------------------------------------------------------------------------------------------------" << std::endl;
290 
291  }
292 
293  std::cout << "FINAL minimized_pose_data_list.size() = " << minimized_pose_data_list.size() << std::endl;
294 
295  if(minimized_pose_data_list.size()==0){
296  std::cout << "After finish minimizing, minimized_pose_data_list.size()==0!" << std::endl;
298  }
299 
300  std::sort(minimized_pose_data_list.begin(), minimized_pose_data_list.end(), minimizer_sort_criteria);
301 
302  for(Size pose_ID=1; pose_ID<=minimized_pose_data_list.size(); pose_ID++){
303  pose_data_struct2 & pose_data=minimized_pose_data_list[pose_ID];
304  pose::Pose & pose=(*pose_data.pose_OP);
305 
306  if(rename_tag_){
307  pose_data.tag = "S_"+ ObjexxFCL::lead_zero_string_of( pose_ID /* start with zero */, 6);
308  }else{
309  pose_data.tag[0]='M'; //M for minimized, these are the poses that will be clustered by master node.
310  }
311 
312  output_pose_data_wrapper(pose_data.tag, pose_data.tag[0], pose, silent_file_data, silent_file_);
313  }
314 
315 
316  std::cout << "--------------------------------------------------------------------" << std::endl;
317  std::cout << "Total time in StepWiseRNA_Minimizer: " << static_cast<Real>( clock() - time_start ) / CLOCKS_PER_SEC << std::endl;
318  std::cout << "--------------------------------------------------------------------" << std::endl;
319 
320  Output_title_text("Exit StepWiseRNA_Minimizer::apply");
321 
322  }
323 
324  ///////////////////////////////////////////////////////////////////////////////////////////////////////
325  core::Size
327 
328  using namespace ObjexxFCL;
329 
330  Size five_prime_chain_break_res = 0;
331 
332  if(job_parameters_->Is_simple_full_length_job_params()){
333  //March 03, 2012. If job_parameters_->Is_simple_full_length_job_params()==true, then
334  //actual five_prime_chain_break_res varies from pose to pose and might not correspond to the one given in the job_params!
335 
336  Size const gap_size( job_parameters_->gap_size() );
337 
338  if(gap_size!=0) utility_exit_with_message("job_parameters_->Is_simple_full_length_job_params()==true but gap_size!=0");
339 
340  Size num_cutpoint_lower_found=0;
341 
342  for(Size lower_seq_num=1; lower_seq_num<pose.total_residue(); lower_seq_num++){
343 
344  Size const upper_seq_num=lower_seq_num+1;
345 
346  if( pose.residue( lower_seq_num ).has_variant_type( chemical::CUTPOINT_LOWER ) ){
347  if( pose.residue( upper_seq_num ).has_variant_type( chemical::CUTPOINT_UPPER )==false ){
349  error_message+= "seq_num " + string_of(lower_seq_num) + " is a CUTPOINT_LOWER ";
350  error_message+= "but seq_num " + string_of(upper_seq_num) + " is not a cutpoint CUTPOINT_UPPER??";
351  utility_exit_with_message(error_message);
352  }
353 
354  five_prime_chain_break_res=lower_seq_num;
355  num_cutpoint_lower_found++;
356 
357  }
358  }
359 
360  if(num_cutpoint_lower_found!=1) utility_exit_with_message("num_cutpoint_lower_found=("+string_of(num_cutpoint_lower_found)+")!=1");
361 
362  }else{ //Default
363  five_prime_chain_break_res = job_parameters_->five_prime_chain_break_res();
364  }
365 
366  return five_prime_chain_break_res;
367 
368  }
369  ///////////////////////////////////////////////////////////////////////////////////////////////////////
370  void
372  char tag_first_char,
373  pose::Pose & pose,
375  std::string const out_silent_file) const{
376 
377  using namespace core::io::silent;
378 
379  //tag_first_char=B for before minimize
380  //tag_first_char=C for consistency_check
381  //tag_first_char=M for minimize
382 
383  tag[0]=tag_first_char;
384  std::cout << "tag= " << tag << std::endl;
385  (*scorefxn_)(pose); //Score pose to ensure that that it has a score to be output
386  Output_data(silent_file_data, out_silent_file, tag, false , pose, get_native_pose(), job_parameters_);
387 
388  }
389  ///////////////////////////////////////////////////////////////////////////////////////////////////////
390  void
392 
393  if ( utility::file::file_exists( silent_file_ ) ) utility_exit_with_message( silent_file_ + " already exist!");
394 
395  std::ofstream outfile;
396  outfile.open(silent_file_.c_str()); //Opening the file with this command removes all prior content..
397 
398  outfile << "StepWiseRNA_Minimizer:: num_pose_outputted==0, empty silent_file!\n"; //specific key signal to SWA_sampling_post_process.py
399 
400  outfile.flush();
401  outfile.close();
402 
403  }
404 
405  ///////////////////////////////////////////////////////////////////////////////////////////////////////
406  void
408 
409  using namespace core::id;
410 
411  std::cout << "Freeze pose sugar torsions, nres=" << nres << std::endl;
412 
413  for(Size i=1; i<=nres; i++){
414 
415  mm.set( TorsionID( i , id::BB, 4 ), false ); //delta_i
416  mm.set( TorsionID( i , id::CHI, 2 ), false ); //nu2_i
417  mm.set( TorsionID( i , id::CHI, 3 ), false ); //nu1_i
418 
419  }
420  }
421  ///////////////////////////////////////////////////////////////////////////////////////////////////////
422 
423  //Cannot pass pose in as constant due to the setPoseExtraScores function
424  bool
426 
427  using namespace core::scoring;
428  using namespace core::scoring::rna;
429  using namespace core::pose;
430  using namespace core::io::silent;
431  using namespace protocols::rna;
432  using namespace core::optimization;
433 
434 
435  Size const gap_size( job_parameters_->gap_size() ); /* If this is zero or one, need to screen or closable chain break */
436 
437  bool pass_screen=true;
438 
439  //March 03, 2012. Don't need this for post-process analysis. For full_length_job_params, Is_prepend, moving_res and five_prime_chain_break_res are not well defined.
440  if(job_parameters_->Is_simple_full_length_job_params()==false){
441 
442  Size const five_prime_chain_break_res = job_parameters_->five_prime_chain_break_res();
443  bool const Is_prepend( job_parameters_->Is_prepend() );
444  Size const moving_res( job_parameters_->working_moving_res() );
445 
446  if (gap_size == 0){
447  //Sept 19, 2010 screen for weird delta/sugar conformation. Sometime at the chain closure step, minimization will severely screw up the pose sugar
448  //if the chain is not a closable position. These pose will have very bad score and will be discarded anyway. The problem is that the clusterer check
449  //for weird delta/sugar conformation and call utility_exit_with_message() if one is found (purpose being to detect bad silent file conversion)
450  //So to prevent code exit, will just screen for out of range sugar here.
451  //Oct 28, 2010 ...ok check for messed up nu1 and nu2 as well. Note that check_for_messed_up_structure() also check for messed up delta but the range is smaller than below.
452  if(check_for_messed_up_structure(pose, in_tag)==true){
453  std::cout << "gap_size == 0, " << in_tag << " discarded: messed up structure " << std::endl;
454  pass_screen=false;
455  }
456 
457  conformation::Residue const & five_prime_rsd = pose.residue(five_prime_chain_break_res);
458  Real const five_prime_delta = numeric::principal_angle_degrees(five_prime_rsd.mainchain_torsion( DELTA ));
459 
460 
461 
462  if( (five_prime_rsd.has_variant_type("VIRTUAL_RNA_RESIDUE")==false) && (five_prime_rsd.has_variant_type("VIRTUAL_RIBOSE")==false)){
463  if( (five_prime_delta>1.0 && five_prime_delta<179.00)==false ){
464 
465  std::cout << "gap_size == 0, " << in_tag << " discarded: five_prime_chain_break_res= " << five_prime_chain_break_res << " five_prime_CB_delta= " << five_prime_delta << " is out of range " << std::endl;
466  pass_screen=false;
467  }
468  }
469 
470  conformation::Residue const & three_prime_rsd = pose.residue(five_prime_chain_break_res+1);
471  Real const three_prime_delta = numeric::principal_angle_degrees(three_prime_rsd.mainchain_torsion( DELTA ));
472 
473  if( (three_prime_rsd.has_variant_type("VIRTUAL_RNA_RESIDUE")==false) && (three_prime_rsd.has_variant_type("VIRTUAL_RIBOSE")==false)){
474  if( (three_prime_delta>1.0 && three_prime_delta<179.00)==false ){
475 
476  std::cout << "gap_size == 0, " << in_tag << " discarded: three_prime_chain_break_res= " << (five_prime_chain_break_res+1) << " three_prime_CB_delta= " << three_prime_delta << " is out of range " << std::endl;
477  pass_screen=false;
478  }
479  }
480  }
481 
482 
483  if(centroid_screen_){
484  if(base_centroid_screener_==0) utility_exit_with_message("base_centroid_screener_==0!");
485 
486  if ( !base_centroid_screener_->Update_base_stub_list_and_Check_that_terminal_res_are_unstacked( pose, true /*reinitialize*/ ) ){
487  std::cout << in_tag << " discarded: fail Check_that_terminal_res_are_unstacked " << std::endl;
488  pass_screen=false;
489  }
490  }
491 
492  if( gap_size == 1){
493  if( !Check_chain_closable(pose, five_prime_chain_break_res, gap_size) ){
494  pass_screen=false;
495  }
496  }
497 
498  if(native_screen_ && get_native_pose()){ //Before have the (&& !Is_chain_break condition). Parin Dec 21, 2009
499 
500  Real const rmsd= suite_rmsd(*get_native_pose(), pose, moving_res, Is_prepend, true /*ignore_virtual_atom*/);
501  Real const loop_rmsd= rmsd_over_residue_list( *get_native_pose(), pose, job_parameters_, true /*ignore_virtual_atom*/);
502 
503  if(rmsd > native_screen_rmsd_cutoff_ || loop_rmsd > native_screen_rmsd_cutoff_){
504  std::cout << in_tag << " discarded: fail native_rmsd_screen. rmsd= " << rmsd << " loop_rmsd= " << loop_rmsd << " native_screen_rmsd_cutoff_= " << native_screen_rmsd_cutoff_ << std::endl;
505  pass_screen=false;
506  }
507  }
508  }
509 
510  if(perform_electron_density_screen_){ //Fang's electron density code
511 
512  //Note to Fang: I moved this inside this funciton. While creating new pose is time-consuming..this does be effect code speed since the rate-limiting step here is the minimizer.run(). Parin S.
513  //setup native score screening
514  pose::Pose native_pose=*(job_parameters_->working_native_pose()); //Hard copy!
515 
516  for (Size i = 1; i <= native_pose.total_residue(); ++i) {
517  pose::remove_variant_type_from_pose_residue(native_pose, "VIRTUAL_PHOSPHATE", i);
518  }
519  /////////////////////////////////////////////////////////
520 
521  bool const pass_native = native_edensity_score_screener(pose, native_pose);
522  if(pass_native==false){
523  std::cout << in_tag << " discarded: fail native_edensity_score_screening" << std::endl;
524  pass_screen=false;
525  }
526  }
527 
528  //March 20, 2011..This is neccessary though to be consistent with FARFAR. Cannot have false low energy state that are due to empty holes in the structure.
529  //Feb 22, 2011. Warning this is inconsistent with the code in SAMPLERER:
530  //In Both standard and floating base sampling, user_input_VDW_bin_screener_ is not used for gap_size==0 or internal case.
531  //This code is buggy for gap_size==0 case IF VDW_screener_pose contains the residue right at 3' or 5' of the building_res
532  //Internal case should be OK.
533  if(user_input_VDW_bin_screener_->user_inputted_VDW_screen_pose() ){
534 
535  //Convert to using physical_pose instead of bin for screening (as default) on June 04, 2011
536  utility::vector1 < core::Size > const & working_global_sample_res_list=job_parameters_->working_global_sample_res_list();
537  bool const pass_physical_pose_VDW_rep_screen=user_input_VDW_bin_screener_->VDW_rep_screen_with_act_pose( pose, working_global_sample_res_list, true /*local verbose*/);
538 
539  if( pass_physical_pose_VDW_rep_screen==false){
540  std::cout << in_tag << " discarded: fail physical_pose_VDW_rep_screen" << std::endl;
541  pass_screen=false;
542  }
543 
544  }
545 
546  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
547  std::string temp_tag= in_tag;
548 
549  if(verbose_) output_pose_data_wrapper(temp_tag, 'S', pose, silent_file_data, silent_file_ + "_screen");
550 
551  return pass_screen;
552 
553  }
554  ////////////////////////////////////////////////////////////////////////////////////////
555  bool
557 
558  using namespace core::scoring;
559 
560  //get the score of elec_dens_atomwise only
561  static ScoreFunctionOP eden_scorefxn = new ScoreFunction;
562  eden_scorefxn -> set_weight( elec_dens_atomwise, 1.0 );
563  core::Real pose_score = ((*eden_scorefxn)(pose));
564  core::Real native_score = ((*eden_scorefxn)(native_pose));
565  core::Size nres = pose.total_residue();
566  core::Real native_score_cutoff = native_score / (static_cast <double> (nres)) *
568  std::cout << "pose_score = " << pose_score << std::endl;
569  std::cout << "native_score = " << native_score << std::endl;
570  if (pose_score > native_score - native_score_cutoff) {
571  std::cout << "Fail native edensity score screening!" << std::endl;
572  return false;
573  } else {
574  return true;
575  }
576  }
577 
578  ////////////////////////////////////////////////////////////////////////////////////////
581 
583 
585  Figure_out_moving_residues( mm, pose );
586 
587  // Allow sugar torsions to move again (RD 01/31/2010), now
588  // that rotamers have been pre-optimized for ribose closure, and
589  // sugar_close is turned back on.
590  // Freeze_sugar_torsions(mm, nres); //Freeze the sugar_torsions!
591 
592  move_map_list.push_back(mm);
593  return move_map_list;
594  }
595 
596  ////////////////////////////////////////////////////////////////////////////////////
597  // This is similar to code in RNA_Minimizer.cc
598  void
600  {
601 
602  using namespace core::id;
603  using namespace core::scoring::rna;
604  using namespace ObjexxFCL;
605 
606  Size const nres( pose.total_residue() );
607 
608  utility::vector1< core::Size > const & fixed_res( job_parameters_->working_fixed_res() );
609 
610  ObjexxFCL::FArray1D< bool > allow_insert( nres, true );
611  for (Size i = 1; i <= fixed_res.size(); i++ ) allow_insert( fixed_res[ i ] ) = false;
612 
613  mm.set_bb( false );
614  mm.set_chi( false );
615  mm.set_jump( false );
616 
617  for(Size i = 1; i <= nres; i++ ){
618 
619  if (pose.residue(i).aa() == core::chemical::aa_vrt ) continue; //Fang's electron density code.
620 
621  utility::vector1< TorsionID > torsion_ids;
622 
623  for ( Size rna_torsion_number = 1; rna_torsion_number <= NUM_RNA_MAINCHAIN_TORSIONS; rna_torsion_number++ ) {
624  torsion_ids.push_back( TorsionID( i, id::BB, rna_torsion_number ) );
625  }
626  for ( Size rna_torsion_number = 1; rna_torsion_number <= NUM_RNA_CHI_TORSIONS; rna_torsion_number++ ) {
627  torsion_ids.push_back( TorsionID( i, id::CHI, rna_torsion_number ) );
628  }
629 
630 
631  for ( Size n = 1; n <= torsion_ids.size(); n++ ) {
632 
633  TorsionID const & torsion_id = torsion_ids[ n ];
634 
635  id::AtomID id1,id2,id3,id4;
636  bool fail = pose.conformation().get_torsion_angle_atom_ids( torsion_id, id1, id2, id3, id4 );
637  if (fail) continue; //This part is risky, should also rewrite...
638 
639  // Dec 19, 2010..Crap there is a mistake here..should have realize this earlier...
640  //Should allow torsions at the edges to minimize...will have to rewrite this. This effect the gamma and beta angle of the 3' fix res.
641 
642  // If there's any atom that is in a moving residue by this torsion, let the torsion move.
643  // should we handle a special case for cutpoint atoms? I kind of want those all to move.
644  if ( !allow_insert( id1.rsd() ) && !allow_insert( id2.rsd() ) && !allow_insert( id3.rsd() ) && !allow_insert( id4.rsd() ) ) continue;
645  mm.set( torsion_id, true );
646 
647  }
648 
649  }
650 
651  std::cout << "pose.fold_tree().num_jump()= " << pose.fold_tree().num_jump() << std::endl;
652 
653  for (Size n = 1; n <= pose.fold_tree().num_jump(); n++ ){
654  Size const jump_pos1( pose.fold_tree().upstream_jump_residue( n ) );
655  Size const jump_pos2( pose.fold_tree().downstream_jump_residue( n ) );
656 
657  if(pose.residue(jump_pos1).aa() == core::chemical::aa_vrt) continue; //Fang's electron density code
658  if(pose.residue(jump_pos2).aa() == core::chemical::aa_vrt) continue; //Fang's electron density code
659 
660  if( allow_insert( jump_pos1 ) || allow_insert( jump_pos2 ) ) mm.set_jump( n, true );
661  std::cout << "jump_pos1= " << jump_pos1 << " jump_pos2= " << jump_pos2 << " mm.jump= "; Output_boolean(allow_insert( jump_pos1 ) || allow_insert( jump_pos2 ) ); std::cout << std::endl;
662 
663  }
664 
665  }
666 
667 
668  ////////////////////////////////////////////////////////////////////////////////////
669  void
671  move_map_list_ = move_map_list;
672  }
673 
674 
675  //////////////////////////////////////////////////////////////////////////
676  void
678  silent_file_ = silent_file;
679  }
680 
681  //////////////////////////////////////////////////////////////////////////
682  void
684  scorefxn_ = scorefxn;
685  }
686 
687  //////////////////////////////////////////////////////////////////////////
690  return sfd_;
691  }
692 
693  //////////////////////////////////////////////////////////////////
694  void
696  base_centroid_screener_ = screener;
697  }
698 
699  //////////////////////////////////////////////////////////////////
700  void
702 
704 
706 
707  }
708  //////////////////////////////////////////////////////////////////
709 
710 }
711 }
712 }