38 #include <ObjexxFCL/format.hh>
41 #include <basic/Tracer.hh>
42 #include <utility/io/ozstream.hh>
55 #include <utility/vector1.hh>
59 namespace constraints {
61 using namespace ObjexxFCL::fmt;
78 return std::sqrt( std::abs( x*x - d2target_ ) );
82 return std::sqrt( std::abs( x*x - d2target_ ) );
94 using namespace ObjexxFCL;
96 static basic::Tracer
tr(
"protocols.jumping");
99 total_residue_( def.total_residue() ),
100 njump_( def.
size() ),
106 jumps_( 1, ct ) = it->jump_.start_;
107 jumps_( 2, ct ) = it->jump_.end_;
110 Size const crs ( it->cut_reg_.start_ );
111 Size const cre ( it->cut_reg_.end_ );
112 cuts_( ct ) = crs+
int( numeric::random::uniform()*( cre-crs ) + 0.5 );
117 tr.Debug <<
"invalid FoldTree in JumpSample: " << (*this) << std::endl;
122 total_residue_( total_residue ),
134 total_residue_( total_residue ),
137 jump_atoms_ ( jump_atoms ),
146 total_residue_( total_residue ),
147 jump_pairings_( jump_pairings ),
150 resize( jump_pairings.size() );
154 for ( core::scoring::dssp::PairingsList::const_iterator it = jump_pairings.begin(),
155 eit = jump_pairings.end(); it != eit; ++it ) {
157 jumps_(1,njump_) = it->Pos1();
158 jumps_(2,njump_) = it->Pos2();
162 runtime_assert( njump_ == jump_pairings.size() );
165 new_ssdef.
extend( total_residue );
173 total_residue_( total_residue ),
174 jump_pairings_( jump_pairings ),
177 resize( jump_pairings.size() );
181 for ( core::scoring::dssp::PairingsList::const_iterator it = jump_pairings.begin(),
182 eit = jump_pairings.end(); it != eit; ++it ) {
184 jumps_(1,njump_) = it->Pos1();
185 jumps_(2,njump_) = it->Pos2();
189 runtime_assert( njump_ == jump_pairings.size() );
201 using namespace kinematics;
221 for (
Size jump_nr = 1; jump_nr <=
size(); jump_nr++ ) {
236 cuts_.dimension( njump_ );
237 tr.Debug <<
"cut points ";
247 tr.Debug << std::endl;
290 jumps_.redimension( 2, njump );
292 cuts_.redimension( njump );
313 for (
Size i = 1; i <= num_jump; ++i ) {
314 for (
Size j = 1; j <= 2; ++j ) {
318 for (
Size k = std::max( (
Size) 1, pos-2 ), ke = std::min( nres, pos+2 );
335 tr.Info <<
"transfer jump " << i <<
" " << aJump <<std::endl;
347 using namespace core::fragment;
351 (*it)->steal( pose );
364 all_frames.reserve( all_frames.size() +
size() );
368 for (
Size jump_nr = 1; jump_nr <=
size(); jump_nr++ ) {
369 int const startpos(
jumps_( 1, jump_nr ) );
370 int const endpos(
jumps_( 2, jump_nr ) );
372 tr.Debug <<
"jump " << jump_nr <<
" from: " << startpos <<
" --> " << endpos << std::endl;
376 int const down_jump_res(
fold_tree().downstream_jump_residue( jump_nr ) );
377 int const up_jump_res(
fold_tree().upstream_jump_residue( jump_nr ) );
378 runtime_assert( (down_jump_res == startpos) || (up_jump_res == startpos) );
379 runtime_assert( (down_jump_res == endpos ) || (up_jump_res == endpos ) );
380 runtime_assert( startpos != endpos );
382 if ( mm.
get_bb( up_jump_res ) || mm.
get_bb( down_jump_res ) ) {
383 using namespace core::fragment;
386 if ( bWithTorsion && mm.
get_bb( up_jump_res ) ) {
388 frag_data->add_residue( start );
393 if ( bWithTorsion && mm.
get_bb( down_jump_res ) ) {
395 frag_data->add_residue( stop );
400 if ( bWithTorsion && mm.
get_bb( up_jump_res ) ) frame->
set_pos( pos++, startpos );
401 frame->set_pos( pos++, startpos );
402 frame->set_pos( pos++, endpos );
403 if ( bWithTorsion && mm.
get_bb( down_jump_res ) ) frame->set_pos( pos++, endpos );
404 frame->add_fragment( frag_data );
405 runtime_assert( frame->nr_frags() );
406 all_frames.push_back( frame );
414 for (
Size jump_nr=1; jump_nr<=
size(); jump_nr++ ) {
417 tr.Info <<
"detect orientation and pleating for jump " << jump_nr <<
" from " << p.
Pos1() <<
" to " << p.
Pos2() << std::endl;
436 if ( it->Pos1() == res1 && it->Pos2() == res2 )
return *it;
437 if ( it->Pos1() == res2 && it->Pos2() == res1 )
return it->generate_reversed();
450 using namespace core::fragment;
452 all_frames.reserve( all_frames.size() +
size() );
458 typedef std::map< std::pair< Size, Size >,
JumpList > JumpOrientations;
459 JumpOrientations jump_kind;
463 Size o_key ( it->Orientation() );
464 Size p_key ( it->Pleating() );
465 jump_kind[ std::make_pair( o_key, p_key ) ].push_back( jump_nr++ );
469 for ( JumpOrientations::const_iterator it=jump_kind.begin(), eit=jump_kind.end();
473 Size o_key( it->first.first );
474 Size p_key( it->first.second );
477 for ( JumpList::const_iterator jit=it->second.begin(), ejit=it->second.end();
479 int const jump_nr ( *jit );
480 int const startpos(
jumps_( 1, jump_nr ) );
481 int const endpos(
jumps_( 2, jump_nr ) );
483 runtime_assert( o_key ==
jump_pairings_[ jump_nr ].Orientation() );
486 tr.Debug <<
"jump " << jump_nr <<
" from: " << startpos <<
" --> " << endpos << std::endl;
491 int const down_jump_res(
fold_tree().downstream_jump_residue( jump_nr ) );
492 int const up_jump_res(
fold_tree().upstream_jump_residue( jump_nr ) );
493 runtime_assert( (down_jump_res == startpos) || (up_jump_res == startpos) );
494 runtime_assert( (down_jump_res == endpos ) || (up_jump_res == endpos ) );
495 runtime_assert( startpos != endpos );
496 if ( mm.
get_bb( up_jump_res ) && mm.
get_bb( down_jump_res ) ) {
497 Size const length( bWithTorsion ? 4 : 2 );
498 runtime_assert( length == frag_data.front()->size() );
500 frame->add_fragment( frag_data );
501 all_frames.push_back( frame );
503 utility_exit_with_message(
"need to implement this: make ss-library fragments that only contain those torsions for residues\
504 that can move according to movemap -- call this function with\
505 bWithTorsions = false ... and it works for now");
516 tr.Debug <<
"add chainbreak variant to residues " <<
cuts_(i) <<
" and " <<
cuts_(i)+1 << std::endl;
530 tr.Debug <<
"add chainbreak variant to residues " <<
cuts_(i) <<
" and " <<
cuts_(i)+1 << std::endl;
537 using namespace scoring::constraints;
560 tr.Debug <<
"add chainbreak as distance constraint to residues " <<
cuts_(i) <<
" and " <<
cuts_(i)+1 << std::endl;
579 for (
Size i=1; i<=t.
size(); i++ ) {
580 os << RJ(4,t.
jumps_(1,i)) <<
" " << RJ(4,t.
jumps_(2,i)) <<
" | ";
583 for (
Size i=1; i<=t.
size(); i++ ) {
584 os <<
" " << RJ(4,t.
cuts_(i));
591 utility::io::ozstream out( fn );
593 out <<
"from pymol import cmd\n";
595 out <<
"cmd.select( \"jumps"<<i<<
"\", \"resi "<<
jumps_(1,i)<<
"+"<<
jumps_(2,i)<<
"\");" << std::endl;
596 out <<
"cmd.show( \"sticks\", \"jumps"<<i<<
"\");\n";
597 out <<
"cmd.select( \"cut"<<i<<
"\", \"resi " <<
cuts_(i)<<
"\");\n";
598 out <<
"cmd.show( \"sphere\",\"cut"<<i<<
"\");" << std::endl;