Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StepWiseRNA_ResidueSampler.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_ResidueSampler
11 /// @brief Not particularly fancy, just minimizes a list of poses.
12 /// @detailed
13 /// @author Parin Sripakdeevong
14 /// @author Rhiju Das
15 
16 //////////////////////////////////
17 //Test_comment
26 
29 #include <protocols/swa/rna/StepWiseRNA_OutputData.hh> //Sept 26, 2011
31 
32 
33 //#include <protocols/swa/rna/StepWiseRNA_Dinucleotide_Sampler_Util.hh>
34 
35 //////////////////////////////////
36 #include <core/types.hh>
42 #include <core/pose/Pose.hh>
43 #include <core/pose/util.hh>
49 #include <basic/Tracer.hh>
53 
55 #include <core/scoring/Energies.hh>
58 
59 #include <core/id/TorsionID.hh>
60 #include <core/id/AtomID.hh>
61 #include <core/id/DOF_ID.hh>
64 #include <core/chemical/util.hh>
66 #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
70 #include <core/io/pdb/pose_io.hh>
71 
72 
73 //GreenPacker
76 
77 #include <numeric/NumericTraits.hh>
78 
79 #include <ObjexxFCL/format.hh>
80 #include <ObjexxFCL/string.functions.hh>
81 
82 #include <utility/exit.hh>
83 #include <time.h>
84 
85 #include <string>
86 #include <fstream>
87 #include <iostream>
88 #include <sstream>
89 #include <math.h>
90 #include <stdlib.h>
91 
92 
93 using namespace core;
94 using core::Real;
95 using io::pdb::dump_pdb;
96 
97 //////////////////////////////////////////////////////////////////////////
98 //////////////////////////////////////////////////////////////////////////
99 // Core routine for stepwise sampling of RNA
100 //////////////////////////////////////////////////////////////////////////
101 //////////////////////////////////////////////////////////////////////////
102 //////////////////////////////////////////////////////////////////////////
103 
104 static basic::Tracer TR( "protocols.swa.rna.stepwise_rna_residue_sampler" ) ;
105 
106 namespace protocols {
107 namespace swa {
108 namespace rna {
109 
110  //////////////////////////////////////////////////////////////////////////
111  //constructor!
112  StepWiseRNA_ResidueSampler::StepWiseRNA_ResidueSampler( StepWiseRNA_JobParametersCOP & job_parameters ):
113  job_parameters_( job_parameters ),
114  sfd_( new core::io::silent::SilentFileData ),
115  scorefxn_( core::scoring::ScoreFunctionFactory::create_score_function( "rna_hires.wts" ) ),// can be replaced from the outside
116  silent_file_( "silent_file.txt" ),
117  output_filename_( "data.txt"),
118  bin_size_( 20 ),
119  rep_cutoff_( 4.0 ),
120  num_pose_kept_( 108 ),
121  multiplier_(2), //Sort and cluster poses when the number of pose is pose_data_list exceed multiplier*num_pose_kept,
122  cluster_rmsd_(0.5001),
123  verbose_( false ),
124  native_rmsd_screen_(false),
125  native_screen_rmsd_cutoff_(2.0),
126  perform_o2star_pack_( true ),
127  use_green_packer_( false ),
128  allow_bulge_at_chainbreak_( false ),
129  fast_( false ),
130  medium_fast_( false ),
131  integration_test_mode_( false ), //March 16, 2012
132  floating_base_( false ), //July 02, 2012
133  centroid_screen_(true),
134  allow_base_pair_only_centroid_screen_(false), //allow for possibility of conformation that base_pair but does not base_stack
135  VDW_atr_rep_screen_(true),
136  include_syn_chi_(false),
137  allow_syn_pyrimidine_(false), //New option Nov 15, 2010
138  distinguish_pucker_(true),
139  build_pose_from_scratch_(false), //July 03, 2012. This was previously uninitialized in floating_base_sampling mode! lead to early return from cluster_pose_data_list() function on some compiler/machine! [Specifically on the Biox2-cluster RUNS after converted to qsub (~April 2012)
140  current_score_cutoff_(999999.9), //Feb 02, 2012
141  //current_score_cutoff_(99999999999.9999), //New option May 12, 2010, Feb 02, 2012; This might lead to server-test error at R47200
142  finer_sampling_at_chain_closure_(false), //New option Jun 10 2010
143  PBP_clustering_at_chain_closure_(false), //New option Aug 15 2010
144  reinitialize_CCD_torsions_(false), //New option Aug 15 2010 //Reinitialize_CCD_torsion to zero before every CCD chain closure
145  extra_epsilon_rotamer_(false), //New option Aug 30, 2010
146  extra_beta_rotamer_(false), //New option Aug 30, 2010
147  extra_anti_chi_rotamer_(false), //Split to syn and anti on June 16, 2011
148  extra_syn_chi_rotamer_(false), //Split to syn and anti on June 16, 2011
149  sample_both_sugar_base_rotamer_(false), //New option Nov 12, 2010 (mainly for square_RNA)
150  include_torsion_value_in_tag_(false), //For checking if the extra rotamer are important
151  rebuild_bulge_mode_(false),
152  debug_eplison_south_sugar_mode_(false),
153  exclude_alpha_beta_gamma_sampling_(false),
154  combine_long_loop_mode_(false), //in this mode, the moving_residues must contact the last residue built from the other side.
155  do_not_sample_multiple_virtual_sugar_(false), //Nov 13, 2010, optimize the chain closure step speed
156  sample_ONLY_multiple_virtual_sugar_(false), //Nov 13, 2010, optimize the chain closure step speed
157  assert_no_virt_ribose_sampling_(false), //July 28 2011
158  output_pdb_(false) //Sept 24, 2011
159 
160  {
161  set_native_pose( job_parameters_->working_native_pose() );
162 
163  ////////////////Parin Feb 28, 2010////////////////////////////////////////////////
164  utility::vector1 < core::Size > const & rmsd_res_list = job_parameters_->rmsd_res_list();
165  working_rmsd_res_= apply_full_to_sub_mapping( rmsd_res_list, job_parameters);
166 
167  std::map< core::Size, bool > const & Is_prepend_map = job_parameters_->Is_prepend_map();
168 
169  Output_is_prepend_map("Is_prepend_map= ", Is_prepend_map , job_parameters_->full_sequence().size(), 30);
170  Output_seq_num_list("rmsd_res= ", rmsd_res_list, 30);
171  Output_seq_num_list("working_rmsd_res= ", working_rmsd_res_, 30);
172  ////////////////////////////////////////////////////////////////////////////////
173 
174  }
175 
176  //////////////////////////////////////////////////////////////////////////
177  //destructor
179  {}
180 
181  /////////////////////
184  return "StepWiseRNA_ResidueSampler";
185  }
186 
187 
188  //////////////////////////////////////////////////////////////////////////
189  bool
190  sort_criteria(pose_data_struct2 pose_data_1, pose_data_struct2 pose_data_2) { //This function used to be call sort_criteria2
191  return (pose_data_1.score < pose_data_2.score);
192  }
193  ////////////////////////////////////////////////////////////////////////////
194 
195 
196  void
198 
199  using namespace ObjexxFCL;
200 
201  Output_title_text("Enter StepWiseRNA_ResidueSampler::apply");
202 
203  clock_t const time_start( clock() );
204 
205  //output screen options
206  std::cout << "--------SCREEN OPTIONS---------- "<< std::endl;
207  Output_boolean("fast_ = ", fast_ ); std::cout << std::endl;
208  Output_boolean("medium_fast_ = ", medium_fast_ ); std::cout << std::endl;
209  Output_boolean("integration_test_mode_ = ", integration_test_mode_ ); std::cout << std::endl;
210  Output_boolean("native_rmsd_screen = ", native_rmsd_screen_ ); std::cout << std::endl;
211  std::cout << "native_screen_rmsd_cutoff = " << native_screen_rmsd_cutoff_ << std::endl;
212  Output_boolean("perform_o2star_pack = ", perform_o2star_pack_ ); std::cout << std::endl;
213  Output_seq_num_list("working_moving_partition_pos= ", job_parameters_->working_moving_partition_pos(), 40);
214  Output_boolean("centroid_screen = ", centroid_screen_ ); std::cout << std::endl;
215  Output_boolean("allow_base_pair_only_centroid_screen = ", allow_base_pair_only_centroid_screen_ ); std::cout << std::endl;
216  Output_boolean("VDW_atr_rep_screen = ", VDW_atr_rep_screen_ ); std::cout << std::endl;
217  Output_boolean("sample_both_sugar_base_rotamer_ = ", sample_both_sugar_base_rotamer_ ); std::cout << std::endl;
218  Output_boolean("do_not_sample_multiple_virtual_sugar_ = ", do_not_sample_multiple_virtual_sugar_ ); std::cout << std::endl;
219  Output_boolean("sample_ONLY_multiple_virtual_sugar_ = ", sample_ONLY_multiple_virtual_sugar_ ); std::cout << std::endl;
220  Output_boolean("assert_no_virt_ribose_sampling_ =" , assert_no_virt_ribose_sampling_ ); std::cout << std::endl;
221  Output_boolean("distinguish_pucker_ ", distinguish_pucker_); std::cout << std::endl;
222  std::cout << "--------------------------------" << std::endl;
223 
224 
225  Pose const pose_save = pose;
226  pose = pose_save; //this recopy is useful for triggering graphics.
227 
228  initialize_scorefunctions(); //////////////// Sets up scorefunctions for a bunch of different screens ////////////////////////////////////////
229 
230  //Sept 2, 2010
232 
233  /////////////////////////////////////Build previously virtualize sugar//////////////////////////////////////////////////
234  Output_title_text("Build previously virtualize sugar");
235  bool const Is_prev_sugar_virt=Is_previous_sugar_virtual( pose );
236  bool const Is_curr_sugar_virt=Is_current_sugar_virtual( pose);
237  bool const Is_five_prime_CB_sugar_virt=Is_five_prime_chain_break_sugar_virtual( pose );
238  bool const Is_three_prime_CB_sugar_virt=Is_three_prime_chain_break_sugar_virtual( pose );
239  Size const num_nucleotides= job_parameters_->working_moving_res_list().size();
240  Size const gap_size= job_parameters_->gap_size();
241 
242  Output_boolean(" Is_previous_sugar_virt=", Is_prev_sugar_virt ); Output_boolean(" Is_current_sugar_virt=", Is_curr_sugar_virt);
243  Output_boolean(" Is_five_prime_chain_break_sugar_virt=", Is_five_prime_CB_sugar_virt ); Output_boolean(" Is_three_prime_chain_break_sugar_virt=", Is_three_prime_CB_sugar_virt );
244  std::cout << std::endl;
245 
246  ///Nov 13, 2010
247 
248  Size num_virtual_sugar=0;
249  if(Is_prev_sugar_virt==true) num_virtual_sugar++;
250  if(Is_curr_sugar_virt==true) num_virtual_sugar++;
251  if(Is_five_prime_CB_sugar_virt==true) num_virtual_sugar++;
252  if(Is_three_prime_CB_sugar_virt==true) num_virtual_sugar++;
253 
254  std::cout << "num_virtual_sugar= " << num_virtual_sugar << std::endl;
255 
257  if(floating_base_ && num_nucleotides==2){ //Hacky..ok the only acception right now is in floating_base_ + dinucleotide mode.
258  if(num_virtual_sugar>1) utility_exit_with_message("assert_no_virt_ribose_sampling_==true and floating_base, but num_virtual_sugar>1");
259  if(num_virtual_sugar==1){
260  if(Is_prev_sugar_virt==false) {
261  utility_exit_with_message("assert_no_virt_ribose_sampling_==true and floating_base and num_virtual_sugar==1 BUT Is_prev_sugar_virt==false!)");
262  }
263  }
264  }else{
265  if(num_virtual_sugar!=0) utility_exit_with_message("assert_no_virt_ribose_sampling_==true but num_virtual_sugar!=0");
266  }
267  }
268 
269  if(Is_curr_sugar_virt){ //Consistency test.
270  //Right now, the only possiblility for Is_curr_sugar_virt==true is when combining two silent_files chunk at chain-break
271  if(gap_size!=0) utility_exit_with_message("Is_curr_sugar_virt==true but gap_size!=0 !!");
272  utility::vector1 < core::Size > const & working_moving_partition_pos = job_parameters_->working_moving_partition_pos();
273  if(working_moving_partition_pos.size()<=1) utility_exit_with_message("Is_curr_sugar_virt==true but working_moving_partition_pos.size()<=1");
274  }
275  if(gap_size!=0 && num_virtual_sugar>1) utility_exit_with_message( "gap_size!=0 but num_virtual_sugar>1" ); //Obsolete!
276 
277  if(floating_base_){
278  if(Is_five_prime_CB_sugar_virt){ //This is rare since floating_base sampling is not often used at chain-closure step!
279  std::cout << "WARNING: floating_base_ and Is_five_prime_CB_sugar_virt case. Code not implemented yet, early return!" << std::endl;
280  return;
281  }
282 
283  if(Is_three_prime_CB_sugar_virt){ //This is rare since floating_base sampling is not often used at chain-closure step!
284  std::cout << "WARNING: floating_base_ and Is_three_prime_CB_sugar_virt case. Code not implemented yet, early return!" << std::endl;
285  return;
286  }
287 
288  if(Is_curr_sugar_virt){
289  utility_exit_with_message("floating_base_ and Is_curr_sugar_virt case. Code not implemented yet!");
290  }
291  }
292 
294  utility_exit_with_message( "do_not_sample_multiple_virtual_sugar_==true && sample_ONLY_multiple_virtual_sugar_==true" );
295  }
296 
298  if(num_virtual_sugar>1) return;
299  }
300 
302  if(gap_size!=0) utility_exit_with_message( "sample_ONLY_multiple_virtual_sugar_==true but gap_size!=0" );
303  if(num_virtual_sugar<=1) return;
304  }
305 
306 
307 
308  bool const Is_prepend( job_parameters_->Is_prepend() );
309  Size const moving_res( job_parameters_->working_moving_res() );
310  Size const five_prime_chain_break_res = job_parameters_->five_prime_chain_break_res();
311  Size const three_prime_chain_break_res = five_prime_chain_break_res+1;
312 
313  //utility::vector1< pose_data_struct2 > prev_sugar_PDL, five_prime_CB_sugar_PDL, three_prime_CB_sugar_PDL;
314 
319 
320 
321  if(Is_prev_sugar_virt){
322  std::cout << "previous_sugar floating_base_chain_closure" << std::endl;
323 
324  Size const prev_moving_res = (Is_prepend) ? (moving_res+num_nucleotides) : (moving_res-num_nucleotides);
325  Size const prev_ref_res = (Is_prepend) ? (moving_res+(num_nucleotides+2)) : (moving_res-(num_nucleotides+2));
326 
327  prev_sugar_FB_JP=FloatingBaseChainClosureJobParameter(prev_moving_res, prev_ref_res);
328  prev_sugar_FB_JP.set_base_and_pucker_state(pose, job_parameters_);
329  prev_sugar_FB_JP.PDL=previous_floating_base_chain_closure(pose, prev_sugar_FB_JP, "previous");
330 
331  if(prev_sugar_FB_JP.PDL.size()==0){
332  std::cout << "Is_prev_sugar_virt==True but prev_sugar_FB_JP.PDL.size()==0!" << std::endl;
333  return;
334  }
335  }
336 
337  if(Is_curr_sugar_virt){ //June 12, 2011
338  std::cout << "current_sugar floating_base_chain_closure" << std::endl;
339 
340  Size const curr_ref_res = (Is_prepend) ? (moving_res-2) : (moving_res+2);
341 
342  curr_sugar_FB_JP=FloatingBaseChainClosureJobParameter(moving_res, curr_ref_res);
343  curr_sugar_FB_JP.set_base_and_pucker_state(pose, job_parameters_);
344  curr_sugar_FB_JP.PDL=previous_floating_base_chain_closure(pose, curr_sugar_FB_JP, "current");
345 
346  if(curr_sugar_FB_JP.PDL.size()==0){
347  std::cout << "Is_curr_sugar_virt==True but curr_sugar_FB_JP.PDL.size()==0!" << std::endl;
348  return;
349  }
350  }
351 
352  if(Is_five_prime_CB_sugar_virt){
353  std::cout << "five_prime_CB_sugar floating_base_chain_closure" << std::endl;
354 
355  five_prime_CB_sugar_FB_JP=FloatingBaseChainClosureJobParameter(five_prime_chain_break_res, five_prime_chain_break_res-2);
356  five_prime_CB_sugar_FB_JP.set_base_and_pucker_state(pose, job_parameters_);
357  five_prime_CB_sugar_FB_JP.PDL=previous_floating_base_chain_closure(pose, five_prime_CB_sugar_FB_JP, "five_prime_CB");
358 
359  if(five_prime_CB_sugar_FB_JP.PDL.size()==0) {
360  std::cout << "Is_five_prime_CB_sugar_virt==True but five_prime_CB_sugar_FB_JP.PDL.size()==0!" << std::endl;
361  return;
362  }
363  }
364 
365  if(Is_three_prime_CB_sugar_virt){
366  std::cout << "three_prime_CB_sugar floating_base_chain_closure:" << std::endl;
367 
368  three_prime_CB_sugar_FB_JP=FloatingBaseChainClosureJobParameter(three_prime_chain_break_res, three_prime_chain_break_res+2);
369  three_prime_CB_sugar_FB_JP.set_base_and_pucker_state(pose, job_parameters_);
370  three_prime_CB_sugar_FB_JP.PDL=previous_floating_base_chain_closure(pose, three_prime_CB_sugar_FB_JP, "three_prime_CB");
371 
372  if(three_prime_CB_sugar_FB_JP.PDL.size()==0){
373  std::cout << "Is_three_prime_CB_sugar_virt==True but three_prime_CB_sugar_FB_JP.PDL.size()==0!" << std::endl;
374  return;
375  }
376  }
377 
378  if( num_virtual_sugar>0 ){
379  std::cout << "Contain_virtual_sugar==true" << std::endl;
380  }else{
381  std::cout << "Contain_virtual_sugar==false" << std::endl;
382  }
383 
384  /////////////Sort the pose_data_list by score..should be determined according to torsional potential score. /////////////////////////
385  std::sort(prev_sugar_FB_JP.PDL.begin(), prev_sugar_FB_JP.PDL.end(), sort_criteria);
386  std::sort(curr_sugar_FB_JP.PDL.begin(), curr_sugar_FB_JP.PDL.end(), sort_criteria);
387  std::sort(five_prime_CB_sugar_FB_JP.PDL.begin(), five_prime_CB_sugar_FB_JP.PDL.end(), sort_criteria);
388  std::sort(three_prime_CB_sugar_FB_JP.PDL.begin(), three_prime_CB_sugar_FB_JP.PDL.end(), sort_criteria);
389  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
390 
391  if(floating_base_){
392 
393  floating_base_sampling(pose, prev_sugar_FB_JP);
394 
395  }else{
396 
397  standard_sampling_WRAPPER(pose, prev_sugar_FB_JP, curr_sugar_FB_JP, five_prime_CB_sugar_FB_JP, three_prime_CB_sugar_FB_JP);
398  }
399 
400  pose = pose_save;
401 
402 
403  if(rebuild_bulge_mode_){ //Ensure that bulge_res is not virtualized in final output.
404 
405  for(Size n=1; n<=pose_data_list_.size(); n++){
406  if((*pose_data_list_[n].pose_OP).residue(job_parameters_->working_moving_res()).has_variant_type( "VIRTUAL_RNA_RESIDUE" )){
407  utility_exit_with_message( "working_moving_res: " + string_of(job_parameters_->working_moving_res()) + " of pose " +string_of(n) + " is a virtual res!" );
408  }
409  }
410  }
411 
412  std::cout << "Total time in StepWiseRNA_ResidueSampler::apply " << static_cast<Real>( clock() - time_start ) / CLOCKS_PER_SEC << std::endl;
413 
414  Output_title_text("Exit StepWiseRNA_ResidueSampler::apply");
415 
416  }
417 
418 
419  void
421 
422  Output_title_text("Enter StepWiseRNA_ResidueSampler::floating_base_sampling");
423 
424  using namespace core::chemical;
425  using namespace core::conformation;
426  using namespace core::scoring;
427  using namespace core::pose;
428  using namespace core::io::silent;
429  using namespace core::id;
430  using namespace core::kinematics;
431 
432  clock_t const time_start( clock() );
433 
434  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
435 
436  const Real RADS_PER_DEG = numeric::NumericTraits<Real>::pi() / 180.;
437 
439 
440  Size const moving_res( job_parameters_->working_moving_res() ); // Might not corresponds to user input.
441  Size const moving_suite( job_parameters_->working_moving_suite() ); // dofs betweeen this value and value+1 actually move.
442  bool const Is_prepend( job_parameters_->Is_prepend() );
443  bool const Is_internal( job_parameters_->Is_internal() ); // no cutpoints before or after moving_res.
444  Size const gap_size( job_parameters_->gap_size()); /* If this is zero or one, need to screen or closable chain break */
445  Size const five_prime_chain_break_res = job_parameters_->five_prime_chain_break_res();
446  Size const num_nucleotides( job_parameters_->working_moving_res_list().size() );
447  Size const reference_res( job_parameters_->working_reference_res() ); //the last static_residues that this attach to the moving residues
448  Size const floating_base_five_prime_chain_break= (Is_prepend) ? moving_res : moving_res - 1; //for floating base chain closure when num_nucleotides=1
449 
450  if(combine_long_loop_mode_) utility_exit_with_message( "combine_long_loop_mode_ have not been implement for floating base sampling yet!!" );
451 
452 
453  bool const Is_dinucleotide=(num_nucleotides==2);
454 
455  std::cout << " NUM_NUCLEOTIDES= " << num_nucleotides << std::endl;
456  Output_boolean(" IS_DINUCLEOTIDE= ", Is_dinucleotide); std::cout << std::endl;
457  std::cout << " GAP SIZE " << gap_size << std::endl;
458  std::cout << " MOVING RES " << moving_res << std::endl;
459  std::cout << " MOVING SUITE " << moving_suite << std::endl;
460  Output_boolean(" PREPEND ", Is_prepend ); std::cout << std::endl;
461  Output_boolean(" INTERNAL ", Is_internal); std::cout << std::endl;
462  std::cout << " REFERENCE_RES " << reference_res << std::endl;
463  std::cout << " FLOATING_BASE_FIVE_PRIME_CHAIN_BREAK " << floating_base_five_prime_chain_break << std::endl;
464  Output_boolean(" build_pose_from_scratch_= ", build_pose_from_scratch_); std::cout << std::endl;
465 
466  if(Is_dinucleotide==true && Is_internal==true) utility_exit_with_message( "Is_dinucleotide==true && Is_internal==true)!!" );
467  if(num_nucleotides!=1 && num_nucleotides!=2) utility_exit_with_message( "num_nucleotides!=1 and num_nucleotides!=2" );
468 
469  if(Is_dinucleotide==true && allow_base_pair_only_centroid_screen_==true){ //Feb 09, 2012: FIXED BUG. Used to be "and" instead of "&&"
470 
471  Size const user_input_num_pose_kept=num_pose_kept_;
473 
474  //std::cout << "Accessible conformational space is larger when sampling a dinucleotide " << std::endl;
475  std::cout << "allow_base_pair_only_centroid_screen_==true for floating base + dinucleotide sampling mode " << std::endl;
476  std::cout << "Increase num_pose_kept by 4 folds" << std::endl;
477 
478  std::cout << " user_input_num_pose_kept= " << user_input_num_pose_kept << " num_pose_kept_ " << num_pose_kept_ << std::endl;
479 
480  }
481 
482  /////////////////////////////////////////////Virtual moving res (This will be moved to PoseSetup later)/////////////////////////////
483  pose::add_variant_type_to_pose_residue( pose, "VIRTUAL_PHOSPHATE", moving_res ); //This is unique to floating_base_mode
484  pose::add_variant_type_to_pose_residue( pose, "VIRTUAL_RIBOSE", moving_res ); //This is unique to floating_base_mode
485  Add_virtual_O2Star_hydrogen( pose ); //Apr 3, 2010
486 
487  //////////////////////////////////////////Setup Atr_rep_screening/////////////////////////////////////////////////
488  //This is getting annoying...need to move this up here since it create a chainbreak conflict with setup_chain_break_jump_point) below..
489 
490  //Real base_rep_score(-9999999999), base_atr_score(-9999999999); //Feb 02, 2012 This might lead to server-test error at R47200
491  Real base_rep_score(-999999), base_atr_score(-999999); //Feb 02, 2012
492  get_base_atr_rep_score(pose, base_atr_score, base_rep_score);
493 
494  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
495 
496  if( num_nucleotides == 1){ //Sept 16, 2010
497  //PURPOSE OF THIS IS FOR FLOATING BASE CHAIN CLOSURE
498  //NEED TO ADD THIS BEFORE calculating moving_rsd_at_origin_list since adding OVL1, OVL2 and OVU1 will change atoms number and positions in the residue
499 
500  std::cout << "setup_chain_break_jump_point for floating_base_five_prime_chain_break= " << floating_base_five_prime_chain_break << std::endl;
501  //pose.dump_pdb( "pose_before_setup_floating_base_chain_break.pdb" );
502 
503  setup_chain_break_jump_point( pose , moving_res, reference_res, floating_base_five_prime_chain_break, true );
504  //OK THIS IS HACKY...still have to find a way to remove the cutpoint (perhap after MINIMIZER?)
505  //pose.dump_pdb( "pose_after_setup_floating_base_chain_break.pdb" );
506  }
507 
508  /////////////////////////////////////////////Setup reference stub///////////////////////////////////////////////////////////////////
509 
510  core::kinematics::Stub const reference_stub=get_reference_stub(reference_res, pose);
511 
513  VDW_bin_screener->setup_using_working_pose( pose , job_parameters_ );
514 
515  user_input_VDW_bin_screener_->reference_xyz_consistency_check( reference_stub.v );
516 
517  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
518  print_atom_info(pose, moving_res, "pose setup_residue_at_origin_list");
519 
520 
521  ////////////////////////////////////////Screening poses///////////////////////////////////////////////////
522 
523 
524  pose::Pose screening_pose = pose; //Hard copy
525  if (gap_size == 0) pose::add_variant_type_to_pose_residue( screening_pose, "VIRTUAL_PHOSPHATE", five_prime_chain_break_res+1 ); //May 31, 2010
526 
527  print_atom_info(screening_pose, moving_res, "screening_pose");
528 
529 
530  pose::Pose ribose_screening_pose= pose; //Hard copy
531  if (gap_size == 0) pose::add_variant_type_to_pose_residue( ribose_screening_pose, "VIRTUAL_PHOSPHATE", five_prime_chain_break_res+1 ); //May 31, 2010
532  pose::remove_variant_type_from_pose_residue( ribose_screening_pose, "VIRTUAL_RIBOSE", moving_res );
533 
534  print_atom_info(ribose_screening_pose, moving_res, "ribose_screening_pose");
535 
536 
537  if ( gap_size == 0 ) { //harmonic angle and distnace constraints are used ONLY by chainbreak_screening
538 
539  pose::remove_variant_type_from_pose_residue( pose, "VIRTUAL_RIBOSE", moving_res ); //May 31, 2010
540 
541  if(moving_res==(five_prime_chain_break_res+1)){ //prepend.
542  pose::remove_variant_type_from_pose_residue( pose, "VIRTUAL_PHOSPHATE", moving_res ); //this virtual_phosphate was added to pose at the beginning of this function.
543  }
544 
545  if( pose.residue_type( five_prime_chain_break_res+1 ).has_variant_type( "VIRTUAL_PHOSPHATE" ) ){
546  utility_exit_with_message("pose have VIRTUAL_PHOSPHATE AT five_prime_chain_break_res+1!");
547  }
548 
549  std::cout << "Adding harmonic chainbreak to standard job_params five_prime_chain_break_res= " << five_prime_chain_break_res << std::endl;
550  Add_harmonic_chainbreak_constraint(pose, five_prime_chain_break_res );
551 
552  }
553 
554  if( num_nucleotides == 1){ //Sept 16, 2010
555 
556  pose::remove_variant_type_from_pose_residue( pose, "VIRTUAL_RIBOSE", moving_res ); //May 31, 2010
557 
558  if(moving_res==(floating_base_five_prime_chain_break+1)){
559  pose::remove_variant_type_from_pose_residue( pose, "VIRTUAL_PHOSPHATE", moving_res ); //this virtual_phosphate was added to pose at the beginning of this function.
560  }
561 
562  if( pose.residue_type( floating_base_five_prime_chain_break+1 ).has_variant_type( "VIRTUAL_PHOSPHATE" ) ){
563  utility_exit_with_message("pose have VIRTUAL_PHOSPHATE AT floating_base_five_prime_chain_break+1!");
564  }
565 
566  std::cout << "Adding harmonic chainbreak to floating_base_five_prime_chain_break= " << floating_base_five_prime_chain_break << std::endl;
567  Add_harmonic_chainbreak_constraint(pose, floating_base_five_prime_chain_break );
568 
569  }
570 
571  print_atom_info(pose, moving_res, "pose after modify variant_types");
572 
573 
574  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
575  pose::Pose pose_with_original_HO2star_torsion;
576  pose::Pose o2star_pack_pose;
577  if( perform_o2star_pack_ ) {
578  pose_with_original_HO2star_torsion=pose;
579 
580  if ( use_green_packer_ ) utility_exit_with_message( "green packer mode have not been tested for floating base sampling!" );
581 
582  //need to un-virtualize the hydrogen (except for the moving base hydrogen, since set_base_coordinate_frame() requires the atom numbering to be consistent
583  //ACTUALLY COULD ALSO UN-VIRTUALIZE THE MOVING_BASE O2STAR_HYDROGEN PROVIDED THAT WE CREATE A SEPERATE moving_rsd_at_origin.
584  //BUT NO POINT IN DURING SO, SINCE THE FULL RIBOSE IS VIRTUAL ANYWAYS!
585 
586  for(Size seq_num=1; seq_num<=pose.total_residue(); seq_num++){
587  if (pose.residue(seq_num).aa() == core::chemical::aa_vrt ) continue; //Fang's electron density code.
588  if( seq_num == moving_res ) continue; //moving_res is actually the working_moving_res
589 
590  if ( pose.residue_type( seq_num ).has_variant_type( "VIRTUAL_O2STAR_HYDROGEN" ) ){
591  pose::remove_variant_type_from_pose_residue( pose, "VIRTUAL_O2STAR_HYDROGEN", seq_num);
592  }
593  }
594 
595  o2star_pack_pose=pose; //NEED THE VARIANT TYPE OF CB_screening_pose and pose to be the same!
596 
597  }
598 
599  pose::Pose CB_screening_pose=pose; //NEED THE VARIANT TYPE OF CB_screening_pose and pose to be the same!
600 
601  print_atom_info(pose, moving_res, "pose after remove o2star variant type");
602 
603 
604  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
605 
606 
607  ///////Setup Residue of moving and reference of various rsd conformation (syn/anti chi, 2' and 3' endo) with base at origin coordinate frame////////////////////
608 
609  utility::vector1 <core::conformation::ResidueOP> const moving_rsd_at_origin_list
611  //std::cout << "Change to Residue const & moving_rsd_at_origin=(*moving_rsd_at_origin_list[5]) " << std::endl;
612  //Residue const & moving_rsd_at_origin=(*moving_rsd_at_origin_list[5]);
613 
614  //March 26, 2011.. after move create screening poses and modify pose variant to ABOVE
615  utility::vector1 <core::conformation::ResidueOP> const screening_moving_rsd_at_origin_list
616  =setup_residue_at_origin_list(screening_pose, moving_res, extra_anti_chi_rotamer_, extra_syn_chi_rotamer_,"screening_pose");
617 
618  std::cout << "Change to Residue const & screening_moving_rsd_at_origin=(*screening_moving_rsd_at_origin_list[5]) " << std::endl;
619  Residue const & screening_moving_rsd_at_origin=(*screening_moving_rsd_at_origin_list[5]);
620  //Doesn't really matter which sugar/base conformation the rsd has...any member of the list is fine. (NEED TO CHECK THAT THIS WORKS!)
621  //UMM, in score vs. rmsd (Trail 7(old) vs. Trail 15(new))....rmsd and disrimination slight worst....could be an artifact of new sugar position.....
622  //Should calculate rmsd...excluding the sugar to see if this is the case..MAKE SURE IT is not something deeper that needs to be fix...Apr 10,2010
623 
624  utility::vector1 <core::conformation::ResidueOP> const ribose_screening_moving_rsd_at_origin_list
625  =setup_residue_at_origin_list(ribose_screening_pose, moving_res, extra_anti_chi_rotamer_, extra_syn_chi_rotamer_, "ribose_screening_pose");
626 
627  if(moving_rsd_at_origin_list.size()!=screening_moving_rsd_at_origin_list.size()){
628  std::cout << "moving_rsd_at_origin_list.size()= " << moving_rsd_at_origin_list.size() << std::endl;
629  std::cout << "screening_moving_rsd_at_origin_list.size()= " << screening_moving_rsd_at_origin_list.size() << std::endl;
630  utility_exit_with_message("moving_rsd_at_origin_list.size()!=screening_moving_rsd_at_origin_list.size()");
631  }
632 
633  if(moving_rsd_at_origin_list.size()!=ribose_screening_moving_rsd_at_origin_list.size()){
634  std::cout << "moving_rsd_at_origin_list.size()= " << moving_rsd_at_origin_list.size() << std::endl;
635  std::cout << "ribose_screening_moving_rsd_at_origin_list.size()= " << ribose_screening_moving_rsd_at_origin_list.size() << std::endl;
636  utility_exit_with_message("moving_rsd_at_origin_list.size()!=ribose_screening_moving_rsd_at_origin_list.size()");
637  }
638 
639  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
640  //int const euler_angle_bin_size_MOCK=180;
641  //int const euler_angle_bin_min_MOCK=-180/(euler_angle_bin_size_MOCK);
642  //int const euler_angle_bin_max_MOCK=180/(euler_angle_bin_size_MOCK)-1;
643 
644 
645  int const euler_angle_bin_min=-180/euler_angle_bin_size; //Should be -180/euler_angle_bin_size
646  int const euler_angle_bin_max=180/euler_angle_bin_size-1; //Should be 180/euler_angle_bin_size-1
647 
648  int const euler_z_bin_min=int(-1/euler_z_bin_size);
649  int const euler_z_bin_max=int(1/euler_z_bin_size);
650 
651  Real C5_centroid_dist=get_max_centroid_to_atom_distance(moving_rsd_at_origin_list, " C5*");
652  Real O5_centroid_dist=get_max_centroid_to_atom_distance(moving_rsd_at_origin_list, " O3*");
653 
654  Real const Max_O3_to_C5_DIST= (num_nucleotides==1) ? O3I_C5I_PLUS_ONE_MAX_DIST : O3I_C5IPLUS2_MAX_DIST;
655 
656  Real const max_distance=Max_O3_to_C5_DIST+C5_centroid_dist+O5_centroid_dist+1; //Theoretical maximum dist between the two base's centroid, +1 is to be lenient
657 
658  std::cout << "max centroid to centroid distance: " << max_distance << std::endl;;
659 
660  int const centroid_bin_min=int(-max_distance/centroid_bin_size);
661  int const centroid_bin_max=int(max_distance/centroid_bin_size)-1;
662 
663  std::cout << "euler_angle_bin min= " << euler_angle_bin_min << " max " << euler_angle_bin_max << std::endl;
664  std::cout << "euler_z_bin_min min= " << euler_z_bin_min << " max " << euler_z_bin_max << std::endl;
665  std::cout << "centroid_bin min= " << centroid_bin_min<< " max " << centroid_bin_max << std::endl;
666 
667  std::map<Base_bin , int , compare_base_bin> base_bin_map;
668  std::map<Base_bin , int , compare_base_bin>::const_iterator it;
669 
670 
671 //////////////////////Probably sure convert to use the class soon...////////////////////////////////////////////////
672 
673  utility::vector1 < core::kinematics::Stub > other_residues_base_list;
674 
675 
676  for(Size seq_num=1; seq_num<=pose.total_residue(); seq_num++){
677 
678  if(pose.residue(seq_num).aa() == core::chemical::aa_vrt ){ //Fang's electron density code
679  std::cout << "Residue.aa() " << seq_num << " is core::chemical::aa_vrt!" << std::endl;
680  continue;
681  }
682 
683  conformation::Residue const & residue_object=pose.residue( seq_num );
684  if(residue_object.has_variant_type( "VIRTUAL_RNA_RESIDUE" )){
685  std::cout << "Residue " << seq_num << " is a VIRTUAL_RNA_RESIDUE!" << std::endl;
686  continue;
687  }
688 
689  if(seq_num==moving_res){
690  std::cout << "Residue " << seq_num << " is a MOVING RESIDUE!" << std::endl;
691  continue;
692  }
693 
694  if(Contain_seq_num(seq_num, job_parameters_->working_terminal_res())){
695  std::cout << "Residue " << seq_num << " is a TERMINAL_RESIDUE!" << std::endl;
696  continue;
697  }
698 
699  core::kinematics::Stub base_info;
700  base_info.v=core::scoring::rna::get_rna_base_centroid( residue_object, true);
701  base_info.M=core::scoring::rna::get_rna_base_coordinate_system( residue_object, base_info.v );
702 
703 
704  // Real distance_square=( base_info.v - pose.residue(reference_res).xyz(" C5*") ).length_squared();
705  //Fix on Jan 15 , 2011..how did I let allow this error to exist for so long!
706  Real const distance_square=( base_info.v - core::scoring::rna::get_rna_base_centroid(pose.residue(reference_res) , false ) ).length_squared();
707 
708 
709  Real const distance=std::sqrt(distance_square);
710 
711  std::cout << "distance= " << distance;
712 
713  if( distance > (max_distance+6.364)) { //6.364 is max centroid to centroid distance for base-stacking centroid_screening.
714  std::cout << " Residue " << seq_num << " is too far from the reference res: " << reference_res << std::endl;
715  continue;
716  }
717 
718  std::cout << " Add to other_residues_base_list: " << seq_num << std::endl;
719 
720  other_residues_base_list.push_back(base_info);
721  }
722  //create screening pose and modify pose variant used to be AFTER THIS POINT.
723 
724 
725 
726  core::kinematics::Stub moving_res_base_stub;
727 
728  Euler_angles euler_angles;
729 
730  Base_bin base_bin;
731 
732  Size total_screen_bin(0);
733 
734  Real /*current_score( 0.0 ),*/ delta_rep_score( 0.0), delta_atr_score( 0.0 );
736 
737  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
738  Output_title_text("START FLOATING BASE SAMPLING");
739 
740 
741  for(base_bin.euler_alpha=euler_angle_bin_min; base_bin.euler_alpha<=euler_angle_bin_max; base_bin.euler_alpha++){
742  for(base_bin.euler_z=euler_z_bin_min; base_bin.euler_z<=euler_z_bin_max; base_bin.euler_z++){
743 
744  if(fast_ && count_data_.both_count>1000) break;
745  if(medium_fast_ && count_data_.both_count>1000 && pose_data_list.size()>5) break;
748 
749  Matrix O_frame_rotation;
750  euler_angles.alpha=(base_bin.euler_alpha+0.5)*euler_angle_bin_size*(RADS_PER_DEG); //convert to radians
751  euler_angles.z=(base_bin.euler_z)*euler_z_bin_size;
752  euler_angles.beta=acos(euler_angles.z);
753  euler_angles.gamma=0;
754 // euler_angles.gamma=(base_bin.euler_gamma+0.5)*euler_angle_bin_size*(RADS_PER_DEG); //convert to radians
755 
756  convert_euler_to_coordinate_matrix(euler_angles, O_frame_rotation);
757 
758  moving_res_base_stub.M= reference_stub.M * O_frame_rotation;
759 
760  ////////////////////////////////////////////////////////////////////////////////////////////////////////
761  for(base_bin.centroid_z=centroid_bin_min; base_bin.centroid_z<=centroid_bin_max; base_bin.centroid_z++){
762  for(base_bin.centroid_x=centroid_bin_min; base_bin.centroid_x<=centroid_bin_max; base_bin.centroid_x++){
763  for(base_bin.centroid_y=centroid_bin_min; base_bin.centroid_y<=centroid_bin_max; base_bin.centroid_y++){
764 
765  Vector O_frame_centroid;
766  O_frame_centroid[0]=(base_bin.centroid_x+0.5)*centroid_bin_size;
767  O_frame_centroid[1]=(base_bin.centroid_y+0.5)*centroid_bin_size;
768  O_frame_centroid[2]=(base_bin.centroid_z)*centroid_bin_size;
769  moving_res_base_stub.v= (reference_stub.M * O_frame_centroid) + reference_stub.v;
770 
771  //count_data_.test_count_one++;
772  ////////////////////Not dependent on euler gamma value//////////////////////////////////////////////////////////////
773  if((moving_res_base_stub.v - reference_stub.v).length_squared()>max_distance*max_distance) continue;
774 
775  //count_data_.test_count_two++;
776 
777  ///////////////////Current implementation of Base_centroid_screen is not dependent on euler_gamma//////////////////////////////////////
778  if( centroid_screen_){
779  if(Base_centroid_screening(moving_res_base_stub, other_residues_base_list, num_nucleotides, count_data_, allow_base_pair_only_centroid_screen_)==false) continue;
780  }
781 
782 //////////////////////Update the moving_res_base_stub/////////////////////////////////////////
783  for(base_bin.euler_gamma=euler_angle_bin_min; base_bin.euler_gamma<=euler_angle_bin_max; base_bin.euler_gamma++){
784 
785 
787 
788  euler_angles.gamma=(base_bin.euler_gamma+0.5)*euler_angle_bin_size*(RADS_PER_DEG); //convert to radians
789 
790 
791  convert_euler_to_coordinate_matrix(euler_angles, O_frame_rotation);
792  moving_res_base_stub.M= reference_stub.M * O_frame_rotation;
793 
794 //////////////////////////////////////////////////////////////////////////////////////////////////////
795 
796  //WHY IS THIS SLOW, CAN IT BE MADE FASTER???
797  if(prev_sugar_FB_JP.sample_sugar){
798  if( check_floating_base_chain_closable(reference_res, prev_sugar_FB_JP.PDL, moving_rsd_at_origin_list, moving_res_base_stub, Is_prepend, (num_nucleotides - 1) )==false) continue;
799  }else{
800  if( check_floating_base_chain_closable(reference_res, ribose_screening_pose, moving_rsd_at_origin_list, moving_res_base_stub, Is_prepend, (num_nucleotides - 1) )==false) continue;
801  }
802 
803  //Right now this only work for the case where the moving base is a single residue element...
804  if(gap_size == 0){ //WAIT this needs to be coupled to the line above!!!...OK since there is a stricter check below...
805  Size const chain_break_reference_res= (Is_prepend) ? five_prime_chain_break_res : five_prime_chain_break_res+1;
806  if( check_floating_base_chain_closable(chain_break_reference_res, ribose_screening_pose, moving_rsd_at_origin_list, moving_res_base_stub, !Is_prepend, 0 /*gap_size*/)==false) continue;
807  }
808 
810  //////////////////////////////////////////////////////
811  //Feb 21, 2011:
812  //When gap_size!=0, there is a always a virtual res serving as buffer between moving_res and surrounding_bin. Virtual res is ignored in create_VDW_screen_bin()
813  //Also the phosphate at 3' prime of working_moving_res_list is ignored.
814  //Potential error for gap_size==0:
815  //VDW_rep doesn't realize that Phosphate and O3' are chain break should be covalently bonded (bond length < Sum VDW)
816  //This beg the question whether normal Rosetta FA_REP realize this or does it score the P-O3' clash?
817  //This is aside from the fact that the 3' phosphate pos is not yet defined.
818  //The code works as long as the 3' phosphate is ignored
819  //For append: 3' phosphate is in surrounding_bin res which is next to res in working_moving_res_list and is ignored in create_VDW_screen_bin()
820  //For prepend: 3' phosphate is in sampling_res is virtualized and hence is ignored in the function VDW_bin_screener->VDW_rep_screen()
821  if( VDW_bin_screener->VDW_rep_screen(screening_pose, moving_res, screening_moving_rsd_at_origin, moving_res_base_stub )==false) continue;
822 
823  if( (user_input_VDW_bin_screener_->user_inputted_VDW_screen_pose()) && (gap_size!=0) && (Is_internal==false) ){
824  //Does not work for chain_closure move and Is_internal move yet...
825  //Residue at 3' of building region have a phosphate that is NOT VIRTUALIZED. This Residue should not be excluded in VDW_bin_screen_pose! Feb 21, 2011.
826  //Residue at 5' of building region also have O3' atom that is covalently bond to the phosphate atom of loop res next to it. VDW_rep doesn't realize this and this lead to clash. Hence This Residue should not be excluded in the VDW_bin_screen_pose as well. Feb 21, 2011.
827 
828  if( user_input_VDW_bin_screener_->VDW_rep_screen(screening_pose, moving_res, screening_moving_rsd_at_origin, moving_res_base_stub)==false) continue;
829  }
830 
832 
833  set_base_coordinate_frame(screening_pose, moving_res, screening_moving_rsd_at_origin, moving_res_base_stub);
834 
835  //screening_pose.dump_pdb( "FIXED_screening_pose.pdb" );
836  //////////////////////////////////////////////////////
837 
839  //This assumes that screening_pose and native_pose are already superimposed.
840  if( suite_rmsd(*get_native_pose(), screening_pose, moving_res, Is_prepend, true /*ignore_virtual_atom*/) >(native_screen_rmsd_cutoff_)) continue;
841  if( rmsd_over_residue_list( *get_native_pose(), screening_pose, job_parameters_, true /*ignore_virtual_atom*/)>(native_screen_rmsd_cutoff_)) continue; //Oct 14, 2010
842 
844  if(verbose_) std::cout << "rmsd_count = " << count_data_.rmsd_count << " total count= " << count_data_.tot_rotamer_count << std::endl;
845  }
846 
847  if( !Full_atom_van_der_Waals_screening( screening_pose, base_rep_score, base_atr_score, delta_rep_score, delta_atr_score, gap_size, Is_internal) ) continue;
848 
849 
850  //van_der_Waal_screening, for ribose clash and CCD loop closure if gap_size==0////////////////////////////////////////////////////////////////////////////
851 
852  for(Size n=1; n<=moving_rsd_at_origin_list.size(); n++){
853 
854  std::string tag="U_" + lead_zero_string_of(count_data_.tot_rotamer_count, 12) + '_' + string_of(n);
855 
856  set_base_coordinate_frame(ribose_screening_pose, moving_res, (*ribose_screening_moving_rsd_at_origin_list[n]), moving_res_base_stub);
857 
858  //ribose_screening_pose.dump_pdb( "FIXED_ribose_screening_pose_"+tag+".pdb" );
859 
860  //OK check that with this sugar, the chain can be theoretically closed..
861  std::string const moving_atom_name= (Is_prepend) ? "O3*" : " C5*";
862  std::string const reference_atom_name= (Is_prepend) ? " C5*" : "O3*";
863 
864  if(gap_size == 0) if(Check_chain_closable(ribose_screening_pose, five_prime_chain_break_res, 0 )==false ) continue;
865 
866  if(prev_sugar_FB_JP.sample_sugar){
867 
868  bool pass_for_loop_screen_1=false;
869 
870  for(Size prev_sugar_ID=1; prev_sugar_ID<=prev_sugar_FB_JP.PDL.size(); prev_sugar_ID++){
871  if(!Check_chain_closable(ribose_screening_pose.residue(moving_res).xyz(moving_atom_name),
872  (*prev_sugar_FB_JP.PDL[prev_sugar_ID].pose_OP).residue(reference_res).xyz(reference_atom_name), (num_nucleotides - 1) )) continue;
873  pass_for_loop_screen_1=true;
874  break;
875  }
876 
877  if(pass_for_loop_screen_1==false) continue;
878 
879  //OK if fail van_der_Waal_screening without previous_moving_res sugar...then should fail WITH the previous_moving_res sugar as well..
880  if(!Full_atom_van_der_Waals_screening_REPLICATE( ribose_screening_pose, base_rep_score, base_atr_score, delta_rep_score, delta_atr_score, gap_size, Is_internal)) continue;
881 
882  bool pass_for_loop_screen_2=false;
883 
884  //Ok, since prev_sugar_FB_JP.PDL is sorted by SCORE, the lower energy conformations are tried first!
885  for(Size prev_sugar_ID=1; prev_sugar_ID<=prev_sugar_FB_JP.PDL.size(); prev_sugar_ID++){
886 
887  //Add this statement on Dec 8, 2010//////////////////////
888  if(!Check_chain_closable(ribose_screening_pose.residue(moving_res).xyz(moving_atom_name),
889  (*prev_sugar_FB_JP.PDL[prev_sugar_ID].pose_OP).residue(reference_res).xyz(reference_atom_name), (num_nucleotides - 1) )) continue;
890  /////////////////////////////////////////////////////////
891 
892  copy_bulge_res_and_ribose_torsion(prev_sugar_FB_JP, ribose_screening_pose, (*prev_sugar_FB_JP.PDL[prev_sugar_ID].pose_OP) );
893 
894  if(!Full_atom_van_der_Waals_screening_REPLICATE( ribose_screening_pose, base_rep_score, base_atr_score, delta_rep_score, delta_atr_score, gap_size, Is_internal)) continue;
895 
896  pose::add_variant_type_to_pose_residue( ribose_screening_pose, "VIRTUAL_RIBOSE", prev_sugar_FB_JP.moving_res ); // copy_bulge_res_and_ribose_torsion removed the variant type
897 
898  copy_bulge_res_and_ribose_torsion(prev_sugar_FB_JP, pose, (*prev_sugar_FB_JP.PDL[prev_sugar_ID].pose_OP) );
899  pose::add_variant_type_to_pose_residue( pose, "VIRTUAL_RIBOSE", prev_sugar_FB_JP.moving_res ); // copy_bulge_res_and_ribose_torsion removed the variant type
900 
901  if( perform_o2star_pack_ ){ //Is this really necessary given that these DOF are virtual anyways!
902  copy_bulge_res_and_ribose_torsion(prev_sugar_FB_JP, o2star_pack_pose, (*prev_sugar_FB_JP.PDL[prev_sugar_ID].pose_OP) );
903  pose::add_variant_type_to_pose_residue( o2star_pack_pose, "VIRTUAL_RIBOSE", prev_sugar_FB_JP.moving_res ); // copy_bulge_res_and_ribose_torsion removed the variant type
904  }
905 
906  tag += prev_sugar_FB_JP.PDL[prev_sugar_ID].tag;
907  pass_for_loop_screen_2=true;
908  break;
909  }
910 
911  if(pass_for_loop_screen_2==false) continue;
912 
913 
914  }else{
915  if(!Check_chain_closable(ribose_screening_pose.residue(moving_res).xyz(moving_atom_name), ribose_screening_pose.residue(reference_res).xyz(reference_atom_name), (num_nucleotides - 1) )) continue;
916  if(!Full_atom_van_der_Waals_screening_REPLICATE( ribose_screening_pose, base_rep_score, base_atr_score, delta_rep_score, delta_atr_score, gap_size, Is_internal)) continue;
917  }
918 
919  count_data_.non_clash_ribose++; //OK CLEARLY base_rep_score and base_atr_score is not correct!
920 
921  set_base_coordinate_frame(CB_screening_pose, moving_res, (*moving_rsd_at_origin_list[n]), moving_res_base_stub);
922 
923  set_base_coordinate_frame(pose, moving_res, (*moving_rsd_at_origin_list[n]), moving_res_base_stub);
924 
925  if ( perform_o2star_pack_ ) set_base_coordinate_frame(o2star_pack_pose, moving_res, (*moving_rsd_at_origin_list[n]), moving_res_base_stub);
926 
927  ////////////////////////////////////////////////////////////////////////////////////////////////////////
928 
929  if(gap_size == 0){
930  if( !Chain_break_screening( pose, chainbreak_scorefxn_) ) continue;
931 
932  Copy_CCD_torsions( pose, CB_screening_pose);
933  if ( perform_o2star_pack_ ) Copy_CCD_torsions( o2star_pack_pose, CB_screening_pose);
934  }
935 
936  if(num_nucleotides==1){
937  if( !Check_chain_closable_floating_base(CB_screening_pose, CB_screening_pose, floating_base_five_prime_chain_break, 0 ) ) continue; //strict version of the check chain closable.
938  if( !Chain_break_screening_general( CB_screening_pose, chainbreak_scorefxn_, floating_base_five_prime_chain_break) ) continue;
939 
940  Copy_CCD_torsions_general(pose, CB_screening_pose, floating_base_five_prime_chain_break, floating_base_five_prime_chain_break+1);
941  if ( perform_o2star_pack_ ) Copy_CCD_torsions_general(o2star_pack_pose, CB_screening_pose, floating_base_five_prime_chain_break, floating_base_five_prime_chain_break+1);
942  }
943  ////////////////////////////////////////////////////////////////////////////////////////////////////////
944 
945  if ( perform_o2star_pack_ ){
946  sample_o2star_hydrogen( o2star_pack_pose , pose_with_original_HO2star_torsion);
947  copy_all_o2star_torsions(pose, o2star_pack_pose); //Copy the o2star torsions from the o2star_pack_pose to the pose!
948  }
949 
950 
951  /*current_score = */ Pose_selection_by_full_score(pose_data_list, pose, tag);
952 
953  if(verbose_){
954  std::cout << tag << std::endl;
956  }
957 
958  if(gap_size!=0 && (num_nucleotides!=1) ) break; //Break once found a valid sugar rotamer, at chain_break(gap_size) keep multiple poses..
959 
960  }
961 
962 
963 
964  it=base_bin_map.find(base_bin);
965 
966  if(it==base_bin_map.end()){
967  base_bin_map[base_bin]=1;
968  total_screen_bin++;
969  }else{
970  base_bin_map[base_bin]=base_bin_map[base_bin]+1;
971  }
972 
973  }
974  }
975  }
976  }
977  }
978  }
979 
980 
981  Output_title_text("Final sort and clustering: BEFORE floating base_chain_closure");
982 
983  std::sort(pose_data_list.begin(), pose_data_list.end(), sort_criteria);
984  cluster_pose_data_list(pose_data_list);
985  if( pose_data_list.size()>num_pose_kept_ ) pose_data_list.erase(pose_data_list.begin()+num_pose_kept_, pose_data_list.end());
986  std::cout<< "after erasing.. pose_data_list= " << pose_data_list.size() << std::endl;
987 
988  std::cout << "floating base sampling time : " << static_cast<Real>( clock() - time_start ) / CLOCKS_PER_SEC << std::endl;
989 
990  if( gap_size == 0 ){
991  std::cout << " angle_n= " << count_data_.good_angle_count << " dist_n= " << count_data_.good_distance_count;
992  std::cout << " chain_break_screening= "<< count_data_.chain_break_screening_count << std::endl;
993  }
994 
995  std::cout << " stack_n= " << count_data_.base_stack_count << " pair_n= " << count_data_.base_pairing_count;
996  std::cout << " strict_pair_n= " << count_data_.strict_base_pairing_count << " centroid_n= " << count_data_.pass_base_centroid_screen;
997  std::cout << " bin_rep= " << count_data_.good_bin_rep_count << " atr= " << count_data_.good_atr_rotamer_count << " rep= " << count_data_.good_rep_rotamer_count;
998  std::cout << " both= " << count_data_.both_count << " total_bin= " << count_data_.tot_rotamer_count << " total_screen_bin= " << total_screen_bin;
999  std::cout << " closable= " << count_data_.chain_closable_count << " non_clash_ribose= " << count_data_.non_clash_ribose << std::endl;
1000  std::cout << " WARNING centroid_n count is severely UNDERSTIMATED...need to be multiply by (euler_angle_bin_max-euler_angle_bin_min+1): ";
1001  std::cout << (euler_angle_bin_max-euler_angle_bin_min+1) << std::endl;
1002 
1003  if(verbose_){ //Don't really need this......May 1, 2010...
1004  std::string const foldername="test/";
1005  int dummy_return_code;
1006  dummy_return_code = system(std::string("rm -r " + foldername).c_str());
1007  dummy_return_code = system(std::string("mkdir -p " + foldername).c_str());
1008  Analyze_base_bin_map( base_bin_map, foldername);
1009  }
1010 
1011  pose_data_list_=pose_data_list;
1012 
1013  }
1014 
1015  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1016 
1017  void
1019  FloatingBaseChainClosureJobParameter const & prev_sugar_FB_JP,
1020  FloatingBaseChainClosureJobParameter const & curr_sugar_FB_JP,
1021  FloatingBaseChainClosureJobParameter const & five_prime_CB_sugar_FB_JP,
1022  FloatingBaseChainClosureJobParameter const & three_prime_CB_sugar_FB_JP){
1023 
1024  using namespace ObjexxFCL;
1025  using namespace core::io::silent;
1026  using namespace core::id;
1027  using namespace core::scoring;
1028 
1029 
1030  pose::Pose const pose_copy= pose;
1031 
1033 
1034 
1035  if( (prev_sugar_FB_JP.sample_sugar || curr_sugar_FB_JP.sample_sugar || five_prime_CB_sugar_FB_JP.sample_sugar || three_prime_CB_sugar_FB_JP.sample_sugar )==false){
1036 
1037  standard_sampling(pose, pose_data_list, "");
1038 
1039  }else{ //Case where have to sample virtual sugar...
1040 
1041  if(prev_sugar_FB_JP.PDL.size()==0 && curr_sugar_FB_JP.PDL.size()==0 && five_prime_CB_sugar_FB_JP.PDL.size()==0 && three_prime_CB_sugar_FB_JP.PDL.size()==0){
1042  utility_exit_with_message("pose_data_list is empty for all 4 possible virtual sugar!");
1043  }
1044  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1045  utility::vector1< pose_data_struct2 > starting_pose_data_list;
1046 
1047  Size count=0;
1048 
1049  for(Size prev_sugar_ID=1; prev_sugar_ID<=prev_sugar_FB_JP.PDL.size() || prev_sugar_ID==1; prev_sugar_ID++){
1050  for(Size curr_sugar_ID=1; curr_sugar_ID<=curr_sugar_FB_JP.PDL.size() || curr_sugar_ID==1; curr_sugar_ID++){
1051  for(Size five_prime_CB_sugar_ID=1; five_prime_CB_sugar_ID<=five_prime_CB_sugar_FB_JP.PDL.size() || five_prime_CB_sugar_ID==1; five_prime_CB_sugar_ID++){
1052  for(Size three_prime_CB_sugar_ID=1; three_prime_CB_sugar_ID<=three_prime_CB_sugar_FB_JP.PDL.size() || three_prime_CB_sugar_ID==1; three_prime_CB_sugar_ID++){
1053 
1054  count++;
1055 
1056  pose_data_struct2 start_pose_data;
1057 
1058  start_pose_data.pose_OP=new pose::Pose;
1059  (*start_pose_data.pose_OP)=pose_copy;
1060  pose::Pose & start_pose=(*start_pose_data.pose_OP);
1061 
1062  start_pose_data.score=0;
1063  start_pose_data.tag="";
1064 
1065  if(prev_sugar_FB_JP.PDL.size()>0) {
1066  start_pose_data.tag+= prev_sugar_FB_JP.PDL[prev_sugar_ID].tag;
1067  copy_bulge_res_and_ribose_torsion(prev_sugar_FB_JP, start_pose, (*prev_sugar_FB_JP.PDL[prev_sugar_ID].pose_OP) );
1068  }else{
1069  start_pose_data.tag+="_null";
1070  }
1071 
1072  if(curr_sugar_FB_JP.PDL.size()>0) {
1073  start_pose_data.tag+= curr_sugar_FB_JP.PDL[curr_sugar_ID].tag;
1074  copy_bulge_res_and_ribose_torsion(curr_sugar_FB_JP, start_pose, (*curr_sugar_FB_JP.PDL[curr_sugar_ID].pose_OP) );
1075  }else{
1076  start_pose_data.tag+="_null";
1077  }
1078 
1079  if(five_prime_CB_sugar_FB_JP.PDL.size()>0){
1080  start_pose_data.tag+= five_prime_CB_sugar_FB_JP.PDL[five_prime_CB_sugar_ID].tag;
1081  copy_bulge_res_and_ribose_torsion(five_prime_CB_sugar_FB_JP, start_pose, (*five_prime_CB_sugar_FB_JP.PDL[five_prime_CB_sugar_ID].pose_OP) );
1082  }else{
1083  start_pose_data.tag+="_null";
1084  }
1085 
1086  if(three_prime_CB_sugar_FB_JP.PDL.size()>0){
1087  start_pose_data.tag+= three_prime_CB_sugar_FB_JP.PDL[three_prime_CB_sugar_ID].tag;
1088  copy_bulge_res_and_ribose_torsion(three_prime_CB_sugar_FB_JP, start_pose, (*three_prime_CB_sugar_FB_JP.PDL[three_prime_CB_sugar_ID].pose_OP) );
1089  }else{
1090  start_pose_data.tag+="_null";
1091  }
1092 
1093  starting_pose_data_list.push_back(start_pose_data);
1094  }
1095  }
1096  }
1097  }
1098 
1100  if(prev_sugar_FB_JP.PDL.size()>0) sampled_sugar_FB_JP_list.push_back(prev_sugar_FB_JP);
1101  if(curr_sugar_FB_JP.PDL.size()>0) sampled_sugar_FB_JP_list.push_back(curr_sugar_FB_JP);
1102  if(five_prime_CB_sugar_FB_JP.PDL.size()>0 ) sampled_sugar_FB_JP_list.push_back(five_prime_CB_sugar_FB_JP);
1103  if(three_prime_CB_sugar_FB_JP.PDL.size()>0) sampled_sugar_FB_JP_list.push_back(three_prime_CB_sugar_FB_JP);
1104 
1105 
1106  ///////Ok, finally have to remove clashes that may arise due to the fact that the floating base sugar sampling and minimization were done individually of each other///
1107  minimize_all_sampled_floating_bases(pose, sampled_sugar_FB_JP_list, starting_pose_data_list, sampling_scorefxn_, job_parameters_, true /*virtual_ribose_is_from_prior_step*/);
1108 
1109  std::cout << "starting_pose_data_list.size()= " << starting_pose_data_list.size() << std::endl;
1110  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1111 
1113  for(Size n=1; n<=starting_pose_data_list.size(); n++){
1114  pose=(*starting_pose_data_list[n].pose_OP); //set viewer_pose;
1115 
1116  ////Debug///////////////////////
1117  if(verbose_){ //Umm..rna_sugar_close score adn geom_sol doesn't check for virtual_res?? lead to slight variation...fix this! May 13, 2010
1118 
1119  std::string starting_pose_tag="starting_pose" + starting_pose_data_list[n].tag;
1120 
1121  utility::vector1 < core::Size > const & working_moving_partition_pos = job_parameters_->working_moving_partition_pos();
1122 
1123  pose::Pose debug_pose=pose;
1124 
1125  for(Size ii=1; ii<=working_moving_partition_pos.size(); ii++){
1126  pose::add_variant_type_to_pose_residue( debug_pose, "VIRTUAL_RNA_RESIDUE", working_moving_partition_pos[ii] );
1127  }
1128 
1129  if (job_parameters_->gap_size() == 0) pose::add_variant_type_to_pose_residue( debug_pose, "VIRTUAL_PHOSPHATE", job_parameters_->five_prime_chain_break_res()+1 );
1130 
1131 
1132  (*sampling_scorefxn_)(debug_pose);
1133  Output_data(silent_file_data, "ribose_sampling.out", starting_pose_tag , false, debug_pose, get_native_pose(), job_parameters_);
1134  Output_data(silent_file_data, "SCORE_ribose_sampling.out", starting_pose_tag, true, debug_pose, get_native_pose(), job_parameters_);
1135  }
1136  //////////////////////////////////////////////////
1137 
1138  standard_sampling(pose, pose_data_list, starting_pose_data_list[n].tag);
1139  }
1140  }
1141 
1142  pose_data_list_=pose_data_list;
1143 
1144  pose=pose_copy;
1145 
1146 
1147  }
1148  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1149 
1150  void
1152 
1153  using namespace core::scoring;
1154  using namespace core::pose;
1155  using namespace core::io::silent;
1156  using namespace protocols::rna;
1157  using namespace core::id;
1158 
1159  Output_title_text("Enter StepWiseRNA_ResidueSampler::standard_sampling");
1160 
1161  clock_t const time_start( clock() );
1162 
1164 
1165  Size const moving_res( job_parameters_->working_moving_res() ); // Might not corresponds to user input.
1166  Size const moving_suite( job_parameters_->working_moving_suite() ); // dofs betweeen this value and value+1 actually move.
1167  bool const Is_prepend( job_parameters_->Is_prepend() );
1168  bool const Is_internal( job_parameters_->Is_internal() ); // no cutpoints before or after moving_res.
1169  Size const actually_moving_res( job_parameters_->actually_moving_res() ); //Now same as moving_res
1170  Size const gap_size( job_parameters_->gap_size()); /* If this is zero or one, need to screen or closable chain break */
1171  utility::vector1 < core::Size > const & working_moving_partition_pos = job_parameters_->working_moving_partition_pos();
1172  Size const num_nucleotides( job_parameters_->working_moving_res_list().size() );
1173  Size const five_prime_chain_break_res = job_parameters_->five_prime_chain_break_res();
1174 
1175 
1176  //Somewhat hacky...basically this check if the pose is build from scratch (for build loop outward), Apr 22, 2010
1177  build_pose_from_scratch_= ( job_parameters_->working_sequence().length()==(num_nucleotides+1) ) ? true: false;
1178 
1179 
1180  if(num_nucleotides!=1 && num_nucleotides!=2){
1181  utility_exit_with_message( "num_nucleotides!=1 and num_nucleotides!=2" );
1182  }
1183 
1184  bool const Is_dinucleotide=(num_nucleotides==2);
1185 
1186 
1187  if(Is_dinucleotide==true && allow_base_pair_only_centroid_screen_==true){ //Feb 09, 2012: FIXED BUG. Used to be "and" instead of "&&"
1188 
1189  Size const user_input_num_pose_kept=num_pose_kept_;
1191 
1192  //std::cout << "Accessible conformational space is larger when sampling a dinucleotide " << std::endl;
1193  std::cout << "allow_base_pair_only_centroid_screen_==true + dinucleotide sampling" << std::endl;
1194  std::cout << "Note that allow_base_pair_only_centroid_screen_ doesn't effect the screening in standard sampling mode." <<std::endl;
1195  std::cout << "Just keeping more pose to be consistent with floating base mode + keep high score basepairing conformations." << std::endl;
1196  std::cout << "Increase num_pose_kept by 4 folds" << std::endl;
1197 
1198  std::cout << " user_input_num_pose_kept= " << user_input_num_pose_kept << " num_pose_kept_ " << num_pose_kept_ << std::endl;
1199 
1200  }
1201 
1203  std::cout << "Since build_pose_from_scratch, choose to increase NUM_POSE_KEPT by 36 fold. ";
1204  std::cout << " Somewhat hacky..since sample both sugar..want to make sure that we keep are good energy score states " << std::endl;
1205  std::cout << "Old_num_pose_kept_ = " << num_pose_kept_ << std::endl;
1207  std::cout << "New_num_pose_kept_ = " << num_pose_kept_ << std::endl;
1208  }
1209 
1211  std::cout << "Since build_pose_from_scratch, choose to increase NUM_POSE_KEPT by 12 fold. ";
1212  std::cout << " Somewhat hacky..since sample both sugar..want to make sure that we keep are good energy score states " << std::endl;
1213  std::cout << "Old_num_pose_kept_ = " << num_pose_kept_ << std::endl;
1215  std::cout << "New_num_pose_kept_ = " << num_pose_kept_ << std::endl;
1216  }
1217 
1218 
1219  std::cout << " NUM_NUCLEOTIDES= " << num_nucleotides << std::endl;
1220  Output_boolean(" IS_DINUCLEOTIDE= ", Is_dinucleotide); std::cout << std::endl;
1221  std::cout << " GAP SIZE " << gap_size << std::endl;
1222  std::cout << " MOVING RES " << moving_res << std::endl;
1223  std::cout << " MOVING SUITE " << moving_suite << std::endl;
1224  Output_boolean(" PREPEND ", Is_prepend ); std::cout << std::endl;
1225  Output_boolean(" INTERNAL ", Is_internal); std::cout << std::endl;
1226  Output_boolean(" allow_bulge_at_chainbreak_ ", allow_bulge_at_chainbreak_); std::cout << std::endl;
1227  Output_boolean(" build_pose_from_scratch_= ", build_pose_from_scratch_); std::cout << std::endl;
1228 
1229  //for combine_long_loop_mode_
1230  Size const last_append_res=(Is_prepend) ? moving_res-1: moving_res;
1231  Size const last_prepend_res=(Is_prepend) ? moving_res: moving_res+1;
1232  Real const atom_atom_overlap_dist_cutoff=-1.0; //value taken from CombineLongLoopFilterer...two atoms in contact if there VDW edge are within 1 angstrom of each other.
1233 
1234  if(combine_long_loop_mode_ && gap_size!=0){//residue-residue contact screen;
1235  std::cout << "combine_long_loop_mode_ && gap_size==0" << std::endl;
1236  std::cout << "Enforcing contact between LAST_APPEND_RES: " << last_append_res << " and LAST_PREPEND_RES: " << last_prepend_res << std::endl;
1237  std::cout << "atom_atom_overlap_dist_cutoff " << atom_atom_overlap_dist_cutoff << std::endl;
1238  }
1239 
1240 
1241 
1242 
1243  /////////////////////////////// O2star sampling/virtualization //////////////////////////
1244  Pose pose_with_virtual_O2star_hydrogen = pose;
1245  Add_virtual_O2Star_hydrogen( pose_with_virtual_O2star_hydrogen );
1246 
1247 
1248  // pose.set_torsion( TorsionID( moving_res, id::CHI, 4 ), 0 ); //This torsion is not sampled. Arbitary set to zero to prevent randomness
1249  // Mod out on Apr 3, 2010 Important so that pose can remember the o2star torsion from previous minimization step.
1250  //This is true only in the INTERNAL CASE!...May 31, 2010
1251 
1252  //if perform_o2star_pack, pose 2'-OH torsion will be sampled!
1253  pose::Pose pose_with_original_HO2star_torsion;
1254  pose::Pose o2star_pack_pose;
1255  if ( perform_o2star_pack_ ) {
1256  pose_with_original_HO2star_torsion=pose;
1257  o2star_pack_pose=pose;
1258  if ( use_green_packer_ ){
1259  initialize_o2star_green_packer( o2star_pack_pose );
1260  }else {
1261  initialize_o2star_packer_task( o2star_pack_pose );
1262  }
1263  } else {
1264  // Otherwise, virtualize the 2-OH.
1265  pose = pose_with_virtual_O2star_hydrogen;
1266  }
1267 
1268  //Real base_rep_score(-9999999999), base_atr_score(-9999999999); //Feb 02, 2012 This might lead to server-test error at R47200
1269  Real base_rep_score(-999999), base_atr_score(-999999); //Feb 02, 2012
1270 
1271 
1272  get_base_atr_rep_score(pose_with_virtual_O2star_hydrogen, base_atr_score, base_rep_score);
1273  //////////////////////////////////////////Setup Atr_rep_screening/////////////////////////////////////////////////
1274 
1275  pose::Pose screening_pose = pose_with_virtual_O2star_hydrogen; //Hard copy
1276 
1277  //Necessary for the case where gap_size == 0. In this case, Pose_setup does not automatically create a VIRTUAL_PHOSPHATE.///
1278  //However since screening_pose is scored before the CCD corrrectly position the chain_break phosphate atoms, ///////////////
1279  // the VIRTUAL_PHOSPHATE is needed to prevent artificial crashes. Parin Jan 28, 2010////////////////////////////////////
1280  if (gap_size == 0) pose::add_variant_type_to_pose_residue( screening_pose, "VIRTUAL_PHOSPHATE", five_prime_chain_break_res+1 );
1281 
1282  ///////////////////////////////////////Setup chainbreak_screening//////////////////////////////////////////////////////
1283  pose::Pose chain_break_screening_pose = pose_with_virtual_O2star_hydrogen; //Hard copy
1284 
1285  if ( gap_size == 0 ) { //harmonic angle and distnace constraints are used ONLY by chainbreak_screening
1286  std::cout << "five_prime_chain_break_res= " << five_prime_chain_break_res << std::endl;
1287  Add_harmonic_chainbreak_constraint(chain_break_screening_pose, five_prime_chain_break_res );
1288  }
1289 
1290 
1291  ////////////////////////////////////Setup RotamerGenerator_Wrapper/////////////////////////////////////////
1292 
1293  // Note: Is_prepend should be generalized to include two more possibilities:
1294  // we are creating a dinucleotide from scratch --> sample sugar/chi for both moving_res and
1295  bool sample_sugar_and_base1( false ), sample_sugar_and_base2( false );
1296  if ( !Is_internal ) {
1297  if ( Is_prepend ) {
1298  sample_sugar_and_base1 = true;
1299  } else {
1300  sample_sugar_and_base2 = true;
1301  }
1302  }
1303 
1304  if(build_pose_from_scratch_){//Override and sample both base in this case....
1305  sample_sugar_and_base1 = true;
1306  sample_sugar_and_base2 = true;
1307  }
1308 
1310  if(Is_dinucleotide==true){
1311  utility_exit_with_message( "sample_both_sugar_base_rotamer_==true and Is_dinucleotide==true!" );
1312  }
1313  sample_sugar_and_base1 = true;
1314  sample_sugar_and_base2 = true;
1315  }
1316 
1317 
1318  if(debug_eplison_south_sugar_mode_){ //only sample the sugar next to the epsilon torsion
1319  utility_exit_with_message("Add VIRTUAL_RNA_RESIDUE_EXCLUDE_PHOSPHATE back to patches.txt before using this option!");
1320  sample_sugar_and_base1 = true;
1321  sample_sugar_and_base2 = false;
1322  pose::add_variant_type_to_pose_residue( pose, "VIRTUAL_RNA_RESIDUE_EXCLUDE_PHOSPHATE", moving_res+1 );
1323  pose::add_variant_type_to_pose_residue( screening_pose, "VIRTUAL_RNA_RESIDUE_EXCLUDE_PHOSPHATE", moving_res+1 );
1324  }
1325 
1326  utility::vector1< core::Size > const working_moving_suite_list( job_parameters_->working_moving_suite_list() );
1327 
1328 
1330  working_moving_suite_list,
1331  sample_sugar_and_base1,
1332  sample_sugar_and_base2);
1333  rotamer_generator->set_fast( fast_ );
1334 
1335  rotamer_generator->set_force_syn_chi_res_list(job_parameters_->working_force_syn_chi_res_list());
1336  rotamer_generator->set_force_north_ribose_list(job_parameters_->working_force_north_ribose_list());
1337  rotamer_generator->set_force_south_ribose_list(job_parameters_->working_force_south_ribose_list());
1338  rotamer_generator->set_include_syn_chi(include_syn_chi_);
1339  rotamer_generator->set_extra_epsilon(extra_epsilon_rotamer_);
1340  rotamer_generator->set_extra_beta(extra_beta_rotamer_);
1341  rotamer_generator->set_extra_anti_chi(extra_anti_chi_rotamer_);
1342  rotamer_generator->set_extra_syn_chi(extra_syn_chi_rotamer_);
1343  rotamer_generator->set_exclude_alpha_beta_gamma_sampling(exclude_alpha_beta_gamma_sampling_);
1344  rotamer_generator->set_allow_syn_pyrimidine(allow_syn_pyrimidine_);
1345  if(gap_size==0 && finer_sampling_at_chain_closure_==true) rotamer_generator->set_bin_size(10);
1346  rotamer_generator->initialize_rotamer_generator_list();
1347  /////////////////////////////////////////////////////////////////////////////////////////////////////////
1348  /////////////////////////////////////////////////////////////////////////////////////////////////////////
1349  // MAIN LOOP --> rotamer sampling.
1350  /////////////////////////////////////////////////////////////////////////////////////////////////////////
1351  /////////////////////////////////////////////////////////////////////////////////////////////////////////
1352 
1353  Real current_score( 0.0 ), delta_rep_score( 0.0), delta_atr_score( 0.0 );
1354 
1355  while( rotamer_generator->has_another_rotamer() ){
1356 
1357  utility::vector1< Torsion_Info > const current_rotamer = rotamer_generator->get_next_rotamer();
1358  apply_rotamer( screening_pose, current_rotamer);
1360 
1361  if(fast_ && count_data_.both_count>=100) break;
1362  if(medium_fast_ && count_data_.both_count>=1000) break;
1365 
1366  std::string tag=create_tag("U" + sugar_tag, rotamer_generator);
1367 
1368 
1370  //This assumes that screening_pose and native_pose are already superimposed.
1371  if( suite_rmsd(*get_native_pose(), screening_pose, actually_moving_res, Is_prepend)>(native_screen_rmsd_cutoff_) ) continue;
1372  if( rmsd_over_residue_list( *get_native_pose(), screening_pose, job_parameters_, false)>(native_screen_rmsd_cutoff_) ) continue; //Oct 14, 2010
1373 
1375  if(verbose_) std::cout << "rmsd_count = " << count_data_.rmsd_count << " total count= " << count_data_.tot_rotamer_count << std::endl;
1376  }
1377 
1378 
1379  if(combine_long_loop_mode_ && gap_size!=0){//residue-residue contact screen;
1380 //Nov 18,2010
1381  if(Is_residues_in_contact(last_append_res, screening_pose, last_prepend_res, screening_pose, atom_atom_overlap_dist_cutoff, 1 /*num_atom_contacts_cutoff*/)==false){
1382  continue;
1383  }
1384  count_data_.residues_contact_screen++; //mistakenly put this inside the if loop, fix on Sept 22, 2010
1385  }
1386 
1387 
1388 
1389 
1390  bool is_possible_bulge=false;
1391 
1392  if( centroid_screen_){
1393 
1394  //Reminder note of independency: Important that base_stub_list is updated even in the case where gap_size == 0 (and bulge is allowed) ////
1395  // since base_stub_list is used later below in the chain_break_screening section Jan 28, 2010 Parin S. ///////////////////////////////////
1396 
1397  // updates base_stub_list.
1398  bool found_a_centroid_interaction_partner( false );
1399  found_a_centroid_interaction_partner = base_centroid_screener_->Update_base_stub_list_and_Check_centroid_interaction( screening_pose, count_data_);
1400 
1401  if( gap_size == 0){ //special case allow for bulges
1402  if( !found_a_centroid_interaction_partner){ //does not stack or base_pair
1403  if(working_moving_partition_pos.size() == 1) is_possible_bulge=true;
1404  }
1405  }
1406 
1407  if(num_nucleotides>1 && is_possible_bulge==true) utility_exit_with_message( "num_nucleotides>1 but is_possible_bulge==true!" );
1408 
1409  if ( gap_size > 0 && !found_a_centroid_interaction_partner ) continue;
1410  //Essential this doesn't screen for centroid interaction at chain_break.
1411  //The chain break can be at both a single strand and a double strand. The statement below is stricter and doesn't screen for centroid interaction only if
1412  //the chainbreak is single stranded.
1413  // if(!found_a_centroid_interaction_partner && !is_possible_bulge) continue; //This is the new version
1414 
1415  // Note that is does not update base_stub_list. To do that, use Update_base_stub_list_and_Check_that_terminal_res_are_unstacked
1416  if ( !base_centroid_screener_->Check_that_terminal_res_are_unstacked() ) continue;
1417 
1418  }
1419 
1420  //////////////////////////////////////////////////////////////////////////////////////////
1421  ///////////////Chain_break_screening -- distance cut /////////////////
1422  //////////////////////////////////////////////////////////////////////////////////////////
1423  if ( gap_size <= 1 ){
1424 
1425  if(gap_size==0 && finer_sampling_at_chain_closure_==true ){//hacky, use strict version of check_chain_closable when using finer_sampling.
1426  if ( !Check_chain_closable_floating_base(screening_pose, screening_pose, five_prime_chain_break_res, gap_size ) ) continue;
1427  }else{
1428  if ( !Check_chain_closable(screening_pose, five_prime_chain_break_res, gap_size ) ) continue;
1429  }
1431  }
1432 
1433  //////////////////////////////////////////////////////////////////////////////////////////
1434  /////////////// Van_der_Waals_screening /////////////////
1435  //////////////////////////////////////////////////////////////////////////////////////////
1436  if ( !Full_atom_van_der_Waals_screening( screening_pose, base_rep_score, base_atr_score, delta_rep_score, delta_atr_score, gap_size, Is_internal ) ) continue;
1437 
1438 
1439  if( (user_input_VDW_bin_screener_->user_inputted_VDW_screen_pose()) && (gap_size!=0) && (Is_internal==false) ){
1440  //Does not work for chain_closure move and Is_internal move yet...
1441  //Residue at 3' of building region have a phosphate that is NOT VIRTUALIZED. This Residue should not be excluded in VDW_bin_screen_pose! Feb 21, 2011.
1442  //Residue at 5' of building region also have O3' atom that is covalently bond to the phosphate atom of loop res next to it. VDW_rep doesn't realize this and this lead to clash. Hence This Residue should not be excluded in the VDW_bin_screen_pose as well. Feb 21, 2011.
1443 
1444  if( user_input_VDW_bin_screener_->VDW_rep_screen(screening_pose, moving_res )==false){
1445  //std::cout << tag << " pass Full_atom_VDW_screening but fail user_input_VDW_bin_screening! " << std::endl;
1446  continue;
1447  }
1449  }
1450 
1451  //////////////////////////////////////////////////////////////////////////////////////////
1452  // Almost ready to actually score pose.
1453  //////////////////////////////////////////////////////////////////////////////////////////
1454  apply_rotamer( pose, current_rotamer );
1455  if ( perform_o2star_pack_ ) apply_rotamer( o2star_pack_pose, current_rotamer );
1456  //////////////////////////////////////////////////////////////////////////////////////////
1457  ///////////////Chain_break_screening -- CCD closure /////////////////////////////////////
1458  //////////////////////////////////////////////////////////////////////////////////////////
1459 
1460  bool bulge_added(false);
1461  if ( gap_size == 0 /*really need to close it!*/ ){
1462 
1463 
1464  apply_rotamer(chain_break_screening_pose, current_rotamer );
1465  if( ! Chain_break_screening( chain_break_screening_pose, chainbreak_scorefxn_) ) continue;
1466 
1467  // Need to be very careful here -- do CCD torsions ever overlap with pose torsions?
1468  Copy_CCD_torsions( pose, chain_break_screening_pose);
1469  if ( perform_o2star_pack_ ) Copy_CCD_torsions( o2star_pack_pose, chain_break_screening_pose);
1470 
1471  if(is_possible_bulge){
1472  bulge_added=apply_bulge_variant( pose, delta_atr_score ); /*further cut on atr, inside*/
1473  if ( perform_o2star_pack_ ) apply_bulge_variant( o2star_pack_pose, delta_atr_score ); /*further cut on atr, inside*/
1474  }
1475  }
1476  /////////////////////////////////////////////////////////////////////////////////////////////
1477 
1478 // if(fast_) screening_pose.dump_pdb( tag + ".pdb" );
1479 
1480  ////////////////Add pose to pose_data_list if pose have good score////////////////////////////////////////////
1481 
1482  if ( perform_o2star_pack_ ){
1483  sample_o2star_hydrogen( o2star_pack_pose , pose_with_original_HO2star_torsion);
1484  copy_all_o2star_torsions(pose, o2star_pack_pose); //Copy the o2star torsions from the o2star_pack_pose to the pose!
1485  }
1486 
1488 
1489  current_score=Pose_selection_by_full_score(pose_data_list, pose, tag);
1490 
1491  if(verbose_){
1492  std::cout << tag << std::endl;
1493 // pose.dump_pdb( tag +".pdb" );
1495  }
1496 
1497  if(bulge_added){
1498  remove_virtual_rna_residue_variant_type(pose, job_parameters_->working_moving_res());
1499  if( perform_o2star_pack_ ) remove_virtual_rna_residue_variant_type(o2star_pack_pose, job_parameters_->working_moving_res());
1500  }
1501 
1502  } //while( rotamer_generator->has_another_rotamer() )
1503 
1504  Output_title_text("Final sort and clustering");
1505  std::sort(pose_data_list.begin(), pose_data_list.end(), sort_criteria);
1506  cluster_pose_data_list(pose_data_list);
1507  if( pose_data_list.size()>num_pose_kept_ ) pose_data_list.erase(pose_data_list.begin()+num_pose_kept_, pose_data_list.end());
1508  std::cout<< "after erasing.. pose_data_list= " << pose_data_list.size() << std::endl;
1509 
1510  //Hacky..temporary until we fix the reroot atom problem..This is just for calculating rmsd purposes... Apr 27 , 2010 Parin/////////////////////////////////////////////
1512  utility::vector1< core::Size > const & working_best_alignment( job_parameters_->working_best_alignment() );
1513  pose::Pose const & native_pose= *get_native_pose();
1514 
1515  for(Size n=1; n<=pose_data_list.size(); n++){ //align all other pose to first pose
1516  pose::Pose & current_pose=(*pose_data_list[n].pose_OP);
1517  std::string const & tag = pose_data_list[n].tag;
1518 
1519  align_poses(current_pose, tag, native_pose, "native", working_best_alignment);
1520  }
1521  }
1522  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1523 
1524  std::cout << "FINAL COUNTS" << std::endl;
1525  if( gap_size <= 1) std::cout << " chain_closable_count= " << count_data_.chain_closable_count << std::endl;
1526  if( gap_size == 0 ){
1527  std::cout << " angle_n= " << count_data_.good_angle_count << " dist_n= " << count_data_.good_distance_count;
1528  std::cout << " chain_break_screening= "<< count_data_.chain_break_screening_count << std::endl;
1529  }
1530  if(combine_long_loop_mode_ && gap_size!=0) std::cout << "res_contact= " << count_data_.residues_contact_screen << " ";
1531 
1532  std::cout << "stack= " << count_data_.base_stack_count << " pair= " << count_data_.base_pairing_count;
1533  std::cout << " strict_pair_n= " << count_data_.strict_base_pairing_count;
1534  std::cout << " atr= " << count_data_.good_atr_rotamer_count;
1535  std::cout << " rep= " << count_data_.good_rep_rotamer_count;
1536  std::cout << " both= " << count_data_.both_count;
1537  std::cout << " bulge= " << count_data_.bulge_at_chain_closure_count;
1538  std::cout << " rmsd= " << count_data_.rmsd_count << " tot= " << count_data_.tot_rotamer_count << std::endl;
1539  std::cout << "Total time in StepWiseRNA_ResidueSampler: " << static_cast<Real>( clock() - time_start ) / CLOCKS_PER_SEC << std::endl;
1540 
1541  }
1542 
1543 
1544  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1547 
1548  return sample_virtual_ribose_and_bulge_and_close_chain(viewer_pose, FB_job_params, name,
1550  job_parameters_, true /*virtual_ribose_is_from_prior_step*/);
1551 
1552 
1553  }
1554  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1555 
1558 
1559  std::string const reference_stub_type="base"; //"ribose"
1560  core::kinematics::Stub reference_stub;
1561 
1562  std::cout << "-----------------------get reference stub-----------------------" << std::endl;
1563  if(reference_stub_type=="ribose"){
1564  reference_stub = Get_ribose_stub(pose.residue( reference_res ), job_parameters_->Is_prepend() , true);
1565  }else{ //Use the base
1566  reference_stub.v=core::scoring::rna::get_rna_base_centroid( pose.residue( reference_res ) , true);
1567  reference_stub.M=core::scoring::rna::get_rna_base_coordinate_system( pose.residue( reference_res ) , reference_stub.v);
1568  }
1569 
1570  std::cout << " reference_stub.v: x= " << reference_stub.v[0] << " y= " << reference_stub.v[1] << " z= " << reference_stub.v[2] << std::endl;
1571  std::cout << "---------------------------------------------------------------------" << std::endl;
1572 
1573  return reference_stub;
1574  }
1575 
1576  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1577 
1578  bool
1580 
1581  //check if previous sugar is virtual, if virtual then need to sample it.
1582  bool const Is_prepend( job_parameters_->Is_prepend() ); // if true, moving_suite+1 is fixed. Otherwise, moving_suite is fixed.
1583  Size const moving_res( job_parameters_->working_moving_res() ); // corresponds to user input.
1584  Size const num_nucleotides( job_parameters_->working_moving_res_list().size() );
1585  Size const previous_moving_res = (Is_prepend) ? (moving_res+num_nucleotides) : (moving_res-num_nucleotides);
1586  Size const previous_bulge_res = (Is_prepend) ? (moving_res+(num_nucleotides+1)) : (moving_res-(num_nucleotides+1));
1587 
1588  return Is_ribose_virtual( pose, previous_moving_res, previous_bulge_res);
1589  }
1590 
1591  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1592  ////New June 12, 2011/////
1593  bool
1595 
1596  //check if curr sugar is virtual, if virtual then need to sample it. This occur when combining two chunk and the moving_res in the moving_chunk was built with a dinucleotide move.
1597  bool const Is_prepend( job_parameters_->Is_prepend() );
1598  Size const moving_res( job_parameters_->working_moving_res() );
1599  Size const virtual_ribose_res = moving_res;
1600  Size const bulge_res = (Is_prepend) ? (moving_res-1) : (moving_res+1);
1601 
1602  return Is_ribose_virtual( pose, virtual_ribose_res, bulge_res);
1603  }
1604 
1605  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1606 
1607  bool
1609 
1610  Size const moving_res( job_parameters_->working_moving_res() );
1611  Size const five_prime_chain_break_res = job_parameters_->five_prime_chain_break_res();
1612  Size const gap_size( job_parameters_->gap_size() );
1613 
1614  if(gap_size!=0) return false;
1615 
1616  //if(moving_res==five_prime_chain_break_res) return false; //Mod out on June 12, 2011
1617 
1618  Size const five_prime_CB_bulge_res = (five_prime_chain_break_res-1);
1619 
1620  bool sugar_is_virtual=Is_ribose_virtual( pose, five_prime_chain_break_res, five_prime_CB_bulge_res);
1621 
1622  ////////////Added on June 12, 2011////////////////
1623  //Make sure that this doesn't overcount number of virtual_ribose,virtual_bulge pairs to be build!
1624  if(sugar_is_virtual){
1625  //This check for ribose that is virtualized during previous steps. Not inconsistent with the current moving_res being a floating base.
1626  if(five_prime_chain_break_res==moving_res){
1627  utility_exit_with_message( "five_prime_chain_break_res==moving_res=" + ObjexxFCL::string_of(moving_res) );
1628  }
1629 
1630  bool const Is_prepend( job_parameters_->Is_prepend() );
1631  Size const num_nucleotides( job_parameters_->working_moving_res_list().size() );
1632  Size const previous_moving_res = (Is_prepend) ? (moving_res+num_nucleotides) : (moving_res-num_nucleotides);
1633 
1634  if(five_prime_chain_break_res==previous_moving_res){
1635  utility_exit_with_message( "five_prime_chain_break_res==previous_moving_res=" + ObjexxFCL::string_of(previous_moving_res) );
1636  }
1637  return true;
1638 
1639  }else{
1640  return false;
1641  }
1642  //////////////////////////////////////////////////
1643  }
1644 
1645  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1646 
1647  bool
1649 
1650  Size const moving_res( job_parameters_->working_moving_res() );
1651  Size const three_prime_chain_break_res = job_parameters_->five_prime_chain_break_res()+1;
1652  Size const gap_size( job_parameters_->gap_size() );
1653 
1654  if(gap_size!=0) return false;
1655 
1656  //if(moving_res==three_prime_chain_break_res) return false; //Mod out on June 12, 2011
1657 
1658  Size const three_prime_CB_bulge_res = (three_prime_chain_break_res+1);
1659 
1660  bool sugar_is_virtual=Is_ribose_virtual( pose, three_prime_chain_break_res, three_prime_CB_bulge_res);
1661 
1662  ////////////Added on June 12, 2011////////////////
1663  //Make sure that this doesn't overcount number of virtual_ribose,virtual_bulge pairs to be build!
1664  if(sugar_is_virtual){
1665  //This check for ribose that is virtualized during previous steps. Not inconsistent with the current moving_res being a floating base.
1666  if(three_prime_chain_break_res==moving_res){
1667  utility_exit_with_message( "three_prime_chain_break_res==moving_res=" + ObjexxFCL::string_of(three_prime_chain_break_res) );
1668  }
1669 
1670  bool const Is_prepend( job_parameters_->Is_prepend() );
1671  Size const num_nucleotides( job_parameters_->working_moving_res_list().size() );
1672  Size const previous_moving_res = (Is_prepend) ? (moving_res+num_nucleotides) : (moving_res-num_nucleotides);
1673 
1674  if(three_prime_chain_break_res==previous_moving_res){
1675  utility_exit_with_message( "three_prime_chain_break_res==previous_moving_res=" + ObjexxFCL::string_of(previous_moving_res) );
1676  }
1677  return true;
1678 
1679  }else{
1680  return false;
1681  }
1682  //////////////////////////////////////////////////
1683 
1684  }
1685 
1686  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1687 
1688 
1689  void
1691 
1692  using namespace core::conformation;
1693  using namespace core::scoring;
1694  using namespace core::pose;
1695  using namespace ObjexxFCL;
1696 
1697  Size const working_moving_suite( job_parameters_->working_moving_suite() );
1698  Size const working_moving_res( job_parameters_->working_moving_res() );
1699 
1700  Size const nres = job_parameters_->working_sequence().size();
1701 
1702  bool const Is_prepend( job_parameters_->Is_prepend() );
1703 
1704  ///////////////////////////////Old_way////////////////////////////////////////////
1705 
1706  pose::Pose base_pose_screen = pose; //hard copy
1707 
1708  if(output_pdb_) base_pose_screen.dump_pdb( "base_atr_rep_before.pdb" );
1709 
1710 // if(working_moving_suite>=nres) utility_exit_with_message( "working_moving_suite " + string_of(working_moving_suite) + " >= nres " + string_of(nres) );
1711 
1712  pose::add_variant_type_to_pose_residue( base_pose_screen, "VIRTUAL_PHOSPHATE", working_moving_res ); //May 7...
1713 
1714  if((working_moving_res+1)<=nres){
1715  pose::add_variant_type_to_pose_residue( base_pose_screen, "VIRTUAL_PHOSPHATE", working_moving_res+1 ); //May 7...
1716  }
1717 
1718  if(sample_both_sugar_base_rotamer_==true){ //Nov 15, 2010
1719  Size const extra_sample_sugar_base_res= (Is_prepend) ? (working_moving_res+1) : (working_moving_res-1);
1720  if(verbose_) std::cout << "extra_sample_sugar_base_res= " << extra_sample_sugar_base_res << std::endl;
1721  pose::add_variant_type_to_pose_residue( base_pose_screen, "VIRTUAL_RIBOSE", extra_sample_sugar_base_res );
1722  }
1723 
1724  // I think this should work... push apart different parts of the structure so that whatever fa_atr, fa_rep is left is due to "intra-domain" interactions.
1725  // Crap this doesn't work when building 2 or more nucleotides.
1726 
1727  Size const jump_at_moving_suite = make_cut_at_moving_suite( base_pose_screen, working_moving_suite);
1728  kinematics::Jump j = base_pose_screen.jump( jump_at_moving_suite );
1729  j.set_translation( Vector( 1.0e4, 0.0, 0.0 ) );
1730  base_pose_screen.set_jump( jump_at_moving_suite, j );
1731 
1732  (*atr_rep_screening_scorefxn_)(base_pose_screen);
1733 
1734  EnergyMap const & energy_map=base_pose_screen.energies().total_energies();
1735  base_atr_score = atr_rep_screening_scorefxn_->get_weight(fa_atr) * energy_map[ scoring::fa_atr ]; //
1736  base_rep_score = atr_rep_screening_scorefxn_->get_weight(fa_rep) * energy_map[ scoring::fa_rep ];
1737  std::cout << "base_rep= " << base_rep_score << " base_atr= " << base_atr_score << std::endl;
1738 
1739  if(output_pdb_) base_pose_screen.dump_pdb( "base_atr_rep_after.pdb" );
1740 
1741  ////////////////////////////////////////////////////////////////////////////////////
1742 
1743  /*
1744 
1745  Size const nres = job_parameters_->working_sequence().size();
1746  utility::vector1< Size > const working_moving_res_list=job_parameters_->working_moving_res_list();
1747 
1748 
1749  utility::vector1< Size > partition_0_seq_num_list;
1750  utility::vector1< Size > partition_1_seq_num_list;
1751 
1752 
1753  bool const root_partition = partition_definition( rerooted_fold_tree.root() );
1754 
1755  for (Size seq_num=1; seq_num<=nres; seq_num++){
1756 // if(Contain_seq_num(seq_num, working_moving_res_list)) continue; //Exclude working_moving_residues (the one being sampled..)
1757 
1758  if ( partition_definition( seq_num ) == 0){
1759  partition_0_seq_num_list.push_back( seq_num );
1760  }else if( partition_definition( seq_num ) == 1){
1761  partition_1_seq_num_list.push_back( seq_num );
1762  }else{
1763  utility_exit_with_message("seq_num " + string_of(seq_num) + " is not both in either partition!!" );
1764  }
1765  }
1766 
1767  sort_seq_num_list(partition_0_seq_num_list); //Low seq_num on the top of the list [1,2,3,4,5]
1768  sort_seq_num_list(partition_1_seq_num_list); //Low seq_num on the top of the list [1,2,3,4,5]
1769 
1770  */
1771 
1772  }
1773 
1774 
1775  ////////////////////////////////////////////////////////////////////////////////////////
1776  void
1778 
1780 
1781  }
1782 
1783  ////////////////////////////////////////////////////////////////////////////////////////
1786  return pose_data_list_;
1787  }
1788 
1789 
1790 
1791  ////////////////////////////////////////////////////////////////////////////////////////
1792  void
1794 
1795  using namespace core::chemical;
1796  using namespace core::conformation;
1797  using namespace core::id;
1798 
1799  Size const five_prime_res = job_parameters_->five_prime_chain_break_res();
1800  Size const three_prime_res = five_prime_res+1;
1801 
1802 
1803  //Even through there is the chain_break, alpha of 3' and epl and gamma of 5' should be defined due to the existence of the upper and lower variant type atoms.
1804  Copy_CCD_torsions_general(pose, template_pose, five_prime_res, three_prime_res);
1805 
1806  }
1807 
1808 
1809  ////////////////////////////////////////////////////////////////////////////////////////
1810  void
1811  StepWiseRNA_ResidueSampler::Copy_CCD_torsions_general(pose::Pose & pose, pose::Pose const & template_pose, Size const five_prime_res, Size const three_prime_res) const {
1812 
1813  using namespace core::chemical;
1814  using namespace core::conformation;
1815  using namespace core::id;
1816 
1817  if((five_prime_res)!=(three_prime_res-1)) utility_exit_with_message("(five_prime_res)!=(three_prime_res-1)");
1818 
1819  conformation::Residue const & lower_res=template_pose.residue(five_prime_res);
1820  conformation::Residue const & upper_res=template_pose.residue(three_prime_res);
1821 
1822  for(Size n=1; n<=3; n++){ //alpha, beta, gamma of 3' res
1823  pose.set_torsion( TorsionID( three_prime_res, id::BB, n ), upper_res.mainchain_torsion(n) );
1824  }
1825 
1826  for(Size n=5; n<=6; n++){ //epsilon and zeta of 5' res
1827  pose.set_torsion( TorsionID( five_prime_res, id::BB, n ), lower_res.mainchain_torsion(n) );
1828  }
1829  }
1830 
1831  ////////////////////////////////////////////////////////////////////////////////////////
1832  bool
1833  StepWiseRNA_ResidueSampler::Chain_break_screening_general( pose::Pose & chain_break_screening_pose, core::scoring::ScoreFunctionOP const & chainbreak_scorefxn, Size const five_prime_res){
1834 
1835  using namespace core::scoring;
1836 
1837  static protocols::rna::RNA_LoopCloser rna_loop_closer;
1838 
1839  if(chain_break_screening_pose.residue(five_prime_res).has_variant_type(chemical::CUTPOINT_LOWER )==false ) {
1840  utility_exit_with_message( "chain_break_screening_pose.residue(five_prime_chain_break_res).has_variant_type( chemical::CUTPOINT_LOWER )==false" );
1841  }
1842 
1843  if(chain_break_screening_pose.residue(five_prime_res+1).has_variant_type(chemical::CUTPOINT_UPPER )==false ) {
1844  utility_exit_with_message( "chain_break_screening_pose.residue(five_prime_chain_break_res+1).has_variant_type( chemical::CUTPOINT_UPPER )==false" );
1845  }
1846 
1847  if(reinitialize_CCD_torsions_) set_CCD_torsions_to_zero(chain_break_screening_pose, five_prime_res);
1848 
1849  // Real const mean_dist_err=rna_loop_closer.apply( chain_break_screening_pose, five_prime_res);
1850  rna_loop_closer.apply( chain_break_screening_pose, five_prime_res);
1851 
1852  (*chainbreak_scorefxn)(chain_break_screening_pose);
1853 
1854  scoring::EMapVector & energy_map= chain_break_screening_pose.energies().total_energies();
1855  Real const angle_score = energy_map[scoring::angle_constraint];
1856  Real const distance_score = energy_map[scoring::atom_pair_constraint];
1857 
1858  if(angle_score<5) count_data_.good_angle_count++;
1859  if(distance_score<5) count_data_.good_distance_count++;
1860  if((angle_score<5) && (distance_score<5)){
1862  if(verbose_){
1863  // std::cout << " C5_O3= " << C5_O3_distance << " C5_O3_n= " << count_data_.C5_O3_distance_count;
1864  std::cout << " chain_closable_count= " << count_data_.chain_closable_count;
1865  std::cout << " angle= " << angle_score << " dist= " << distance_score;
1866  std::cout << " angle_n= " << count_data_.good_angle_count;
1867  std::cout << " dist_n= " << count_data_.good_distance_count;
1868  std::cout << " chain_break_screening= " << count_data_.chain_break_screening_count;
1869  std::cout << " tot= " << count_data_.tot_rotamer_count << std::endl;
1870  }
1871  return true;
1872  } else {
1873  return false;
1874  }
1875  }
1876 
1877 
1878  bool
1879  StepWiseRNA_ResidueSampler::Chain_break_screening( pose::Pose & chain_break_screening_pose, core::scoring::ScoreFunctionOP const & chainbreak_scorefxn ){
1880 
1881  Size const five_prime_res = job_parameters_->five_prime_chain_break_res();
1882 
1883  return (Chain_break_screening_general(chain_break_screening_pose, chainbreak_scorefxn, five_prime_res));
1884 
1885  }
1886 
1887  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1888 
1889  bool
1891 
1892  using namespace ObjexxFCL;
1893 
1894  if(rebuild_bulge_mode_) return false; //Hacky want to output sample diverse bulge conformation
1895 
1896 // static Real const atr_cutoff_for_bulge( -1.0 );
1897 // static Real const atr_cutoff_for_bulge( -1.0 );
1898 // static Real const atr_cutoff_for_bulge( 0.0 );
1899 
1900  //static Real const atr_cutoff_for_bulge( -9999999999999999999.0 ); //Feb 02, 2012 This might lead to server-test error at R47200
1901  static Real const atr_cutoff_for_bulge( -999999.0 ); //Feb 02, 2012
1902 
1903 
1904 
1905 // Size const five_prime_chain_break_res = job_parameters_->five_prime_chain_break_res();
1906  Size const working_moving_res( job_parameters_->working_moving_res() );
1907 
1908  if(delta_atr_score>(+0.01)){
1909  utility_exit_with_message( "delta_atr_score>(+0.01). delta_atr_score= " + string_of(delta_atr_score) );
1910  }
1911 
1912  if(Is_virtual_base(pose.residue( working_moving_res ) ) ) { //Check that the residue is not be already virtualized...
1913  utility_exit_with_message("The base at " + string_of(working_moving_res) + " is already virtualized!!" );
1914  }
1915 
1916  bool bulge_added=false;
1917 
1919  if ( delta_atr_score >= atr_cutoff_for_bulge ) {
1920 
1921 
1922  //Note that there is problem in that even after applying virtual_rna_residue, the chain break torsion potential is still scored for the chain_break torsions.
1923  //The should_score_torsion function in RNA_torsional_potential returns true (indicating that the score should be scored) if it finds a chain_break torsion,
1924  //even if this torsion contain virtual atoms.. May 4, 2010
1925  apply_virtual_rna_residue_variant_type(pose, working_moving_res, true);
1926 
1927 
1929  bulge_added=true;
1930 
1931  if (verbose_){
1932  std::cout << "delta_atr " << delta_atr_score << " passes cutoff for bulge. " << atr_cutoff_for_bulge;
1933  std::cout << " bulge= " << count_data_.bulge_at_chain_closure_count << " both= " << count_data_.both_count << " tot= " << count_data_.tot_rotamer_count << std::endl;
1934  }
1935 
1936  } else {
1937 
1938  bulge_added=false;
1939  if (verbose_) std::cout << "delta_atr " << delta_atr_score << " DOES NOT PASS cutoff for bulge " << atr_cutoff_for_bulge << std::endl;
1940 
1941  }
1942  }
1943 
1944  return bulge_added;
1945  }
1946 
1947 
1948  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1949  void
1950  StepWiseRNA_ResidueSampler::Update_pose_data_list(std::string const & tag, utility::vector1< pose_data_struct2 > & pose_data_list, pose::Pose const & current_pose, Real const & current_score) const{
1951 
1952  bool add_pose_to_list=false;
1953 
1954  add_pose_to_list= ( current_score < current_score_cutoff_ ) ? true: false; //May 12, 2010: updated code to be more robust (Parin S).
1955 
1956 
1957  //The order of evaluation of the two expression in the if statement is important!
1958  if(add_pose_to_list){
1959 
1960  if(verbose_){
1961  std::cout << "tag= " << tag << " current_score_cutoff_ " << current_score_cutoff_ << " score= " << current_score;
1962  }
1963 
1964  pose_data_struct2 current_pose_data;
1965  current_pose_data.pose_OP=new pose::Pose;
1966  (*current_pose_data.pose_OP)=current_pose;
1967  current_pose_data.score = current_score;
1968  current_pose_data.tag=tag;
1969 
1970  //if ( get_native_pose()) { //ACTUALLY DEPRECATED SINCE EARLY 2010!! Comment out on March 16, 2012
1971  // setPoseExtraScores( *current_pose_data.pose_OP, "all_rms",
1972  // core::scoring::rms_at_corresponding_heavy_atoms( *current_pose_data.pose_OP, *get_native_pose() ) );
1973  //}
1974 
1975  pose_data_list.push_back(current_pose_data);
1976  if(verbose_) std::cout << " pose_data_list.size= " << pose_data_list.size() << std::endl;
1977  }
1978  }
1979 
1980  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1981  Real
1983 
1984  using namespace core::scoring;
1985 
1986  Real const current_score=(*sampling_scorefxn_)(current_pose);
1987 
1988  Update_pose_data_list(tag, pose_data_list, current_pose, current_score);
1989 
1990  if((pose_data_list.size()==num_pose_kept_*multiplier_)){
1991  std::sort(pose_data_list.begin(), pose_data_list.end(), sort_criteria);
1992  cluster_pose_data_list(pose_data_list);
1993  if(pose_data_list.size()>num_pose_kept_){
1994  pose_data_list.erase(pose_data_list.begin()+num_pose_kept_, pose_data_list.end());
1995  std::cout<< "after erasing.. pose_data_list.size()= " << pose_data_list.size() << std::endl;
1996  }else{
1997  std::cout<< "pose_data_list.size()= " << pose_data_list.size() << std::endl;
1998  }
1999  }
2000 
2001  return current_score;
2002 
2003  }
2004 
2005 
2006  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2007  //Dec 18, 2009...took off alot of optimization from this code since it is very fast (not rate limiting) anyways.
2008  void
2010 
2011 
2012  //Super hacky...take this out once solve the root atom problem
2013  if(build_pose_from_scratch_) return; //no clustering at all;
2014 
2015  bool const Is_prepend( job_parameters_->Is_prepend() );
2016  Size const actually_moving_res = job_parameters_->actually_moving_res();
2017 
2018  utility::vector1< bool > pose_state_list( pose_data_list.size(), true );
2019 
2020  Size num_clustered_pose=0;
2021 
2022  for(Size i=1; i<=pose_data_list.size(); i++){
2023 
2024  if(pose_state_list[i]==true){
2025  num_clustered_pose++;
2026  for(Size j=i+1; j<=pose_data_list.size(); j++){
2027 
2028 
2029  Real rmsd;
2030  if(PBP_clustering_at_chain_closure_ && job_parameters_->gap_size()==0 ){ //new option Aug 15, 2010..include both phosphates in rmsd calculation at chain_break
2031  rmsd = phosphate_base_phosphate_rmsd( (*pose_data_list[i].pose_OP), (*pose_data_list[j].pose_OP), actually_moving_res, false /*ignore_virtual_atom*/);
2032  }else{
2033  rmsd = suite_rmsd( (*pose_data_list[i].pose_OP), (*pose_data_list[j].pose_OP), actually_moving_res, Is_prepend , false /*ignore_virtual_atom*/);
2034  }
2035 
2036  bool const same_pucker= Is_same_ribose_pucker((*pose_data_list[i].pose_OP), (*pose_data_list[j].pose_OP), actually_moving_res);
2037 
2038  if(rmsd < cluster_rmsd_ && (same_pucker || !distinguish_pucker_) ){
2039  pose_state_list[j]=false;
2040  if(verbose_) {
2041  std::cout << "rmsd= " << rmsd << " pose " << pose_data_list[j].tag << " is a neighbor of pose " << pose_data_list[i].tag;
2042  std::cout << " same_pucker= "; Output_boolean(same_pucker);
2043  print_ribose_pucker_state(" center_pucker= ", Get_residue_pucker_state((*pose_data_list[i].pose_OP), actually_moving_res));
2044  print_ribose_pucker_state(" curr_pucker= ", Get_residue_pucker_state((*pose_data_list[j].pose_OP), actually_moving_res));
2045  std::cout << std::endl;
2046  }
2047  }
2048  }
2049  }
2050  }
2051 
2052 
2053  utility::vector1< pose_data_struct2> clustered_pose_data_list;
2054 
2055  for(Size i=1; i<=pose_data_list.size(); i++) {
2056  if(pose_state_list[i]==true){
2057  clustered_pose_data_list.push_back(pose_data_list[i]);
2058  }
2059  }
2060 
2061  pose_data_list=clustered_pose_data_list;
2062 
2063  //check if pose_data_list size is equal to or exceed num_pose_kept_. Important to get score_cutoff here right after clustering.
2064  if(pose_data_list.size()>=num_pose_kept_){
2065  current_score_cutoff_=pose_data_list[num_pose_kept_].score;
2066  }else{
2067  //keep on adding pose to list if there are still not enough clusters
2068 
2069  //current_score_cutoff_=99999999999.9999; //Feb 02, 2012 This might lead to server-test error at R47200
2070  current_score_cutoff_=999999.9; //Feb 02, 2012
2071  }
2072  ////////////////////////////////////////////
2073 
2074 
2075  }
2076  ///////////////////////////////////////////////////////////////////////////////
2077  //TEMPORARY
2078  bool
2080  Real const & base_rep_score,
2081  Real const & base_atr_score,
2082  Real & delta_atr_score,
2083  Real & delta_rep_score,
2084  Size const & gap_size,
2085  bool const & Is_internal){
2086 
2087  using namespace core::scoring;
2088 
2089  if(VDW_atr_rep_screen_==false) return true;
2090 
2091  bool close_chain = (gap_size==0) ? true: false;
2092 
2093  if(close_chain && Is_internal) return true; //Don't screen at all Mar 1, 2010
2094 
2095  (*atr_rep_screening_scorefxn_)(current_pose_screen);
2096 
2097  EnergyMap const & energy_map = current_pose_screen.energies().total_energies();
2098 
2099  Real rep_score = atr_rep_screening_scorefxn_->get_weight(fa_rep) * energy_map[scoring::fa_rep];
2100  Real atr_score = atr_rep_screening_scorefxn_->get_weight(fa_atr) * energy_map[scoring::fa_atr];
2101 
2102  delta_rep_score=rep_score-base_rep_score;
2103  delta_atr_score=atr_score-base_atr_score;
2104 
2105  Real actual_rep_cutoff=rep_cutoff_; //defualt
2106  if(close_chain) actual_rep_cutoff=10; //Parin's old parameter
2107  if(close_chain && Is_internal) actual_rep_cutoff=200; //Bigger chunk..easier to crash...not using this right now.
2108 
2109  bool pass_rep_screen=false;
2110 
2111  if( delta_rep_score < actual_rep_cutoff ){
2112  pass_rep_screen=true;
2113  }
2114 
2115 
2116  bool pass_atr_rep_screen=false;
2117 
2118  if(close_chain){
2119  pass_atr_rep_screen=pass_rep_screen;
2120  }else{
2121  if( delta_atr_score<(-1) && (delta_rep_score+delta_atr_score) < 0 ) pass_atr_rep_screen=true;
2122  }
2123 
2124 
2125  if( pass_atr_rep_screen ) {
2126  if ( verbose_ ) {
2127  std::cout << " rep= " << delta_rep_score << " atr= " << delta_atr_score;
2128  std::cout << " stack_n= " << count_data_.base_stack_count << " pair_n= " << count_data_.base_pairing_count;
2129  std::cout << " strict_pair_n= " << count_data_.strict_base_pairing_count;
2130  std::cout << " centroid_n= " << count_data_.pass_base_centroid_screen;
2131  std::cout << " bin_rep_n= " << count_data_.good_bin_rep_count;
2132  std::cout << " atr_n= " << count_data_.good_atr_rotamer_count;
2133  std::cout << " rep_n= " << count_data_.good_rep_rotamer_count;
2134  std::cout << " both= " << count_data_.both_count << " tot= " << count_data_.tot_rotamer_count;
2135  std::cout << " closable= " << count_data_.chain_closable_count;
2136  std::cout << " non_clash_ribose= " << count_data_.non_clash_ribose;
2137  std::cout << std::endl;
2138  }
2139  return true;
2140  } else {
2141  return false;
2142  }
2143 
2144  }
2145  ///////////////////////////////////////////////////////////////////////////////
2146  bool
2148  Real const & base_rep_score,
2149  Real const & base_atr_score,
2150  Real & delta_rep_score,
2151  Real & delta_atr_score,
2152  Size const & gap_size,
2153  bool const & Is_internal){
2154 
2155  using namespace core::scoring;
2156  using namespace ObjexxFCL;
2157 
2158  if(VDW_atr_rep_screen_==false) return true;
2159 
2160  bool close_chain = (gap_size==0) ? true: false;
2161 
2162  if(close_chain && Is_internal) return true; //Don't screen at all Mar 1, 2010
2163 
2164  (*atr_rep_screening_scorefxn_)(current_pose_screen);
2165 
2166  EnergyMap const & energy_map = current_pose_screen.energies().total_energies();
2167 
2168  Real rep_score = atr_rep_screening_scorefxn_->get_weight(fa_rep) * energy_map[scoring::fa_rep];
2169  Real atr_score = atr_rep_screening_scorefxn_->get_weight(fa_atr) * energy_map[scoring::fa_atr];
2170 
2171  delta_rep_score=rep_score-base_rep_score;
2172  delta_atr_score=atr_score-base_atr_score;
2173 
2174  if(delta_rep_score<(-0.01)){
2175  std::string const message="delta_rep_score= " + string_of(delta_rep_score) + " rep_score= " + string_of(rep_score) + " base_rep_score= " + string_of(base_rep_score);
2176  utility_exit_with_message( "delta_rep_score<(-0.01), " + message );
2177  }
2178 
2179  if(delta_atr_score>(+0.01)){
2180  std::string const message="delta_atr_score= " + string_of(delta_atr_score) + " atr_score= " + string_of(atr_score) + " base_atr_score= " + string_of(base_atr_score);
2181  utility_exit_with_message( "delta_atr_score>(+0.01), " + message );
2182  }
2183 
2184  Real actual_rep_cutoff=rep_cutoff_; //defualt
2185  if(close_chain) actual_rep_cutoff=10; //Parin's old parameter
2186  if(Is_internal) actual_rep_cutoff=200; //Bigger chunk..easier to crash (before May 4 used to be (close_chain && Is_internal) actual_rep_cutoff=200
2187 
2188  bool pass_rep_screen=false;
2189 
2190  if( delta_rep_score < actual_rep_cutoff ){
2191  pass_rep_screen=true;
2193  }
2194 
2195  if( delta_atr_score<(-1) || close_chain) count_data_.good_atr_rotamer_count++;
2196 
2197  bool pass_atr_rep_screen=false;
2198 
2199  if(close_chain){
2200  pass_atr_rep_screen=pass_rep_screen;
2201  }else if(Is_internal){
2202  if( delta_atr_score<(-1) && (delta_rep_score+delta_atr_score) < (actual_rep_cutoff-rep_cutoff_) ) pass_atr_rep_screen=true;
2203  }else{
2204  if( delta_atr_score<(-1) && (delta_rep_score+delta_atr_score) < 0 ) pass_atr_rep_screen=true;
2205  }
2206 
2207 
2208  if( pass_atr_rep_screen ) {
2209  // if((delta_atr_score<(-1)) && ((delta_rep_score+delta_atr_score) < 200) ) { //This causes about 5times more pose to pass the screen (50,000 poses vs 10,000 poses)
2211  if ( verbose_ ) {
2212  std::cout << " rep= " << delta_rep_score << " atr= " << delta_atr_score;
2213  if(combine_long_loop_mode_ && (job_parameters_->gap_size()!=0) ) std::cout << " res_contact= " << count_data_.residues_contact_screen;
2214  std::cout << " stack_n= " << count_data_.base_stack_count << " pair_n= " << count_data_.base_pairing_count;
2215  std::cout << " strict_pair_n= " << count_data_.strict_base_pairing_count;
2216  std::cout << " centroid_n= " << count_data_.pass_base_centroid_screen;
2217  std::cout << " bin_rep_n= " << count_data_.good_bin_rep_count;
2218  std::cout << " atr_n= " << count_data_.good_atr_rotamer_count;
2219  std::cout << " rep_n= " << count_data_.good_rep_rotamer_count;
2220  std::cout << " both= " << count_data_.both_count << " tot= " << count_data_.tot_rotamer_count << std::endl;
2221  }
2222  return true;
2223  } else {
2224  return false;
2225  }
2226 
2227  }
2228 
2229  ////////////////////////////////////////////////////////////////////////
2230  void
2232 
2233  utility::vector1 < core::Size > const & working_moving_partition_pos = job_parameters_->working_moving_partition_pos();
2234 
2235  utility::vector1< core::Size > const O2star_pack_seq_num=get_surrounding_O2star_hydrogen(pose, working_moving_partition_pos, false /*verbose*/);
2236 
2237  o2star_pack_task_=create_standard_o2star_pack_task(pose, O2star_pack_seq_num);
2238 
2239  }
2240 
2241  ////////////////////////////////////////////////////////////////////////////////
2242  void
2244  {
2245  using namespace protocols::simple_moves;
2246  using namespace core::pack;
2247  using namespace core::pack::task;
2248  using namespace core::pack::task::operation;
2249 
2251 
2252  ObjexxFCL::FArray1D< bool > const & partition_definition = job_parameters_->partition_definition();
2253  bool const root_partition = partition_definition( pose.fold_tree().root() );
2254 
2255  Size const nres = pose.total_residue();
2256  UserDefinedGroupDiscriminatorOP user_defined_group_discriminator( new UserDefinedGroupDiscriminator);
2257  utility::vector1< Size > group_ids;
2258 
2259  Size current_group = 0;
2260  Size spectator_group = 1;
2261 
2262  for (Size i = 1; i <= nres; i++ ) {
2263 
2264  if ( partition_definition( i ) != root_partition ) {
2265  current_group = 0;
2266  std::cout << "GREENPACKER SAMPLER " << i << std::endl;
2267  } else {
2268  std::cout << "GREENPACKER SPECTATOR " << i << " --> group " << spectator_group << std::endl;
2269  }
2270  group_ids.push_back( current_group );
2271  }
2272 
2273  user_defined_group_discriminator->set_group_ids( group_ids );
2274  o2star_green_packer_->set_scorefunction( *o2star_pack_scorefxn_ );
2275  o2star_green_packer_->set_group_discriminator( user_defined_group_discriminator );
2276 
2277  TaskFactoryOP task_factory( new TaskFactory );
2278  task_factory->push_back( new InitializeFromCommandline );
2279  task_factory->push_back( new RestrictToRepacking );
2280  task_factory->push_back( new IncludeCurrent );
2281  for (Size i = 1; i <= nres; i++) {
2282  if ( !pose.residue(i).is_RNA() ) continue;
2283  task_factory->push_back( new ExtraChiCutoff( i, 0 ) );
2284  task_factory->push_back( new ExtraRotamers( i, 4 /*ex4*/ ) );
2285  }
2286 
2287  o2star_green_packer_->set_task_factory( task_factory );
2288  o2star_green_packer_->set_reference_round_task_factory( task_factory );
2289 
2290  // This should also initialize rotamers, etc...
2291  o2star_green_packer_->apply( pose );
2292  }
2293 
2294 
2295 
2296  ////////////////////////////////////////////////////////////////////////
2297  void
2299 
2300  using namespace core::id;
2301  using namespace core::conformation;
2302 
2303 
2304  //reset the HO2star torsion to its starting value as to prevent randomness due to conformations sampling order...
2305  copy_all_o2star_torsions(pose, pose_with_original_HO2star_torsion);
2306 
2307  //std::cout << "Packing 2'-OH ... ";
2308  if ( use_green_packer_ ) {
2309  o2star_green_packer_->apply( pose );
2310  } else {
2311 
2312  //problem with bulge variant -- need to initialize_o2star_packer_task each time.
2314 
2316 
2317  }
2318 
2319  }
2320 
2321  ////////////////////////////////////////////////////////////////////////
2322  std::string //silly function to convert to real to string
2324 
2325  using namespace ObjexxFCL;
2326 
2327  std::string torsion_string="";
2328 
2329  core::Real const principal_torsion=numeric::principal_angle_degrees( torsion_value);
2330 
2331  Size const principal_torsion_SIZE=Size(std::abs(principal_torsion+0.00001)); //0.00001 is to prevent random ambiguity if the torsion decimal value is exactly .0000 Oct 12, 2010
2332 
2333 
2334  if(principal_torsion>0){
2335  torsion_string="p" + lead_zero_string_of(principal_torsion_SIZE, 3);
2336  }else{
2337  torsion_string="n" + lead_zero_string_of(principal_torsion_SIZE, 3);
2338  }
2339 
2340  return torsion_string;
2341  }
2342 
2343  ////////////////////////////////////////////////////////////////////////
2344  std::string //silly function used for appending the rotamer value to the tag
2346 
2347  std::string rotamer_tag="";
2348 
2349  bool const Is_prepend( job_parameters_->Is_prepend() );
2350  Size const moving_res( job_parameters_->working_moving_res() );
2351 
2352  conformation::Residue const & five_prime_rsd= (Is_prepend) ? pose.residue(moving_res): pose.residue(moving_res-1);
2353  conformation::Residue const & three_prime_rsd= (Is_prepend) ? pose.residue(moving_res+1) : pose.residue(moving_res);
2354 
2355 
2356  rotamer_tag.append("_E" + create_torsion_value_string(five_prime_rsd.mainchain_torsion( 5 ) ) );
2357  rotamer_tag.append("_Z" + create_torsion_value_string(five_prime_rsd.mainchain_torsion( 6 ) ) );
2358  rotamer_tag.append("_A" + create_torsion_value_string(three_prime_rsd.mainchain_torsion( 1 ) ) );
2359  rotamer_tag.append("_B" + create_torsion_value_string(three_prime_rsd.mainchain_torsion( 2 ) ) );
2360  rotamer_tag.append("_G" + create_torsion_value_string(three_prime_rsd.mainchain_torsion( 3 ) ) );
2361 
2362 
2363  if(Is_prepend){
2364  rotamer_tag.append("_D" + create_torsion_value_string(five_prime_rsd.mainchain_torsion( 4 ) ) );
2365  rotamer_tag.append("_C" + create_torsion_value_string(five_prime_rsd.chi( 1) ) );
2366 
2367  }else{
2368  rotamer_tag.append("_D" + create_torsion_value_string(three_prime_rsd.mainchain_torsion( 4) ) );
2369  rotamer_tag.append("_C" + create_torsion_value_string(three_prime_rsd.chi( 1) ) );
2370  }
2371 
2372  return rotamer_tag;
2373 
2374  }
2375  ////////////////////////////////////////////////////////////////////////
2376 
2377  std::string
2379 
2380  using namespace ObjexxFCL;
2381 
2382  std::string tag=prestring;
2383 
2384  for(Size list_position=rotamer_generator->rotamer_generator_list_size(); list_position>=2; list_position--){ //For dinucleotide
2385  tag.append("_" + lead_zero_string_of(rotamer_generator->group_rotamer(list_position), 4));
2386  }
2387 
2388  tag.append("_" + lead_zero_string_of(rotamer_generator->group_rotamer(1), 4));
2389  tag.append("_" + lead_zero_string_of(rotamer_generator->subgroup_rotamer(1), 5));
2390 
2391 
2392  return tag;
2393  }
2394 
2395  //////////////////////////////////////////////////////////////////////////
2396  void
2398  silent_file_ = silent_file;
2399  }
2400 
2401  //////////////////////////////////////////////////////////////////////////
2402  void
2404  num_pose_kept_=num_pose_kept ;
2405  }
2406 
2407  //////////////////////////////////////////////////////////////////////////
2408  void
2409  StepWiseRNA_ResidueSampler::set_fast( bool const & setting ){
2410  fast_ = setting;
2411  if (fast_) num_pose_kept_ = 2;
2412  }
2413 
2414  //////////////////////////////////////////////////////////////////////////
2415  void
2417  medium_fast_ = setting;
2418  if (medium_fast_) num_pose_kept_ = 20;
2419  }
2420 
2421  //////////////////////////////////////////////////////////////////////////
2422  void
2424  native_rmsd_screen_ = setting;
2425  }
2426 
2427  //////////////////////////////////////////////////////////////////////////
2428  void
2430  native_screen_rmsd_cutoff_= setting;
2431  }
2432  //////////////////////////////////////////////////////////////////////////
2433  void
2435  integration_test_mode_ = setting;
2437  num_pose_kept_ = 20;
2438  native_rmsd_screen_=false; //Start off as false, will change to true after count_data_.both_count>=1000!
2440  }
2441 
2442  }
2443 
2444  //////////////////////////////////////////////////////////////////////////
2445  void
2447  verbose_ = setting;
2448  }
2449  //////////////////////////////////////////////////////////////////////////
2450  void
2452  perform_o2star_pack_ = setting;
2453  }
2454 
2455 
2456  //////////////////////////////////////////////////////////////////////////
2457  void
2459  allow_bulge_at_chainbreak_ = setting;
2460  }
2461 
2462 
2463  //////////////////////////////////////////////////////////////////////////
2464  void
2466  output_filename_=output_filename;
2467  }
2468 
2469  //////////////////////////////////////////////////////////////////////////
2470  void
2472  scorefxn_ = scorefxn;
2473  }
2474 
2475  //////////////////////////////////////////////////////////////////////////
2478  return sfd_;
2479  }
2480 
2481 
2482  //////////////////////////////////////////////////////////////////
2483  void
2484  StepWiseRNA_ResidueSampler::output_pose_data_list( std::string const final_sampler_output_silent_file ) const{
2485  using namespace core::io::silent;
2486 
2487  if(verbose_==false){ //consistency check Apr 3, 2010
2488  utility_exit_with_message( "verbose_==false, but StepWiseRNA_ResidueSampler::output_pose_data_list is still called?!" );
2489  }
2490 
2492 
2493  for ( Size n = 1; n <= pose_data_list_.size(); n++ ) {
2494  Output_data(silent_file_data, final_sampler_output_silent_file, pose_data_list_[n].tag, false, *(pose_data_list_[n].pose_OP), get_native_pose(), job_parameters_);
2495  }
2496 
2497  }
2498 
2499  //////////////////////////////////////////////////////////////////
2500  void
2502  base_centroid_screener_ = screener;
2503  }
2504 
2505  //////////////////////////////////////////////////////////////////
2506  void
2508  cluster_rmsd_ = setting;
2509  std::cout << "Set cluster_rmsd to " << cluster_rmsd_ << std::endl;
2510  }
2511 
2512  //////////////////////////////////////////////////////////////////
2513 
2514 
2515 }
2516 }
2517 }