Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_SWA_MonteCarloUtil.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 Torsions an RNA residue from a chain terminus.
12 /// @detailed
13 /// @author Rhiju Das
14 
18 
19 // libRosetta headers
20 #include <core/types.hh>
22 #include <core/pose/Pose.hh>
23 #include <core/pose/util.hh>
24 
26 
27 #include <basic/Tracer.hh>
28 
29 #include <map>
30 
31 #include <numeric/random/random.hh>
32 
33 static numeric::random::RandomGenerator RG(239111); // <- Magic number, do not change it!
34 
35 using namespace core;
36 using core::Real;
37 
38 namespace protocols {
39 namespace swa {
40 namespace monte_carlo {
41 
42  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44  get_moving_residue_case( pose::Pose const & pose, Size const i ) {
45 
46  MovingResidueCase moving_residue_case( NO_CASE );
47 
48  Size const & nres( pose.total_residue() );
49  kinematics::FoldTree const & fold_tree( pose.fold_tree() );
50  if ( i == nres || fold_tree.is_cutpoint( i ) ){ // could be a 5' chain terminus
51  if ( i == 1 || fold_tree.is_cutpoint( i-1 ) ){
52  moving_residue_case = FLOATING_BASE; // don't know how to handle this yet.
53  } else {
54  moving_residue_case = CHAIN_TERMINUS_3PRIME;
55  }
56  } else if ( i == 1 || fold_tree.is_cutpoint( i-1 ) ){
57  moving_residue_case = CHAIN_TERMINUS_5PRIME;
58  } else {
59  moving_residue_case = INTERNAL;
60  }
61 
62  return moving_residue_case;
63  }
64 
65 
66 
67  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
68  void
70  utility::vector1< Size > & possible_res,
71  utility::vector1< MovingResidueCase > & moving_residue_cases,
72  utility::vector1< AddOrDeleteChoice > & add_or_delete_choices ) {
73 
74 
75  Size const & nres( pose.total_residue() );
76  kinematics::FoldTree const & fold_tree( pose.fold_tree() );
77 
78  SubToFullInfo & sub_to_full_info = nonconst_sub_to_full_info_from_pose( pose );
79  utility::vector1< Size > const & moving_res_list = sub_to_full_info.moving_res_list();
80 
81  for ( Size n = 1; n <= moving_res_list.size(); n++ ){
82 
83  Size const i = moving_res_list[ n ];
84 
85  if ( i == nres || fold_tree.is_cutpoint( i ) ){ // could be a 3' chain terminus
86 
87  possible_res.push_back( i );
88  moving_residue_cases.push_back( CHAIN_TERMINUS_3PRIME );
89  add_or_delete_choices.push_back( DELETE );
90 
91  } else if ( i == 1 || fold_tree.is_cutpoint( i-1 ) ) {
92 
93  possible_res.push_back( i );
94  moving_residue_cases.push_back( CHAIN_TERMINUS_5PRIME );
95  add_or_delete_choices.push_back( DELETE );
96 
97  }
98 
99 
100  }
101 
102  }
103 
104  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
105  void
107  utility::vector1< Size > & possible_res,
108  utility::vector1< MovingResidueCase > & moving_residue_cases,
109  utility::vector1< AddOrDeleteChoice > & add_or_delete_choices ) {
110 
111  Size const & nres( pose.total_residue() );
112  kinematics::FoldTree const & fold_tree( pose.fold_tree() );
113 
114  SubToFullInfo & sub_to_full_info = nonconst_sub_to_full_info_from_pose( pose );
115  std::map< Size, Size > sub_to_full = sub_to_full_info.sub_to_full();
116  utility::vector1< Size > cutpoints_in_full_pose = sub_to_full_info.cutpoints_in_full_pose();
117  Size nres_full = sub_to_full_info.full_sequence().size();
118 
119  utility::vector1< bool > is_cutpoint_in_full_pose;
120  for ( Size i = 1; i <= nres_full; i++ ) is_cutpoint_in_full_pose.push_back( false );
121  for ( Size n = 1; n <= cutpoints_in_full_pose.size(); n++ ) is_cutpoint_in_full_pose[ cutpoints_in_full_pose[n] ] = true;
122 
123  for ( Size i = 1; i <= nres; i++ ){
124 
125  if ( ( i == nres ) ||
126  ( fold_tree.is_cutpoint( i ) && (sub_to_full[ i ]+1 < sub_to_full[ i+1 ]) ) ) { // could be a 3' chain terminus
127 
128  Size const i_full = sub_to_full[ i ] ;
129  if ( !is_cutpoint_in_full_pose[ i_full ] && i_full < nres_full ){ // good, there's still a gap!
130 
131  possible_res.push_back( i );
132  moving_residue_cases.push_back( CHAIN_TERMINUS_3PRIME );
133  add_or_delete_choices.push_back( ADD );
134 
135  }
136  }
137  }
138 
139  for ( Size i = 1; i <= nres; i++ ){
140 
141  if ( ( i == 1 ) ||
142  ( fold_tree.is_cutpoint( i-1 ) && (sub_to_full[ i ]-1 > sub_to_full[ i-1 ]) ) ) { // could be a 5' chain terminus
143 
144  Size const i_full = sub_to_full[ i ];
145  if ( i_full > 1 && !is_cutpoint_in_full_pose[ i_full-1 ] ) { // good, there's still a gap!
146 
147  possible_res.push_back( i );
148  moving_residue_cases.push_back( CHAIN_TERMINUS_5PRIME );
149  add_or_delete_choices.push_back( ADD );
150  }
151  }
152  }
153 
154  }
155 
156  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
157  void
159  Size & residue_at_chain_terminus,
160  MovingResidueCase & moving_residue_case,
161  AddOrDeleteChoice & add_or_delete_choice,
162  bool const disallow_delete ) {
163 
164 
165  utility::vector1< Size > possible_res;
166  utility::vector1< MovingResidueCase > moving_residue_cases;
167  utility::vector1< AddOrDeleteChoice > add_or_delete_choices;
168 
169  if ( !disallow_delete ){
170  get_potential_delete_residues( pose, possible_res, moving_residue_cases, add_or_delete_choices );
171  }
172 
173  get_potential_add_residues( pose, possible_res, moving_residue_cases, add_or_delete_choices );
174 
175  Size const res_idx = int( RG.uniform() * possible_res.size() ) + 1;
176 
177  residue_at_chain_terminus = possible_res[ res_idx ];
178  moving_residue_case = moving_residue_cases[ res_idx ];
179  add_or_delete_choice = add_or_delete_choices[ res_idx ];
180 
181  }
182 
183 
184 }
185 }
186 }