Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.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
11 /// @brief
12 /// @author Frank DiMaio
13 /// @author Srivatsan Raman
16 #include <protocols/loops/Loop.hh>
17 #include <protocols/loops/Loops.hh>
19 
20 // Rosetta Headers
21 #include <core/pose/Pose.hh>
24 
26 
35 
38 #include <basic/basic.hh>
39 #include <basic/Tracer.hh>
40 
41 // Random number generator
42 // AUTO-REMOVED #include <numeric/xyzVector.io.hh>
43 // AUTO-REMOVED #include <numeric/xyz.functions.hh>
44 #include <numeric/random/random.hh>
45 #include <ObjexxFCL/FArray1D.hh>
46 
47 //
48 #include <string>
49 
50 //Auto Headers
52 #include <core/pose/util.hh>
53 #include <utility/vector1.hh>
54 #include <utility/options/IntegerVectorOption.hh>
55 
56 
57 namespace protocols {
58 namespace rbsegment_relax {
59 
60 using namespace core;
61 
62 static numeric::random::RandomGenerator rbseg_RG(186331);
63 static basic::Tracer TR("protocols::moves::RBSegmentMover");
64 
65 
66 //
67 ///@brief set up constraints from RB segs
68 /// currently uses bounded constraints on each CA ... make CST type flag-selectable????
70  core::pose::Pose & pose,
71  core::pose::Pose const &cst_pose,
72  utility::vector1< RBSegment > const & rbsegs ,
73  core::id::SequenceMapping const & resmap,
74  core::Real cst_width,
75  core::Real cst_stdev,
76  core::Size cst_seqwidth
77  ) {
79 
80  for (int i = 1; i <= (int)rbsegs.size(); ++i) {
81  for (core::Size j=1; j<=rbsegs[i].nContinuousSegments(); ++j) {
82  int rbstart = rbsegs[i][j].start(), rbend = rbsegs[i][j].end();
83 
84  for (int cst_i=rbstart; cst_i<=rbend; ++cst_i) {
85 
86  // make ambiguous cst from ( cst_i-cst_seqwidth , cst_i+cst_seqwidth )
88 
89  //
90  for (int cst_ij = std::max(1,cst_i-(int)cst_seqwidth), cst_ij_end=std::min(cst_pose.total_residue(),cst_i+cst_seqwidth);
91  cst_ij<=cst_ij_end; ++cst_ij) {
92  // only constrain protein residues
93  if (!cst_pose.residue(cst_ij).is_protein()) continue;
94 
96  core::id::AtomID( pose.residue(resmap[cst_i]).atom_index("CA"), resmap[cst_i]),
97  core::id::AtomID( pose.residue(pose.total_residue()).atom_index("ORIG"), pose.total_residue()),
98  cst_pose.residue(cst_ij).xyz( "CA" ),
99  new core::scoring::constraints::BoundFunc(0,cst_width,cst_stdev,"xyz") );
100 
101 
102  // make sure not randomized <<<< kind of hacky
103  core::Real len = (cst_pose.residue(cst_ij).xyz( "CA" )).length();
104  if ( len < 500 )
105  CSTs_i.push_back( newcst_ij );
106  }
107 
108  //
109  if ( CSTs_i.size() > 0 ) {
110  TR << "Adding " << CSTs_i.size() << " ambiguous constraints for res " << resmap[cst_i]
111  << " (= input " << cst_i << ")" << std::endl;
112  new_csts->add_constraint( new core::scoring::constraints::AmbiguousConstraint( CSTs_i ) );
113  }
114 
115  }
116  }
117  }
118  pose.constraint_set( new_csts );
119 }
120 
121 
122 ///@brief set up constraints on complete pose (not just RB segments)
123 /// currently uses bounded constraints ... make CST type flag-selectable????
125  core::pose::Pose & pose,
126  core::pose::Pose const &cst_pose,
127  core::Real cst_width,
128  core::Real cst_stdev,
129  core::Size cst_seqwidth
130  ) {
131  if (pose.total_residue() != cst_pose.total_residue()) {
132  TR.Warning << "set_constraints() error: #res in cst_pose (" << cst_pose.total_residue()
133  << ") != #res in pose (" << pose.total_residue() << "). Continuing..." << std::endl;
134  }
135  int nres = (int)std::min( pose.total_residue() , cst_pose.total_residue() );
136 
138  for (int cst_i = 1; cst_i < nres; ++cst_i) {
139  // make ambiguous cst from ( cst_i-cst_seqwidth , cst_i+cst_seqwidth )
141 
142  for (int cst_ij=std::max(1,cst_i-(int)cst_seqwidth), cst_ij_end=std::min(nres,cst_i+(int)cst_seqwidth);
143  cst_ij<=cst_ij_end; ++cst_ij) {
144  // only constrain protein residues
145  if (!cst_pose.residue(cst_ij).is_protein()) continue;
146 
148  core::id::AtomID( pose.residue(cst_i ).atom_index("CA" ), cst_i),
149  core::id::AtomID( pose.residue(pose.total_residue()).atom_index("ORIG"), pose.total_residue()),
150  cst_pose.residue(cst_ij).xyz( "CA" ),
151  new core::scoring::constraints::BoundFunc(0,cst_width,cst_stdev,"xyz")
152  );
153 
154  // make sure not randomized <<<< kind of hacky
155  core::Real len = (cst_pose.residue(cst_ij).xyz( "CA" )).length();
156  if ( len < 500 )
157  CSTs_i.push_back( newcst_ij );
158  }
159 
160  //
161  if ( CSTs_i.size() > 0 ) {
162  TR << "Adding " << CSTs_i.size() << " ambiguous constraints for res " << cst_i << std::endl;
163  new_csts->add_constraint( new core::scoring::constraints::AmbiguousConstraint( CSTs_i ) );
164  }
165  }
166  pose.constraint_set( new_csts );
167 }
168 
169 
170 ///
171 ///@brief Helper function to set up a pose; unlike alt version keep loops (use cutpoint variants)
172 /// unlike version in loops_main, this uses RBSegment structure to build multi-level topology
173 /// returns jump residues
175  core::pose::Pose &pose,
176  utility::vector1< RBSegment > const &rbsegs,
177  loops::Loops const &loops,
179  using namespace core::kinematics;
180 
181  core::Size nres( pose.total_residue()-1 );
182  core::Size vrtid = nres+1;
183  core::Size nrbsegs( rbsegs.size() );
184 
185  // "star" topology fold tree
186  utility::vector1< core::Size > cuts, jump_res;
188  for( loops::Loops::const_iterator it=loops.begin(), it_end=loops.end(); it != it_end; ++it ) {
189  if (it->start() == 1 || it->stop() == nres) continue;
190  cuts.push_back( it->cut() );
191  }
192  cuts.push_back( nres );
193  //cuts.push_back( nres+1 ); //?
194  for (int i=1; i <= (int)nrbsegs; ++i ) {
195  // jump from vrt to midpt of 1st seg
196  core::Size midpt = (rbsegs[i][1].start()+rbsegs[i][1].end()) / 2;
197  jumps.push_back (std::pair<core::Size,core::Size>( vrtid, midpt ) );
198  jump_res.push_back ( midpt );
199  }
200  for (int i=1; i <= (int)nrbsegs; ++i ) {
201  for (int j=2; j<= (int)rbsegs[i].nContinuousSegments() ; ++j ) {
202  // jump from midpt of 1st seg here
203  core::Size midpt1 = (rbsegs[i][1].start()+rbsegs[i][1].end()) / 2;
204  core::Size midpt2 = (rbsegs[i][j].start()+rbsegs[i][j].end()) / 2;
205  jumps.push_back (std::pair<core::Size,core::Size>( midpt1, midpt2 ) );
206  jump_res.push_back ( midpt2 );
207  }
208  }
209 
210  ObjexxFCL::FArray2D_int fjumps( 2, jumps.size() );
211  ObjexxFCL::FArray1D_int fcuts ( cuts.size() );
212  for ( Size i=1; i<=jumps.size(); ++i ) {
213  fjumps(1,i) = std::min( jumps[i].first , jumps[i].second );
214  fjumps(2,i) = std::max( jumps[i].first , jumps[i].second );
215  }
216  for ( Size i=1; i<=cuts.size(); ++i ) {
217  fcuts(i) = cuts[i];
218  }
220  bool valid_tree = f.tree_from_jumps_and_cuts( nres+1, jumps.size(), fjumps, fcuts );
221  runtime_assert( valid_tree );
222  f.reorder( vrtid );
223  TR << "New fold tree: " << f << std::endl;
224 
225  pose.fold_tree( f );
226 
227  // movemap
228  mm->clear();
229  for( loops::Loops::const_iterator it=loops.begin(), it_end=loops.end(); it != it_end; ++it )
230  for ( int j=(int)(it->start()) ; j<=(int)(it->stop()); ++j )
231  mm->set_bb(j,true);
232  for (int i=1; i <= (int)nrbsegs; ++i )
233  mm->set_jump(i,true);
234 
235  // cb variants
236  for( protocols::loops::Loops::const_iterator it=loops.begin(), it_end=loops.end(); it != it_end; ++it ) {
237  Size const loop_cut(it->cut());
238  if ( !pose.residue(loop_cut).is_upper_terminus() ) {
241  if ( ! pose.residue(loop_cut+1).has_variant_type(core::chemical::CUTPOINT_UPPER) )
243  }
244  }
245 
246  return jump_res;
247 }
248 
249 
250 ///
251 ///@brief Helper function to set up a loop-removed pose
253  utility::vector1< RBSegment > const &rbsegs ,
254  core::pose::Pose const &pose_in ,
255  core::pose::Pose &pose_out ,
258  bool fix_ligand ) {
259  using namespace core::kinematics;
260 
261  core::Size nres( pose_in.total_residue() );
262  core::Size nres_rb = 0;
263 
264  // each ligand is its own rb-segment (for the purposes of fold-tree generation)
265  utility::vector1< RBSegment > rbsegs_with_ligands = rbsegs;
266  core::Size last_peptide_res = nres;
267  while ( !pose_in.residue( last_peptide_res ).is_protein() )
268  last_peptide_res--;
269  for (core::Size i=last_peptide_res+1; i<=nres; ++i) {
270  if ( pose_in.residue( i ).aa() != core::chemical::aa_vrt ) {
271  rbsegs_with_ligands.push_back( RBSegment( i, i, 'X' ) );
272  TR << "setup_pose_from_rbsegs: Ligand at " << i << std::endl;
273  }
274  }
275 
276  // count rb reses
277  for ( core::Size i=1; i <= rbsegs_with_ligands.size(); ++i )
278  for (core::Size j=1; j<=rbsegs_with_ligands[i].nContinuousSegments(); ++j)
279  nres_rb += rbsegs_with_ligands[i][j].end() - rbsegs_with_ligands[i][j].start() + 1;
280 
281  resmap.resize( nres, nres_rb );
282 
283  pose_out.clear();
284  int rb_ctr = 0;
285  for ( core::Size i=1; i <= rbsegs_with_ligands.size(); ++i ) {
286 
287  for (core::Size j=1; j<=rbsegs_with_ligands[i].nContinuousSegments(); ++j) {
288  core::Size rb_start = rbsegs_with_ligands[i][j].start() ,
289  rb_end = rbsegs_with_ligands[i][j].end() ;
290  int nsegment_reses = rb_end - rb_start + 1;
291  rb_ctr++;
292 
293  char secstruct = rbsegs_with_ligands[i][j].char_type();
294 
295  if (nsegment_reses > 0) {
296  core::conformation::Residue new_res_0 = pose_in.residue( rb_start );
297  pose_out.append_residue_by_jump( new_res_0 , pose_out.total_residue(), "" , "" , true );
298  resmap[rb_start] = pose_out.total_residue();
299 
300  for (int k=1; k<nsegment_reses; ++k) {
301  core::conformation::Residue new_res_k = pose_in.residue( rb_start+k );
302  pose_out.append_residue_by_bond( new_res_k );
303  resmap[rb_start + k] = pose_out.total_residue();
304 
305  // set secstruct
306  if ( (secstruct == 'H' || secstruct == 'E') && k!=nsegment_reses-1 )
307  pose_out.set_secstruct( pose_out.total_residue(), secstruct );
308  }
309  }
310  }
311  }
312 
313  // virtual res as root
314  core::chemical::ResidueTypeSetCAP const &residue_set(
316  core::chemical::ResidueTypeCOPs const & rsd_type_list( residue_set->name3_map("VRT") );
318  pose_out.append_residue_by_jump( *new_res , 1 );
319 
320  // "star" topology fold tree
322  core::Size nstart = 1, njump = 1;
323  for ( core::Size i=1; i <= rbsegs_with_ligands.size(); ++i ) {
324  core::Size in_start = rbsegs_with_ligands[i][1].start() ,
325  in_end = rbsegs_with_ligands[i][1].end();
326  core::Size out_start = nstart,
327  out_end = nstart + (in_end - in_start);
328  core::Size out_midpt = (out_end + out_start)/2;
329 
330  newF.add_edge( nres_rb+1, out_midpt, njump );
331  newF.add_edge( out_midpt, out_start, Edge::PEPTIDE );
332  newF.add_edge( out_midpt, out_end , Edge::PEPTIDE );
333  nstart = out_end+1;
334 
335  // let all jumps except those to ligands move
336  if ( !fix_ligand || i <= rbsegs.size() )
337  mm.set_jump( njump , true );
338 
339  njump++;
340 
341  // in strands let bb move
342  if (rbsegs_with_ligands[i].isSheet()) {
343  for ( core::Size j=out_start; j<=out_end; ++j) {
344  mm.set_bb( j, true );
345  }
346  }
347 
348  core::Size in_midpt = out_midpt;
349  for (core::Size j=2; j<=rbsegs_with_ligands[i].nContinuousSegments(); ++j) {
350  in_start = rbsegs_with_ligands[i][j].start();
351  in_end = rbsegs_with_ligands[i][j].end();
352  out_start = nstart;
353  out_end = nstart + (in_end - in_start);
354  out_midpt = (out_end + out_start)/2;
355 
356  newF.add_edge( in_midpt, out_midpt, njump );
357  newF.add_edge( out_midpt, out_start, Edge::PEPTIDE );
358  newF.add_edge( out_midpt, out_end , Edge::PEPTIDE );
359  nstart = out_end+1;
360  mm.set_jump( njump , false );
361  njump++;
362  }
363  }
364 
365  newF.reorder( nres_rb+1 );
366  pose_out.fold_tree( newF );
367 
368  TR << "New fold tree: " << newF << std::endl;
369 }
370 
371 
372 
373 ///@brief Helper function to restore a fully-connected pose
375  utility::vector1< RBSegment > const &rbsegs ,
376  core::pose::Pose const &pose_in ,
377  core::pose::Pose &pose_out /* input/output */ )
378 {
379  using namespace core::kinematics;
380 
381  // each ligand is its own rb-segment (for the purposes of fold-tree generation)
382  utility::vector1< RBSegment > rbsegs_with_ligands = rbsegs;
383  /*
384  int nres( pose_out.total_residue() );
385  // keep ligand confs from starting pose
386  int last_peptide_res = nres;
387  while ( !pose_out.residue( last_peptide_res ).is_protein() )
388  last_peptide_res--;
389  for (core::Size i=last_peptide_res+1; i<=nres; ++i) {
390  if ( pose_out.residue( i ).aa() != core::chemical::aa_vrt ) {
391  rbsegs_with_ligands.push_back( RBSegment( i, i, 'X' ) );
392  TZ << "restore_pose_from_rbsegs: Ligand at " << i << std::endl;
393  }
394  }
395  */
396 
397  int res_rb_counter = 1;
398  for ( core::Size i=1; i <= rbsegs_with_ligands.size(); ++i ) {
399 
400  for (core::Size j=1; j<=rbsegs_with_ligands[i].nContinuousSegments(); ++j) {
401 
402  core::Size rb_start = rbsegs_with_ligands[i][j].start() ,
403  rb_end = rbsegs_with_ligands[i][j].end() ;
404  int nsegment_reses = rb_end - rb_start + 1;
405 
406  // xyz copy??
407  if (nsegment_reses > 0) {
408  pose_out.copy_segment( nsegment_reses, pose_in, rb_start, res_rb_counter );
409  }
410  // copy secstruct
411  for (int k=(int)rb_start; k<=(int)rb_end; ++k)
412  pose_out.set_secstruct( k, pose_in.secstruct( res_rb_counter+k-rb_start ) );
413  res_rb_counter += nsegment_reses;
414  }
415 
416  }
417 
418  // virtual res as root
419  core::chemical::ResidueTypeSetCAP const &residue_set(
421  core::chemical::ResidueTypeCOPs const & rsd_type_list( residue_set->name3_map("VRT") );
423  pose_out.append_residue_by_jump( *new_res , pose_out.total_residue()/2 );
424 
425  // make the virt atom the root
426  core::kinematics::FoldTree newF(pose_out.fold_tree());
427  newF.reorder( pose_out.total_residue() );
428  pose_out.fold_tree( newF );
429 
430  TR << "New fold tree: " << newF << std::endl;
431 }
432 
433 ////
434 //// set up foldtree, variants, movemap, etc.
436  core::pose::Pose const & pose,
437  utility::vector1< RBSegment > & rigid_segs,
438  utility::vector1< RBSegment > & rb_chunks,
440 ) {
441  core::Size nres = pose.total_residue()-1; // terminal VRT
442 
443  rigid_segs.clear();
444  rb_chunks.clear();
445  loops.clear();
446 
447  // dssp parse
448  core::scoring::dssp::Dssp secstruct( pose );
449  ObjexxFCL::FArray1D< char > dssp_pose( nres );
450  secstruct.dssp_reduced (dssp_pose);
451  //secstruct.insert_ss_into_pose( pose );
452 
453  // find all helices > 5 residues
454  // strands > 3 residues
455  utility::vector1< RBSegment > simple_segments;
456  bool in_helix=false, in_strand=false;
457  int ss_start = -1;
458  for (int i=1; i<=(int)nres; ++i) {
459  // strand end
460  if (dssp_pose(i) != 'E' && in_strand) {
461  in_strand = false;
462  if (i-ss_start >= 3)
463  simple_segments.push_back( RBSegment( ss_start, i-1, 'E' ) );
464  }
465  // helix end
466  if (dssp_pose(i) != 'H' && in_helix) {
467  in_helix = false;
468  if (i-ss_start >= 5)
469  simple_segments.push_back( RBSegment( ss_start, i-1, 'H' ) );
470  }
471  // strand start
472  if (dssp_pose(i) == 'E' && !in_strand) {
473  in_strand = true;
474  ss_start = i;
475  }
476  // helix start
477  if (dssp_pose(i) == 'H' && !in_helix) {
478  in_helix = true;
479  ss_start = i;
480  }
481  }
482 
483  // put at least 2 "loop residues" inbetween each RB segment.
484  // always eat into the helix (even if this leaves a helix < 3 reses)
485  for (int i=1; i< (int)simple_segments.size(); ++i) {
486  if (simple_segments[i+1][1].start() - simple_segments[i][1].end() <= 2) {
487  if (simple_segments[i][1].char_type() == 'H') {
488  simple_segments[i][1].set_end( simple_segments[i+1][1].start()-3 );
489  } else if (simple_segments[i+1][1].char_type() == 'H') {
490  simple_segments[i+1][1].set_start( simple_segments[i][1].end()+3 );
491  } else {
492  // eat into longer strand (will only need to chomp 1 res)
493  if (simple_segments[i+1][1].length() > simple_segments[i][1].length() )
494  simple_segments[i+1][1].set_start( simple_segments[i][1].end()+3 );
495  else
496  simple_segments[i][1].set_end( simple_segments[i+1][1].start()-3 );
497  }
498  }
499  }
500 
501  // check for "1-residue" loops at termini; extend RB segments if necessary
502  if (simple_segments[1][1].start() == 2) simple_segments[1][1].set_start(1);
503  if (simple_segments[simple_segments.size()][1].end() == nres-1) simple_segments[simple_segments.size()][1].set_end(nres);
504 
505 
506  // auto-gen loops
507  if ( simple_segments.size() > 1 ) {
508  std::sort( simple_segments.begin(), simple_segments.end(), RB_lt());
509  int start_res=1, end_res=simple_segments[1][1].start()-1;
510  //int cutpt = (start_res+end_res)/2;
511  int nsegs = simple_segments.size();
512 
513  if (end_res >= start_res)
514  loops.push_back( protocols::loops::Loop(start_res, end_res, 0, 0.0, false) );
515  for (int i=1; i<nsegs; ++i) {
516  start_res = simple_segments[i][1].end()+1;
517  end_res = simple_segments[i+1][1].start()-1;
518  loops.push_back( protocols::loops::Loop(start_res, end_res, 0, 0.0, false) );
519  }
520  start_res = simple_segments[nsegs][1].end()+1;
521  end_res = nres;
522  //cutpt = (start_res+end_res)/2; // set but never used ~Labonte
523  if (end_res >= start_res)
524  loops.push_back( protocols::loops::Loop(start_res, end_res, 0, 0.0, false) );
525 
526  // TODO: split loops on cutpoints from original pose
527  }
528 
529 
530  // now combine paired strands into a compound segment
531  // look for NH--O distance < 2.6A (?)
533  utility::vector1< core::Size > parent_seg( simple_segments.size(), 0 );
534  for (int i=1; i< (int)simple_segments.size(); ++i) {
535  if (simple_segments[i][1].char_type() != 'E') continue;
536 
537  utility::vector1< int > this_seg( 1, i );
538  for (int j=i+1; j<=(int)simple_segments.size(); ++j) {
539  if (simple_segments[j][1].char_type() != 'E') continue;
540 
541  // foreach res in i,j
542  bool found = false;
543  for (int ii=(int)simple_segments[i][1].start(); ii<=(int)simple_segments[i][1].end() && !found; ++ii)
544  for (int jj=(int)simple_segments[j][1].start(); jj<=(int)simple_segments[j][1].end() && !found; ++jj) {
545  core::Real d2=10;
546 
547  if (pose.residue(ii).aa() != core::chemical::aa_pro && pose.residue(jj).aa() != core::chemical::aa_pro)
548  d2 = std::min(
549  (pose.residue(ii).atom("H").xyz() - pose.residue(jj).atom("O").xyz()).length_squared() ,
550  (pose.residue(ii).atom("O").xyz() - pose.residue(jj).atom("H").xyz()).length_squared() );
551  else if (pose.residue(jj).aa() != core::chemical::aa_pro)
552  d2 = (pose.residue(ii).atom("O").xyz() - pose.residue(jj).atom("H").xyz()).length_squared();
553  else if (pose.residue(ii).aa() != core::chemical::aa_pro)
554  d2 = (pose.residue(jj).atom("O").xyz() - pose.residue(ii).atom("H").xyz()).length_squared();
555 
556  if (d2 < 2.6*2.6) {
557  this_seg.push_back(j);
558  if (parent_seg[i] == 0)
559  parent_seg[i] = i;
560  if (parent_seg[j] == 0)
561  parent_seg[j] = parent_seg[i];
562  else {
563  // tricky case ... j is already mapped
564  // in this case map everything mapped to i to parent_seg[j]
565  for (int k=1; k<j; ++k)
566  if ((int)parent_seg[k] == i) parent_seg[k] = parent_seg[j];
567  }
568 
569  TR << "Merging " << j << " (" << simple_segments[j][1].start() << "," << simple_segments[j][1].end() << ") ";
570  TR << " to " << i << " (" << simple_segments[i][1].start() << "," << simple_segments[i][1].end() << ") " << std::endl;
571  found = true;
572  }
573  }
574  }
575  }
576 
577  // make the compound segments
578  for (int i=1; i< (int)simple_segments.size(); ++i) {
579  if (((int)parent_seg[i]) != i) continue; // not compound or already added
580  utility::vector1< RBSegment > thisLockSeg;
581  for (core::Size j=i; j<=simple_segments.size(); ++j) {
582  if ( ((int)parent_seg[j]) == i )
583  thisLockSeg.push_back( simple_segments[ j ] );
584  }
585  rigid_segs.push_back( RBSegment( thisLockSeg ) );
586  }
587  // add in all other simple segs
588  for (int i=1; i<=(int)simple_segments.size(); ++i)
589  if (parent_seg[i] == 0)
590  rigid_segs.push_back( simple_segments[i] );
591 
592  // sort loops & rbsegs, choose cutpoints
593  std::sort( rigid_segs.begin(), rigid_segs.end(), RB_lt());
594  std::sort( loops.v_begin(), loops.v_end(), protocols::loops::Loop_lt());
595  loops.auto_choose_cutpoints( pose );
596 
597  // define chunks
598  rb_chunks = rigid_segs;
599  for (int i=1; i<=(int)rigid_segs.size(); ++i) {
600  for (int j=1; j<=(int)rigid_segs[i].nContinuousSegments() ; ++j ) {
601  core::Size c_low=1, c_high=nres;
602  for (int k=1; k<=(int)loops.size(); ++k) {
603  if (loops[k].cut() < rigid_segs[i][j].start() && loops[k].cut() > c_low )
604  c_low = loops[k].cut();
605  if (loops[k].cut()+1 > rigid_segs[i][j].end() && loops[k].cut()+1 < c_high )
606  c_high = loops[k].cut()+1;
607  }
608  rb_chunks[i][j].set_start(c_low);
609  rb_chunks[i][j].set_end(c_high);
610  }
611  }
612 }
613 
614 //// remap all segs
616  utility::vector1< RBSegment > const &rbsegs,
617  utility::vector1< RBSegment > &rbsegs_remap,
618  core::id::SequenceMapping const &resmap ) {
619  for ( RBConsIt it_seg = rbsegs.begin(), it_seg_end = rbsegs.end(); it_seg != it_seg_end; ++it_seg ) {
620  RBSegment it_remap = it_seg->remap( resmap );
621  rbsegs_remap.push_back( it_remap );
622  }
623 }
624 
625 
626 
627 }
628 }