38 #include <basic/basic.hh>
39 #include <basic/Tracer.hh>
44 #include <numeric/random/random.hh>
45 #include <ObjexxFCL/FArray1D.hh>
53 #include <utility/vector1.hh>
54 #include <utility/options/IntegerVectorOption.hh>
58 namespace rbsegment_relax {
62 static numeric::random::RandomGenerator
rbseg_RG(186331);
63 static basic::Tracer
TR(
"protocols::moves::RBSegmentMover");
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();
84 for (
int cst_i=rbstart; cst_i<=rbend; ++cst_i) {
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) {
105 CSTs_i.push_back( newcst_ij );
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;
132 TR.Warning <<
"set_constraints() error: #res in cst_pose (" << cst_pose.
total_residue()
133 <<
") != #res in pose (" << pose.
total_residue() <<
"). Continuing..." << std::endl;
138 for (
int cst_i = 1; cst_i < nres; ++cst_i) {
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) {
157 CSTs_i.push_back( newcst_ij );
161 if ( CSTs_i.size() > 0 ) {
162 TR <<
"Adding " << CSTs_i.size() <<
" ambiguous constraints for res " << cst_i << std::endl;
179 using namespace core::kinematics;
189 if (it->start() == 1 || it->stop() == nres)
continue;
190 cuts.push_back( it->cut() );
192 cuts.push_back( nres );
194 for (
int i=1; i <= (
int)nrbsegs; ++i ) {
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 );
200 for (
int i=1; i <= (
int)nrbsegs; ++i ) {
201 for (
int j=2; j<= (
int)rbsegs[i].nContinuousSegments() ; ++j ) {
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 );
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 );
216 for (
Size i=1; i<=cuts.size(); ++i ) {
221 runtime_assert( valid_tree );
223 TR <<
"New fold tree: " << f << std::endl;
230 for (
int j=(
int)(it->start()) ; j<=(
int)(it->stop()); ++j )
232 for (
int i=1; i <= (
int)nrbsegs; ++i )
233 mm->set_jump(i,
true);
237 Size const loop_cut(it->cut());
259 using namespace core::kinematics;
269 for (
core::Size i=last_peptide_res+1; i<=nres; ++i) {
271 rbsegs_with_ligands.push_back(
RBSegment( i, i,
'X' ) );
272 TR <<
"setup_pose_from_rbsegs: Ligand at " << i << std::endl;
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;
281 resmap.
resize( nres, nres_rb );
285 for (
core::Size i=1; i <= rbsegs_with_ligands.size(); ++i ) {
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;
293 char secstruct = rbsegs_with_ligands[i][j].char_type();
295 if (nsegment_reses > 0) {
300 for (
int k=1; k<nsegment_reses; ++k) {
306 if ( (secstruct ==
'H' || secstruct ==
'E') && k!=nsegment_reses-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();
327 out_end = nstart + (in_end - in_start);
328 core::Size out_midpt = (out_end + out_start)/2;
330 newF.add_edge( nres_rb+1, out_midpt, njump );
336 if ( !fix_ligand || i <= rbsegs.size() )
342 if (rbsegs_with_ligands[i].isSheet()) {
343 for (
core::Size j=out_start; j<=out_end; ++j) {
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();
353 out_end = nstart + (in_end - in_start);
354 out_midpt = (out_end + out_start)/2;
356 newF.add_edge( in_midpt, out_midpt, njump );
365 newF.reorder( nres_rb+1 );
368 TR <<
"New fold tree: " << newF << std::endl;
379 using namespace core::kinematics;
397 int res_rb_counter = 1;
398 for (
core::Size i=1; i <= rbsegs_with_ligands.size(); ++i ) {
400 for (
core::Size j=1; j<=rbsegs_with_ligands[i].nContinuousSegments(); ++j) {
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;
407 if (nsegment_reses > 0) {
408 pose_out.
copy_segment( nsegment_reses, pose_in, rb_start, res_rb_counter );
411 for (
int k=(
int)rb_start; k<=(
int)rb_end; ++k)
413 res_rb_counter += nsegment_reses;
430 TR <<
"New fold tree: " << newF << std::endl;
449 ObjexxFCL::FArray1D< char > dssp_pose( nres );
456 bool in_helix=
false, in_strand=
false;
458 for (
int i=1; i<=(
int)nres; ++i) {
460 if (dssp_pose(i) !=
'E' && in_strand) {
463 simple_segments.push_back(
RBSegment( ss_start, i-1,
'E' ) );
466 if (dssp_pose(i) !=
'H' && in_helix) {
469 simple_segments.push_back(
RBSegment( ss_start, i-1,
'H' ) );
472 if (dssp_pose(i) ==
'E' && !in_strand) {
477 if (dssp_pose(i) ==
'H' && !in_helix) {
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 );
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 );
496 simple_segments[i][1].set_end( simple_segments[i+1][1].
start()-3 );
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);
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;
511 int nsegs = simple_segments.size();
513 if (end_res >= start_res)
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;
520 start_res = simple_segments[nsegs][1].end()+1;
523 if (end_res >= start_res)
534 for (
int i=1; i< (
int)simple_segments.size(); ++i) {
535 if (simple_segments[i][1].char_type() !=
'E')
continue;
538 for (
int j=i+1; j<=(
int)simple_segments.size(); ++j) {
539 if (simple_segments[j][1].char_type() !=
'E')
continue;
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) {
557 this_seg.push_back(j);
558 if (parent_seg[i] == 0)
560 if (parent_seg[j] == 0)
561 parent_seg[j] = parent_seg[i];
565 for (
int k=1; k<j; ++k)
566 if ((
int)parent_seg[k] == i) parent_seg[k] = parent_seg[j];
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;
578 for (
int i=1; i< (
int)simple_segments.size(); ++i) {
579 if (((
int)parent_seg[i]) != i)
continue;
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 ] );
585 rigid_segs.push_back(
RBSegment( thisLockSeg ) );
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] );
593 std::sort( rigid_segs.begin(), rigid_segs.end(),
RB_lt());
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 ) {
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;
608 rb_chunks[i][j].set_start(c_low);
609 rb_chunks[i][j].set_end(c_high);
619 for (
RBConsIt it_seg = rbsegs.begin(), it_seg_end = rbsegs.end(); it_seg != it_seg_end; ++it_seg ) {
621 rbsegs_remap.push_back( it_remap );