34 #include <basic/Tracer.hh>
36 #include <numeric/random/random.hh>
37 #include <numeric/angle.functions.hh>
38 #include <numeric/xyz.functions.hh>
39 #include <numeric/xyzVector.hh>
40 #include <numeric/conversions.hh>
41 #include <numeric/kinematic_closure/bridgeObjects.hh>
43 #include <utility/exit.hh>
44 #include <utility/vector1.hh>
45 #include <ObjexxFCL/FArray1D.hh>
46 #include <ObjexxFCL/string.functions.hh>
47 #include <ObjexxFCL/format.hh>
51 static basic::Tracer
TR(
"protocols.coarse_rna.coarse_rna_loop_closer" ) ;
52 static numeric::random::RandomGenerator
RG(2289440);
53 using ObjexxFCL::fmt::I;
54 using ObjexxFCL::fmt::F;
59 using numeric::conversions::radians;
60 using numeric::conversions::degrees;
61 using numeric::angle_radians;
62 using numeric::principal_angle;
63 using numeric::dihedral_radians;
66 namespace coarse_rna {
68 CoarseRNA_LoopCloser::CoarseRNA_LoopCloser():
69 a_little_verbose_( false ),
73 which_scratch_res_is_cut_( 0 ),
74 choose_least_perturb_solution_( true ),
75 choose_best_solution_( false ),
76 choose_random_solution_( false ),
77 save_all_solutions_( false )
79 Mover::type(
"CoarseRNA_LoopCloser");
87 std::cout <<
"Does nothing for now -- input the residue that you changed." << std::endl;
133 return "CoarseRNA_LoopCloser¯";
143 bool success(
true );
151 if ( !success_in_finding_pivots ) {
159 if (
nsol_ == 0 ) success =
false;
176 std::cout << std::endl;
186 if (
verbose_ ) std::cout <<
"AFFECTED CUTPOINT: " << n << std::endl;
195 std::cout <<
"BACKWARD_RES ";
197 std::cout << std::endl;
199 std::cout <<
"FORWARD_RES ";
201 std::cout << std::endl << std::endl;
215 if ( tot_pivot_res < 2 )
return false;
235 for (
Size n = 1; n <= res_vector.size(); n++ ) {
236 if ( res_vector[ n ] != res ) new_res_vector.push_back( res_vector[ n ] );
239 res_vector = new_res_vector;
252 while ( current_atom->parent() ){
254 current_atom = ( current_atom->parent() );
255 AtomID const & atom_id( current_atom->id() );
256 if ( pose.
residue_type( atom_id.rsd() ).atom_name( atom_id.atomno() ) ==
" P " ) {
257 upstream_res.push_back( current_atom->id().rsd() );
258 is_upstream_res[ current_atom->id().rsd() ] =
true;
310 for (
Size n = 1; n <= upstream_res.size(); n++ ) {
312 Size const i( upstream_res[ n ] );
318 if ( !is_filter_res[ i ] &&
323 upstream_res = new_upstream_res;
338 if ( total_pivots < 3 ){
339 utility_exit_with_message(
"Not enough pivots to close chainbreak!" );
347 pivots_in_order.push_back(
cutpos_ + 1 );
357 pivots_selected[ cutpoint_pivot ] =
true;
361 for (
Size n = 1; n <= 2; n++ ){
363 Size const which_pivot =
static_cast<int>(
RG.uniform() * total_pivots ) + 1;
366 for (
Size i = 1; i <= pivots_selected.size(); i++ ) {
367 if ( !pivots_selected[ i ] ) count++;
368 if ( count == which_pivot ) {
369 pivots_selected[ i ] =
true;
400 std::cout <<
"PIVOTS_SELECTED: ";
401 for (
Size i = 1; i <= pivots_selected.size(); i++ ) std::cout << pivots_selected[ i ];
402 std::cout << std::endl;
405 for (
Size i = 1; i <= pivots_selected.size(); i++ ) {
406 if( pivots_selected[ i ] ) {
415 std::cout <<
"IS_PIVOT_RES: ";
417 std::cout << std::endl;
419 std::cout <<
"IS_SCRATCH_RES: ";
421 std::cout << std::endl;
445 std::cout <<
"SCRATCH RES: ";
447 std::cout << std::endl;
457 std::cout <<
"SCRATCH RES: ";
458 std::cout <<
"PIVOT_TO_SCRATCH_RES: ";
460 std::cout << std::endl;
471 using namespace core::kinematics;
472 using namespace numeric::kinematic_closure;
499 for (
Size i = 1; i <= nscratch; i++ ){
509 for (
Size i = 1; i <= 3; i++ ){
520 for (
Size i = 1; i <= atoms.size(); i++ ) {
521 atoms_xyz.push_back(
Vector(atoms[i][1],atoms[i][2],atoms[i][3]) );
534 static const Real idl_S_nextP_( 3.838 );
537 if (
verbose_) std::cout <<
" D_S_NEXT_P " << d_S_nextP <<
" " << idl_S_nextP_ << std::endl;
540 static const Real idl_S_Snudge_nextP_( 65.908 );
548 if (
verbose_) std::cout <<
" THETA_S_Snudge_NEXTP " << theta_S_Snudge_nextP <<
" " << idl_S_Snudge_nextP_ << std::endl;
552 static const Real idl_S_nextP_nextS_( 84.947 );
556 if (
verbose_) std::cout <<
" THETA_S_NEXTP_NEXTS " << theta_S_nextP_nextS <<
" " << idl_S_nextP_nextS_ << std::endl;
560 static const Real idl_P_S_CEN_nextP( 86.592 );
569 if (
verbose_) std::cout <<
" PHI_P_S_Snudge_NEXTP " << phi_P_S_Snudge_nextP <<
" " << idl_P_S_CEN_nextP << std::endl;
581 if (
verbose_) std::cout <<
" PHI_S_Snudge_nextP_nextS " << phi_cutpivot1 << std::endl;
595 for (
Size i = 1; i <= 3; i++ ) {
601 std::cout <<
"after chainbreak geometry fix" << std::endl;
617 if (
nsol_ == 0 )
return;
650 AtomID id1, id2, id3, id4;
651 for (
Size i = 1; i <= 3; i++ ){
713 std::cout <<
"Problem with DOF_ID "<< pivot <<
" " << dof_id << std::endl;
714 utility_exit_with_message(
"Problem with DOF_ID" );
717 offset_save.push_back( pose.
dof( dof_id ) - radians( original_torsion_value ) );
720 std::cout <<
" offset " << pose.
dof( dof_id ) <<
" " << radians( original_torsion_value )
721 <<
" " << pose.
dof( dof_id ) - radians( original_torsion_value ) << std::endl;
735 if (
nsol_ == 0 )
return;
741 std::cout <<
"---------------------------------- " << std::endl;
742 std::cout <<
" start pose " << std::endl;
743 std::cout <<
"---------------------------------- " << std::endl;
748 pose.
dump_pdb(
"before_closed.pdb" );
751 Real best_deviation2( 0.0 );
755 Size const ref_atom( 1 );
762 Real deviation2( 0.0 );
764 deviation2 += ( pose.
xyz(
id::AtomID(ref_atom,i) ) - ref_vectors[i] ).length_squared();
766 if ( n==1 || deviation2 < best_deviation2){
767 best_deviation2 = deviation2;
776 std::cout <<
"---------------------------------- " << std::endl;
777 std::cout <<
" solution " << best_sol << std::endl;
778 std::cout <<
"---------------------------------- " << std::endl;
786 std::cout <<
"pose " << best_sol <<
": " << std::endl;
798 Real best_score( 0.0 );
802 Real const score = (*scorefxn_)( pose );
803 if ( score < best_score || n == 1 ) {
809 std::cout <<
"solution " << n <<
": " << std::endl;
812 std::cout <<
"pose " << n <<
": " << std::endl;
826 Size const n =
static_cast<int>(
nsol_ *
RG.uniform() ) + 1;
846 pose_list.push_back( pose_save );
849 pose.
dump_pdb(
"KIC_"+ ObjexxFCL::string_of( n )+
".pdb" );
897 std::cout <<
"------ chainTORS output ---- " << std::endl;
898 for (
Size i = 1; i <= dt_ang.size(); i++) {
899 std::cout << I( 3, i ) <<
" ";
900 std::cout <<
"TORSIONS: ";
901 std::cout << F(8,3,dt_ang[ i ]) <<
" ";
903 std::cout <<
" BOND_ANGLES: ";
904 std::cout << F(8,3,db_ang[ i ]) <<
" ";
906 std::cout <<
" BOND_LENGTHS: ";
907 std::cout << F(8,3,db_len[ i ]) <<
" ";
909 std::cout << std::endl;
924 using namespace core::kinematics;
925 using namespace numeric::kinematic_closure;
931 for (
Size i = 1; i <= atom_ids_.size(); i++ ) {
933 atoms_xyz.push_back( pose.
xyz( atom_ids_[ i ] ) );
937 atoms_xyz[ 1 ] =
Vector( 0.0, 0.0, 0.0 );
938 atoms_xyz[ 2 ] =
Vector( 0.0, 0.0, 1.0 );
939 atoms_xyz[ 3 ] =
Vector( 0.0, 1.0, 0.0 );
941 atoms_xyz[ atom_ids_.size() - 2 ] =
Vector( 1.0, 0.0, 0.0 );
942 atoms_xyz[ atom_ids_.size() - 1 ] =
Vector( 1.0, 0.0, 1.0 );
943 atoms_xyz[ atom_ids_.size() ] =
Vector( 1.0, 1.0, 0.0 );
948 static Real const nudge( 0.000001 );
949 for (
Size n = 1; n <= ( (atom_ids_.size()/3) - 3 ) ; n++ ){
950 Size const i = 3 + (n * 3);
951 if ( atom_ids_[ i ] == atom_ids_[ i+1 ] ){
954 Size const seqpos = atom_ids_[ i ].rsd();
955 atoms_xyz[ i+1 ] = atoms_xyz[ i ] +
956 nudge * ( pose.
xyz(
NamedAtomID(
" CEN", seqpos ) ) - atoms_xyz[i] ).normalize();
962 for (
Size i = 1; i <= atom_ids_.size(); i++ ){
964 atom_xyz_vals.push_back( atoms_xyz[i].x() );
965 atom_xyz_vals.push_back( atoms_xyz[i].y() );
966 atom_xyz_vals.push_back( atoms_xyz[i].z() );
967 atoms.push_back( atom_xyz_vals );
970 chainTORS(atoms.size(), atoms, dt_ang, db_ang, db_len, R0, Q0);