Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_FragmentMover.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file relax_protocols
11 /// @brief protocols that are specific to RNA_FragmentMover
12 /// @detailed
13 /// @author Rhiju Das
14 
15 
21 // AUTO-REMOVED #include <core/scoring/rna/RNA_Util.hh>
22 #include <core/pose/Pose.hh>
23 
24 // ObjexxFCL Headers
25 #include <ObjexxFCL/FArray1D.hh>
26 // AUTO-REMOVED #include <ObjexxFCL/FArray3D.hh>
27 
28 #include <core/types.hh>
29 #include <basic/Tracer.hh>
30 
31 #include <numeric/random/random.hh>
32 #include <numeric/xyzVector.hh>
33 
34 // External library headers
35 
36 
37 //C++ headers
38 #include <vector>
39 #include <string>
40 #include <sstream>
41 // AUTO-REMOVED #include <fstream>
42 // AUTO-REMOVED #include <ctime>
43 
44 #include <core/kinematics/Jump.hh>
46 #include <utility/vector1.hh>
47 
48 using namespace core;
49 using basic::T;
50 
51 static numeric::random::RandomGenerator RG(22220); // <- Magic number, do not change it!
52 
53 static basic::Tracer TR( "protocols.rna.rna_fragment_mover" ) ;
54 
55 namespace protocols {
56 namespace rna {
57 
58  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
59  //////////////////////////////////////////////////////////////////////////////////////////////////////////////
60  RNA_FragmentMover::RNA_FragmentMover(
61  RNA_FragmentsOP rna_fragments,
62  protocols::toolbox::AllowInsertOP allow_insert ):
63  Mover(),
64  rna_fragments_( rna_fragments ),
65  allow_insert_( allow_insert ),
66  num_insertable_residues_( 0 ),
67  insert_map_frag_size_( 0 ),
68  frag_size_( 0 )
69 {
70  Mover::type("RNA_FragmentMover");
71 }
72 
73  // This constructor is not actually used anymore -- better to use AllowInsert object above.
75  ObjexxFCL::FArray1D<bool> const & allow_insert_in,
76  pose::Pose const & pose ):
77  Mover(),
78  rna_fragments_( all_rna_fragments ),
79  num_insertable_residues_( 0 ),
80  insert_map_frag_size_( 0 ),
81  frag_size_( 0 )
82 {
83  Mover::type("RNA_FragmentMover");
84 
85  allow_insert_ = new toolbox::AllowInsert( pose );
86  allow_insert_->set( false );
87  for ( Size i = 1; i <= allow_insert_in.size(); i++ ){
88  if ( pose.residue_type( i ).is_RNA() && allow_insert_in[ i ] ) allow_insert_->set( i, true );
89  }
90 
91 }
92 
93 
94 
95 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
97 {
98 }
99 
102  return "RNA_FragmentMover";
103 }
104 
105 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
106 void
108  core::pose::Pose & pose
109 )
110 {
111  //Note, its better to call random_fragment_insertion directly...
113 }
114 
115 ///////////////////////////////////////////////////////////////////////////////
116 void
118 {
119 
120  // Maybe we don't need to do any updating.
121  if (frag_size_ == insert_map_frag_size_) return;
122 
123  // OK we do.
125  insert_map_.clear();
126 
127  for (Size i = 1; i <= pose.total_residue() - frag_size_ + 1; i++ ) {
128 
129  // Look to see if frame has *any* insertable residues.
130  // This is different from the past. Now we have a atom-resolution
131  // allow_insert map, so when we do the insertion, we can
132  // avoid changing atom positions that should be fixed.
133  bool frame_ok = true;
134 
135  // if ( !rna_fragments_->is_fullatom() ){
136  frame_ok = false;
137  for (Size offset = 1; offset <= frag_size_; offset++ ){
138  Size const n = i + offset - 1;
139  if ( allow_insert_->get( n ) ) { //sucka!
140  frame_ok = true;
141  break;
142  }
143  }
144 
145  // } else {
146 
147  // frame_ok = true;
148  // //Old school. Default for full-atom fragments.
149  // for (Size offset = 1; offset <= frag_size_; offset++ ){
150  // if ( !allow_insert_->get( i + offset - 1 ) ) { //sucka!
151  // frame_ok = false;
152  // break;
153  // }
154  // }
155  // }
156 
157  if ( !frame_ok ) continue;
158 
159  // Must make sure the whole frame is RNA, of course.
160 
161  for (Size offset = 1; offset <= frag_size_; offset++ ){
162  if ( !pose.residue_type( i + offset - 1 ).is_RNA() ){
163  frame_ok = false; break;
164  }
165  }
166 
167  // Check for cutpoints that interrupt frame. Wait. why?
168  // for (Size offset = 1; offset <= frag_size_; offset++ ){
169  // if ( offset < frag_size_ &&
170  // pose.fold_tree().is_cutpoint( i + offset - 1) &&
171  // !( pose.residue_type( i+offset-1).has_variant_type( chemical::CUTPOINT_LOWER ) &&
172  // pose.residue_type( i+offset ).has_variant_type( chemical::CUTPOINT_UPPER ) ) ) {
173  // frame_ok = false; break;
174  // }
175  // }
176 
177  if ( !frame_ok ) continue; // for (Size offset = 1; offset <= frag_size_; offset++ ){
178  // if ( offset < frag_size_ &&
179  // pose.fold_tree().is_cutpoint( i + offset - 1) &&
180  // !( pose.residue_type( i+offset-1).has_variant_type( chemical::CUTPOINT_LOWER ) &&
181  // pose.residue_type( i+offset ).has_variant_type( chemical::CUTPOINT_UPPER ) ) ) {
182  // frame_ok = false; break;
183  // }
184 
185 
188 
189  }
190 
191  // std::cout << "NUM_INSERTABEL_RESIDUES: " << num_insertable_residues_ << " for FRAG SIZE " << frag_size_ << std::endl;
192 
193  // std::cout << "ALLOW INSERT! ALLOW INSERT! ALLOW INSERT!" << std::endl;
194  // for (Size i = 1; i <= pose.total_residue(); i++ ){
195  // std::cout << allow_insert_->get( i );
196  // }
197  // std::cout << std::endl;
198  // std::cout << "ALLOW INSERT! ALLOW INSERT! ALLOW INSERT!"<< std::endl;
199 
200 
201 
202  insert_map_frag_size_ = frag_size_; //up to date!
203 
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////////////
207 Size
209  core::pose::Pose & pose,
210  Size const & frag_size
211 )
212 {
213  frag_size_ = frag_size;
214 
215  //Size const type = protocols::rna::MATCH_YR;
217 
218  // Make this insertion stuff a class before checking in?
219  update_insert_map( pose );
220  if ( num_insertable_residues_ == 0) return 0; // nothing to do
221  Size const position_index = static_cast <int> ( RG.uniform() * num_insertable_residues_ ) + 1;
222  Size const position = insert_map_[ position_index ];
223 
224  // std::cout << " --- Trying fragment! at " << position << std::endl;
225 
226  rna_fragments_->apply_random_fragment( pose, position, frag_size_, type, allow_insert_ );
227 
228  return position;
229 }
230 
231 
232 void
234  Size const fragment_size
235 )
236 {
237  frag_size_ = fragment_size;
238 }
239 
240 } // namespace rna
241 } // namespace protocols