39 #include <basic/options/keys/OptionKeys.hh>
43 #include <ObjexxFCL/FArray1D.hh>
46 #include <basic/Tracer.hh>
66 #include <utility/vector1.hh>
67 #include <numeric/conversions.hh>
68 #include <ObjexxFCL/string.functions.hh>
71 namespace ObjexxFCL { }
using namespace ObjexxFCL;
78 static basic::Tracer
TR(
"protocols.rna.rna_loop_closer" ) ;
85 RNA_LoopCloser::RNA_LoopCloser():
88 check_tolerance_( false ),
89 ccd_tolerance_( 0.000001 ),
90 absolute_ccd_tolerance_( 0.01 ),
91 attempt_closure_cutoff_( 20.0 ),
92 gap_distance_cutoff_( 8.0 ),
95 Mover::type(
"RNA_LoopCloser");
110 using namespace core::scoring;
111 using namespace core::kinematics;
112 using namespace core::optimization;
113 using namespace basic::options;
114 using namespace basic::options::OptionKeys;
130 apply( pose, connections, i );
139 std::map< Size, Size > connections_dummy;
140 apply( pose, connections_dummy );
145 return "RNA_LoopCloser";
152 if (
verbose_)
TR <<
"Closing loop at: " << cutpoint << std::endl;
163 if (
verbose_)
TR <<
"Closing loop at: " << cutpoint << std::endl;
166 std::map< Size, Size > connections;
181 if ( domain_map( i ) == domain_map( i+1 ) ) {
182 if (
verbose_)
TR <<
"Skipping " << i <<
" due to domain map." << std::endl;
189 if (
verbose_)
TR <<
"Cutpoint " << i <<
" will be tough to close: " << current_dist_err << std::endl;
196 if (
verbose_)
TR <<
"Cutpoint " << i <<
" will be tough to close since gap is : " << current_gap_distance << std::endl;
202 if (
verbose_)
TR <<
"Cutpoint " << i <<
" already pretty close to closed: " << current_dist_err << std::endl;
224 if ( current_dist_err > ccd_tolerance )
return false;
236 using namespace core::scoring::rna;
237 using namespace core::id;
241 utility_exit_with_message(
"RNA CCD closure at "+string_of( cutpoint )+
" but residues are not RNA?");
246 utility_exit_with_message(
"RNA CCD closure at "+string_of( cutpoint )+
" but CUTPOINT_LOWER or CUTPOINT_UPPER variants not properly set up." );
258 pose.append_residue_by_jump( input_pose.
residue( cutpoint+1), 1 );
262 bool close_two_base_pairs =
false;
263 Size cutpoint_partner( 0 ), cutpoint_next_partner( 0 );
265 if ( connections.find( cutpoint ) != connections.end() &&
266 connections.find( cutpoint+1 ) != connections.end() ) {
268 cutpoint_partner = connections.find( cutpoint )->second;
269 cutpoint_next_partner = connections.find( cutpoint+1 )->second;
271 if (cutpoint_partner == cutpoint_next_partner + 1 ) {
272 close_two_base_pairs =
true;
275 if ( close_two_base_pairs ) {
276 TR <<
"Also including some torsions in partners in CCD: " << cutpoint_partner <<
" " << cutpoint_next_partner << std::endl;
280 if (close_two_base_pairs ) {
281 pose.append_residue_by_jump( input_pose.
residue( cutpoint_next_partner ), 1 );
282 pose.append_residue_by_jump( input_pose.
residue( cutpoint_partner ), 1 );
286 if ( close_two_base_pairs ) {
292 f.new_jump( 2, 3, 2 );
298 f.new_jump( 1, 2, 1 );
310 Real mean_dist_err( -1.0 ), mean_dist_err_prev( 9999.9999 );
318 for (
Size j = 5; j <=6; ++ j){
320 input_tor_ids.push_back(
TorsionID( cutpoint,
BB, j ) );
324 for (
Size j = 1; j <=3; ++ j){
326 input_tor_ids.push_back(
TorsionID( cutpoint+1,
BB, j ) );
359 mean_dist_err_prev = mean_dist_err;
367 for (
Size n = 1; n <= tor_ids.size(); n++ )
369 TorsionID const & tor_id( tor_ids[ n ] );
371 pose.conformation().get_torsion_angle_atom_ids( tor_id, id1, id2, id3, id4 );
376 if (
Size( tor_id.
rsd() ) == 1 ){
387 Matrix const & M_i( stub_i.M );
388 Vector const & x_i = M_i.col_x();
390 Real weighted_sine( 0.0 ), weighted_cosine( 0.0 );
391 for (
Size m = 1; m <= upstream_xyzs.size(); m++ ){
392 Vector const current_xyz( current_atom.xyz() );
394 Vector const r1 = upstream_xyzs[m] - current_xyz;
395 Vector const rho1 = r1 - dot( r1, x_i) * x_i;
397 Vector const r2 = downstream_xyzs[m] - current_xyz;
398 Vector const rho2 = r2 - dot( r2, x_i) * x_i;
400 Real const current_sine = dir * dot( x_i, cross( rho1, rho2 ) );
401 Real const current_cosine = dot( rho1, rho2 );
404 weighted_sine += current_sine;
405 weighted_cosine += current_cosine;
410 Real const twist_torsion = numeric::conversions::degrees( std::atan2( weighted_sine, weighted_cosine) );
414 Real const current_val = pose.torsion( tor_id );
415 pose.set_torsion( tor_id, current_val + twist_torsion );
420 if (
verbose_ ) std::cout <<
"Distance error: " << mean_dist_err << std::endl;
424 if (
verbose_) pose.dump_pdb(
"scratch_close.pdb" );
428 for (
Size n = 1; n <= tor_ids.size(); n++ ) {
429 input_pose.
set_torsion( input_tor_ids[n], pose.torsion( tor_ids[n] ) );
434 return mean_dist_err;
459 upstream_xyzs.clear();
460 downstream_xyzs.clear();
462 upstream_xyzs.push_back( pose.
residue( cutpoint ).
xyz(
" O3*" ) );
463 upstream_xyzs.push_back( pose.
residue( cutpoint ).
xyz(
"OVL1" ) );
464 upstream_xyzs.push_back( pose.
residue( cutpoint ).
xyz(
"OVL2" ) );
466 downstream_xyzs.push_back( pose.
residue( cutpoint+1 ).
xyz(
"OVU1" ) );
467 downstream_xyzs.push_back( pose.
residue( cutpoint+1 ).
xyz(
" P " ) );
468 downstream_xyzs.push_back( pose.
residue( cutpoint+1 ).
xyz(
" O5*" ) );
470 Real mean_dist_err( 0.0 );
471 for (
Size m = 1; m <= upstream_xyzs.size(); m++ ){
472 mean_dist_err += ( upstream_xyzs[m] - downstream_xyzs[m] ).length();
474 mean_dist_err /= upstream_xyzs.size();
476 return mean_dist_err;
493 using namespace core::kinematics;
494 using namespace core::scoring::constraints;
502 if ( ! f.is_cutpoint( cutpos ) )
continue;
508 bool cst_found(
false );
511 for (
Size n = 1; n <= csts.size(); n++ ) {
515 if ( cst->natoms() == 2 ) {
516 Size const i = cst->atom( 1 ).rsd();
518 Size const j = cst->atom( 2 ).rsd();
521 if ( i == cutpos && j == cutpos+1 && name1 ==
" O3*" && name2 ==
" P " ){
522 cst_found =
true;
break;
524 if ( j == cutpos && i == cutpos+1 && name2 ==
" O3*" && name1 ==
" P " ){
525 cst_found =
true;
break;
532 if (!cst_found)
continue;
534 extra_cutpoints.push_back( cutpos );
538 return extra_cutpoints;
547 for (
Size n = 1; n <= extra_cutpoints.size(); n++ ) {
549 Size cutpos( extra_cutpoints[ n ] );
555 for (
Size i = cutpos; i <= cutpos + 1; i++ ){
574 for (
Size n = 1; n <= extra_cutpoints.size(); n++ ) {
575 Size cutpos( extra_cutpoints[ n ] );
579 for (
Size i = cutpos; i <= cutpos + 1; i++ ){
619 using namespace core::scoring;
644 apply( pose, connections );
668 using namespace core::optimization;
669 using namespace core::kinematics;
670 using namespace core::scoring;
677 float const dummy_tol( 0.0000025);
678 bool const use_nblist(
true );
679 static MinimizerOptions options(
"dfpmin", dummy_tol, use_nblist,
false ,
false );
686 mm.set_jump (
false );
688 minimizer.run( pose, mm, *lores_scorefxn, options );
700 using namespace core::optimization;
703 float const dummy_tol( 0.0000025);
704 bool const use_nblist(
true );
710 mm.set_jump(
false );
720 if ( ! f.is_cutpoint( cutpos ) )
continue;
725 mm.set_bb( cutpos,
true );
726 mm.set_bb( cutpos+1,
true );
727 minimizer.run( pose, mm, *scorefxn_local, options );
729 TR <<
"Trying to minimize chain near cutpoint " << cutpos << std::endl;