39 #include <basic/Tracer.hh>
44 #include <ObjexxFCL/string.functions.hh>
45 #include <ObjexxFCL/format.hh>
47 #include <ObjexxFCL/FArray1D.hh>
48 #include <ObjexxFCL/FArray2D.hh>
53 #include <utility/exit.hh>
70 static basic::Tracer
TR(
"protocols.swa.rna.stepwise_rna_pose_setup" ) ;
79 rsd_set_( core::chemical::
ChemicalManager::get_instance()->residue_type_set( core::chemical::
RNA ) ),
80 job_parameters_( job_parameters ),
83 rebuild_bulge_mode_(false),
85 apply_virtual_res_variant_at_dinucleotide_(true),
86 align_to_native_( false )
99 return "StepWiseRNA_PoseSetup";
107 using namespace ObjexxFCL;
118 std::cout <<
"read_input_pose_and_copy_dofs( pose_without_cutpoints )" << std::endl;
123 std::cout <<
"read_input_pose_and_copy_dofs( pose )" << std::endl;
127 pose_without_cutpoints=pose;
154 using namespace core::conformation;
155 using namespace core::pose;
156 using namespace protocols::rna;
178 std::cout <<
"User passed in full length native pose" << std::endl;
180 (*working_native_pose)=native_pose_copy;
182 for(
Size seq_num = native_pose_copy.total_residue(); seq_num >= 1 ; seq_num--){
183 if (!is_working_res[ seq_num ] ){
188 }
else if( native_pose_copy.sequence() == working_sequence){
189 std::cout <<
"User passed in working native pose" << std::endl;
190 (*working_native_pose)=native_pose_copy;
192 std::cout << std::setw(50) <<
" native_pose_copy.sequence() = " << native_pose_copy.sequence() << std::endl;
193 std::cout << std::setw(50) <<
" job_parameters_->full_sequence()= " <<
job_parameters_->full_sequence() << std::endl;
194 std::cout << std::setw(50) <<
" working_sequence= " << working_sequence << std::endl;
195 utility_exit_with_message(
"The native pose passed in by the User does not match both the full_sequence and the working sequence of the inputted fasta_file" );
198 if(working_native_pose->sequence() != working_sequence ){
199 std::cout << std::setw(50) <<
"working_native_pose->sequence()= " << working_native_pose->sequence();
200 std::cout << std::setw(50) <<
"working_sequence= " << working_sequence << std::endl;
201 utility_exit_with_message(
"working_native_pose->sequence() != working_sequence" );
209 act_working_alignment.clear();
213 if(working_native_alignment.size()!=0){
214 std::cout <<
"working_native_alignment.size()!=0!, align native_pose with working_native_alignment!" << std::endl;
216 for(
Size n=1; n<=working_native_alignment.size(); n++){
217 Size const seq_num=working_native_alignment[n];
220 act_working_alignment.push_back(seq_num);
225 std::cout <<
"working_native_alignment.size()==0!, align native_pose with working_best_alignment!" << std::endl;
227 for(
Size n=1; n<=working_best_alignment.size(); n++){
228 Size const seq_num=working_best_alignment[n];
231 act_working_alignment.push_back(seq_num);
242 if(act_working_alignment.size()==0) utility_exit_with_message(
"act_working_alignment.size()==0");
255 (*working_native_pose).fold_tree( pose.
fold_tree() );
256 align_poses( pose,
"working_pose", (*working_native_pose),
"working_native_pose", act_working_alignment);
260 align_poses( pose,
"working_pose", (*working_native_pose),
"working_native_pose", act_working_alignment);
263 align_poses( (*working_native_pose),
"working_native_pose" , pose,
"working_pose", act_working_alignment);
274 if(
output_pdb_) working_native_pose->dump_pdb(
"working_native_pose.pdb" );
278 for(
Size n=1; n<=working_native_virtual_res_list_.size(); n++){
284 if(
output_pdb_) working_native_pose->dump_pdb(
"working_native_pose_with_virtual_res_variant_type.pdb" );
297 using namespace core::conformation;
300 if ( i >
input_tags_.size()) utility_exit_with_message(
"i > input_tags_.size()!" );
301 if (
copy_DOF_==
false) utility_exit_with_message(
"copy_DOF_==false!" );
307 std::size_t found=pose_name.find(
".pdb");
308 if (found==std::string::npos) {
309 pose_name.append(
".pdb");
328 std::cout <<
"import_pose.total_residue()= " << import_pose.
total_residue() <<
" input_res.size()= " << input_res.size() << std::endl;
329 utility_exit_with_message(
"input pose does not have same # residues as input res" );
333 if ( import_pose.
sequence()[ n-1 ] != full_sequence[ input_res[n] - 1 ] ) {
334 match =
false;
break;
337 if (!match) utility_exit_with_message(
"mismatch in sequence between input pose and desired sequence, given input_res " );
344 using namespace core::conformation;
354 std::cout <<
"outputting extended_chain.pdb" << std::endl;
355 pose.
dump_pdb(
"extended_chain.pdb" );
368 if (
input_tags_.size() < 1) utility_exit_with_message(
"input_tags_.size() < 1" );
370 if (
copy_DOF_==
false) utility_exit_with_message(
"copy_DOF_==false!" );
372 using namespace core::pose;
373 using namespace ObjexxFCL;
375 std::map< core::Size, core::Size > & full_to_sub(
job_parameters_->full_to_sub() );
380 Pose start_pose_with_variant;
383 std::cout <<
"import_pose " << i << std::endl;
387 if(input_res_vectors[i].
size()!=1) utility_exit_with_message(
"input_tags_[i]==\"build_from_scratch\" but input_res_vectors[i].size()!=1" );
392 start_pose_with_variant=start_pose;
393 start_pose_list.push_back(start_pose);
405 variant_type_list.push_back(
"VIRTUAL_PHOSPHATE");
406 variant_type_list.push_back(
"VIRTUAL_O2STAR_HYDROGEN");
407 variant_type_list.push_back(
"CUTPOINT_LOWER");
408 variant_type_list.push_back(
"CUTPOINT_UPPER");
409 variant_type_list.push_back(
"VIRTUAL_RNA_RESIDUE");
410 variant_type_list.push_back(
"VIRTUAL_RNA_RESIDUE_UPPER");
411 variant_type_list.push_back(
"BULGE");
412 variant_type_list.push_back(
"VIRTUAL_RIBOSE");
413 variant_type_list.push_back(
"PROTONATED_H1_ADENOSINE");
414 variant_type_list.push_back(
"3PRIME_END_OH");
415 variant_type_list.push_back(
"5PRIME_END_PHOSPHATE");
416 variant_type_list.push_back(
"5PRIME_END_OH");
418 for (
Size seq_num = 1; seq_num <= start_pose.total_residue(); seq_num++ ) {
419 for (
Size k = 1; k <= variant_type_list.size(); ++k ) {
420 std::string const & variant_type = variant_type_list[k];
422 if( start_pose.residue(seq_num).has_variant_type(variant_type) ) {
430 start_pose.dump_pdb(
"import_" + string_of(i) +
".pdb" );
431 start_pose_with_variant.dump_pdb(
"import_orig_" + string_of(i) +
".pdb" );
437 if ( input_res.size() != start_pose.total_residue() ) {
438 utility_exit_with_message(
"Need to specify -already_built_residues, and the number of residues needs to match pdb file inputted after -s" );
441 std::map< core::Size, core::Size > res_map;
442 for (
Size n = 1; n <= input_res.size(); n++ ) {
443 res_map[ full_to_sub[ input_res[n] ] ] = n;
461 for (
Size n = 1; n <= start_pose_with_variant.total_residue(); n++ ) {
466 if(start_pose_with_variant.residue(n).has_variant_type(
"VIRTUAL_RIBOSE")){
470 if ( start_pose_with_variant.residue(n).has_variant_type(
"3PRIME_END_OH") ) {
472 }
else if ( start_pose_with_variant.residue(n).has_variant_type(
"5PRIME_END_PHOSPHATE") ) {
474 }
else if ( start_pose_with_variant.residue(n).has_variant_type(
"5PRIME_END_OH") ) {
482 if ( start_pose_with_variant.residue(n).has_variant_type(
"PROTONATED_H1_ADENOSINE") ) {
484 utility_exit_with_message(
"start_pose have PROTONATED_H1_ADENOSINE variant type at full_seq_num=" + ObjexxFCL::string_of(input_res[n]) +
" even though it was read in from PDB file!");
493 if( start_pose_with_variant.residue(n).has_variant_type(
"PROTONATED_H1_ADENOSINE") ) {
496 utility_exit_with_message(
"start_pose have PROTONATED_H1_ADENOSINE variant type at full_seq_num=" + ObjexxFCL::string_of(input_res[n]) +
" but rsd.aa()!=core::chemical::na_rad!");
501 utility_exit_with_message(
"full_seq_num=" + ObjexxFCL::string_of(input_res[n]) +
" is have a PROTONATED_H1_ADENOSINE variant type in the start_pose but is not in the protonate_H1_adenosine_list");
512 std::cout << pose.
fold_tree() << std::endl;
526 using namespace ObjexxFCL;
527 using namespace core::conformation;
528 using namespace core::id;
532 if(
output_pdb_) working_pose.
dump_pdb(
"copy_dof_pose_BEFORE_correctly_copy_HO2star_positions.pdb" );
534 std::map< core::Size, core::Size > & full_to_sub(
job_parameters_->full_to_sub() );
547 if(input_res_vectors.size()!=2)
return;
553 for(
Size n=1; n<=input_res_vectors[1].size(); n++){
554 Size const seq_num=input_res_vectors[1][n];
556 common_res_list.push_back(seq_num);
566 if(common_res_list.size()==0) {
571 for(
Size n=1; n<=common_res_list.size(); n++){
572 Size const full_seq_num=common_res_list[n];
573 Size const working_seq_num=full_to_sub[full_seq_num];
575 Size const input_ONE_seq_num=full_to_input_res_map_ONE.find(full_seq_num)->second;
579 Size const input_TWO_seq_num=full_to_input_res_map_TWO.find(full_seq_num)->second;
587 if(
verbose_) std::cout <<
"full_seq_num= " << full_seq_num <<
" nearest_dist_ONE= " << nearest_dist_ONE <<
" nearest_dist_TWO= " << nearest_dist_TWO;
589 if(nearest_dist_ONE < nearest_dist_TWO){
591 std::cout <<
" NEARER TO INPUT_POSE_ONE " ;
594 std::cout <<
" NEARER TO INPUT_POSE_TWO " ;
597 std::cout << std::endl;
601 if(
output_pdb_) working_pose.
dump_pdb(
"copy_dof_pose_AFTER_correctly_copy_HO2star_positions.pdb" );
610 using namespace core::conformation;
611 using namespace ObjexxFCL;
615 Real nearest_dist_SQ=99999999.9;
619 if ( !input_pose_O2star_rsd.has(
" O2*" ) ) utility_exit_with_message(
"rsd at input_seq_num= " + string_of(O2star_seq_num) +
" doesn't have O2* atom! " );
624 for(
Size input_pose_seq_num=1; input_pose_seq_num<=input_res_list.size(); input_pose_seq_num++){
625 Size const full_seq_num=input_res_list[input_pose_seq_num];
633 Real const dist_to_o2star_SQ=(input_pose_rsd.
xyz(
at)-O2star_xyz).length_squared();
634 if(dist_to_o2star_SQ < nearest_dist_SQ ) nearest_dist_SQ=dist_to_o2star_SQ;
641 Real const nearest_dist= sqrt(nearest_dist_SQ);
652 using namespace core::id;
655 std::map< core::Size, core::Size > & full_to_sub(
job_parameters_->full_to_sub() );
658 for(
Size n=1; n<=cutpoint_closed_list.size(); n++){
660 Size const cutpoint_closed=cutpoint_closed_list[n];
662 if ( cutpoint_closed == 0 )
continue;
664 if ( full_to_sub.find( cutpoint_closed ) != full_to_sub.end() && full_to_sub.find( cutpoint_closed+1 ) != full_to_sub.end() ) {
666 std::cout <<
"Applying cutpoint variants to " << cutpoint_closed << std::endl;
668 Size const cutpos = full_to_sub[ cutpoint_closed];
678 std::cout <<
"pose (before copy): " << std::endl;
682 for (
Size i = cutpos; i <= cutpos + 1; i++ ){
690 std::cout <<
"pose_without_cutpoints " << std::endl;
693 std::cout <<
"pose: " << std::endl;
720 utility_exit_with_message(
"User provided cutpoint_closed not in working pose?" );
735 using namespace ObjexxFCL;
738 std::map< core::Size, core::Size > & full_to_sub(
job_parameters_->full_to_sub() );
741 Size const num_chains = chain_boundaries.size();
743 for (
Size n = 1; n <= num_chains; n++ ) {
744 Size const chain_start = chain_boundaries[ n ].first;
746 bool chain_start_is_cutpoint_closed=
false;
748 for(
Size i=1; i <= cutpoint_closed_list.size(); i++){
749 Size const cutpoint_closed=cutpoint_closed_list[i];
751 if ( cutpoint_closed > 0 && full_to_sub[ chain_start ] == full_to_sub[ cutpoint_closed ]+1 ) {
752 chain_start_is_cutpoint_closed=
true;
756 if(chain_start_is_cutpoint_closed)
continue;
759 utility_exit_with_message(
"Should not be trying to virtualize phosphate on close cutpoint residue (chain_start= " + string_of(chain_start) +
" )");
770 using namespace core::conformation;
771 using namespace core::id;
772 using namespace core::scoring::constraints;
773 using namespace core::scoring::rna;
780 if ( working_terminal_res.size() == 0 )
return;
786 ObjexxFCL::FArray1D<bool> is_moving_res( nres,
false );
787 ObjexxFCL::FArray1D<bool> is_fixed_res( nres,
false );
789 ObjexxFCL::FArray1D< bool >
const & partition_definition =
job_parameters_->partition_definition();
790 bool const root_partition = partition_definition( pose.
fold_tree().
root() );
792 for (
Size seq_num=1; seq_num <= nres; seq_num++){
793 if ( partition_definition( seq_num ) == root_partition ) {
794 is_fixed_res( seq_num ) =
true;
796 is_moving_res( seq_num ) =
true;
803 FuncOP const repulsion_func(
new FadeFunc( -2.0 , DIST_CUTOFF , 1.0 , 100.0 ) );
805 for (
Size i = 1; i <= working_terminal_res.size(); i++ ) {
807 Size const k = working_terminal_res[ i ];
809 if(rsd1.has_variant_type(
"VIRTUAL_RNA_RESIDUE")){
810 std::cout <<
"rsd1.has_variant_type(\"VIRTUAL_RNA_RESIDUE\"), seq_num= " << k <<
" Ignore terminal_res_repulsion distance constraint " << std::endl;
813 for (
Size m = 1; m <= nres; m++ ) {
816 if(rsd2.has_variant_type(
"VIRTUAL_RNA_RESIDUE")){
817 std::cout <<
"rsd2.has_variant_type(\"VIRTUAL_RNA_RESIDUE\"), seq_num= " << m <<
" Ignore terminal_res_repulsion distance constraint " << std::endl;
825 if ( ( ( is_moving_res( k ) && is_moving_res( m ) ) ||
826 ( is_fixed_res( k ) && is_fixed_res( m ) ) ) &&
827 ( pose.
xyz( atom_id1 ) - pose.
xyz( atom_id2 ) ).length() < DIST_CUTOFF ) {
833 cst_set->add_constraint(
new AtomPairConstraint( atom_id1, atom_id2, repulsion_func ) );
855 bool apply_check=
true;
860 std::cout <<
"rebuild_bulge_mode_=true, setting apply_check for apply_protonated_H1_adenosine_variant_type to false" << std::endl;
863 if(
Contain_seq_num(working_moving_res, working_protonated_H1_adenosine_list ) ){
873 using namespace core::conformation;
874 using namespace core::pose;
875 using namespace ObjexxFCL;
887 utility_exit_with_message(
"Contain_seq_num(seq_num, working_protonated_H1_adenosine_list )==true but pose.residue(seq_num).aa() != core::chemical::na_rad, seq_num= " + string_of(seq_num) );
892 utility_exit_with_message(
"Contain_seq_num(seq_num, working_protonated_H1_adenosine_list )==true but residue doesn't either PROTONATED_H1_ADENOSINE or VIRTUAL_RNA_RESIDUE variant type , seq_num=" + string_of(seq_num) );
898 std::cout <<
"ERROR: seq_num=" << seq_num << std::endl;
899 std::cout <<
"ERROR: start_pose.residue(n).aa()=" <<
name_from_aa(pose.
residue(seq_num).
aa()) << std::endl;
900 utility_exit_with_message(
"Contain_seq_num(seq_num, working_protonated_H1_adenosine_list)==false but pose.residue(seq_num).has_variant_type(\"PROTONATED_H1_ADENOSINE\") )==false");
913 using namespace core::conformation;
914 using namespace core::pose;
915 using namespace ObjexxFCL;
918 std::map< core::Size, core::Size > & full_to_sub(
job_parameters_->full_to_sub() );
926 if(
Contain_seq_num(seq_num, terminal_res) ==
true) utility_exit_with_message(
"seq_num: " + string_of(seq_num) +
" cannot be both both a bulge_res and a terminal res!");
928 if(full_to_sub.find( seq_num ) == full_to_sub.end() )
continue;
940 using namespace core::id;
941 using namespace ObjexxFCL;
944 std::map< core::Size, core::Size > & full_to_sub(
job_parameters_->full_to_sub() );
952 Size const working_bulge_moving_res= (Is_prepend) ? working_moving_res+1 : working_moving_res-1;
954 bool const Is_dinucleotide=(
job_parameters_->working_moving_res_list().size()==2);
957 if(working_bulge_moving_res!=
job_parameters_->working_moving_res_list()[2]){
959 std::cout <<
" working_moving_res= " << working_moving_res << std::endl;
960 std::cout <<
"working_bulge_moving_res= " << working_bulge_moving_res <<
" working_moving_res_list()[2]= " <<
job_parameters_->working_moving_res_list()[2] << std::endl;
961 utility_exit_with_message(
"working_bulge_moving_res!=working_moving_res_list[2]" );
964 if(
Contain_seq_num(working_bulge_moving_res, working_terminal_res ) ==
true){
965 utility_exit_with_message(
"working_bulge_moving_res cannot be both both a virtual_res and a terminal res!");
976 if(
Contain_seq_num(seq_num, terminal_res) ==
true) utility_exit_with_message(
"seq_num: " + string_of(seq_num) +
" cannot be both both a virtual_res and a terminal res!");
978 if(full_to_sub.find( seq_num ) == full_to_sub.end() )
continue;
996 TR.Warning <<
"addVirtualResAsRoot() called but pose is already rooted on a VRT residue ... continuing." << std::endl;
1003 if (working_moving_res == 1) {