47 #include <basic/Tracer.hh>
50 #include <ObjexxFCL/FArray1D.hh>
51 #include <ObjexxFCL/string.functions.hh>
55 #include <utility/io/ozstream.hh>
65 #include <utility/vector1.hh>
66 #include <numeric/xyz.functions.hh>
67 #include <ObjexxFCL/format.hh>
71 using namespace ObjexxFCL;
72 using namespace ObjexxFCL::fmt;
75 static basic::Tracer
TR(
"protocols.rna.rna_protocol_util" ) ;
89 using namespace core::conformation;
97 for (
Size i=1; i < nres; ++i) {
138 FArray1D <bool> & edge_is_base_pairing ){
140 using namespace core::scoring::rna;
141 using namespace core::chemical;
142 using namespace core::conformation;
146 Energy_base_pair_list const & scored_base_pair_list( rna_filtered_base_base_info.scored_base_pair_list() );
148 edge_is_base_pairing.dimension( 3 );
149 edge_is_base_pairing =
false;
151 bool forms_canonical_base_pair(
false ), forms_base_pair(
false );
154 for ( Energy_base_pair_list::const_iterator it = scored_base_pair_list.begin();
155 it != scored_base_pair_list.end(); ++it ){
165 }
else if ( j == seqpos ){
172 edge_is_base_pairing( k ) =
true;
173 forms_base_pair =
true;
183 if ( !rsd_i.is_coarse() ) {
185 if ( ( rsd_i.xyz( atom1 ) - rsd_j.xyz( atom2 ) ).length() > 3.5 )
continue;
188 forms_canonical_base_pair =
true;
194 if (forms_canonical_base_pair ) {
196 }
else if (forms_base_pair ){
208 using namespace core::scoring;
209 using namespace core::chemical;
210 using namespace core::conformation;
211 using namespace core::scoring::rna;
220 Energy_base_pair_list const & scored_base_pair_list( rna_filtered_base_base_info.scored_base_pair_list() );
226 std::list < std::pair< Size,Size > > base_pair_list0;
228 for ( Energy_base_pair_list::const_iterator it = scored_base_pair_list.begin();
229 it != scored_base_pair_list.end(); ++it ){
236 if ( i > j )
continue;
249 if ( !rsd_i.is_coarse() ) {
251 if ( ( rsd_i.xyz( atom1 ) - rsd_j.xyz( atom2 ) ).length() > 3.5 )
continue;
254 base_pair_list0.push_back( std::make_pair( i, j ) );
260 base_pair_list0.sort();
261 base_pairing_list.clear();
262 for ( std::list< std::pair<Size,Size > >::const_iterator it = base_pair_list0.begin();
263 it != base_pair_list0.end(); ++it ){
264 base_pairing_list.push_back( *it );
273 using namespace core::scoring;
274 using namespace ObjexxFCL;
282 FArray1D < bool > edge_is_base_pairing( 3,
false );
283 char secstruct1(
'X' );
286 secstruct += secstruct1;
289 std::cout <<
"SECSTRUCT: " << secstruct << std::endl;
299 utility::io::ozstream & torsions_out,
303 using namespace core::chemical;
304 using namespace core::scoring;
305 using namespace core::scoring::rna;
306 using namespace protocols::rna;
316 scorefxn->show( std::cout, pose );
318 bool const idealize_frag(
false );
320 idealizer.
fast(
false );
326 for (
Size i=1; i <= total_residue; ++i) {
331 if (idealize_frag ) {
342 if ( i < total_residue ){
347 idealizer.apply( mini_pose );
348 idealizer.apply( mini_pose );
352 torsions_out << F( 12, 6, mini_pose.
torsion( my_ID ) );
357 torsions_out << F( 12, 6, mini_pose.
torsion( my_ID ) ) <<
" ";
363 torsions_out << F( 12, 6, pose.
torsion( my_ID ) );
368 torsions_out << F( 12, 6, pose.
torsion( my_ID ) ) <<
" ";
377 torsions_out <<
" S " ;
380 torsions_out << F( 12, 6, v.x() ) <<
" " ;
381 torsions_out << F( 12, 6, v.y() ) <<
" " ;
382 torsions_out << F( 12, 6, v.z() ) <<
" " ;
391 FArray1D < bool > edge_is_base_pairing( 3,
false );
392 char secstruct(
'X' );
394 torsions_out << secstruct <<
" " <<
395 edge_is_base_pairing( 1 ) <<
" " <<
396 edge_is_base_pairing( 2 ) <<
" " <<
397 edge_is_base_pairing( 3 ) <<
" ";
399 bool is_cutpoint =
false;
405 torsions_out << is_cutpoint << I(6, i) << std::endl;
417 utility::io::ozstream torsions_out ( outfile );
429 bool found_valid_sign=
false;
434 if (!rsd.is_RNA() )
continue;
436 sign = dot( rsd.xyz(
" O5*" ) - rsd.xyz(
" P " ), cross( rsd.xyz(
" O2P" ) - rsd.xyz(
" P " ), rsd.xyz(
" O1P" ) - rsd.xyz(
" P " ) ) );
438 found_valid_sign=
true;
443 if(found_valid_sign==
false) utility_exit_with_message(
"found_valid_sign==false");
453 if(res_num > pose.
total_residue()) utility_exit_with_message(
"res_num > pose.total_residue()");
457 if(rsd.is_RNA()==
false) utility_exit_with_message(
"rsd.is_RNA()==false!");
459 Real const sign = dot( rsd.xyz(
" O5*" ) - rsd.xyz(
" P " ), cross( rsd.xyz(
" O2P" ) - rsd.xyz(
" P " ), rsd.xyz(
" O1P" ) - rsd.xyz(
" P " ) ) );
479 if ( sign1 * sign2 < 0 ) {
481 std::cout <<
"In the assert_phosphate_nomenclature_matches_mini function: phosphate_nomenclature_matches does not match mini! " << std::endl;
482 utility_exit_with_message(
"In the assert_phosphate_nomenclature_matches_mini function: phosphate_nomenclature_matches does not match mini!");
486 if(rsd.is_RNA()==
false){
487 std::cout <<
"residue # " << res_num <<
" should be a RNA nucleotide" << std::endl;
488 utility_exit_with_message(
"residue # " + string_of(res_num)+
" should be a RNA nucleotide!");
510 if ( sign1 * sign2 > 0 )
return;
512 std::cout <<
"*************************************************************" << std::endl;
513 std::cout <<
" Warning ... flipping O1P <--> O2P to match mini convention " << std::endl;
514 std::cout <<
"*************************************************************" << std::endl;
519 if (!rsd.is_RNA() )
continue;
521 if (!rsd.type().has(
" O1P"))
continue;
522 if (!rsd.type().has(
" O2P"))
continue;
524 Vector const temp1 = rsd.xyz(
" O1P" );
525 Vector const temp2 = rsd.xyz(
" O2P" );
548 if ( sign1 * sign2 < 0 ) {
554 if(rsd.is_RNA()==
false){
555 std::cout <<
"residue # " << res_num <<
" should be a RNA nucleotide!" << std::endl;
556 utility_exit_with_message(
"residue # " + string_of(res_num)+
" should be a RNA nucleotide!");
559 Vector const temp1 = rsd.xyz(
" O1P" );
560 Vector const temp2 = rsd.xyz(
" O2P" );
577 utility::io::ozstream out( outfile );
578 for (
Size n = 1; n <= results.size() ; n++ ){
579 out << F(8,3,results[n].first) <<
" " << results[n].second << std::endl;
583 using namespace core::io::silent;
587 Size pos( silent_file.find(
".txt" ) );
588 silent_file.replace( pos, 4,
".out" );
590 for (
Size n = 1; n <= results.size() ; n++ ){
593 std::string const tag(
"S_"+lead_zero_string_of( n, 4 ) );
595 if ( dump ) pose.
dump_pdb( tag+
".pdb");
596 silent_file_data.write_silent_struct( s, silent_file,
true );
607 using namespace core::scoring::rna;
608 using namespace core::scoring;
609 using namespace core::chemical;
610 using namespace core::conformation;
617 Energy_base_pair_list const & scored_base_pair_list( rna_filtered_base_base_info.scored_base_pair_list() );
620 FArray1D_bool forms_noncanonical_base_pair( nres,
false );
621 FArray1D_bool forms_canonical_base_pair( nres,
false );
622 FArray1D_int WC_base_pair_partner( nres, 0 );
624 for ( Energy_base_pair_list::const_iterator it = scored_base_pair_list.begin();
625 it != scored_base_pair_list.end(); ++it ){
635 bool WC_base_pair(
false );
646 std::cout << rsd_i.name1() << I(3,i) <<
"--" << rsd_j.name1() << I(3,j) <<
" WC:" << WC_base_pair <<
" score: " << F(10,6,it->first) << std::endl;
648 if ( WC_base_pair ) {
649 forms_canonical_base_pair( i ) =
true;
650 forms_canonical_base_pair( j ) =
true;
651 WC_base_pair_partner( i ) = j;
652 WC_base_pair_partner( j ) = i;
654 forms_noncanonical_base_pair( i ) =
true;
655 forms_noncanonical_base_pair( j ) =
true;
661 struct_type.dimension( nres );
662 for (
Size i = 1; i <= nres; i++ ) {
663 if ( !forms_noncanonical_base_pair(i) && !forms_canonical_base_pair(i) ) {
664 struct_type( i ) = 0;
665 }
else if (forms_canonical_base_pair(i) && !forms_noncanonical_base_pair( WC_base_pair_partner(i) ) ) {
666 struct_type( i ) = 1;
668 struct_type( i ) = 2;
680 Real const suppress_factor )
683 using namespace core::scoring::constraints;
684 using namespace core::scoring::rna;
686 Real const WC_distance( 1.9 );
687 Real const distance_stddev( 0.25 / suppress_factor );
691 Real const C1star_distance( 10.5 );
692 Real const C1star_distance_stddev( 1.0 / suppress_factor );
693 FuncOP const C1star_distance_func(
new HarmonicFunc( C1star_distance, C1star_distance_stddev ) );
695 for (
Size n = 1; n <= pairings.size(); n++ ) {
697 Size const & i = pairings[n].first;
698 Size const & j = pairings[n].second;
710 C1star_distance_func ) );
715 for (
Size p = 1; p <= atom_ids1.size(); p++ ){
720 TR <<
"BASEPAIR: Adding rna_force_atom_pair constraint: " << pose.
residue(i).
name1() << I(3,i) <<
" <--> " <<
722 atom_ids1[p] <<
" <--> " <<
723 atom_ids2[p] <<
". [ " << atom1 <<
"-" << atom2 <<
"]" << std::endl;
733 static Real const coarse_WC_SUG_distance_min( 12.3 );
734 static Real const coarse_WC_SUG_distance_max( 14.3 );
735 static Real const coarse_WC_SUG_distance_stddev( 2.0 );
736 static Real const coarse_WC_SUG_bonus( -2.5 );
737 static FuncOP const coarse_SUG_distance_func(
new FadeFunc( coarse_WC_SUG_distance_min - coarse_WC_SUG_distance_stddev,
738 coarse_WC_SUG_distance_max + coarse_WC_SUG_distance_stddev,
739 coarse_WC_SUG_distance_stddev,
740 coarse_WC_SUG_bonus ) );
745 TR <<
"BASEPAIR: Adding rna_force_atom_pair constraint: " << pose.
residue(i).
name1() << I(3,i) <<
" <--> " <<
748 " S " <<
". [ " << atom1 <<
"-" << atom2 <<
"]" << std::endl;
752 coarse_SUG_distance_func ) );
755 static Real const coarse_WC_CEN_distance( 5.5 );
756 static Real const coarse_WC_CEN_distance_stddev( 3.0 );
757 static Real const coarse_WC_CEN_bonus( -5.0 );
758 static FuncOP const coarse_CEN_distance_func(
new FadeFunc( coarse_WC_CEN_distance - coarse_WC_CEN_distance_stddev,
759 coarse_WC_CEN_distance + coarse_WC_CEN_distance_stddev,
760 coarse_WC_CEN_distance_stddev,
761 coarse_WC_CEN_bonus ) );
766 TR <<
"BASEPAIR: Adding rna_force_atom_pair constraint: " << pose.
residue(i).
name1() << I(3,i) <<
" <--> " <<
768 " CEN" <<
" <--> " <<
769 " CEN" <<
". [ " << atom1 <<
"-" << atom2 <<
"]" << std::endl;
773 coarse_CEN_distance_func ) );
776 static Real const coarse_WC_X_distance( 3.5 );
777 static Real const coarse_WC_X_distance_stddev( 2.0 );
778 static Real const coarse_WC_X_bonus( -5.0 );
779 static FuncOP const coarse_X_distance_func(
new FadeFunc( coarse_WC_X_distance - coarse_WC_X_distance_stddev,
780 coarse_WC_X_distance + coarse_WC_X_distance_stddev,
781 coarse_WC_X_distance_stddev, coarse_WC_X_bonus ) );
786 TR <<
"BASEPAIR: Adding rna_force_atom_pair constraint: " << pose.
residue(i).
name1() << I(3,i) <<
" <--> " <<
789 " X " <<
". [ " << atom1 <<
"-" << atom2 <<
"]" << std::endl;
793 coarse_X_distance_func ) );
808 using namespace core::scoring::constraints;
809 using namespace core::scoring::rna;
814 std::cout <<
"Adding CHAINBREAK constraints to " << n <<
" " << n+1 << std::endl;
816 static Real const S_P_distance_min( 3 );
817 static Real const S_P_distance_max( 4 );
818 static Real const S_P_distance_fade( 1.0 );
819 static Real const S_P_distance_bonus( -10.0 );
820 static FuncOP const S_P_distance_func(
new FadeFunc( S_P_distance_min - S_P_distance_fade,
821 S_P_distance_max + S_P_distance_fade,
823 S_P_distance_bonus ) );
826 static Real const S_P_distance( 4.0 );
827 static Real const S_P_distance_stdev( 10.0 );
829 S_P_distance_stdev ) );
832 static Real const S_S_distance_min( 4.5 );
833 static Real const S_S_distance_max( 7.5 );
834 static Real const S_S_distance_fade( 2.0 );
835 static Real const S_S_distance_bonus( -5.0 );
836 static FuncOP const S_S_distance_func(
new FadeFunc( S_S_distance_min - S_S_distance_fade,
837 S_S_distance_max + S_S_distance_fade,
839 S_S_distance_bonus ) );
841 static Real const P_P_distance_min( 4.5 );
842 static Real const P_P_distance_max( 7.5 );
843 static Real const P_P_distance_fade( 2.0 );
844 static Real const P_P_distance_bonus( -5.0 );
845 static FuncOP const P_P_distance_func(
new FadeFunc( P_P_distance_min - P_P_distance_fade,
846 P_P_distance_max + P_P_distance_fade,
848 P_P_distance_bonus ) );
858 S_P_distance_func ) );
863 S_P_harmonic_func ) );
868 P_P_distance_func ) );
873 S_S_distance_func ) );
883 Size const size = RNA_string.length();
888 for (
Size i = 0; i <
size; i++) RNA_string_local[ i ] =
'n';
893 if (RNA_string[ i ] ==
'g' || RNA_string[ i ] ==
'a' ){
894 RNA_string_local[ i ] =
'r';
896 runtime_assert( RNA_string[ i ] ==
'u' || RNA_string[ i ] ==
'c' );
897 RNA_string_local[ i ] =
'y';
903 return RNA_string_local;
910 if (char1 == char2)
return true;
911 if (char1 ==
'n' || char2 ==
'n')
return true;
912 if (char1 ==
'r' && (char2 ==
'a' || char2 ==
'g'))
return true;
913 if (char1 ==
'y' && (char2 ==
'c' || char2 ==
'u'))
return true;
914 if (char2 ==
'r' && (char1 ==
'a' || char1 ==
'g'))
return true;
915 if (char2 ==
'y' && (char1 ==
'c' || char1 ==
'u'))
return true;
922 if (char1 == char2)
return true;
923 if (char1 ==
'X' || char2 ==
'X' )
return true;
924 if (char1 ==
'L' && ( char2 ==
'N' || char2 ==
'P') )
return true;
925 if (char2 ==
'L' && ( char1 ==
'N' || char1 ==
'P') )
return true;
946 using namespace core::chemical;
947 using namespace core::id;
965 using namespace core::chemical;
966 using namespace core::id;
967 using namespace core::scoring::rna;
982 Vector base_centroid = rna_centroid_info.get_base_centroid( pose.
residue( n ) );
1003 using namespace core::chemical;
1004 using namespace core::kinematics;
1018 for (
Size n = 1; n <= num_jump; n++ ) {
1023 ObjexxFCL::FArray1D<int> cuts( num_jump-1 );
1025 for (
Size n = 1; n <= num_jump; n++ ) {
1026 if ( cutpoints[n] == static_cast<int>( i ) )
continue;
1028 cuts( count ) = cutpoints[ n ];
1034 Size jump_to_remove( 0 );
1035 for (
Size k = 1; k <= num_jump; k++ ) {
1036 FArray1D< bool > partition_definition( nres,
false );
1038 if ( partition_definition( i ) != partition_definition( i+1 ) ){
1039 jump_to_remove = k;
break;
1043 bool success(
false );
1045 ObjexxFCL::FArray2D<int> jump_point( 2, num_jump-1 );
1048 for (
Size n = 1; n <= num_jump; n++ ) {
1049 if ( n == jump_to_remove )
continue;
1051 if ( upstream_pos[ n ] < downstream_pos[ n ] ){
1052 jump_point( 1, count ) = upstream_pos[ n ];
1053 jump_point( 2, count ) = downstream_pos[ n ];
1055 jump_point( 1, count ) = downstream_pos[ n ];
1056 jump_point( 2, count ) = upstream_pos[ n ];
1066 if ( !success ) utility_exit_with_message(
"FAIL to remove cutpoint "+string_of( i ) );
1110 using namespace core::id;
1111 using numeric::conversions::degrees;
1117 std::cout <<
"----------------------------------------------------------------------" << std::endl;
1118 std::cout <<
"RESIDUE: " << rsd.
name3() <<
" " << rsd.seqpos() << std::endl;
1120 for (
Size j = 1; j <= rsd.natoms(); j++ ){
1126 if ( !(current_atom && input_stub_atom1 && input_stub_atom2 && input_stub_atom3) )
continue;
1128 if ( current_atom->is_jump() ) {
1135 std::cout <<
"JUMP! " <<
1138 "FROM " << input_stub_atom1->id().rsd() <<
" " <<
1139 pose.
residue( (input_stub_atom1->id()).rsd() ).atom_name( (input_stub_atom1->id()).atomno() ) <<
" " <<
1140 pose.
residue( (input_stub_atom2->id()).rsd() ).atom_name( (input_stub_atom2->id()).atomno() ) <<
" " <<
1141 pose.
residue( (input_stub_atom3->id()).rsd() ).atom_name( (input_stub_atom3->id()).atomno() );
1142 std::cout <<
"TO " << current_atom->id().rsd() <<
" " <<
1143 pose.
residue( (jump_stub_atom1->id()).rsd() ).atom_name( (jump_stub_atom1->id()).atomno() ) <<
" " <<
1144 pose.
residue( (jump_stub_atom2->id()).rsd() ).atom_name( (jump_stub_atom2->id()).atomno() ) <<
" " <<
1145 pose.
residue( (jump_stub_atom3->id()).rsd() ).atom_name( (jump_stub_atom3->id()).atomno() ) << std::endl;
1146 std::cout <<
" MY JUMP: " << current_atom->jump() << std::endl;
1148 kinematics::Stub const input_stub( input_stub_atom1->xyz(), input_stub_atom1->xyz(), input_stub_atom2->xyz(), input_stub_atom3->xyz());
1149 kinematics::Stub const jump_stub ( jump_stub_atom1->xyz(), jump_stub_atom1->xyz(), jump_stub_atom2->xyz(), jump_stub_atom3->xyz());
1151 std::cout <<
" MY JUMP: " <<
kinematics::Jump( input_stub, jump_stub ) << std::endl;
1155 std::cout <<
"ICOOR_INTERNAL " <<
1156 A( 5, rsd.atom_name( j )) <<
" " <<
1160 pose.
residue( (input_stub_atom1->id()).rsd() ).atom_name( (input_stub_atom1->id()).atomno() ) <<
" " <<
1161 pose.
residue( (input_stub_atom2->id()).rsd() ).atom_name( (input_stub_atom2->id()).atomno() ) <<
" " <<
1162 pose.
residue( (input_stub_atom3->id()).rsd() ).atom_name( (input_stub_atom3->id()).atomno() ) <<
" " <<
1164 " " << (input_stub_atom1->id()).rsd() <<
1165 " " << (input_stub_atom2->id()).rsd() <<
1166 " " << (input_stub_atom3->id()).rsd() <<
1194 if ( n == 1 )
return true;
1195 if ( n == f.
nres() )
return true;
1208 TR.Debug <<
"Initialize RigidBodyMover: Is last residue virtual? " << pose.
residue( pose.
total_residue() ).name3() << std::endl;
1216 TR.Debug <<
"found jump to virtual anchor at: " << n << std::endl;
1218 rigid_body_jumps.push_back( n );
1219 if ( rigid_body_jumps.size() > 1 ) {
1220 TR.Debug <<
"found moveable jump!" << std::endl;
1225 return rigid_body_jumps;
1233 bool const move_first_rigid_body ){
1236 Size const found_jumps = rigid_body_jumps.size();
1237 if ( found_jumps <= 1 )
return false;
1239 Size start = ( move_first_rigid_body ) ? 1 : 2;
1240 for (
Size n = start; n <= rigid_body_jumps.size(); n++ ) movemap.
set_jump( rigid_body_jumps[n],
true );
1250 if ( rigid_body_jumps.size() == 0 )
return;
1259 Vector const offset = anchor1 - root1;
1263 pose.
set_xyz( atom_id, pose.
xyz( atom_id ) + offset );