36 #include <basic/options/option.hh>
50 #include <basic/datacache/BasicDataCache.hh>
51 #include <basic/datacache/CacheableString.hh>
57 #include <basic/Tracer.hh>
58 #include <utility/string_util.hh>
63 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
66 #include <utility/vector0.hh>
67 #include <utility/vector1.hh>
76 static basic::Tracer
tr(
"protocols.enzdes.SecondaryMatchProtocol");
80 found_res_compatibility_determined_( false ),
83 cut3_( basic::options::option[basic::options::OptionKeys::enzdes::cut3] ),
84 cut4_( basic::options::option[basic::options::OptionKeys::enzdes::cut4] )
100 using namespace basic::datacache;
104 if( basic::options::option[basic::options::OptionKeys::enzdes::change_lig].user() ){
107 tr <<
"Warning: could not perform the requested ligand switch, aborting protocol... " << std::endl;
114 if( basic::options::option[basic::options::OptionKeys::enzdes::cstfile].user() ){
119 else if( basic::options::option[basic::options::OptionKeys::enzdes::change_lig].user() ){
127 else utility_exit_with_message(
"This protocol either needs a cstfile or change_lig file.");
138 return "SecondaryMatchProtocol";
146 using namespace basic::datacache;
151 poses_to_process.clear();
154 poses_to_process.push_back( & start_pose );
166 tr <<
"Weird. No constraints seem to have been setup in the pose." << std::endl;
175 tmp_it != tmp_params.end(); ++tmp_it) {
181 if( num_res_to_match == 0 ){
182 tr.Info <<
"The pose already has all the required constraints present, aborting protocol.\n";
185 else tr.Info <<
"There are " << num_res_to_match <<
" interactions that need to be found.\n" << std::endl;
194 pose_it != poses_to_process.end(); ++pose_it){
201 tr.Info <<
"Bummer :( Could not find the desired interaction... " << std::endl;
204 if( basic::options::option[basic::options::OptionKeys::enzdes::change_lig].user() ){
207 poses_to_process[1]->dump_pdb( outtag );
236 tr.Info <<
"Trying to add interaction of pose residue(s) ";
237 for( std::map< Size, toolbox::match_enzdes_util::EnzCstTemplateResAtomsOP >::const_iterator pos_it =
toolbox::match_enzdes_util::get_enzdes_observer( pose )->cst_cache()->param_cache( params->cst_block() )->template_res_cache( present_template->param_index() )->seqpos_map_begin(), pos_end =
toolbox::match_enzdes_util::get_enzdes_observer( pose )->cst_cache()->param_cache( params->cst_block() )->template_res_cache( present_template->param_index() )->seqpos_map_end();
238 pos_it != pos_end; ++pos_it ){
239 target_residues.push_back( pos_it->first );
243 if( target_residues.size() != 1 ){
244 utility_exit_with_message(
"Error: there are more (or less) than 1 target residue. This protocol isn't setup to handle dealing with multiple target residues yet( and it shouldn't necesseraly be.");
246 core::Size target_residue = target_residues[1];
248 tr.Info <<
"with a newly placed residue of type(s) ";
252 if( missing_template->is_backbone() ){
253 trial_restypes.clear();
254 trial_restypes.push_back(
"GLY" );
258 tr.Info << *resi_it <<
", ";
260 tr.Info << std::endl;
272 tr <<
"starting search for restype " << *resi_it <<
"... ";
276 tr <<
"searching position " << *pos_try_it <<
"... ";
283 if( !variants_match ){
289 if( !variants_match ){
290 for(
core::Size var = 1; var <= current_variants.size(); var++){
296 cstio->set_position_for_missing_res_in_parameter_block( pose, params->cst_block(), *pos_try_it );
298 cstio()->add_constraints_to_pose_for_block_without_clearing_and_header_processing( pose,
reduced_scofx_, params->cst_block() );
304 if( ( i == *pos_try_it ) || ( i == target_residue ) ){
305 task->nonconst_residue_task( i ).restrict_to_repacking();
306 task->nonconst_residue_task( i ).initialize_from_command_line();
308 else task->nonconst_residue_task( i ).prevent_repacking();
312 trial_packer->apply( pose );
314 (*reduced_scofx_)( pose );
333 tr.Info <<
"For restype " << pose.
residue_type( *pos_try_it ).
name() <<
" at pos " << *pos_try_it <<
" the cst_sum is " << cst_sum <<
" and the clashE is " << try_targ_clash <<
"." << std::endl;
335 if( ( cst_sum < basic::options::option[basic::options::OptionKeys::enzdes::secmatch_Ecutoff] )
336 && ( try_targ_clash < basic::options::option[basic::options::OptionKeys::enzdes::sc_sc_bump_cutoff] )
337 && try_bb_clash < basic::options::option[basic::options::OptionKeys::enzdes::bb_bump_cutoff]){
341 found_res_this_param.push_back( fres );
343 tr.Info <<
"Success: " << *resi_it <<
" at position " << *pos_try_it <<
" satisfies constraints." << std::endl;
346 cstio->remove_constraints_from_pose_for_block( pose, params->cst_block(), true );
348 cstio->remove_position_from_template_res_for_block( pose, *pos_try_it, params->cst_block() );
350 cstio->clear_active_pose_constraints_for_block( pose, params->cst_block() );
354 if( !variants_match ){
355 for(
core::Size var = 1; var <= current_variants.size(); var++){
381 std::set< core::Size > interface_res;
384 lig_prot_interface->find_design_interface(pose, interface_res,
cut1_,
cut2_,
cut3_,
cut4_, allowed_res, dummy );
390 if( allowed_res[ i ] ==
true ){
406 tr <<
"trying at a maximum of " <<
trial_positions_.size() <<
" pose positions." << std::endl;
433 res_it != param_it->end(); ++res_it )
437 pp_it != process_combos.end(); ++pp_it )
442 success_combo->add_residue( *res_it );
443 temp_combos.push_back( success_combo );
448 process_combos = temp_combos;
457 bool successful =
false;
460 pp_it != process_combos.end(); ++pp_it )
462 if( (*pp_it)->construct_and_dump_outpose(
match_params_ ) ) successful =
true;
481 core::Size target_nbr_atom = target_residue->type().nbr_atom();
487 core::Real dist = trial_xyz.distance( targ_neighbor_xyz );
489 if( dist < ( 4.0 + restype->nbr_radius() + target_residue->type().nbr_radius() ) ) {
493 tr.Info <<
"Can't place " << restype->name3() <<
" at position " << trial_pos <<
"because it's too far from target "<< target_residue->type().name3() << target_residue->seqpos() <<
"." << std::endl;
509 using namespace core::conformation;
512 utility_exit_with_message(
"Error: trying to lookup residue compatibility without having determined it previously." );
516 std::map< ResidueCOP, std::map< ResidueCOP, core::Size > >::const_iterator map_this_res =
found_res_compatibility_.find( res1 );
519 utility_exit_with_message(
"Error: no residue compatibility map found for residue "+utility::to_string( res1->seqpos() )+
"." );
522 std::map< ResidueCOP, core::Size>::const_iterator res2_it = map_this_res->second.find( res2 );
524 if( res2_it == map_this_res->second.end() ){
525 utility_exit_with_message(
"Error: no residue compatibility info found for res1 "+utility::to_string( res1->seqpos() )+
" and res2 "+utility::to_string( res2->seqpos() ) +
"." );
528 return res2_it->second;
542 core::Real Ecutoff = basic::options::option[ basic::options::OptionKeys::enzdes::sc_sc_bump_cutoff ];
551 std::map< core::conformation::ResidueCOP, core::Size > map_this_res;
559 if( (*res1_it)->seqpos() != (*res2_it)->seqpos() ){
563 reduced_scofx_->bump_check_full( **res1_it, **res2_it, *ref_poseCOP, emap );
565 if( (
reduced_scofx_->weights().dot( emap )) < Ecutoff ) compatible = 1;
570 map_this_res.insert( std::pair<core::conformation::ResidueCOP, core::Size> (*res2_it, compatible ) );
592 ) : ref_pose_( ref_pose_in ),
593 secmatch_prot_( secmatch_in )
608 using namespace basic::datacache;
622 bool all_residues_compatible =
true;
626 if( num_resis_to_combine != match_params.size() ){
627 utility_exit_with_message(
"ERROR: number of matching parameters doesn't fit number of residues.\n");
630 for(
core::Size i = 1; i <= num_resis_to_combine; ++i){
649 for( std::map< Size, toolbox::match_enzdes_util::EnzCstTemplateResAtomsOP >::const_iterator pos_it = other_template_cache->seqpos_map_begin(), pos_end = other_template_cache->seqpos_map_end();
650 pos_it != pos_end; ++pos_it ){
653 other_positions.push_back( pos_it->first );
655 if( other_positions.size() != 1 ){
656 utility_exit_with_message(
"Impossible error just happened...");
659 otherpos = outpose.
pdb_info()->number( other_positions[1] );
665 other_chain = outpose.
pdb_info()->chain( other_positions[1] );
669 if( match_params[i]->resA() == match_params[i]->get_missing_template_res( outpose ) ){
673 else if( match_params[i]->resB() == match_params[i]->get_missing_template_res( outpose ) ){
678 utility_exit_with_message(
"Weird. Suddenly no residue is missing anymore.\n");
681 pose_pdbinfo->remarks().push_back( ri );
685 for(
core::Size j = i + 1; j <= num_resis_to_combine; ++j){
689 all_residues_compatible =
false;
702 outtag = outtag +
".pdb";
710 if( all_residues_compatible ){