Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CircularPermutation.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/fldsgn/CircularPermutation.cc
11 /// @brief perform circularpermutation give a pose ( under development )
12 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
13 
14 // unit headers
17 
18 // projects headers
22 #include <core/pose/Pose.hh>
25 // AUTO-REMOVED #include <core/chemical/ResidueSelector.hh>
27 
28 #include <basic/Tracer.hh>
29 
30 #include <core/pose/util.hh>
32 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
33 
34 
38 // AUTO-REMOVED #include <protocols/forge/build/SegmentRebuild.hh>
39 
41 
42 // Headers for Paser block
43 #include <utility/tag/Tag.hh>
44 
46 #include <utility/vector0.hh>
47 #include <utility/vector1.hh>
48 
49 //Auto Headers
50 //#include <protocols/moves/DataMap.hh>
51 
52 
53 namespace protocols {
54 namespace fldsgn {
55 
56 static basic::Tracer TR( "protocols.fldsgn.CircularPermutation" );
57 
60 {
62 }
63 
66  return new CircularPermutation;
67 }
68 
71 {
72  return "CircularPermutation";
73 }
74 
75 
76 /// @brief default constructor
78  Mover( "CircularPermutation" ),
79  new_terminal_pos_( 0 ),
80  ignore_chain_( false ),
81  split_( 0 )
82 {}
83 
84 
85 /// @Brief copy constructor
87  //utility::pointer::ReferenceCount(),
88  Super( rval ),
89  new_terminal_pos_( rval.new_terminal_pos_ ),
90  split_( rval.split_ )
91 {}
92 
93 
94 /// @brief default destructor
96 
97 
98 /// @brief clone this object
101 {
102  return new CircularPermutation( *this );
103 }
104 
105 
106 /// @brief create this type of object
109 {
110  return new CircularPermutation();
111 }
112 
113 
114 /// @brief new N- & C- terminal position
115 void
117 {
118  new_terminal_pos_ = s;
119 }
120 
121 
122 /// @brief total number of cycles
125 {
126  return new_terminal_pos_;
127 }
128 
129 /// @brief total number of cycles
131 CircularPermutation::which_chain( Size const pos, Pose const pose ) const
132 {
133  for( Size i=1; i<=pose.conformation().num_chains(); i++ ) {
134 
135  Size chain_begin( pose.conformation().chain_begin( i ) );
136  Size chain_end( pose.conformation().chain_end( i ) );
137 
138  if( chain_begin <= pos && chain_end >= pos ) {
139  return i;
140  }
141 
142  }
143  return 0;
144 }
145 
149 }
150 
151 
152 /// @brief
153 void
155 {
156 
159  using core::pose::Pose;
161 
162  // information of original fold tree completely overridded
163  FoldTree ft = fold_tree_from_pose( pose, pose.fold_tree().root(), MoveMap() );
164 
165  // insert chain endings
166  for( Size i=1; i<=pos.size(); i++ ) {
167  Size position = pos[ i ];
168  runtime_assert( position >= 1 && position <= pose.total_residue() );
169  pose.conformation().insert_chain_ending( position );
170  }
171 
172  // add terminals
173  for( Size i=1; i<=pose.conformation().num_chains(); i++ ) {
174  Size begin = pose.conformation().chain_begin( i );
175  Size end = pose.conformation().chain_end( i );
176  if( pose.residue( begin ).is_protein() && !pose.residue( begin ).is_lower_terminus() ) {
178  }
179  if( pose.residue( end ).is_protein() && !pose.residue( end ).is_upper_terminus() ) {
181  }
182  }
183 
184  // add jumps
185  for( Size i=2; i<=pose.conformation().num_chains(); i++ ) {
186  Size begin = pose.conformation().chain_begin( i );
187  Size end = pose.conformation().chain_end( i-1 );
188  ft.new_jump( end, begin, end );
189  }
190 
191  pose.fold_tree( ft );
192 
193 }
194 
195 
196 /// @brief main apply
198 {
210 
211  // make sure position of new terminal within chain lengths
212  if( new_terminal_pos_ == 0 ) {
213  TR << "No position to be permutated was specified. " << std::endl;
214  return;
215  }
216  runtime_assert( new_terminal_pos_ > 1 && new_terminal_pos_ <= pose.total_residue() );
217 
218  // make pose asymmetric if pose is symmetric
219  if( is_symmetric( pose ) ) {
220  Pose work_pose( pose );
222  }
223 
224  // prepare pose for latter swapped in region
225  Pose swap_in( pose );
226 
227  // determine begin and end positions of chain to be swapped
228  Size chain_begin;
229  Size chain( 0 );
230  if( ignore_chain_ ) {
231 
232  chain_begin = 1;
233  // find final chains
234  for( Size i=1; i<=pose.total_residue(); i++ ) {
235  if( pose.residue( i ).is_protein() && static_cast< int >( chain )< pose.chain( i ) ) {
236  chain = pose.chain( i );
237  }
238  }
239  runtime_assert( chain != 0 );
240 
241  } else {
242  chain = which_chain( new_terminal_pos_, pose );
243  chain_begin = pose.conformation().chain_begin( chain );
244  }
245  Size chain_end = pose.conformation().chain_end( chain );
246 
247  // add 4 residues at the end of chain
248  ResidueTypeSet const & rsd_set( pose.residue(1).residue_type_set() );
249  ResidueOP ala( ResidueFactory::create_residue( rsd_set.name_map( "ALA" ) ) );
250  for( Size i=1; i<=4; i++ ) {
251  Size pos = pose.conformation().chain_end( chain );
253  }
254 
255  // Blow away the former parts of pose
256  pose.conformation().delete_residue_range_slow( chain_begin, new_terminal_pos_ - 1 );
257 
258  // Blow away the latter parts of swap_in pose
260  if( chain_begin > 1 ) {
261  // Blow away the former parts of swap_in pose
262  swap_in.conformation().delete_residue_range_slow( 1, chain_begin - 1 );
263  }
264 
265  // swap_in swapped into the 3 residues added at the terminal of the chain
266  MoveMap movemap;
267  Size nt = chain_end - ( new_terminal_pos_ - chain_begin ) + 1;
268  BuildManager manager;
269  manager.add( new SegmentSwap( Interval( nt, nt+2 ), movemap, swap_in ) );
270  manager.modify( pose );
271 
272  // delete the final residues added at the terminal of the chain
273  pose.conformation().delete_residue_range_slow( chain_end + 1, chain_end + 1 );
274 
275  // re-add terminus
276  if ( !pose.residue( chain_end - 1 ).is_upper_terminus() ) {
278  }
279 
280  // re-add terminus
281  if ( !pose.residue( chain_begin ).is_lower_terminus() ) {
283  }
284 
285  TR << "FoldTree after circular permutation: " << pose.fold_tree() << std::endl;
286 
287  if( split_ != 0 ) {
288  utility::vector1< Size > positions;
289  positions.push_back( split_ );
291  split_chains( pose, positions );
292  }
293 
294  TR << pose.fold_tree() << std::endl;
295 
296 }
297 
298 
299 /// @brief parse xml
300 void
302  TagPtr const tag,
303  DataMap &,
304  Filters_map const &,
305  Movers_map const &,
306  Pose const & )
307 {
308 
309  // set positions of new N- and C- terminal
310  new_terminal_pos_ = ( tag->getOption<Size>( "pos", 0 ) );
311 
312  // ignore chain
313  ignore_chain_ = ( tag->getOption<bool>( "ignore_chain", 0 ) );
314 
315  // split chain
316  split_ = ( tag->getOption<Size>( "split_chain", 0 ) );
317 
318 }
319 
320 
321 
322 } // namespace fldsgn
323 } // namespace protocols