Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pose_mod.hh
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/forge/methods/pose_mod.hh
11 /// @brief methods for Pose modifications
12 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
13 
14 #ifndef INCLUDED_protocols_forge_methods_pose_mod_hh
15 #define INCLUDED_protocols_forge_methods_pose_mod_hh
16 
17 // type headers
18 #include <core/types.hh>
19 
20 // project headers
21 
25 #include <core/id/AtomID.fwd.hh>
26 #include <core/pose/Pose.hh>
27 
28 //Auto Headers
29 #include <platform/types.hh>
30 #include <core/chemical/AA.hh>
32 #include <core/chemical/Adduct.hh>
49 #include <core/chemical/types.hh>
71 #include <core/id/AtomID.hh>
73 #include <core/id/AtomID_Map.hh>
75 #include <core/id/DOF_ID.fwd.hh>
76 #include <core/id/DOF_ID.hh>
78 #include <core/id/DOF_ID_Map.hh>
81 #include <core/id/NamedAtomID.hh>
84 #include <core/id/TorsionID.fwd.hh>
85 #include <core/id/types.hh>
92 #include <core/kinematics/Edge.hh>
96 #include <core/kinematics/Jump.hh>
100 #include <core/kinematics/RT.hh>
103 #include <core/kinematics/Stub.hh>
107 #include <core/pose/MiniPose.fwd.hh>
108 #include <core/pose/PDBInfo.fwd.hh>
109 #include <core/pose/Pose.fwd.hh>
110 #include <core/pose/util.hh>
119 #include <core/scoring/ScoreType.hh>
122 #include <utility/Bound.fwd.hh>
123 #include <utility/Bound.hh>
124 #include <utility/down_cast.hh>
125 #include <utility/exit.hh>
126 #include <utility/stream_util.hh>
127 #include <utility/string_util.hh>
128 #include <utility/vector0_bool.hh>
129 #include <utility/vector1.fwd.hh>
130 #include <utility/vector1.hh>
131 #include <utility/vector1_bool.hh>
132 #include <utility/vectorL.fwd.hh>
133 #include <utility/vectorL.hh>
134 #include <utility/vectorL_Selector.hh>
135 #include <utility/vectorL_bool.hh>
136 #include <utility/file/FileName.fwd.hh>
137 #include <utility/file/FileName.hh>
138 #include <utility/file/PathName.fwd.hh>
139 #include <utility/file/PathName.hh>
140 #include <utility/keys/AutoKey.fwd.hh>
141 #include <utility/keys/AutoKey.hh>
142 #include <utility/keys/Key.fwd.hh>
143 #include <utility/keys/Key.hh>
144 #include <utility/keys/Key2Tuple.fwd.hh>
145 #include <utility/keys/Key2Tuple.hh>
146 #include <utility/keys/Key3Tuple.fwd.hh>
147 #include <utility/keys/Key3Tuple.hh>
148 #include <utility/keys/Key4Tuple.fwd.hh>
149 #include <utility/keys/Key4Tuple.hh>
150 #include <utility/keys/KeyLess.fwd.hh>
151 #include <utility/keys/KeyLookup.fwd.hh>
152 #include <utility/keys/KeyLookup.hh>
153 #include <utility/keys/NoClient.fwd.hh>
154 #include <utility/keys/NoClient.hh>
155 #include <utility/keys/SmallKeyVector.fwd.hh>
156 #include <utility/keys/SmallKeyVector.hh>
157 #include <utility/keys/UserKey.fwd.hh>
158 #include <utility/keys/VariantKey.fwd.hh>
159 #include <utility/keys/VariantKey.hh>
160 #include <utility/options/AnyOption.fwd.hh>
161 #include <utility/options/AnyOption.hh>
162 #include <utility/options/AnyVectorOption.fwd.hh>
163 #include <utility/options/AnyVectorOption.hh>
164 #include <utility/options/BooleanOption.fwd.hh>
165 #include <utility/options/BooleanOption.hh>
166 #include <utility/options/BooleanVectorOption.fwd.hh>
167 #include <utility/options/BooleanVectorOption.hh>
168 #include <utility/options/FileOption.fwd.hh>
169 #include <utility/options/FileOption.hh>
170 #include <utility/options/FileVectorOption.fwd.hh>
171 #include <utility/options/FileVectorOption.hh>
172 #include <utility/options/IntegerOption.fwd.hh>
173 #include <utility/options/IntegerOption.hh>
174 #include <utility/options/IntegerVectorOption.fwd.hh>
175 #include <utility/options/IntegerVectorOption.hh>
176 #include <utility/options/Option.fwd.hh>
177 #include <utility/options/Option.hh>
178 #include <utility/options/OptionCollection.fwd.hh>
179 #include <utility/options/OptionCollection.hh>
180 #include <utility/options/PathOption.fwd.hh>
181 #include <utility/options/PathOption.hh>
182 #include <utility/options/PathVectorOption.fwd.hh>
183 #include <utility/options/PathVectorOption.hh>
184 #include <utility/options/RealOption.fwd.hh>
185 #include <utility/options/RealOption.hh>
186 #include <utility/options/RealVectorOption.fwd.hh>
187 #include <utility/options/RealVectorOption.hh>
188 #include <utility/options/ScalarOption.fwd.hh>
189 #include <utility/options/ScalarOption.hh>
190 #include <utility/options/ScalarOption_T_.fwd.hh>
191 #include <utility/options/ScalarOption_T_.hh>
192 #include <utility/options/StringOption.fwd.hh>
193 #include <utility/options/StringOption.hh>
194 #include <utility/options/StringVectorOption.fwd.hh>
195 #include <utility/options/StringVectorOption.hh>
196 #include <utility/options/VariantOption.fwd.hh>
197 #include <utility/options/VariantOption.hh>
198 #include <utility/options/VectorOption.fwd.hh>
199 #include <utility/options/VectorOption.hh>
200 #include <utility/options/VectorOption_T_.fwd.hh>
201 #include <utility/options/VectorOption_T_.hh>
202 #include <utility/options/mpi_stderr.hh>
203 #include <utility/options/keys/AnyOptionKey.fwd.hh>
204 #include <utility/options/keys/AnyOptionKey.hh>
205 #include <utility/options/keys/AnyVectorOptionKey.fwd.hh>
206 #include <utility/options/keys/AnyVectorOptionKey.hh>
207 #include <utility/options/keys/BooleanOptionKey.fwd.hh>
208 #include <utility/options/keys/BooleanOptionKey.hh>
209 #include <utility/options/keys/BooleanVectorOptionKey.fwd.hh>
210 #include <utility/options/keys/BooleanVectorOptionKey.hh>
211 #include <utility/options/keys/FileOptionKey.fwd.hh>
212 #include <utility/options/keys/FileOptionKey.hh>
213 #include <utility/options/keys/FileVectorOptionKey.fwd.hh>
214 #include <utility/options/keys/FileVectorOptionKey.hh>
215 #include <utility/options/keys/IntegerOptionKey.fwd.hh>
216 #include <utility/options/keys/IntegerOptionKey.hh>
217 #include <utility/options/keys/IntegerVectorOptionKey.fwd.hh>
218 #include <utility/options/keys/IntegerVectorOptionKey.hh>
219 #include <utility/options/keys/OptionKey.fwd.hh>
220 #include <utility/options/keys/OptionKey.hh>
221 #include <utility/options/keys/OptionKeys.hh>
222 #include <utility/options/keys/PathOptionKey.fwd.hh>
223 #include <utility/options/keys/PathOptionKey.hh>
224 #include <utility/options/keys/PathVectorOptionKey.fwd.hh>
225 #include <utility/options/keys/PathVectorOptionKey.hh>
226 #include <utility/options/keys/RealOptionKey.fwd.hh>
227 #include <utility/options/keys/RealOptionKey.hh>
228 #include <utility/options/keys/RealVectorOptionKey.fwd.hh>
229 #include <utility/options/keys/RealVectorOptionKey.hh>
230 #include <utility/options/keys/ScalarOptionKey.fwd.hh>
231 #include <utility/options/keys/ScalarOptionKey.hh>
232 #include <utility/options/keys/StringOptionKey.fwd.hh>
233 #include <utility/options/keys/StringOptionKey.hh>
234 #include <utility/options/keys/StringVectorOptionKey.fwd.hh>
235 #include <utility/options/keys/StringVectorOptionKey.hh>
236 #include <utility/options/keys/VectorOptionKey.fwd.hh>
237 #include <utility/options/keys/VectorOptionKey.hh>
238 #include <utility/options/keys/all.hh>
239 #include <utility/pointer/ReferenceCount.fwd.hh>
240 #include <utility/pointer/ReferenceCount.hh>
241 #include <utility/pointer/access_ptr.fwd.hh>
242 #include <utility/pointer/access_ptr.hh>
243 #include <utility/pointer/owning_ptr.functions.hh>
244 #include <utility/pointer/owning_ptr.fwd.hh>
245 #include <utility/pointer/owning_ptr.hh>
246 #include <utility/signals/BufferedSignalHub.fwd.hh>
247 #include <utility/signals/BufferedSignalHub.hh>
248 #include <utility/signals/Link.fwd.hh>
249 #include <utility/signals/Link.hh>
250 #include <utility/signals/LinkUnit.fwd.hh>
251 #include <utility/signals/LinkUnit.hh>
252 #include <utility/signals/PausableSignalHub.fwd.hh>
253 #include <utility/signals/PausableSignalHub.hh>
254 #include <utility/signals/SignalHub.fwd.hh>
255 #include <utility/signals/SignalHub.hh>
256 #include <numeric/NumericTraits.hh>
257 #include <numeric/constants.hh>
258 #include <numeric/conversions.hh>
259 #include <numeric/numeric.functions.hh>
260 #include <numeric/sphericalVector.fwd.hh>
261 #include <numeric/sphericalVector.hh>
262 #include <numeric/trig.functions.hh>
263 #include <numeric/types.hh>
264 #include <numeric/xyz.functions.fwd.hh>
265 #include <numeric/xyz.functions.hh>
266 #include <numeric/xyzMatrix.fwd.hh>
267 #include <numeric/xyzMatrix.hh>
268 #include <numeric/xyzVector.fwd.hh>
269 #include <numeric/xyzVector.hh>
270 #include <numeric/internal/ColPointers.hh>
271 #include <numeric/internal/ColVectors.hh>
272 #include <numeric/internal/ColsPointer.hh>
273 #include <numeric/internal/RowPointers.hh>
274 #include <numeric/internal/RowVectors.hh>
275 #include <numeric/internal/RowsPointer.hh>
276 #include <ObjexxFCL/Dimension.fwd.hh>
277 #include <ObjexxFCL/Dimension.hh>
278 #include <ObjexxFCL/DimensionExpression.hh>
279 #include <ObjexxFCL/DynamicIndexRange.fwd.hh>
280 #include <ObjexxFCL/DynamicIndexRange.hh>
281 #include <ObjexxFCL/FArray.all.fwd.hh>
282 #include <ObjexxFCL/FArray.fwd.hh>
283 #include <ObjexxFCL/FArray.hh>
284 #include <ObjexxFCL/FArray1.all.fwd.hh>
285 #include <ObjexxFCL/FArray1.fwd.hh>
286 #include <ObjexxFCL/FArray1.hh>
287 #include <ObjexxFCL/FArray1A.fwd.hh>
288 #include <ObjexxFCL/FArray1D.fwd.hh>
289 #include <ObjexxFCL/FArray1D.hh>
290 #include <ObjexxFCL/FArray1P.fwd.hh>
291 #include <ObjexxFCL/FArray2.all.fwd.hh>
292 #include <ObjexxFCL/FArray2.fwd.hh>
293 #include <ObjexxFCL/FArray2.hh>
294 #include <ObjexxFCL/FArray2A.fwd.hh>
295 #include <ObjexxFCL/FArray2D.fwd.hh>
296 #include <ObjexxFCL/FArray2D.hh>
297 #include <ObjexxFCL/FArray2P.fwd.hh>
298 #include <ObjexxFCL/FArray3.all.fwd.hh>
299 #include <ObjexxFCL/FArray3.fwd.hh>
300 #include <ObjexxFCL/FArray3A.fwd.hh>
301 #include <ObjexxFCL/FArray3D.fwd.hh>
302 #include <ObjexxFCL/FArray3P.fwd.hh>
303 #include <ObjexxFCL/FArray4.all.fwd.hh>
304 #include <ObjexxFCL/FArray4.fwd.hh>
305 #include <ObjexxFCL/FArray4A.fwd.hh>
306 #include <ObjexxFCL/FArray4D.fwd.hh>
307 #include <ObjexxFCL/FArray4P.fwd.hh>
308 #include <ObjexxFCL/FArray5.all.fwd.hh>
309 #include <ObjexxFCL/FArray5.fwd.hh>
310 #include <ObjexxFCL/FArray5A.fwd.hh>
311 #include <ObjexxFCL/FArray5D.fwd.hh>
312 #include <ObjexxFCL/FArray5P.fwd.hh>
313 #include <ObjexxFCL/FArray6.all.fwd.hh>
314 #include <ObjexxFCL/FArray6.fwd.hh>
315 #include <ObjexxFCL/FArray6A.fwd.hh>
316 #include <ObjexxFCL/FArray6D.fwd.hh>
317 #include <ObjexxFCL/FArray6P.fwd.hh>
318 #include <ObjexxFCL/FArrayInitializer.fwd.hh>
319 #include <ObjexxFCL/FArrayInitializer.hh>
320 #include <ObjexxFCL/FArraySection.fwd.hh>
321 #include <ObjexxFCL/FArraySection.hh>
322 #include <ObjexxFCL/FArrayTraits.fwd.hh>
323 #include <ObjexxFCL/FArrayTraits.hh>
324 #include <ObjexxFCL/IndexRange.fwd.hh>
325 #include <ObjexxFCL/IndexRange.hh>
326 #include <ObjexxFCL/InitializerSentinel.hh>
327 #include <ObjexxFCL/KeyFArray1D.fwd.hh>
328 #include <ObjexxFCL/KeyFArray2D.fwd.hh>
329 #include <ObjexxFCL/KeyFArray3D.fwd.hh>
330 #include <ObjexxFCL/KeyFArray4D.fwd.hh>
331 #include <ObjexxFCL/KeyFArray5D.fwd.hh>
332 #include <ObjexxFCL/KeyFArray6D.fwd.hh>
333 #include <ObjexxFCL/Observer.fwd.hh>
334 #include <ObjexxFCL/Observer.hh>
335 #include <ObjexxFCL/ObserverMulti.hh>
336 #include <ObjexxFCL/ObserverSingle.hh>
337 #include <ObjexxFCL/ProxySentinel.hh>
338 #include <ObjexxFCL/SetWrapper.fwd.hh>
339 #include <ObjexxFCL/Star.fwd.hh>
340 #include <ObjexxFCL/Star.hh>
341 #include <ObjexxFCL/TypeTraits.hh>
342 #include <ObjexxFCL/char.functions.hh>
343 #include <ObjexxFCL/proxy_const_assert.hh>
344 #include <ObjexxFCL/string.functions.hh>
345 #include <algorithm>
346 #include <cassert>
347 #include <cmath>
348 #include <cstddef>
349 #include <cstdio>
350 #include <cstdlib>
351 #include <iomanip>
352 #include <iosfwd>
353 #include <iostream>
354 #include <limits>
355 #include <list>
356 #include <map>
357 #include <ostream>
358 #include <set>
359 #include <sstream>
360 #include <string>
361 #include <typeinfo>
362 #include <utility>
363 #include <vector>
364 #include <basic/MetricValue.fwd.hh>
365 #include <basic/datacache/BasicDataCache.fwd.hh>
366 #include <basic/datacache/BasicDataCache.hh>
367 #include <basic/datacache/CacheableData.fwd.hh>
368 #include <basic/datacache/CacheableData.hh>
369 #include <basic/datacache/DataCache.fwd.hh>
370 #include <basic/datacache/DataCache.hh>
371 #include <basic/options/keys/OptionKeys.hh>
372 #include <basic/options/option.hh>
373 #include <boost/algorithm/string/erase.hpp>
374 #include <boost/bind.hpp>
375 #include <boost/function.hpp>
376 #include <boost/functional/hash.hpp>
377 #include <core/pose/util.tmpl.hh>
378 
379 namespace protocols {
380 namespace forge {
381 namespace methods {
382 
383 
384 /// @brief grow a series of residues to the left of a position
385 /// @param[in,out] pose Pose the pose to modify
386 /// @param[in] anchor the anchor position
387 /// @param[in] begin iterator that points to the first ResidueOP
388 /// @param[in] end iterator that points just beyond the last ResidueOP
389 /// @param[in] correct_terminus re-add lower terminus if found, default true
390 /// @param[in] use_existing_crd No idealization: place residues with existing
391 /// coordinates, default false.
392 /// @return the left endpoint of the new growth or zero if nothing to do
393 /// @remarks Use a reverse iterator to grow right -> left along vector containers.
394 template< typename ResidueOPIterator >
397  core::pose::Pose & pose,
398  core::Size anchor,
399  ResidueOPIterator begin,
400  ResidueOPIterator end,
401  bool const correct_terminus = true,
402  bool const use_existing_crd = false
403 )
404 {
405  using core::Size;
406 
407  if ( begin == end ) {
408  return 0;
409  }
410 
411  // query to see if position we're extending from is a true terminus
412  bool const had_lower_terminus = pose.residue( anchor ).is_lower_terminus();
413 
414  // grow extension
415  Size current_pos = anchor; // tracks the anchor as it moves
416  for ( ResidueOPIterator i = begin; i != end; ++i, ++current_pos ) {
417  pose.conformation().safely_prepend_polymer_residue_before_seqpos( **i, anchor, !use_existing_crd ); // will remove any terminus
418  }
419 
420  // add terminus if necessary
421  if ( correct_terminus && had_lower_terminus && !pose.residue( anchor ).is_lower_terminus() ) {
423  }
424 
425  return anchor; // the left endpoint of the new growth
426 }
427 
428 
429 /// @brief grow a series of residues to the left of a position
430 /// @param[in,out] pose Pose the pose to modify
431 /// @param[in] anchor the anchor position
432 /// @param[in] begin iterator that points to the first ResidueTypeOP
433 /// @param[in] end iterator that points just beyond the last ResidueTypeOP
434 /// @param[in] correct_terminus re-add lower terminus if found, default true
435 /// @return the left endpoint of the new growth or zero if nothing to do
436 /// @remarks Use a reverse iterator to grow right -> left along vector containers.
437 template< typename ResidueTypeOPIterator >
440  core::pose::Pose & pose,
441  core::Size anchor,
442  ResidueTypeOPIterator begin,
443  ResidueTypeOPIterator end,
444  bool const correct_terminus = true
445 )
446 {
449 
450  // create residues
451  ResidueOPs residues;
452  for ( ResidueTypeOPIterator i = begin; i != end; ++i ) {
453  residues.push_back( ResidueFactory::create_residue( **i ) );
454  }
455 
456  return grow_left_r( pose, anchor, residues.begin(), residues.end(), correct_terminus, false );
457 }
458 
459 
460 /// @brief grow a series of residues to the right of a position
461 /// @param[in,out] pose Pose the pose to modify
462 /// @param[in] anchor the anchor position, can be 0 if operating on empty
463 /// Pose
464 /// @param[in] begin iterator that points to the first ResidueOP
465 /// @param[in] end iterator that points just beyond the last ResidueOP
466 /// @param[in] correct_terminus re-add upper terminus if found, default true
467 /// @param[in] use_existing_crd No idealization: place residues with existing
468 /// coordinates, default false.
469 /// @return the right endpoint of the new growth or zero if nothing to do
470 template< typename ResidueOPIterator >
473  core::pose::Pose & pose,
474  core::Size anchor,
475  ResidueOPIterator begin,
476  ResidueOPIterator end,
477  bool const correct_terminus = true,
478  bool const use_existing_crd = false
479 )
480 {
481  using core::Size;
482 
483  if ( begin == end ) {
484  return 0;
485  }
486 
487  // query to see if position we're extending from is a true terminus
488  bool const had_upper_terminus = anchor > 0 ? pose.residue( anchor ).is_upper_terminus() : false;
489 
490  // grow extension
491  Size current_pos = anchor; // tracks the right endpoint of the new growth
492 
493  ResidueOPIterator i = begin;
494  if ( anchor == 0 ) { // special case where pose is empty
495  pose.append_residue_by_bond( **i );
496  ++i;
497  ++current_pos;
498  }
499 
500  for ( ; i != end; ++i, ++current_pos ) {
501  pose.conformation().safely_append_polymer_residue_after_seqpos( **i, current_pos, !use_existing_crd ); // will remove any terminus
502  }
503 
504  // add terminus if necessary
505  if ( correct_terminus && had_upper_terminus && !pose.residue( current_pos ).is_upper_terminus() ) {
507  }
508 
509  return current_pos; // the right endpoint of the new growth
510 }
511 
512 
513 /// @brief grow a series of residues to the right of a position
514 /// @param[in,out] pose Pose the pose to modify
515 /// @param[in] anchor the anchor position, can be 0 if operating on empty
516 /// Pose
517 /// @param[in] begin iterator that points to the first ResidueTypeOP
518 /// @param[in] end iterator that points just beyond the last ResidueTypeOP
519 /// @param[in] correct_terminus re-add upper terminus if found, default true
520 /// @return the right endpoint of the new growth or zero if nothing to do
521 template< typename ResidueTypeOPIterator >
524  core::pose::Pose & pose,
525  core::Size anchor,
526  ResidueTypeOPIterator begin,
527  ResidueTypeOPIterator end,
528  bool const correct_terminus = true
529 )
530 {
533 
534  // create residues
535  ResidueOPs residues;
536  for ( ResidueTypeOPIterator i = begin; i != end; ++i ) {
537  residues.push_back( ResidueFactory::create_residue( **i ) );
538  }
539 
540  return grow_right_r( pose, anchor, residues.begin(), residues.end(), correct_terminus, false );
541 }
542 
543 
544 /// @brief add cutpoint variants at a specific position
545 /// @param[in,out] Pose to modify
546 /// @param[in] position at which to add cutpoint variants
547 /// @return true if cutpoint variants added, false if position not a topological cutpoint
548 bool
550  core::pose::Pose & pose,
551  core::Size const pos
552 );
553 
554 
555 /// @brief remove cutpoint variants at a specific position
556 /// @param[in,out] Pose to modify
557 /// @param[in] position at which to remove cutpoint variants
558 /// @return true if cutpoint variants removed, false if no cutpoint variants found
559 /// or position not a topological cutpoint
560 bool
562  core::pose::Pose & pose,
563  core::Size const pos
564 );
565 
566 
567 /// @brief restore residues (i.e. sidechains)
568 /// @param[in] old2new map indicating residues to be transferred and
569 /// the mapping from archive_pose position -> pose position
570 /// @param[in] archive_pose the original Pose to take residues from
571 /// @param[out] pose the altered Pose that needs residue restoration
572 void
574  std::map< core::Size, core::Size > const & old2new,
575  core::pose::Pose & archive_pose,
576  core::pose::Pose & pose
577 );
578 
579 
580 /// @brief restore residues (i.e. sidechains)
581 /// @param[in] archive_pose the original Pose to take residues from
582 /// @param[out] pose the altered Pose that needs residue restoration
583 /// @remarks length between two poses must be equal
584 void
586  core::pose::Pose & archive_pose,
587  core::pose::Pose & pose
588 );
589 
590 
591 } // methods
592 } // forge
593 } // protocols
594 
595 
596 #endif /* INCLUDED_protocols_forge_methods_pose_mod_HH */