Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SecondaryMatchProtocol.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/enzdes/SecondaryMatchProtocol.cc
11 ///
12 /// @brief
13 /// @author Florian Richter
14 
15 
16 
28 
31 
34 #include <core/io/pdb/file_data.hh> //reading remarks
35 
36 #include <basic/options/option.hh>
39 
40 #include <core/pose/Pose.hh>
41 #include <core/pose/PDBInfo.hh> //reading remarks
42 //#include <core/pose/PDBPoseMap.hh> //for PDB-info-to-resid functionality
44 
45 #include <core/scoring/Energies.hh>
49 
50 #include <basic/datacache/BasicDataCache.hh>
51 #include <basic/datacache/CacheableString.hh>
52 
53 // AUTO-REMOVED #include <protocols/ligand_docking/LigandDockProtocol.hh>
56 
57 #include <basic/Tracer.hh>
58 #include <utility/string_util.hh>
59 
60 
61 // option key includes
62 
63 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
64 
65 #include <core/pose/util.hh>
66 #include <utility/vector0.hh>
67 #include <utility/vector1.hh>
68 
69 //Auto Headers
71 
72 
73 namespace protocols{
74 namespace enzdes{
75 
76 static basic::Tracer tr("protocols.enzdes.SecondaryMatchProtocol");
77 
80  found_res_compatibility_determined_( false ),
81  cut1_(0),
82  cut2_(0),
83  cut3_( basic::options::option[basic::options::OptionKeys::enzdes::cut3] ),
84  cut4_( basic::options::option[basic::options::OptionKeys::enzdes::cut4] )
85 {
86 
88  match_params_.clear();
90 }
91 
93 
94 void
96  core::pose::Pose & start_pose
97 ){
98 
99 
100  using namespace basic::datacache;
101  //using core::pose::datacache::CacheableDataType::JOBDIST_OUTPUT_TAG;
102 
103  //in case we want to swich ligands, let's do it now
104  if( basic::options::option[basic::options::OptionKeys::enzdes::change_lig].user() ){
105  bool lig_switch = exchange_ligands_in_pose( start_pose, true, reduced_scofx_ );
106  if( !lig_switch ){
107  tr << "Warning: could not perform the requested ligand switch, aborting protocol... " << std::endl;
108  return;
109  }
110  }
111 
112 
113  //set up constraints (read cstfile, do mapping, etc, then add to pose)
114  if( basic::options::option[basic::options::OptionKeys::enzdes::cstfile].user() ){
116  setup_enzdes_constraints( start_pose, true );
117  }
118  //if there is no cstfile but a change of lig requested, we need to dump the pose now before returning
119  else if( basic::options::option[basic::options::OptionKeys::enzdes::change_lig].user() ){
120 
121  std::string outtag = start_pose.data().get_ptr< CacheableString >( core::pose::datacache::CacheableDataType::JOBDIST_OUTPUT_TAG )->str() + "_" + "lx.pdb";
122  start_pose.dump_pdb( outtag );
123 
124  return;
125  }
126 
127  else utility_exit_with_message("This protocol either needs a cstfile or change_lig file.");
128 
129  //TO DO: check whether the newly placed ligand clashes with the catalytic residues
130 
131  find_all_allowed_positions( start_pose );
132  do_matching( start_pose );
133 
134 }
135 
138  return "SecondaryMatchProtocol";
139 }
140 
141 bool
143  core::pose::Pose & start_pose
144 ){
145 
146  using namespace basic::datacache;
147  //using core::pose::datacache::CacheableDataType::JOBDIST_OUTPUT_TAG;
148 
149 
151  poses_to_process.clear();
152 
153  //this might be a little iffy, come back to this if it causes problems
154  poses_to_process.push_back( & start_pose );
155 
156  core::pose::PoseCOP ref_pose( new core::pose::Pose( start_pose ) );
157  //core::pose::Pose ref_pose = start_pose;
158 
159  //clear_catalytic_res(); //make sure this gets done first thing
160 
161  found_resis_.clear();
162  match_params_.clear();
163 
165  if( !cstio ){
166  tr << "Weird. No constraints seem to have been setup in the pose." << std::endl;
167  return false;
168  }
169 
170  utility::vector1< toolbox::match_enzdes_util::EnzConstraintParametersCOP > tmp_params = cstio->enz_cst_params_missing_in_pose( start_pose );
171  //utility::vector1< EnzConstraintParametersCOP > match_params;
172 
173  //first we'll clone the missing params
175  tmp_it != tmp_params.end(); ++tmp_it) {
177  }
178 
179  core::Size num_res_to_match = match_params_.size();
180 
181  if( num_res_to_match == 0 ){
182  tr.Info << "The pose already has all the required constraints present, aborting protocol.\n";
183  return true;
184  }
185  else tr.Info << "There are " << num_res_to_match << " interactions that need to be found.\n" << std::endl;
186 
188  param_it != match_params_.end(); ++param_it) {
189 
190  toolbox::match_enzdes_util::EnzCstTemplateResCOP missing_template = (*param_it)->get_missing_template_res( start_pose );
191  toolbox::match_enzdes_util::EnzCstTemplateResCOP present_template = (*param_it)->get_missing_template_other_res( start_pose );
192 
193  for( utility::vector1< core::pose::PoseOP >::iterator pose_it = poses_to_process.begin();
194  pose_it != poses_to_process.end(); ++pose_it){
195 
196  add_enz_cst_interaction_to_pose( **pose_it, *param_it, missing_template, present_template, cstio);
197 
198  } // loop over all poses to process
199 
200  if( found_resis_.size() == 0 ) {
201  tr.Info << "Bummer :( Could not find the desired interaction... " << std::endl;
202 
203  //in case a switch of ligands was requested, we dump the pose(s) now
204  if( basic::options::option[basic::options::OptionKeys::enzdes::change_lig].user() ){
205 
206  std::string outtag = poses_to_process[1]->data().get_ptr< CacheableString >( core::pose::datacache::CacheableDataType::JOBDIST_OUTPUT_TAG )->str() + "_" + "lx.pdb";
207  poses_to_process[1]->dump_pdb( outtag );
208  }
209 
210  return false;
211  }
212 
213  } //loop over all params to process
214 
215 
217 
218 
219 } //do matching function
220 
221 
222 void
224  core::pose::Pose & pose,
229 {
230 
232 
233  //1. we need to find out which residues in the pose we are looking at
234  utility::vector1< core::Size > target_residues;
235 
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 );
240  tr.Info << pose.residue_type( pos_it->first ).name() << " " << pos_it->first << ", ";
241  }
242 
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.");
245  }
246  core::Size target_residue = target_residues[1];
247 
248  tr.Info << "with a newly placed residue of type(s) ";
249 
250  utility::vector1< std::string > trial_restypes = missing_template->allowed_res_types();
251 
252  if( missing_template->is_backbone() ){
253  trial_restypes.clear();
254  trial_restypes.push_back( "GLY" );
255  }
256 
257  for( utility::vector1< std::string >::const_iterator resi_it = trial_restypes.begin(); resi_it != trial_restypes.end(); ++resi_it ){
258  tr.Info << *resi_it << ", ";
259  }
260  tr.Info << std::endl;
261 
262 
263  //create poly A pose of neighbors
265 
266  core::conformation::Residue ala_res( restype_set()->name_map("ALA"), true );
267 
268  for( utility::vector1< std::string >::const_iterator resi_it = trial_restypes.begin(); resi_it != trial_restypes.end(); ++resi_it ){
269 
270  core::conformation::Residue trial_res( restype_set()->name_map( *resi_it ), true );
271 
272  tr << "starting search for restype " << *resi_it << "... ";
273 
274  for( utility::vector1< core::Size >::const_iterator pos_try_it = trial_positions_.begin(); pos_try_it != trial_positions_.end(); ++pos_try_it){
275 
276  tr << "searching position " << *pos_try_it << "... ";
277 
278  if( ! restype_possible_at_position( pose, & trial_res.type(), & pose.residue( target_residue ), *pos_try_it ) ) continue;
279 
280  utility::vector1< std::string > current_variants;
281  bool variants_match = pose.residue_type( *pos_try_it).variants_match( trial_res.type() );
282 
283  if( !variants_match ){
284  current_variants = pose.residue_type( *pos_try_it ).variant_types();
285  }
286 
287  pose.replace_residue( *pos_try_it, trial_res, true);
288 
289  if( !variants_match ){
290  for(core::Size var = 1; var <= current_variants.size(); var++){
291  core::pose::add_variant_type_to_pose_residue( pose, current_variants[ var ], *pos_try_it );
292  }
293  }
294 
295  //gotta mark the new residue in the constraint object
296  cstio->set_position_for_missing_res_in_parameter_block( pose, params->cst_block(), *pos_try_it );
297 
298  cstio()->add_constraints_to_pose_for_block_without_clearing_and_header_processing( pose, reduced_scofx_, params->cst_block() );
299 
300 
302  //task->initialize_from_command_line();
303  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
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();
307  }
308  else task->nonconst_residue_task( i ).prevent_repacking();
309  }
310 
312  trial_packer->apply( pose );
313 
314  (*reduced_scofx_)( pose );
315 
316  //make a bump check and constraint scoreterm check
317  //bump check necessary in case each of the rotamers clashed
318  core::Real try_targ_clash(0.0);
319 
320  core::scoring::EnergyEdge const * eedge = pose.energies().energy_graph().find_energy_edge( *pos_try_it, target_residue );
321 
322  if( eedge != 0 ){
323  // apl -- removing TwoBodyEnergyMap + making this call a little more efficient.
324  try_targ_clash = eedge->dot( reduced_scofx_->weights() );
325  }
326 
327  core::Real cst_sum = enzutil::sum_constraint_scoreterms( pose, *pos_try_it );
328 
329 
330  //little hacky, not the real bbclash energy, but in this case probably a better approximation because it also includes the clash with ALAs, etc
331  core::Real try_bb_clash = pose.energies().residue_total_energies( *pos_try_it )[ core::scoring::fa_rep ];
332 
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;
334 
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]){
338 
339  core::conformation::ResidueOP fres = new core::conformation::Residue( pose.residue( *pos_try_it ) );
340 
341  found_res_this_param.push_back( fres );
342 
343  tr.Info << "Success: " << *resi_it << " at position " << *pos_try_it << " satisfies constraints." << std::endl;
344  }
345 
346  cstio->remove_constraints_from_pose_for_block( pose, params->cst_block(), true );
347 
348  cstio->remove_position_from_template_res_for_block( pose, *pos_try_it, params->cst_block() );
349 
350  cstio->clear_active_pose_constraints_for_block( pose, params->cst_block() );
351 
352  pose.replace_residue( *pos_try_it, ala_res, true);
353 
354  if( !variants_match ){
355  for(core::Size var = 1; var <= current_variants.size(); var++){
356  core::pose::add_variant_type_to_pose_residue( pose, current_variants[ var ], *pos_try_it );
357  }
358  }
359 
360  } //iterator over all trial positions
361 
362  }// iterator over all trial residue types
363 
364  found_resis_.push_back( found_res_this_param );
365 
366 
367 } //add_enz_cst_interaction_to_pose
368 
369 
370 void
372  core::pose::Pose const & pose
373 )
374 {
375  trial_positions_.clear();
376 
377  //still to be developed properly. for now we assume that we only allow attaching
378  //residues at the design or repack positions as specified by the one ligand in the pose
379  utility::vector1< bool > dummy( pose.total_residue() );
380  utility::vector1< bool > allowed_res( pose.total_residue() );
381  std::set< core::Size > interface_res;
382  interface_res.insert( pose.fold_tree().downstream_jump_residue( pose.num_jump() ) );
384  lig_prot_interface->find_design_interface(pose, interface_res, cut1_, cut2_, cut3_, cut4_, allowed_res, dummy );
385 
386  //utility::vector1< core::Size > cat_res = catalytic_res();
387 
388  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
389 
390  if( allowed_res[ i ] == true ){
391 
392 
393  if( pose.residue_type( i ).is_ligand() ) continue;
394 
395  if( ( pose.residue_type( i ).name3() == "GLY" )
396  || ( pose.residue_type( i ).name3() == "PRO" ) ) continue;
397 
398  //utility::vector1< Size >::iterator find_res = find( cat_res.begin(), cat_res.end(), i );
399 
400  //if( find_res == cat_res.end() ) trial_positions_.push_back( i );
401  if( !is_catalytic_position( pose, i ) ) trial_positions_.push_back( i );
402 
403  }
404  }
405 
406  tr << "trying at a maximum of " << trial_positions_.size() << " pose positions." << std::endl;
407 
408 } //find_neighbors function
409 
410 
411 
412 bool
414 {
415 
416 
417  //utility::vector1< core::pose::PoseCOP > process_poses ;
419 
420  //process_poses.push_back( ref_poseCOP );
421 
422  process_combos.push_back( new PoseFoundResiduesCombination( ref_poseCOP, this ) );
423 
424 
426  param_it != found_resis_.end(); ++param_it )
427  {
428 
429  //utility::vector1< core::pose::PoseCOP > temp_poses;
431 
432  for( utility::vector1< core::conformation::ResidueOP >::iterator res_it = param_it->begin();
433  res_it != param_it->end(); ++res_it )
434  {
435 
436  for( utility::vector1< PoseFoundResiduesCombinationOP >::iterator pp_it = process_combos.begin();
437  pp_it != process_combos.end(); ++pp_it )
438  {
439  //core::pose::PoseOP success_pose = new core::pose::Pose(**pp_it);
440  //success_pose->replace_residue( (*res_it)->seqpos(), **res_it, true);
441  PoseFoundResiduesCombinationOP success_combo = new PoseFoundResiduesCombination( **pp_it );
442  success_combo->add_residue( *res_it );
443  temp_combos.push_back( success_combo );
444  }
445 
446  }
447 
448  process_combos = temp_combos;
449 
450  }
451 
452  //now hopefully all the output poses are in the process combos array
453 
454  //before we can begin outputting, we first have to figure out which residues are compatible with which
456 
457  bool successful = false;
458 
459  for( utility::vector1< PoseFoundResiduesCombinationOP >::iterator pp_it = process_combos.begin();
460  pp_it != process_combos.end(); ++pp_it )
461  {
462  if( (*pp_it)->construct_and_dump_outpose( match_params_ ) ) successful = true;
463  }
464 
465  return successful;
466 
467 } //generate_output_names_for_found_poses
468 
469 
470 
471 /// @brief rough check whether the two residues in question are close to each other
472 bool
474  core::pose::Pose const & pose,
476  core::conformation::ResidueCOP target_residue,
477  core::Size const trial_pos
478 )
479 {
480 
481  core::Size target_nbr_atom = target_residue->type().nbr_atom();
482  //core::Size trial_pos_nbr_atom = pose.residue_type( trial_pos ).nbr_atom();
483 
484  core::PointPosition trial_xyz = pose.residue( trial_pos).xyz( "CB" );
485  core::PointPosition targ_neighbor_xyz = target_residue->xyz( target_nbr_atom );
486 
487  core::Real dist = trial_xyz.distance( targ_neighbor_xyz );
488 
489  if( dist < ( 4.0 + restype->nbr_radius() + target_residue->type().nbr_radius() ) ) {
490  return true;
491  }
492  else{
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;
494  }
495 
496  return false;
497 
498 } //restype possible at position
499 
500 
501 /// @brief lookup function to determine whether to residues are compatible
506 ) const
507 {
508 
509  using namespace core::conformation;
510 
512  utility_exit_with_message( "Error: trying to lookup residue compatibility without having determined it previously." );
513  }
514 
515 
516  std::map< ResidueCOP, std::map< ResidueCOP, core::Size > >::const_iterator map_this_res = found_res_compatibility_.find( res1 );
517 
518  if( map_this_res == found_res_compatibility_.end() ){
519  utility_exit_with_message( "Error: no residue compatibility map found for residue "+utility::to_string( res1->seqpos() )+"." );
520  }
521 
522  std::map< ResidueCOP, core::Size>::const_iterator res2_it = map_this_res->second.find( res2 );
523 
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() ) +"." );
526  }
527 
528  return res2_it->second;
529 
530 
531 } //residues compatible
532 
533 
534 
535 /// @brief this function does clash checks between all residues that were found,
536 /// and saves the information in a map
537 void
539  core::pose::PoseCOP ref_poseCOP )
540 {
541 
542  core::Real Ecutoff = basic::options::option[ basic::options::OptionKeys::enzdes::sc_sc_bump_cutoff ];
543  found_res_compatibility_.clear();
544 
545  for( core::Size i = 1; i <= found_resis_.size(); ++i ){
546 
547 
549  res1_it != found_resis_[i].end(); ++res1_it){
550 
551  std::map< core::conformation::ResidueCOP, core::Size > map_this_res;
552 
553  for( core::Size j = i+1; j<= found_resis_.size(); ++j ){
554 
556  res2_it != found_resis_[j].end(); ++res2_it){
557 
558  core::Size compatible(0);
559  if( (*res1_it)->seqpos() != (*res2_it)->seqpos() ){
560 
561  //perform the clash check between res1 and res2
563  reduced_scofx_->bump_check_full( **res1_it, **res2_it, *ref_poseCOP, emap );
564 
565  if( (reduced_scofx_->weights().dot( emap )) < Ecutoff ) compatible = 1;
566  //std::cerr << "just checked compatibility for i=" << i << " and j=" << j;
567  //std::cerr << ", res i is a " << (*res1_it)->name3() << " at " << (*res1_it)->seqpos() << ", and res j is a " << (*res2_it)->name3() << " at " << (*res2_it)->seqpos() << std::endl;
568  }
569 
570  map_this_res.insert( std::pair<core::conformation::ResidueCOP, core::Size> (*res2_it, compatible ) );
571  }
572  }
573 
574  //save the map for this residue
575  found_res_compatibility_.insert( std::pair< core::conformation::ResidueCOP, std::map< core::conformation::ResidueCOP, core::Size > > ( *res1_it, map_this_res) );
576 
577  }
578 
579  }
580 
582 
583 } // determine_found_residues_compatibility
584 
585 
586 
588 
590  core::pose::PoseCOP ref_pose_in,
591  SecondaryMatchProtocolCAP secmatch_in
592  ) : ref_pose_( ref_pose_in ),
593  secmatch_prot_( secmatch_in )
594 {
595  combine_resis_.clear();
596 }
597 
598 void
600  combine_resis_.push_back( res_in );
601 }
602 
603 
604 bool
607 {
608  using namespace basic::datacache;
609  //using core::pose::datacache::CacheableDataType::JOBDIST_OUTPUT_TAG;
610 
611  //1.first we have to copy the refpose
612  core::pose::Pose outpose( *ref_pose_ );
613 
614  CacheableStringOP outcache = outpose.data().get_ptr< CacheableString >( core::pose::datacache::CacheableDataType::JOBDIST_OUTPUT_TAG );
615  core::pose::PDBInfoOP pose_pdbinfo = outpose.pdb_info();
616  std::string outtag = outcache->str() + "_sm";
617 
618  //2. then we need to go through the found residues, figure
619  // out if they are all compatible with each other and
620  // generate the new header line
621 
622  bool all_residues_compatible = true;
623 
624  core::Size num_resis_to_combine = combine_resis_.size();
625 
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");
628  }
629 
630  for( core::Size i = 1; i <= num_resis_to_combine; ++i){
631 
632  //generate the header line for this interaction
633  std::string mis_chain(""), mis_name3("");
634  std::string other_chain(""), other_name3("");
635  core::Size mispos(0), otherpos(0);
636 
637  mispos = outpose.pdb_info()->number( combine_resis_[i]->seqpos() );
638 
639  //for traditional reasons, if residue is a ligand, it will be set to 0
640  if( outpose.residue_type( combine_resis_[i]->seqpos() ).is_ligand() ) mispos = 0;
641 
642  mis_name3 = combine_resis_[i]->name3();
643  mis_chain = outpose.pdb_info()->chain( combine_resis_[i]->seqpos() );
644 
645  utility::vector1< core::Size > other_positions;
646  toolbox::match_enzdes_util::EnzCstTemplateResCOP other_template( match_params[i]->get_missing_template_other_res( outpose ) );
647  toolbox::match_enzdes_util::EnzCstTemplateResCacheCOP other_template_cache( toolbox::match_enzdes_util::get_enzdes_observer( outpose )->cst_cache()->param_cache( match_params[i]->cst_block() )->template_res_cache( other_template->param_index() ) );
648 
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 ){
651  //for( std::map< Size, EnzCstTemplateResAtomsOP >::const_iterator pos_it = match_params[i]->get_missing_template_other_res( outpose )->respos_map_begin();
652  //pos_it != match_params[i]->get_missing_template_other_res( outpose )->respos_map_end(); ++pos_it ){
653  other_positions.push_back( pos_it->first );
654  }
655  if( other_positions.size() != 1 ){
656  utility_exit_with_message("Impossible error just happened...");
657  }
658 
659  otherpos = outpose.pdb_info()->number( other_positions[1] );
660 
661  //for traditional reasons, if residue is a ligand, it will be set to 0
662  if( outpose.residue_type( other_positions[1] ).is_ligand() ) otherpos = 0;
663 
664  other_name3 = outpose.residue_type( other_positions[1] ).name3();
665  other_chain = outpose.pdb_info()->chain( other_positions[1] );
666 
668 
669  if( match_params[i]->resA() == match_params[i]->get_missing_template_res( outpose ) ){
670  //ri.value = "BONE TEMPLATE "+mis_remark+" MATCH MOTIF "+other_remark;
671  ri.value = toolbox::match_enzdes_util::assemble_remark_line( mis_chain, mis_name3, mispos, other_chain, other_name3, otherpos, match_params[i]->cst_block() );
672  }
673  else if( match_params[i]->resB() == match_params[i]->get_missing_template_res( outpose ) ){
674  // ri.value = "BONE TEMPLATE "+other_remark+" MATCH MOTIF "+mis_remark;
675  ri.value = toolbox::match_enzdes_util::assemble_remark_line( other_chain, other_name3, otherpos, mis_chain, mis_name3, mispos, match_params[i]->cst_block() );
676  }
677  else{
678  utility_exit_with_message("Weird. Suddenly no residue is missing anymore.\n");
679  }
680 
681  pose_pdbinfo->remarks().push_back( ri );
682 
683  //then determine if it's compatible with all other residues
684 
685  for( core::Size j = i + 1; j <= num_resis_to_combine; ++j){
686 
687  //if( ! residues_compatible_without_checking( combine_resis_[i], combine_resis_[j] ) ){
688  if( secmatch_prot_->residues_compatible( combine_resis_[i], combine_resis_[j] ) == 0 ) {
689  all_residues_compatible = false;
690  return false;
691  }
692  }
693 
694  //finally put the residue into the pose
695  outpose.replace_residue( combine_resis_[i]->seqpos(), *(combine_resis_[i]), true);
696 
697  outtag = outtag + combine_resis_[i]->name1() + utility::to_string( combine_resis_[i]->seqpos() ) ;
698 
699 
700  } // loop over all residues
701 
702  outtag = outtag + ".pdb";
703 
704  //3. now we can output
705  //if all the residues are compatible, we just dump
706  //else we have to repack/minimize the pose, and only dump if
707  //the cst_score is still below the cutoff
708 
709  //note: the all_residues_compatible check is not really necessary, but just to make sure...
710  if( all_residues_compatible ){
711  outpose.dump_pdb( outtag );
712  return true;
713  }
714  return false;
715 
716 } //construct and dump outpose
717 
718 
719 
720 } //namespace enzdes
721 } //namespace protocols
722 
723