33 #include <basic/options/option.hh>
35 #include <basic/options/keys/packing.OptionKeys.gen.hh>
36 #include <basic/options/keys/match.OptionKeys.gen.hh>
43 #include <basic/Tracer.hh>
46 #include <numeric/constants.hh>
47 #include <numeric/xyz.functions.hh>
50 #include <utility/string_util.hh>
51 #include <utility/io/izstream.hh>
56 #include <utility/vector1.hh>
62 static basic::Tracer
TR(
"protocols.match.MatcherTask" );
65 enumerate_ligand_rotamers_( false ),
66 only_enumerate_non_match_redundant_ligand_rotamers_( false ),
67 ignore_cmdline_for_build_points_(false),
68 share_build_points_for_geomcsts_( true ),
69 gridlig_active_site_definition_( false ),
71 euclidean_bin_widths_( 1.0 ),
72 euler_bin_widths_( 10.0 ),
73 permitted_overlap_( 0.0 ),
74 use_input_sc_( false ),
75 dynamic_grid_refinement_( false ),
76 consolidate_matches_( true ),
77 n_to_output_per_group_( 5 ),
78 grouper_name_(
"SameChiBinComboGrouper" ),
79 evaluator_name_(
"DownstreamRMSEvaluator" ),
80 output_writer_name_(
"PDB" ),
81 output_file_name_(
"output_matches.kin" ),
82 grouper_ds_rmsd_(1.5),
83 output_matchres_only_(true),
84 filter_upstream_residue_collisions_( false ),
85 filter_upstream_collisions_by_score_( false ),
86 upstream_residue_collision_tolerance_( 1.0 ),
87 upstream_residue_collision_score_cutoff_( 1.0 ),
88 upstream_residue_collision_Wfa_atr_( 1.0 ),
89 upstream_residue_collision_Wfa_rep_( 1.0 ),
90 upstream_residue_collision_Wfa_sol_( 1.0 ),
91 filter_upstream_and_downstream_residue_collisions_( false ),
92 filter_upstream_and_downstream_collisions_by_score_( false ),
93 upstream_downstream_atom_collision_tolerance_( 1.0 ),
94 upstream_downstream_residue_collision_score_cutoff_( 1.0 ),
95 upstream_downstream_residue_collision_Wfa_atr_( 1.0 ),
96 upstream_downstream_residue_collision_Wfa_rep_( 1.0 ),
97 upstream_downstream_residue_collision_Wfa_sol_( 1.0 ),
98 define_match_by_single_downstream_positioning_( false )
110 if (
this != & rhs ) {
247 std::map< std::string, utility::vector1< std::string > >
const & alg_map = (*(
enz_input_data_->mcfi_list( i )->mcfi( 1 ))).algorithm_inputs();
248 std::map< std::string, utility::vector1< std::string > >::const_iterator map_it( alg_map.find(
"match_positions" ) );
249 if( map_it == alg_map.end() )
continue;
252 if( switch_to_per_cst_resids_necessary ){
254 switch_to_per_cst_resids_necessary =
false;
260 for(
core::Size mpm_string =1; mpm_string <= map_it->second.size(); ++mpm_string ){
262 tokens.push_back(
"");
265 if( !mpm ) utility_exit_with_message(
"Could not create a MatchPositionModifier based on name "+tokens[1]+
".");
269 TR <<
"Match position modifiers changed match positions for geomcst " << i <<
" to the following: " << std::endl;
290 Size n_geometric_constraints
314 TR <<
"overriding res/radius active site definition by setting gridlig file " << file_name << std::endl;
333 TR <<
"overriding gridlig_active_site_definition_ by appending res/radius pair: " << resid <<
" " << radius << std::endl;
375 using namespace basic::options;
588 std::map< core::Size, core::Size >
const &
608 std::list< std::pair< MatcherTask::Size, MatcherTask::Real > >
const &
615 std::list< core::id::AtomID >
const &
676 std::list< std::string >
const &
874 using namespace basic::options;
877 if ( option[ grid_boundary ].user() ) {
880 utility::io::izstream istr( filename.c_str() );
882 istr >> name >> liggrid;
883 runtime_assert( name ==
"NAME:" || name ==
"@NAME:" );
884 runtime_assert( liggrid ==
"gridlig" );
886 Real xbase( 0.0 ), ybase( 0.0 ), zbase( 0.0 );
888 runtime_assert( base ==
"BASE:" );
889 istr >> xbase; runtime_assert( ! istr.bad() );
890 istr >> ybase; runtime_assert( ! istr.bad() );
891 istr >> zbase; runtime_assert( ! istr.bad() );
895 runtime_assert( size ==
"SIZE:" );
896 Size xsize( 0 ), ysize( 0 ), zsize( 0 );
897 istr >> xsize; runtime_assert( ! istr.bad() );
898 istr >> ysize; runtime_assert( ! istr.bad() );
899 istr >> zsize; runtime_assert( ! istr.bad() );
901 runtime_assert( xsize != 0 );
902 runtime_assert( ysize != 0 );
903 runtime_assert( zsize != 0 );
907 runtime_assert( length ==
"LENGTH:");
908 Real xwidth( 0.0 ), ywidth( 0.0 ), zwidth( 0.0 );
910 istr >> xwidth; runtime_assert( ! istr.bad() );
911 istr >> ywidth; runtime_assert( ! istr.bad() );
912 istr >> zwidth; runtime_assert( ! istr.bad() );
914 runtime_assert( xwidth != 0 );
915 runtime_assert( ywidth != 0 );
916 runtime_assert( zwidth != 0 );
918 Vector lower_corner( xbase, ybase, zbase );
919 Vector upper_corner( lower_corner );
920 upper_corner.x() += xwidth * xsize;
921 upper_corner.y() += ywidth * ysize;
922 upper_corner.z() += zwidth * zsize;
927 if( !
upstream_pose_ ) utility_exit_with_message(
"Grid boundary defintion file must be specified with the -match::grid_boundary <filename> flag, or the upstram_pose_ must be set in the MatcherTask." );
929 TR <<
"WARNING WARNING WARNING: no grid file specified for option -grid_boundary. The bounding grid will be generated from the dimensions of the pose. This is experimental at the moment." << std::endl;
934 Real highx(lowx), highy(lowy), highz(lowz);
939 if( !cur_res.is_protein() )
continue;
942 for(
Size j =1; j <= bb_atoms.size(); ++j){
943 Real curx( cur_res.xyz( bb_atoms[j] ).x() ), cury( cur_res.xyz( bb_atoms[j] ).y() ), curz( cur_res.xyz( bb_atoms[j] ).z() );
945 if( curx < lowx ) lowx = curx;
946 else if( curx > highx ) highx = curx;
947 if( cury < lowy ) lowy = cury;
948 else if( cury > highy ) highy = cury;
949 if( curz < lowz ) lowz = curz;
950 else if( curz > highz ) highz = curz;
957 Vector lower_corner( lowx , lowy, lowz );
958 Vector upper_corner( highx, highy, highz );
959 TR <<
"Bounding box lower corner set to (" << lower_corner.x() <<
"," << lower_corner.y() <<
"," << lower_corner.z() <<
"), upper corner set to to (" << upper_corner.x() <<
"," << upper_corner.y() <<
"," << upper_corner.z() <<
")." << std::endl;
970 using namespace basic::options;
974 utility_exit_with_message(
"Scaffold build point defintion file must be specified with either "
975 "the -match::scaffold_active_site_residues <filename> flag\n"
976 "or the -match::scaffold_active_site_residues_for_geomcsts <filename> flag" );
984 if( scaf_seqpos.num_seqpos_lists() == 0 ) utility_exit_with_message(
"Apparently match positions couldn't get read from file...");
986 else if( scaf_seqpos.num_seqpos_lists() == 1 ){
989 for(
core::Size i = 1; i <= scaf_seqpos.seqpos_for_geomcst( 1 ).size(); ++i ){
990 if( scaf_seqpos.seqpos_for_geomcst( 1 )[i] <=
upstream_pose_->total_residue() ){
993 else std::cerr <<
"Warning: seqpos number " << scaf_seqpos.seqpos_for_geomcst( 1 )[i] <<
" is larger than size of pose, ignoring. Check if you're using the right match posfile.";
998 if( scaf_seqpos.num_seqpos_lists() !=
enz_input_data_->mcfi_lists_size() ) utility_exit_with_message(
"#geometric constraints disagreement between file given for option match::scaffold_active_site_residues_for_geomcsts having " + utility::to_string(scaf_seqpos.num_seqpos_lists() ) +
"constraitns and Enz .cst file: " + option[ geometric_constraint_file ]()() +
999 " having (" + utility::to_string(
enz_input_data_->mcfi_lists_size()) +
") constraints." );
1005 for(
core::Size i =1; i <= scaf_seqpos.num_seqpos_lists(); ++i ){
1006 for(
core::Size j = 1; j <= scaf_seqpos.seqpos_for_geomcst( i ).size(); ++j ){
1007 if( scaf_seqpos.seqpos_for_geomcst( i )[j] <=
upstream_pose_->total_residue() ){
1010 else std::cerr <<
"Warning: seqpos number " << scaf_seqpos.seqpos_for_geomcst( i )[j] <<
" is larger than size of pose, ignoring. Check if you're using the right match posfile.";
1027 bool change_build_point_lists(
false );
1030 std::set< Size > cst_ids_already_present;
1034 for( std::vector< core::pose::RemarkInfo >::const_iterator remark_it = pose_remarks.begin(); remark_it != pose_remarks.end(); remark_it++){
1037 int resA_num(0), resB_num(0);
1042 resA_type, resA_num, resB_chain, resB_type,
1043 resB_num, cst_block, ex_geom_id) ){
1045 if( !change_build_point_lists ) {
1046 change_build_point_lists =
true;
1050 Size upstream_seqpos( pose_pdbinfo->pdb2pose(resB_chain.c_str()[0],resB_num) );
1052 runtime_assert(
upstream_pose_->residue_type( upstream_seqpos ).is_protein() );
1053 TR <<
"An interaction for geometric constraint " << cst_block <<
" already seems to be present in the pose at seqpos " << upstream_seqpos <<
". Matching for this geomcst will only be done at this position." << std::endl;
1054 res_id.push_back( upstream_seqpos );
1056 cst_ids_already_present.insert( cst_block );
1059 if( change_build_point_lists){
1064 if( switch_to_different_build_points_required ){
1065 for(
Size i = 1; i <= n_geometric_constraints; ++i){
1066 if( cst_ids_already_present.find( i ) == cst_ids_already_present.end() ){
1078 if( (
downstream_pose_->total_residue() != 1 ) ) utility_exit_with_message(
"Can't remove a downstream pose containing more than one residue from the upstream pose.");
1083 if( (
upstream_pose_->conformation().chain_end( i ) - chain_begin == 0 ) &&
1085 seqpos_to_remove.push_back( chain_begin );
1088 if( seqpos_to_remove.size() == 0 )
return;
1091 for(
core::Size i = seqpos_to_remove.size(); i >= 1; --i){
1092 TR <<
"Removing seqpos " << seqpos_to_remove[i] <<
" from upstream_pose_ because it is part of the downstream object." << std::endl;
1093 mod_up_pose->conformation().delete_residue_slow( seqpos_to_remove[i] );
1101 using namespace basic::options;
1104 using namespace protocols::toolbox::match_enzdes_util;
1105 using namespace core::chemical;
1109 if ( ! option[ geometric_constraint_file ].user() ) {
1110 utility_exit_with_message(
"Option match::geometric_constraint_file must be specified on the command line" );
1129 std::set< core::id::AtomID > seen_atoms;
1134 bool upstream_matching(
false);
1135 std::map< std::string, utility::vector1< std::string > >
const &
1136 alg_info(
enz_input_data_->mcfi_list( i )->mcfi( 1 )->algorithm_inputs() );
1137 if ( alg_info.find(
"match" ) != alg_info.end() ) {
1139 for (
Size ll = 1; ll <= info.size(); ++ll ) {
1141 std::istringstream llstream( llstr );
1143 llstream >> first >> second;
1144 if( first ==
"SECONDARY_MATCH:" && second ==
"UPSTREAM_CST" ){
1146 llstream >> target_id;
1147 upstream_matching =
true;
1152 if( upstream_matching )
continue;
1158 core::Size ds_matchres( cur_mcfi->downstream_res() );
1163 for(
core::Size l = 1; l <= cur_mcfi->template_atom_inds( ds_matchres, k, *ds_restype ).size(); ++l ){
1164 core::id::AtomID this_at( cur_mcfi->template_atom_inds( ds_matchres, k, *ds_restype )[l], 1 );
1165 if( seen_atoms.find( this_at ) == seen_atoms.end() ){
1166 seen_atoms.insert( this_at );
1179 using namespace basic::options;
1182 if ( option[ orientation_atoms ].user() ) {
1185 if ( names.size() != 3 ) {
1186 std::cerr <<
"ERROR: expected exactly three atom names for the downstream pose, but read ";
1187 std::cerr << names.size() <<
" from the command line." << std::endl;
1188 for (
Size ii = 1; ii <= names.size(); ++ii ) {
1189 std::cerr << names[ ii ] <<
" ";
1191 std::cerr << std::endl;
1192 utility_exit_with_message(
"Invalid use of the flag -match::orientation_atoms" );
1196 std::cerr <<
"ERROR: Cannot use the flag -match::orientation_atoms if the downstream pose has multiple residues" << std::endl;
1197 utility_exit_with_message(
"Invalide use of the flag -match::orientation_atoms" );
1200 for (
Size ii = 1; ii <= 3; ++ii ) {
1202 std::cerr <<
"Could not find atom named '" << names[ ii ] <<
"' in residue " <<
downstream_pose_->residue( 1 ).name() << std::endl;
1203 utility_exit_with_message (
"Unrecognized atom name listed in flag -match::orientation_atoms" );
1210 Real angle = numeric::constants::d::radians_to_degrees * numeric::angle_radians(
1214 if ( angle > 175 ) {
1215 std::cerr <<
"ERROR: The three atoms used to define the orientation of the downstream partner are nearly co-linear: angle= " << angle <<
"\n";
1216 std::cerr <<
"Please choose atoms with an angle that will not be so numerically sensitive." << std::endl;
1217 utility_exit_with_message(
"Nearly-colinear points chosen as orientation atoms of the downstream partner" );
1221 std::cout <<
"Warning, Downstream Pose has not been set in MatcherTask when initialize_from_command_line\n";
1222 std::cout <<
"was invoked. The parameters in the command-line flag -match::orientation_atoms are being ignored" << std::endl;
1292 using namespace basic::options;
1295 if ( option[ required_active_site_atom_names ].user() ) {
1297 utility_exit_with_message(
"Flag match::required_active_site_atom_names may only be used when the downstream pose is a single residue" );
1300 ! option[ active_site_definition_by_residue ].user() &&
1301 ! option[ active_site_definition_by_gridlig ].user() ) {
1302 utility_exit_with_message(
"Flag match::required_active_site_atom_names must be used in combination with\n" "either the match::active_site_definition_by_residue flag or the match::active_site_definition_by_gridlig flag" );
1305 utility::io::izstream istr( filename.c_str() );
1309 if ( ! istr.bad() ) {
1310 if ( atname ==
"" )
break;
1312 TR <<
"Requiring downstream atom '" << atname <<
"' to reside in the scaffold's active site" << std::endl;
1316 std::cerr <<
"ERROR reading required_active_site_atom_names: atom named '" << atname <<
"' is not an atom of " <<
downstream_pose_->residue( 1 ).name() << std::endl;
1317 utility_exit_with_message(
"Problem reading required_active_site_atom_names file " + filename );
1322 utility_exit_with_message(
"No active site atoms read; empty required_active_site_atom_names file " + filename );
1326 if ( option[ active_site_definition_by_residue ].user() ) {
1327 if ( option[ active_site_definition_by_gridlig ].user() ) {
1328 std::cerr <<
"ERROR: found incompatible flags active_site_definition_by_residue and active_site_definition_by_gridlig on the command line" << std::endl;
1329 utility_exit_with_message(
"Ambiguous command line." );
1332 utility::io::izstream istr( filename.c_str() );
1337 std::cerr <<
"ERROR reading active_site_definition: residue " << resid <<
" exceeds the number of residues in the scaffold pose." << std::endl;
1338 utility_exit_with_message(
"Problem reading active_site_definition " + filename );
1340 if ( ! istr.good() )
break;
1343 std::cerr <<
"Error reading active_site_definition: expected to read a radius after reading resid " << resid << std::endl;
1344 utility_exit_with_message(
"Problem reading active_site_definition " + filename );
1346 TR <<
"Including sphere of radius " << radius <<
" surrounding scaffold residue " << resid <<
" in active site definition" << std::endl;
1353 std::cerr <<
"ERROR reading active_site_definition: no active site residues were read!" << std::endl;
1354 utility_exit_with_message(
"Problem reading active_site_definition " + filename );
1359 if ( option[ active_site_definition_by_gridlig ].user() ) {
1368 using namespace basic::options;
1371 if ( option[ OptionKeys::match::filter_colliding_upstream_residues ] ) {
1373 if ( option[ OptionKeys::match::upstream_residue_collision_score_cutoff ].user() ) {
1381 if ( option[ OptionKeys::match::upstream_residue_collision_tolerance ].user() ) {
1393 using namespace basic::options;
1396 if ( option[ OptionKeys::match::filter_upstream_downstream_collisions ] ) {
1398 if ( option[ OptionKeys::match::updown_residue_collision_score_cutoff ].user() ) {
1406 if ( option[ OptionKeys::match::updown_collision_tolerance ].user() ) {
1419 using namespace basic::options;
1429 if( tempvec.size() == 0 ) utility_exit_with_message(
"Bad user input: empty vector specified for option -match::geom_csts_downstream_output.");
1434 for(
core::Size i = 1; i <= tempvec.size(); ++i ){
1436 if( tempvec[ i ] < 1 ){
1437 utility_exit_with_message(
"Retarded user input. Output for geom cst with id smaller than 1 requested.");
1440 if( (
Size) tempvec[ i ] > num_geom_csts ){
1441 utility_exit_with_message(
"Bad user input. Output for geom cst with id higher than the number of total geomcsts requested.");
1447 if ( option[ OptionKeys::match::define_match_by_single_downstream_positioning ] ) {
1448 if(
geom_csts_downstream_output_.size() != 1 ) utility_exit_with_message(
"Bad user input: values specified for options -match::define_match_by_single_downstream_positioning and -match::geom_csts_downstream_output are incompatible.");
1449 if ( ! option[ OptionKeys::match::consolidate_matches ] ) {
1455 if ( option[ OptionKeys::match::output_format ]() ==
"PDB" &&
1457 TR <<
"MatcherTask initialised to treat matches as defined by single downstream positioning." << std::endl;