34 #include <basic/Tracer.hh>
61 #include <numeric/conversions.hh>
62 #include <numeric/NumericTraits.hh>
66 #include <ObjexxFCL/format.hh>
67 #include <ObjexxFCL/string.functions.hh>
76 static basic::Tracer
TR(
"protocols.swa.rna.stepwise_rna_floating_base_sampler_util" ) ;
95 for(
Size i=1; i<=other_residues_base_list.size(); i++){
106 subtract( moving_res_base.
v, base_info.
v, centroid_diff);
107 Real const centroid_distance=centroid_diff.length();
111 if( centroid_distance>(6.3640+small_offset) )
continue;
113 Real const base_z_offset_one=std::abs(dot( centroid_diff, other_z_vector));
114 Real const base_z_offset_two=std::abs(dot( centroid_diff, rebuild_z_vector));
118 if( (base_z_offset_one>(4.5000+small_offset) || base_z_offset_one<(2.5000-small_offset)) && (base_z_offset_two>(4.5000+small_offset) || base_z_offset_two<(2.5000-small_offset)) )
continue;
120 Real const base_axis_one=base_z_offset_one/centroid_distance;
121 Real const base_axis_two=base_z_offset_two/centroid_distance;
125 if( base_axis_one<(base_axis_CUTOFF-small_offset) && base_axis_two<(base_axis_CUTOFF-small_offset) )
continue;
127 Real const base_planarity=std::abs(dot( other_z_vector, rebuild_z_vector));
131 if( base_planarity<(base_planarity_CUTOFF-small_offset) )
continue;
154 for(
Size i=1; i<=other_residues_base_list.size(); i++){
165 subtract( moving_res_base.
v, base_info.
v, centroid_diff);
167 Real const centroid_distance=centroid_diff.length();
173 if(centroid_distance<(5.0000-small_offset) || centroid_distance>(12.0000+small_offset) )
continue;
175 Real const base_z_offset_one=std::abs(dot( centroid_diff, other_z_vector));
176 Real const base_z_offset_two=std::abs(dot( centroid_diff, rebuild_z_vector));
180 if(base_z_offset_one>(3.0000+small_offset) && base_z_offset_two>(3.0000+small_offset) )
continue;
182 Real const base_axis_one=base_z_offset_one/centroid_distance;
183 Real const base_axis_two=base_z_offset_two/centroid_distance;
187 if(base_axis_one>(base_axis_CUTOFF+small_offset) && base_axis_two>(base_axis_CUTOFF+small_offset) )
continue;
189 Real const base_planarity=std::abs(dot( rebuild_z_vector, other_z_vector));
193 if( base_planarity<(base_planarity_CUTOFF-small_offset) )
continue;
197 Real const rho_one=centroid_diff_perpendicular_one.length();
201 Real const rho_two=centroid_diff_perpendicular_two.length();
207 if((rho_one<(5.0000-small_offset) || rho_one>(10.0000+small_offset) ) && (rho_two<(5.0000-small_offset) || rho_two>(10.0000+small_offset) ))
continue;
222 Real const base_axis_CUTOFF=0.9000;
223 Real const base_planarity_CUTOFF=0.9000;
227 return Is_base_stack(moving_res_base, other_residues_base_list, base_axis_CUTOFF, base_planarity_CUTOFF);
236 bool base_stack =
Is_base_stack(moving_res_base, other_residues_base_list, 0.7070 , 0.7070 );
238 bool base_pair =
Is_base_pair(moving_res_base, other_residues_base_list, 0.5000 , 0.7070 );
243 return (base_stack && base_pair);
252 if(num_nucleotides>2) utility_exit_with_message(
"Error: num_nucleotides>2!" );
254 if(num_nucleotides==2){
264 bool strict_base_pair=
false;
265 if(allow_base_pair_only_screen){
267 strict_base_pair=
Is_base_pair(moving_res_base, other_residues_base_list, 0.2588 , 0.8660 );
273 if ( strong_stack_base || medium_base_stack_and_medium_base_pair || (allow_base_pair_only_screen && strict_base_pair) ){
288 bool const regular_base_stack =
Is_base_stack(moving_res_base, other_residues_base_list, 0.707 , 0.707 );
292 bool const regular_base_pair =
Is_base_pair(moving_res_base, other_residues_base_list, 0.5 , 0.866 );
296 if( regular_base_stack || regular_base_pair){
313 using namespace chemical;
316 std::string const center_atom = (Is_prepend) ?
" C4*" :
" C3*";
317 std::string const x_axis_atom = (Is_prepend) ?
" H4*" :
" C2*";
318 std::string const y_axis_atom = (Is_prepend) ?
" C5*" :
" H3*";
321 std::cout <<
"Get_ribose_stub function: ";
323 std::cout <<
" center_atom= " << center_atom <<
" x_axis_atom= " << x_axis_atom <<
" y_axis_atom= " << y_axis_atom << std::endl;
332 Vector const origin=rsd.
xyz(center_atom);
334 Vector const x_axis_coord =rsd.
xyz(x_axis_atom);
335 x = x_axis_coord - origin;
338 Vector const y_axis_coord =rsd.
xyz(y_axis_atom);
339 y = y_axis_coord - origin;
346 anchor_ribose_stub.v =origin ;
347 anchor_ribose_stub.M=Matrix::cols( x, y, z );
349 return anchor_ribose_stub;
375 if(euler_angles.
z<0) base_bin.
euler_z--;
386 return base_bin_it->first.centroid_x;
388 return base_bin_it->first.centroid_y;
390 return base_bin_it->first.centroid_z;
391 }
else if(DOF==
"alpha"){
392 return base_bin_it->first.euler_alpha;
393 }
else if(DOF==
"euler_z"){
394 return base_bin_it->first.euler_z;
395 }
else if(DOF==
"gamma"){
396 return base_bin_it->first.euler_gamma;
398 utility_exit_with_message(
"Invalid DOF= " + DOF);
408 if(DOF==
"x" || DOF==
"y" || DOF==
"z"){
410 }
else if(DOF==
"alpha" || DOF==
"gamma"){
412 }
else if(DOF==
"euler_z"){
415 utility_exit_with_message(
"Invalid DOF= " + DOF);
426 std::map<std::pair<int, int> , int ,
compare_int_pair>::iterator count_density_it;
428 std::map<Base_bin , int , compare_base_bin>::const_iterator base_bin_it;
431 int total_occupied_bin=0;
433 for (base_bin_it=base_bin_map.begin(); base_bin_it!=base_bin_map.end(); base_bin_it++ ){
435 total_occupied_bin++;
436 total_count=total_count+base_bin_it->second;
438 std::pair< int, int >
const & DOF_pair=std::make_pair(
DOF_bin_value(base_bin_it, DOF_one),
DOF_bin_value(base_bin_it, DOF_two));
440 count_density_it=count_density_map.find(DOF_pair);
442 if(count_density_it==count_density_map.end()){
443 count_density_map[DOF_pair]=1;
445 count_density_it->second++;
450 std::ofstream outfile;
452 outfile.open(filename.c_str());
453 Size const spacing=14;
455 outfile << std::setw(spacing) << DOF_one;
456 outfile << std::setw(spacing) << DOF_two;
457 outfile << std::setw(30) <<
"occupied_bin_count";
460 int DOF_one_bin_max=0;
461 int DOF_one_bin_min=0;
462 int DOF_two_bin_max=0;
463 int DOF_two_bin_min=0;
465 for (count_density_it=count_density_map.begin(); count_density_it!=count_density_map.end(); count_density_it++ ){
466 int const & DOF_one_bin_value=count_density_it->first.first;
467 int const & DOF_two_bin_value=count_density_it->first.second;
469 if(DOF_one_bin_value>DOF_one_bin_max) DOF_one_bin_max=DOF_one_bin_value;
470 if(DOF_two_bin_value>DOF_two_bin_max) DOF_two_bin_max=DOF_two_bin_value;
471 if(DOF_one_bin_value<DOF_one_bin_min) DOF_one_bin_min=DOF_one_bin_value;
472 if(DOF_two_bin_value<DOF_two_bin_min) DOF_two_bin_min=DOF_two_bin_value;
476 for(
int DOF_one_bin_value=(DOF_one_bin_min-5); DOF_one_bin_value<(DOF_one_bin_max+5); DOF_one_bin_value++){
477 for(
int DOF_two_bin_value=(DOF_two_bin_min-5); DOF_two_bin_value<(DOF_two_bin_max+5); DOF_two_bin_value++){
482 int occupied_bin_count;
483 std::pair< int, int >
const & DOF_pair=std::make_pair(DOF_one_bin_value, DOF_two_bin_value);
484 count_density_it=count_density_map.find(DOF_pair);
486 if(count_density_it==count_density_map.end()){
487 occupied_bin_count=0;
489 occupied_bin_count=count_density_it->second;
492 outfile << std::setw(spacing) << DOF_one_value;
493 outfile << std::setw(spacing) << DOF_two_value;
494 outfile << std::setw(spacing) << occupied_bin_count;
500 std::cout << std::setw(50) <<
std::left <<
"Analysis " + DOF_one +
"_" + DOF_two;
501 std::cout <<
" tot_count = " << std::setw(15) <<
std::left << total_count <<
" tot_occ= " << std::setw(15) <<
std::left << total_occupied_bin;
502 std::cout <<
" tot_count/tot_occ_bin= " << std::setw(5) <<
std::left << (double(total_count)/double(total_occupied_bin)) << std::endl;
547 const Real DEGS_PER_RAD = 180. / numeric::NumericTraits<Real>::pi();
550 euler_angles.
alpha= atan2(M.xz(),-M.yz()) * DEGS_PER_RAD;
551 euler_angles.
z= M.zz();
552 euler_angles.
gamma= atan2(M.zx(), M.zy()) * DEGS_PER_RAD ;
580 coordinate_matrix.xz( sin(E.
alpha)*sin(E.
beta));
583 coordinate_matrix.yz(-cos(E.
alpha)*sin(E.
beta));
584 coordinate_matrix.zx( sin(E.
beta) *sin(E.
gamma));
585 coordinate_matrix.zy( sin(E.
beta) *cos(E.
gamma));
586 coordinate_matrix.zz( cos(E.
beta));
588 Real determinant=coordinate_matrix.det();
590 if(determinant>1.000001 || determinant<0.999999){
591 utility_exit_with_message(
"determinant != 1.00 !!!" );
628 using namespace core::id;
629 using namespace core::pose;
638 if(verbose) std::cout <<
"seq_num= " << seq_num <<
" atom_name= " << atom_name << std::endl;
656 using namespace core::chemical;
657 using namespace core::scoring;
658 using namespace core::pose;
659 using namespace core::io::silent;
660 using namespace core::id;
679 pose.
set_xyz(
id, invert_coordinate_matrix * pose.
xyz(
id));
698 atom_pos= new_coordinate_matrix * rsd_at_origin.
xyz(atom_name);
699 atom_pos= atom_pos + new_centroid;
708 using namespace core::conformation;
710 if(rsd_at_origin_list.size()<1){
711 utility_exit_with_message(
"rsd_at_origin_list.size()<1!!" );
716 for(
Size n=1; n<=rsd_at_origin_list.size(); n++){
717 Residue const & rsd_at_origin= (*rsd_at_origin_list[n]);
720 Real const distance =( rsd_at_origin.
xyz(atom_name) - centroid ).length();
722 if(max_distance< distance) max_distance=
distance;
723 std::cout <<
" sugar/base conformation num: " << n <<
" distance = " << distance << std::endl;
726 std::cout <<
"max_centroid_to_atom_distance for atom: " << atom_name <<
" base " <<
name_from_aa((*rsd_at_origin_list[1]).aa()) <<
": " << max_distance << std::endl;
735 using namespace ObjexxFCL;
736 using namespace ObjexxFCL::fmt;
737 using namespace core::id;
738 using namespace core::chemical;
739 using namespace core::conformation;
740 using namespace core::scoring::rna;
742 std::cout <<
"-------setup_residue_at_origin_list (various sugar rotamers) for pose: " << pose_name <<
"-------" << std::endl;
743 Output_boolean(
"extra_anti_chi_rotamer= " , extra_anti_chi_rotamer); std::cout << std::endl;
744 Output_boolean(
"extra_syn_chi_rotamer= " , extra_syn_chi_rotamer); std::cout << std::endl;
752 base_sugar_rotamer->set_extra_anti_chi(extra_anti_chi_rotamer);
753 base_sugar_rotamer->set_extra_syn_chi(extra_syn_chi_rotamer);
759 while(base_sugar_rotamer->get_next_rotamer()){
762 std::cout <<
" delta1= " << F(8, 3, base_sugar_rotamer->delta()) <<
" chi_1= " << F(8, 3, base_sugar_rotamer->chi());
763 std::cout <<
" nu2_1= " << F(8, 3, base_sugar_rotamer->nu2()) <<
" nu1_1= " << F(8, 3, base_sugar_rotamer->nu1());
764 std::cout << std::endl;
780 rsd_at_origin_list.push_back(rsd_at_origin);
785 std::cout <<
"--------------------------------" << std::endl;
786 return rsd_at_origin_list;
795 bool const Is_prepend,
798 using namespace core::conformation;
800 for(
Size n=1; n<=rsd_at_origin_list.size(); n++){
802 Residue const & rsd_at_origin=(*rsd_at_origin_list[n]);
804 std::string const moving_atom_name= (Is_prepend) ?
"O3*" :
" C5*";
805 std::string const reference_atom_name= (Is_prepend) ?
" C5*" :
"O3*";
811 for(
Size sugar_ID=1; sugar_ID<=pose_data_list.size(); sugar_ID++){
813 pose::Pose const & pose = (*pose_data_list[sugar_ID].pose_OP);
834 bool const Is_prepend,
835 Size const gap_size){
837 using namespace core::conformation;
839 for(
Size n=1; n<=rsd_at_origin_list.size(); n++){
841 Residue const & rsd_at_origin=(*rsd_at_origin_list[n]);
843 std::string const moving_atom_name= (Is_prepend) ?
"O3*" :
" C5*";
844 std::string const reference_atom_name= (Is_prepend) ?
" C5*" :
"O3*";
867 for(
Size n=1; n<=xyz_list.size(); n++){
868 pose.
set_xyz(xyz_list[n].first, xyz_list[n].second);