Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pose_manipulation.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 protocols/toolbox/pose_manipulation.cc
11 /// @brief some general functions to manipulate poses. feel free to add your own
12 /// @brief if you add your own, please mention your name:)
13 /// @author Florian Richter, floric@u.washington.edu
14 
15 
16 // Unit headers
18 
19 // Project headers
23 //#include <core/chemical/VariantType.hh>
24  //needed for adding variant types
25 
28 
31 #include <core/kinematics/util.hh>
32 #include <core/pose/Pose.hh>
33 
34 #include <core/scoring/Energies.hh>
35 #include <core/scoring/rms_util.hh>
37 
38 #include <core/id/AtomID_Map.hh>
39 
43 #include <protocols/simple_moves/SwitchResidueTypeSetMover.hh> //typeset swapping
44 
46 
48 #include <protocols/loops/Loops.hh>
49 
50 
51 // Utility Headers
52 // AUTO-REMOVED #include <basic/options/option.hh>
53 #include <basic/Tracer.hh>
54 #include <core/types.hh>
55 
57 #include <core/pose/util.hh>
58 #include <utility/vector1.hh>
59 
60 //Auto Headers
61 #include <core/pose/util.tmpl.hh>
62 
63 // C++ Headers
64 
65 namespace protocols {
66 namespace toolbox {
67 namespace pose_manipulation{
68 
69 static basic::Tracer TR("protocols.toolbox.pose_manipulation");
70 static basic::Tracer TR_DI("protocols.toolbox.pose_manipulation.insert_pose_into_pose");
71 using basic::T;
72 using basic::Error;
73 using basic::Warning;
75 
76 void
78  core::pose::Pose & pose,
79  utility::vector1< core::Size > const & positions,
80  bool keep_pro,
81  bool keep_gly,
82  bool keep_disulfide_cys
83 )
84 {
85  construct_poly_uniq_restype_pose( pose, positions, core::chemical::ChemicalManager::get_instance()->residue_type_set( core::chemical::FA_STANDARD )->name_map("ALA"), keep_pro, keep_gly, keep_disulfide_cys);
86 }
87 
88 
89 void
91  core::pose::Pose & pose,
92  utility::vector1< core::Size > const & positions,
93  ResidueType const & restype,
94  bool keep_pro,
95  bool keep_gly,
96  bool keep_disulfide_cys
97 )
98 {
99  using namespace core;
100 
101  chemical::ResidueTypeSetCAP restype_set = chemical::ChemicalManager::get_instance()->residue_type_set( core::chemical::FA_STANDARD );
102 
103  conformation::Residue const replace_res( restype, true );
104 
105  for( utility::vector1< Size >::const_iterator pos_it = positions.begin();
106  pos_it != positions.end(); ++pos_it )
107  {
108 
109  chemical::ResidueTypeCOP cur_restype = & pose.residue_type( *pos_it );
110 
111 
112  if( ( keep_pro && ( cur_restype->aa() == chemical::aa_pro ) )
113  ||( keep_gly && ( cur_restype->aa() == chemical::aa_gly ) )
114  ||( keep_disulfide_cys && ( cur_restype->aa() == chemical::aa_cys ) && cur_restype->has_variant_type( chemical::DISULFIDE ) ) )
115  {
116  continue;
117  }
118 
119  utility::vector1< std::string > current_variants;
120 
121  bool variants_match = cur_restype->variants_match( replace_res.type() );
122  //TR<< "replacing: " << *pos_it << std::endl;
123 
124  if( !variants_match ){
125 
126  current_variants = cur_restype->variant_types();
127  chemical::ResidueTypeCOP var_replace_type = & ( replace_res.type() );
128 
129  for(core::Size var = 1; var <= current_variants.size(); var++){
130  var_replace_type = & ( restype_set->get_residue_type_with_variant_added( * var_replace_type, current_variants[ var ] ));
131  }
132 
133  //runtime_assert( var_replace_type->name3() == "ALA" );
134  conformation::Residue const var_replace_res( *var_replace_type, true );
135 
136  pose.replace_residue( *pos_it, var_replace_res, true );
137  }
138 
139  else pose.replace_residue( *pos_it, replace_res, true);
140 
141  } //iterator over positions to replace
142 
143 } // construct_poly_ala_pose function
144 
145 void
147  std::string const & aa,
148  core::pose::Pose & pose,
149  utility::vector1< core::Size > const & positions,
150  bool keep_pro,
151  bool keep_gly,
152  bool keep_disulfide_cys
153 )
154 {
155  using namespace core;
156 
157  chemical::ResidueTypeSetCAP restype_set = chemical::ChemicalManager::get_instance()->residue_type_set( core::chemical::FA_STANDARD );
158 
159  conformation::Residue const replace_res( restype_set->name_map( aa ), true );
160 
161  for( utility::vector1< Size >::const_iterator pos_it = positions.begin();
162  pos_it != positions.end(); ++pos_it )
163  {
164 
165  chemical::ResidueTypeCOP cur_restype = & pose.residue_type( *pos_it );
166 
167 
168  if( ( keep_pro && ( cur_restype->aa() == chemical::aa_pro ) )
169  ||( keep_gly && ( cur_restype->aa() == chemical::aa_gly ) )
170  ||( keep_disulfide_cys && ( cur_restype->aa() == chemical::aa_cys ) && cur_restype->has_variant_type( chemical::DISULFIDE ) ) )
171  {
172  continue;
173  }
174 
175  utility::vector1< std::string > current_variants;
176 
177  bool variants_match = cur_restype->variants_match( replace_res.type() );
178 
179  if( !variants_match ){
180 
181  current_variants = cur_restype->variant_types();
182  chemical::ResidueTypeCOP var_replace_type = & replace_res.type();
183 
184  for(core::Size var = 1; var <= current_variants.size(); var++){
185  var_replace_type = & ( restype_set->get_residue_type_with_variant_added( * var_replace_type, current_variants[ var ] ));
186  }
187 
188  runtime_assert( var_replace_type->name3() == aa );
189  conformation::Residue const var_replace_res( *var_replace_type, true );
190 
191  pose.replace_residue( *pos_it, var_replace_res, true );
192  }
193 
194  else pose.replace_residue( *pos_it, replace_res, true);
195 
196  } //iterator over positions to replace
197 
198 } // construct_poly_XXX_pose function
199 
200 
201 void
203  core::pose::Pose & pose
204 )
205 {
206 
207  bool residues_deleted(false);
208 
209  for( core::Size i = pose.total_residue(); i > 0 ; --i){
210 
211  if( ! pose.residue_type( i ).is_protein() ){
212  pose.conformation().delete_residue_slow( i );
213  residues_deleted = true;
214  }
215  }
216 
217  if( residues_deleted ) pose.energies().clear();
218 
219 } //remove_non_protein_residues
220 
221 
222 void
224 {
225  for( core::Size i =1; i <= pose.fold_tree().num_jump(); ++i ){
226 
227  core::Size this_cutpoint( pose.fold_tree().cutpoint( i ) );
228 
229  if ( pose.residue_type( this_cutpoint ).has_variant_type( core::chemical::UPPER_TERMINUS ) ) continue;
230 
231  if ( pose.residue_type( this_cutpoint +1 ).has_variant_type( core::chemical::LOWER_TERMINUS ) ) continue;
232 
233  if ( !pose.residue_type( this_cutpoint ).is_protein() ) continue;
234  if ( !pose.residue_type( this_cutpoint +1 ).is_protein() ) continue;
235 
236  if( !pose.residue_type( this_cutpoint ).has_variant_type( core::chemical::CUTPOINT_LOWER ) ){
238  }
239  if( !pose.residue_type( this_cutpoint +1 ).has_variant_type( core::chemical::CUTPOINT_UPPER ) ){
241  }
242  }
243 }
244 
245 void
247 {
248  for( core::Size i =1; i <= pose.fold_tree().num_jump(); ++i ){
249 
250  core::Size this_cutpoint( pose.fold_tree().cutpoint( i ) );
251  //exclude residue numbers in array
252  if ( find( no_cutpoint_residues.begin(), no_cutpoint_residues.end(), this_cutpoint ) != no_cutpoint_residues.end() ) {
253  continue;
254  }
255 
256  if ( pose.residue_type( this_cutpoint ).has_variant_type( core::chemical::UPPER_TERMINUS ) ) continue;
257 
258  if ( pose.residue_type( this_cutpoint +1 ).has_variant_type( core::chemical::LOWER_TERMINUS ) ) continue;
259 
260  if( !pose.residue_type( this_cutpoint ).has_variant_type( core::chemical::CUTPOINT_LOWER ) ){
262  }
263  if( !pose.residue_type( this_cutpoint +1 ).has_variant_type( core::chemical::CUTPOINT_UPPER ) ){
265  }
266  }
267 }
268 
269 
270 void
272 {
273  for( core::Size i =1; i <= pose.fold_tree().num_jump(); ++i ){
274 
275  core::Size this_cutpoint( pose.fold_tree().cutpoint( i ) );
276 
277  if( pose.residue_type( this_cutpoint ).has_variant_type( core::chemical::CUTPOINT_LOWER ) ){
279  }
280  if( pose.residue_type( this_cutpoint + 1).has_variant_type( core::chemical::CUTPOINT_UPPER ) ){
282  }
283  }
284 }
285 
288  core::pose::Pose & pose,
289  core::pose::Pose const & ref_pose,
290  utility::vector1< core::Size > const & positions,
291  int const offset
292 )
293 {
294  using namespace core::id;
295 
296  AtomID_Map< AtomID > atom_map;
297 
299 
300  for( utility::vector1< core::Size >::const_iterator res_it = positions.begin(); res_it != positions.end(); ++res_it){
301 
302  AtomID id1( pose.residue( *res_it + offset).atom_index("CA"), *res_it + offset );
303  AtomID id2( ref_pose.residue( *res_it ).atom_index("CA"), *res_it );
304 
305  atom_map.set( id1, id2);
306 
307  } //iterator over residues
308 
309  return core::scoring::superimpose_pose( pose, ref_pose, atom_map );
310 } //superimpose_pose_on_subset_CA
311 
312 
313 } // namespace pose_manipulation
314 } //toolbox
315 } //protocols