Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_AddMover.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file RNA_DeleteMover
11 /// @brief Adds an RNA residue from a chain terminus.
12 /// @detailed
13 /// @author Rhiju Das
14 
18 
19 // libRosetta headers
20 #include <core/types.hh>
24 #include <core/pose/Pose.hh>
25 #include <core/pose/util.hh>
27 
30 
31 #include <basic/Tracer.hh>
32 
33 #include <map>
34 
35 using namespace core;
36 using core::Real;
37 
38 //////////////////////////////////////////////////////////////////////////
39 // Removes one residue from a 5' or 3' chain terminus, and appropriately
40 // updates the pose sub_to_full_info object.
41 //////////////////////////////////////////////////////////////////////////
42 
43 static basic::Tracer TR( "protocols.swa.monte_carlo.rna_add_mover" ) ;
44 
45 namespace protocols {
46 namespace swa {
47 namespace monte_carlo {
48 
49 
50  //////////////////////////////////////////////////////////////////////////
51  //constructor!
52  RNA_AddMover::RNA_AddMover( chemical::ResidueTypeSetCAP rsd_set,
53  scoring::ScoreFunctionOP scorefxn ):
54  rsd_set_( rsd_set ),
55  scorefxn_( scorefxn ),
56  presample_added_residue_( true ), // need get/set functions
57  start_added_residue_in_aform_( false ), // need get/set functions
58  internal_cycles_( 50 ),
59  rna_torsion_mover_( new RNA_TorsionMover ),
60  sample_range_small_( 5.0 ),
61  sample_range_large_( 40.0 ),
62  kT_( 0.5 )
63  {}
64 
65  //////////////////////////////////////////////////////////////////////////
66  //destructor
68  {}
69 
70  //////////////////////////////////////////////////////////////////////////
71  void
73  {
74  std::cout << "not defined yet" << std::endl;
75  }
76 
77  //////////////////////////////////////////////////////////////////////
78  void
79  RNA_AddMover::apply( core::pose::Pose & pose, Size const res_to_build_off, MovingResidueCase const moving_residue_case )
80  {
81 
82  using namespace protocols::moves;
83 
84  Size suite_num( 0 ), nucleoside_num( 0 ); // will record which new dofs added.
85 
86  //pose.dump_pdb( "before_add.pdb" );
87  SubToFullInfo & sub_to_full_info = nonconst_sub_to_full_info_from_pose( pose );
88  std::string const full_sequence = sub_to_full_info.full_sequence();
89  std::map< Size, Size > sub_to_full = sub_to_full_info.sub_to_full();
90 
91  if ( moving_residue_case == CHAIN_TERMINUS_3PRIME ){
92 
93  runtime_assert( res_to_build_off < pose.total_residue() ); // wait is this necessary?
94  runtime_assert( sub_to_full[ res_to_build_off ] < sub_to_full[ res_to_build_off+1 ] -1 );
95 
96  Size const res_to_add = res_to_build_off + 1;
97 
98  char newrestype = full_sequence[ (sub_to_full[ res_to_build_off ] + 1) - 1 ];
99  //std::cout << "I want to add: " << newrestype << std::endl;
100 
101  chemical::AA my_aa = chemical::aa_from_oneletter_code( newrestype );
102  chemical::ResidueTypeCOPs const & rsd_type_list( rsd_set_->aa_map( my_aa ) );
103  // iterate over rsd_types, pick one.
104  chemical::ResidueType const & rsd_type = *rsd_type_list[1];
105  core::conformation::ResidueOP new_rsd = conformation::ResidueFactory::create_residue( rsd_type );
106 
107  pose.append_polymer_residue_after_seqpos( *new_rsd, res_to_build_off, true /*build ideal geometry*/ );
108 
109  reorder_sub_to_full_info_after_append( pose, res_to_add );
110 
111  suite_num = res_to_add-1;
112  nucleoside_num = res_to_add;
113 
114  } else {
115 
116  //Size const res_to_add = moving_res_list[1]; // for now, just build off 5' fragment.
117  Size const res_to_add = res_to_build_off;
118 
119  runtime_assert( sub_to_full[ res_to_add ] > 1 );
120 
121  char newrestype = full_sequence[ (sub_to_full[ res_to_add ] - 1) - 1 ];
122  //std::cout << "I want to add: " << newrestype << std::endl;
123 
124  chemical::AA my_aa = chemical::aa_from_oneletter_code( newrestype );
125  chemical::ResidueTypeCOPs const & rsd_type_list( rsd_set_->aa_map( my_aa ) );
126  // iterate over rsd_types, pick one.
127  chemical::ResidueType const & rsd_type = *rsd_type_list[1];
128  core::conformation::ResidueOP new_rsd = conformation::ResidueFactory::create_residue( rsd_type );
129 
130  pose::remove_variant_type_from_pose_residue( pose, "VIRTUAL_PHOSPHATE", res_to_add ); // got to be safe.
131 
132  pose.prepend_polymer_residue_before_seqpos( *new_rsd, res_to_add, true /*build ideal geometry*/ );
133  pose::add_variant_type_to_pose_residue( pose, "VIRTUAL_PHOSPHATE", res_to_add );
134 
135  reorder_sub_to_full_info_after_prepend( pose, res_to_add );
136 
137  // initialize with a random torsion... ( how about an A-form + perturbation ... or go to a 'reasonable' rotamer)
138  suite_num = res_to_add;
139  nucleoside_num = res_to_add;
140 
141  }
142 
144  rna_torsion_mover_->apply_suite_torsion_Aform( pose, suite_num );
145  rna_torsion_mover_->apply_nucleoside_torsion_Aform( pose, nucleoside_num );
146  } else {
147  rna_torsion_mover_->apply_random_nucleoside_torsion( pose, nucleoside_num );
148  rna_torsion_mover_->apply_random_suite_torsion( pose, suite_num );
149  }
150 
151  rna_torsion_mover_->sample_near_suite_torsion( pose, suite_num, sample_range_large_);
152  rna_torsion_mover_->sample_near_nucleoside_torsion( pose, nucleoside_num, sample_range_large_);
153 
154  ///////////////////////////////////
155  // Presampling added residue
156  ///////////////////////////////////
158  TR.Debug << "presampling added residue! " << nucleoside_num << " over " << internal_cycles_ << " cycles " << std::endl;
159  MonteCarloOP monte_carlo_internal = new MonteCarlo( pose, *scorefxn_, kT_ );
160 
161  std::string move_type( "" );
162  for ( Size count_internal = 1; count_internal <= internal_cycles_; count_internal++ ){
163 
164  rna_torsion_mover_->sample_near_suite_torsion( pose, suite_num, sample_range_large_);
165  rna_torsion_mover_->sample_near_nucleoside_torsion( pose, nucleoside_num, sample_range_large_);
166  monte_carlo_internal->boltzmann( pose, move_type );
167 
168  rna_torsion_mover_->sample_near_suite_torsion( pose, suite_num, sample_range_small_);
169  rna_torsion_mover_->sample_near_nucleoside_torsion( pose, nucleoside_num, sample_range_small_);
170  monte_carlo_internal->boltzmann( pose, move_type );
171  //std::cout << "During presampling: " << (*scorefxn_)( pose );
172  }
173  }
174 
175  }
176 
179  return "RNA_AddMover";
180  }
181 
182 }
183 }
184 }