48 #include <basic/Tracer.hh>
53 #include <ObjexxFCL/string.functions.hh>
54 #include <ObjexxFCL/format.hh>
56 #include <ObjexxFCL/FArray1D.hh>
57 #include <ObjexxFCL/FArray2D.hh>
60 #include <utility/exit.hh>
81 static basic::Tracer
TR(
"protocols.swa.rna_stepwise_rna_CombineLongLoopFilterer") ;
89 StepWiseRNA_CombineLongLoopFilterer::StepWiseRNA_CombineLongLoopFilterer(
StepWiseRNA_JobParametersCOP const & job_parameters,
bool const combine_helical_silent_file):
90 rsd_set_( core::chemical::
ChemicalManager::get_instance()->residue_type_set( core::chemical::
RNA ) ),
91 job_parameters_( job_parameters ),
93 filter_for_previous_contact_(false),
94 filter_for_previous_clash_(false),
95 undercount_ribose_rotamers_(false),
96 filter_for_chain_closable_(true),
97 filter_for_moving_res_contact_(true),
98 moving_res_to_base_contact_only_(true),
99 total_input_struct_pair_(0),
100 pass_screen_struct_pair_(0),
101 output_filename_(
"filter_struct.txt"),
104 best_combine_score_(999999.99),
105 worst_combine_score_(-999999.99),
107 contact_dist_cutoff_(-1.0),
108 clash_dist_cutoff_(0.8),
112 num_contact_cutoff_(1),
113 num_clash_cutoff_(1),
114 max_pose_data_list_size_(200),
115 side_ONE_NUM_pose_list_(0),
116 side_TWO_NUM_pose_list_(0),
117 side_ONE_pose_list_id_(1),
118 side_TWO_pose_list_id_(1),
121 combine_helical_silent_file_(combine_helical_silent_file)
128 if(input_res_vectors.size()!=2) utility_exit_with_message(
"input_res_vectors.size()!=2");
173 for(
Size n=1; n<=input_res_vectors[1].size(); n++){
175 Size const seq_num=input_res_vectors[1][n];
178 common_res_list.push_back(seq_num);
186 for(
Size n=1; n<=input_res_vectors[1].size(); n++){
187 Size const seq_num=input_res_vectors[1][n];
190 full_pose_appended_res_list.push_back(seq_num);
200 for(
Size n=1; n<=input_res_vectors[2].size(); n++){
201 Size const seq_num=input_res_vectors[2][n];
204 full_pose_prepended_res_list.push_back(seq_num);
262 std::cout <<
" full_pose_last_prepended_res_= " << full_last_prepended_res <<
" input_pose_TWO_last_prepended_res_= " <<
input_pose_TWO_last_prepended_res_ << std::endl;
309 using namespace core::pose;
310 using namespace ObjexxFCL;
332 Size num_struct_in_range=0;
334 silent_file_stream->reset();
336 while ( silent_file_stream->has_another_pose() ) {
342 if( (pose_ID < min_pose_ID) || (pose_ID>max_pose_ID) )
continue;
344 num_struct_in_range++;
348 silent_struct->fill_pose( *pose_op,*(
rsd_set_) );
353 std::string const & tag( silent_struct->decoy_tag() );
356 utility_exit_with_message(
"tag= " + tag +
" is messed up!");
361 pose_data.
score=score;
364 pose_data_list.push_back(pose_data);
369 if(num_struct_in_range==0) utility_exit_with_message(
"num_struct_in_range==0! for pose_list_id= " + string_of(pose_list_id) +
" min_pose_ID= " + string_of(min_pose_ID)+
" max_pose_ID= " + string_of(max_pose_ID) );
376 return pose_data_list;
384 using namespace chemical;
388 if(side_ONE_pose_data_list.size()==0) utility_exit_with_message(
"side_ONE_pose_data_list.size()==0" );
389 if(side_TWO_pose_data_list.size()==0) utility_exit_with_message(
"side_TWO_pose_data_list.size()==0" );
392 core::pose::Pose const alignment_pose=(*side_ONE_pose_data_list[1].pose_OP);
395 for(
Size n=1; n<=side_ONE_pose_data_list.size(); n++){
412 for(
Size n=1; n<=side_TWO_pose_data_list.size(); n++){
455 bool const residues_in_contact=
Is_residues_in_contact(input_pose_ONE_appended_res, side_ONE_pose, input_pose_TWO_prepended_res, side_TWO_pose, overlap_dist_cutoff, num_atom_contacts_cutoff);
457 if(residues_in_contact)
return false;
545 utility_exit_with_message(
"enforce_contact_rsd.type().atom_name(enforce_contact_rsd.first_sidechain_atom()) !=\" O2*\" " );
554 Real const atom_atom_dist_squared=(enforce_contact_rsd.
xyz(
at)-anchor_atom_xyz).length_squared();
568 using namespace ObjexxFCL;
578 if(previous_step_gap_size==0) utility_exit_with_message(
"previous_step_gap_size==0!!" );
585 Real const curr_combine_score=side_ONE_pose_data.
score + side_TWO_pose_data.
score;
643 using namespace ObjexxFCL;
654 if(side_ONE_pose_data_list.size()==0)
return;
655 if(side_TWO_pose_data_list.size()==0)
return;
662 for(
Size i=1; i<=side_ONE_pose_data_list.size(); i++){
663 for(
Size j=1; j<=side_TWO_pose_data_list.size(); j++){
671 if(
pass_all_filters(side_ONE_pose_data, side_TWO_pose_data)==
false)
continue;
674 Real const curr_combine_score=side_ONE_pose_data.
score + side_TWO_pose_data.
score;
689 std::cout <<
"struct pair: (" << side_ONE_pose_data.
tag <<
" ," << side_TWO_pose_data.
tag <<
") pass screening test. ";
706 Output_title_text(
"Exit StepWiseRNA_CombineLongLoopFilterer::do_some_filtering");
721 Size total_pose_side_ONE=0;
724 total_pose_side_ONE++;
728 Size total_pose_side_TWO=0;
731 total_pose_side_TWO++;
763 std::cout <<
"total_pose_side_ONE= " << total_pose_side_ONE <<
" side_ONE_NUM_pose_list_= " <<
side_ONE_NUM_pose_list_<< std::endl;
764 std::cout <<
"total_pose_side_TWO= " << total_pose_side_TWO <<
" side_TWO_NUM_pose_list_= " <<
side_TWO_NUM_pose_list_<< std::endl;
780 std::cout <<
"silent_file_stream_ONE_ parent_remarks" << std::endl;
785 std::string const & tag( silent_struct->decoy_tag() );
787 if(
tag_to_source_map_TWO_.count(tag)!=0) utility_exit_with_message(
"tag " + tag +
" already exist in tag_to_source_map_TWO_" );
789 if(silent_struct->has_parent_remark(
"SOURCE")==
false){
795 std::string const source_file=silent_struct->get_parent_remark(
"SOURCE");
801 std::cout <<
"--------------------------------" << std::endl;
803 std::cout <<
"silent_file_stream_TWO_ parent_remarks" << std::endl;
808 std::string const & tag( silent_struct->decoy_tag() );
810 if(
tag_to_source_map_TWO_.count(tag)!=0) utility_exit_with_message(
"tag " + tag +
" already exist in tag_to_source_map_TWO_" );
812 if(silent_struct->has_parent_remark(
"SOURCE")==
false){
818 std::string const source_file=silent_struct->get_parent_remark(
"SOURCE");
826 std::cout <<
"--------------------------------" << std::endl;
842 using namespace ObjexxFCL;
876 sort(combine_tags_info_list.begin(), combine_tags_info_list.end(),
score_sort_citeria);
884 if(tag_token.size()<2) utility_exit_with_message(
"tag_token.size()<2");
886 return (tag_token[1] +
"_" + tag_token[2]);
894 if(tag_token.size()>=5){
897 if(tag_token[3]!=
"sample") utility_exit_with_message(
"tag_token[3]!=\"sample\" for tag= " + tag);
899 if(tag_token[4]!=
"ribose") utility_exit_with_message(
"tag_token[4]!=\"ribose\" for tag= " + tag);
903 }
else if(tag_token.size()==2){
907 utility_exit_with_message(
"tag_token.size()!=5 and tag_token.size()!=2 for tag= " + tag);
916 std::map< std::string , std::string >
const & tag_to_source_map)
const{
930 if(prev_parent_tag!=curr_parent_tag)
return false;
934 if(curr_tag_is_virt_sample_ribose!=prev_tag_is_virt_sample_ribose){
935 utility_exit_with_message(
"curr_tag_is_virt_sample_ribose!=prev_tag_is_virt_sample_ribose");
938 if(tag_to_source_map.count(curr_tag)==0){
939 utility_exit_with_message(
"tag " + curr_tag +
" doesn't exist in tag_to_source_map" );
942 if(tag_to_source_map.count(prev_tag)==0){
943 utility_exit_with_message(
"tag " + prev_tag +
" doesn't exist in tag_to_source_map" );
946 std::string const curr_source_file = tag_to_source_map.find(curr_tag)->second;
947 std::string const prev_source_file = tag_to_source_map.find(prev_tag)->second;
950 if(curr_source_file!=prev_source_file) utility_exit_with_message(
"curr_source_file!=prev_source_file");
964 using namespace ObjexxFCL;
966 clock_t
const time_start( clock() );
978 std::cout <<
"max_decoys_(nstruct)= " <<
max_decoys_ << std::endl;
1004 std::cout <<
"CombineLongLoopFilterer COUNTS (BEFORE FINAL SCORE SCREENING)" << std::endl;
1014 std::cout << std::endl;
1018 std::cout <<
"StepWiseRNA_CombineLongLoopFilterer::apply: " <<
static_cast<Real>( clock() - time_start ) / CLOCKS_PER_SEC << std::endl;
1021 utility_exit_with_message(
" (filterered_combine_tag_info_list_.size() ) != pass_screen_struct_pair_");
1024 std::ofstream outfile;
1027 Size pass_screen_struct_pair_ACT=0;
1028 Size pass_screen_struct_pair_undercount_ribose_rotamers=0;
1036 clock_t
const time_start_FINAL_output( clock() );
1046 bool match_existing_pair=
false;
1048 for(
Size ii=(n-1); ii>=1; ii--){
1056 std::cout <<
"tag_pair: ";
1059 std::cout <<
" is a sibling of prev_tag_pair: ";
1062 std::cout << std::endl;
1064 match_existing_pair=
true;
1071 if(match_existing_pair==
false) pass_screen_struct_pair_undercount_ribose_rotamers++;
1075 pass_screen_struct_pair_ACT++;
1081 outfile << std::setw(15) <<
std::left << pass_screen_struct_pair_ACT;
1084 bool max_decoys_reached=
false;
1087 if(pass_screen_struct_pair_undercount_ribose_rotamers>=
max_decoys_) max_decoys_reached=
true;
1089 if(pass_screen_struct_pair_ACT>=
max_decoys_) max_decoys_reached=
true;
1092 if(max_decoys_reached){
1093 std::cout <<
" max_decoys_ (" <<
max_decoys_ <<
"), early break! " << std::endl;
1099 if(pass_screen_struct_pair_ACT==0){
1100 outfile <<
"Empty filterer_outfile. No struct_pair passed screen.\n";
1106 std::cout <<
"CombineLongLoopFilterer COUNTS (AFTER FINAL SCORE SCREENING)" << std::endl;
1107 std::cout <<
"pass_screen_struct_pair_ACT= " << pass_screen_struct_pair_ACT << std::endl;
1108 std::cout <<
"pass_screen_struct_pair_undercount_ribose_rotamers= " << pass_screen_struct_pair_undercount_ribose_rotamers << std::endl;
1109 std::cout <<
"StepWiseRNA_CombineLongLoopFilterer::final_output: " <<
static_cast<Real>( clock() - time_start_FINAL_output ) / CLOCKS_PER_SEC << std::endl;
1110 std::cout <<
"StepWiseRNA_CombineLongLoopFilterer::apply: " <<
static_cast<Real>( clock() - time_start ) / CLOCKS_PER_SEC << std::endl;