Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Bridge.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/forge/build/Bridge.cc
11 /// @brief connect two contiguous but disjoint sections of a Pose into one
12 /// continuous section
13 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
14 
15 // unit headers
17 
18 // package headers
23 
24 // project headers
25 
26 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
30 #include <core/pose/Pose.hh>
31 
33 #include <utility/vector1.hh>
34 
35 
36 
37 namespace protocols {
38 namespace forge {
39 namespace build {
40 
41 
42 /// @brief default constructor
44  Super()
45 {}
46 
47 
48 /// @brief sec.struct only constructor (poly-alanine for new region)
49 /// @param[in] interval bridge these two residues
50 /// @param[in] ss the secondary structure desired, also defines length of new bridge,
51 /// region between the anchor positions, can be empty
52 /// @param[in] rts the residue type set to use, default FA_STANDARD
53 /// @remarks length of the *one-letter* aa must equal the length of ss
55  Interval const & i,
56  String const & ss,
58 ) :
59  Super( i, rts ),
60  interval_( i ),
61  ss_( ss )
62 {
63  // build poly-alanine if empty string
64  if ( !ss_.empty() && aa_.empty() ) {
65  aa_ = String( ss_.length(), 'A' );
66  }
67 
68  assert( ss_.length() == core::pose::annotated_to_oneletter_sequence( aa_ ).length() );
69 }
70 
71 
72 /// @brief full constructor
73 /// @param[in] interval bridge these two residues
74 /// @param[in] ss the secondary structure desired, also defines length of new bridge,
75 /// region between the anchor positions, can be empty
76 /// @param[in] aa the annotated amino acid sequence desired, default is poly-alanine
77 /// @param[in] rts the residue type set to use, default FA_STANDARD
78 /// @remarks length of the *one-letter* aa must equal the length of ss
80  Interval const & i,
81  String const & ss,
82  String const & aa,
84 ) :
85  Super( i, rts ),
86  interval_( i ),
87  ss_( ss ),
88  aa_( aa )
89 {
90  // build poly-alanine if empty string
91  if ( !ss_.empty() && aa_.empty() ) {
92  aa_ = String( ss_.length(), 'A' );
93  }
94 
95  assert( ss_.length() == core::pose::annotated_to_oneletter_sequence( aa_ ).length() );
96 }
97 
98 
99 /// @brief copy constructor
100 Bridge::Bridge( Bridge const & rval ) :
101  Super( rval ),
102  interval_( rval.interval_ ),
103  ss_( rval.ss_ ),
104  aa_( rval.aa_ )
105 {}
106 
107 
108 /// @brief default destructor
110 
111 
112 /// @brief copy assignment
113 Bridge & Bridge::operator =( Bridge const & rval ) {
114  if ( this != &rval ) {
115  Super::operator =( rval );
116 
117  interval_ = rval.interval_;
118  ss_ = rval.ss_;
119  aa_ = rval.aa_;
120  }
121  return *this;
122 }
123 
124 
125 /// @brief clone this object
127  return new Bridge( *this );
128 }
129 
130 
131 /// @brief return a copy of the set of positions within the new region
132 /// that were pre-existing in the original Pose prior to modify()
133 /// @return A set containing two positions -- interval.left and interval.right.
135  Positions pre;
136 
137  // the interval endpoints are defined
138  Interval const ival = interval();
139  pre.insert( ival.left );
140  pre.insert( ival.right );
141 
142  return pre;
143 }
144 
145 
146 /// @brief return a copy of the set of positions that are "new" and did
147 /// not exist in the original Pose.
148 /// @return A set containing positions spanning [interval.left+1, interval.right-1].
151 
152  // everything except for the interval endpoints is undefined
153  Interval const ival = interval();
154  return closed_range( ival.left + 1, ival.right - 1 );
155 }
156 
157 
158 /// @brief return a copy of the set of positions within the newly modified
159 /// region that has a defined conformation. E.g. existing or copied residues.
160 /// @return A set containing two positions -- interval.left and interval.right.
161 /// @details This set can change wrt length changes in Pose/Conformation being
162 /// watched.
164  // for Bridge this is the same as the pre-existing positions
165  return preexisting_positions();
166 }
167 
168 
169 /// @brief return a copy of the set of positions within the newly modified
170 /// region that has an undefined conformation. E.g. newly created residues.
171 /// @return A set containing positions spanning [interval.left+1, interval.right-1].
172 /// @details This set can change wrt length changes in Pose/Conformation being
173 /// watched.
175  // for Bridge this is the same as the new positions
176  return new_positions();
177 }
178 
179 
180 /// @brief return a copy of the MoveMap that defines the moveable/fixed
181 /// positions/dofs for this instruction
182 /// @return a MoveMap with [interval.left, interval.right] bb & chi set to true
183 /// at the MoveMapTorsionID level
184 /// @details This set can change wrt length changes in Pose/Conformation being
185 /// watched.
187  // the entire region is mutable
188  Interval const ival = interval();
189 
190  MoveMap mm;
191 
192  for ( Size i = ival.left; i <= ival.right; ++i ) {
193  mm.set_bb( i, true );
194  mm.set_chi( i, true );
195  }
196 
197  return mm;
198 }
199 
200 
201 /// @brief update indexing on residue append
202 /// @remarks left and right endpoints of the interval can travel independently
203 void Bridge::on_residue_append( LengthEvent const & event ) {
204  if ( event.position < interval_.left ) {
205  //++interval_.left;
206  interval_.left = interval_.left + event.length_change;
207  }
208 
209  if ( event.position < interval_.right ) {
210  //++interval_.right;
211  interval_.right += event.length_change;
212  }
213 }
214 
215 
216 /// @brief update indexing on residue prepend
217 /// @remarks left and right endpoints of the interval can travel independently
219  if ( event.position <= interval_.left ) {
220  //++interval_.left;
221  interval_.left += event.length_change;
222  }
223 
224  if ( event.position <= interval_.right ) {
225  //++interval_.right;
226  interval_.right += event.length_change;
227  }
228 }
229 
230 
231 /// @brief update indexing on residue delete
232 /// @remarks Left and right endpoints of the interval can travel independently.
233 void Bridge::on_residue_delete( LengthEvent const & event ) {
234  // event.position == interval.left is not caught below.
235  // It has context dependent consequences and is manually corrected for
236  // during modify().
237  if ( event.position < interval_.left ) { // left
238  //--interval_.left;
239  if( int(interval_.left) + event.length_change < int(event.position) ) interval_.left = event.position;
240  else interval_.left += event.length_change;
241  }
242 
243  if ( event.position < interval_.right ) { // right
244  //--interval_.right;
245  if( int(interval_.right) + event.length_change < int(event.position) ) interval_.right = event.position;
246  else interval_.right += event.length_change;
247  }
248 }
249 
250 
251 /// @brief return the set of positions within the original interval that
252 /// will be kept in this BuildInstruction
253 /// @return A set containing the endpoints of the original interval.
255  Positions kept;
256  kept.insert( original_interval().left );
257  kept.insert( original_interval().right );
258  return kept;
259 }
260 
261 
262 /// @brief return set of positions within the original interval that will
263 /// be deleted in this BuildInstruction
264 /// @return A set containing the positions in [original.left+1, original.right-1].
267  return closed_range( original_interval().left + 1, original_interval().right - 1 );
268 }
269 
270 
271 /// @brief return set of any fixed positions necessary with respect to the original
272 /// interval and original Pose numbering
273 /// @remarks Used for ensuring build regions for instructions do not overlap and
274 /// so that jumps may be placed correctly.
275 /// @return empty set if no fixed positions necessary
277  Positions fixed;
278  fixed.insert( original_interval().left - 1 );
279  fixed.insert( original_interval().right + 1 );
280  return fixed;
281 }
282 
283 
284 /// @brief return set of any mutable positions necessary with respect to the original
285 /// interval and original Pose numbering
286 /// @remarks Used for ensuring build regions for instructions do not overlap and
287 /// so that jumps may be placed correctly.
288 /// @return empty set if no mutable positions
290  Positions muta;
291  muta.insert( original_interval().left );
292  muta.insert( original_interval().right );
293  return muta;
294 }
295 
296 
297 /// @brief do the actual work of modifying the Pose
298 void Bridge::modify_impl( Pose & pose ) {
301 
307 
308  // check conditions
309  runtime_assert( interval_.left > 0 );
310  runtime_assert( interval_.right <= pose.n_residue() );
311  runtime_assert( interval_.left == interval_.right - 1 );
312  runtime_assert( pose.fold_tree().is_cutpoint( interval_.left ) );
313 
314  // safety, remove any cutpoint variants in case they exist
317 
318  // safety, remove any termini variants in case they exist
319  if ( pose.residue( interval_.left ).is_upper_terminus() ) {
321  }
322 
323  if ( pose.residue( interval_.right ).is_lower_terminus() ) {
325  }
326 
327  // BEGIN INTERVAL SHIFT: after this point, interval_ will begin to shift due to length
328  // changes in the Pose
329 
330  if ( !ss_.empty() ) {
331  // Grow out the new section from interval_.left using GrowRight.
332  // GrowRight will also handle setting proper omega and secondary
333  // structure.
335  grow.modify( pose );
336  }
337 
338  // END INTERVAL SHIFT: after this point, interval_ has stabilized and stores
339  // the new endpoints of the rebuilt segment
340 
341  // seal the tree at the cutpoint between [left, right]
342  FoldTree new_ft = pose.fold_tree();
343  remove_cutpoint( interval_.right - 1, new_ft );
344  pose.fold_tree( new_ft );
345 
346  // the anchor positions will need to move during remodeling (e.g. fragment
347  // insertion), so go ahead and idealize them
350 
351  // assume proper omega
352  pose.set_omega( interval_.left, 180.0 );
353  pose.set_omega( interval_.right, 180.0 );
354 }
355 
356 
357 /// @brief do the actual reset of intervals, positions, etc to initial state
360 }
361 
362 
363 } // namespace build
364 } // namespace forge
365 } // namespace protocols