Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnzdesTaskOperations.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 src/protocols/enzdes/DesignProteinLigandInterface.hh
11 /// @brief various task operations used in enzyme design
12 /// @author Florian Richter (floric@u.washington.edu), Sinisa Bjelic (sbjelic@u.washington.edu), Rocco Moretti (rmoretti@u.washington.edu)
13 
14 #include <protocols/motifs/BuildPosition.hh> // REQUIRED FOR WINDOWS
15 #include <protocols/motifs/Motif.hh> // REQUIRED FOR WINDOWS
16 // AUTO-REMOVED #include <protocols/motifs/MotifHit.hh> // REQUIRED FOR WINDOWS
17 
24 
29 
30 #include <protocols/dna/util.hh> // Needed for arginine sweep interface detection
31 
35 // AUTO-REMOVED #include <protocols/toolbox/pose_manipulation.hh>
38 
42 // AUTO-REMOVED #include <core/pack/task/TaskFactory.hh>
48 #include <core/pose/Pose.hh>
52 #include <basic/options/option.hh>
53 #include <core/types.hh>
54 #include <basic/Tracer.hh>
56 #include <utility/tag/Tag.hh>
57 #include <utility/pointer/access_ptr.hh>
58 
59 // option key includes
60 
61 // utility includes
62 #include <utility/string_util.hh>
63 
64 // AUTO-REMOVED #include <basic/options/keys/score.OptionKeys.gen.hh>
65 #include <basic/options/keys/packing.OptionKeys.gen.hh>
66 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
67 // AUTO-REMOVED #include <basic/options/keys/motifs.OptionKeys.gen.hh>
68 // AUTO-REMOVED #include <basic/options/keys/docking.OptionKeys.gen.hh>
69 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
70 
72 #include <utility/vector0.hh>
73 #include <utility/vector1.hh>
74 
75 
76 namespace protocols{
77 namespace enzdes {
78 
79 static basic::Tracer tr("protocols.enzdes.EnzdesTaskOperations");
80 
82  fix_catalytic_aa_(basic::options::option[basic::options::OptionKeys::enzdes::fix_catalytic_aa]),
83  behavior_non_catalytic_("")
84 {}
85 
87 
90 {
92  to_return->set_fix_catalytic_aa( this->fix_catalytic_aa_);
93  to_return->behavior_non_catalytic_ = this->behavior_non_catalytic_;
94  return to_return;
95 }
96 
97 void
99  Pose const & pose,
100  PackerTask & task ) const
101 {
102 
104  if( !enz_obs) return;
105  toolbox::match_enzdes_util::EnzdesCstCacheCOP cst_cache( enz_obs->cst_cache() );
106  if( !cst_cache ) return;
107  toolbox::match_enzdes_util::EnzConstraintIOCOP cstio( cst_cache->enzcst_io() );
108  std::string catinfo("SetCatalyticResPackBehavior task operation touched the following catalytic residues: ");
109 
110  bool also_touch_noncatalytic( behavior_non_catalytic_ != "" );
112 
113  //in case the user requested it, we'll use the resfile reading machinery
114  //to also set the behavior for the noncatalytic residues
115  if( also_touch_noncatalytic ){
116  std::map< std::string, core::pack::task::ResfileCommandOP > command_map = core::pack::task::create_command_map();
117  resf_command = command_map[ behavior_non_catalytic_ ]->clone();
118  }
119 
120  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
121 
122  if( cst_cache->contains_position( i ) ){
123  catinfo = catinfo + utility::to_string( i ) + ", ";
124 
125  if( fix_catalytic_aa_ ) {
127  }
128 
129  else{
130  if( cstio->is_backbone_only_cst( pose, i ) ){
132  utility::vector1< std::string > allowed_name3 = cstio->allowed_res_name3_at_position( pose, i );
133  for( core::Size j =1; j <= allowed_name3.size(); ++j){
134  allowed_aas[ core::chemical::aa_from_name( allowed_name3[ j ] ) ] = true;
135  }
137  }
138 
139  else{
141  //is catalytic oversampling requested?
142  if( basic::options::option[basic::options::OptionKeys::enzdes::ex_catalytic_rot].user() &&
143  pose.residue_type( i ).is_protein() ){
144 
145  core::pack::task::ExtraRotSample cat_rot_sample( static_cast<core::pack::task::ExtraRotSample>(basic::options::option[basic::options::OptionKeys::enzdes::ex_catalytic_rot].value() ) );
146  if( pose.residue_type( i ).nchi() >= 1 ){
147  task.nonconst_residue_task(i).or_ex1( true );
148  task.nonconst_residue_task(i).or_ex1_sample_level( cat_rot_sample );
149  }
150  if( pose.residue_type( i ).nchi() >= 2 ){
151  task.nonconst_residue_task(i).or_ex2( true );
152  task.nonconst_residue_task(i).or_ex2_sample_level( cat_rot_sample );
153  }
154  if( pose.residue_type( i ).nchi() >= 3 ){
155  task.nonconst_residue_task(i).or_ex3( true );
156  task.nonconst_residue_task(i).or_ex3_sample_level( cat_rot_sample );
157  }
158  if( pose.residue_type( i ).nchi() >= 4 ){
159  task.nonconst_residue_task(i).or_ex4( true );
160  task.nonconst_residue_task(i).or_ex4_sample_level( cat_rot_sample );
161  }
162  }//if catalytic oversampling
163  } //if( backbone only cst ) else
164  } //if fix_catalytic_aa else
165  } //if position is catalytic
166  else if( also_touch_noncatalytic ) resf_command->residue_action(task, i );
167  } //loop over all pose residues
168  tr << catinfo << std::endl;
169 }
170 
171 void
173 {
174  if( tag->hasOption("fix_catalytic_aa") ) fix_catalytic_aa_ = tag->getOption<bool>( "fix_catalytic_aa", 1);
175  if( tag->hasOption("behavior_non_catalytic") ) behavior_non_catalytic_ = tag->getOption<std::string>("behavior_non_catalytic" );
176 
177 }
178 
181 {
182  return new SetCatalyticResPackBehavior;
183 }
184 
187 {
188  return new DetectProteinLigandInterface;
189 }
190 
193 {
195 }
196 
199 {
200  return new AddLigandMotifRotamers;
201 }
202 
204  detect_design_interface_(true), catalytic_res_part_of_interface_(false), design_(true),
205  repack_only_(false), score_only_(false),
206  resfilename_(), //Empty string
207  add_observer_cache_segs_to_interface_(false),
208  no_design_cys_(true),
209  catres_only_(false),
210  use_cstid_list_(false),
211  cstid_list_()
212 {
214  design_target_res_.clear();
215 }
216 
218 
221 {
222  return new DetectProteinLigandInterface(*this);
223 }
224 
225 /// @brief Initialize the class based on the command line options.
226 void
228 {
229  detect_design_interface_ = basic::options::option[basic::options::OptionKeys::enzdes::detect_design_interface];
230  arg_sweep_interface_ = basic::options::option[basic::options::OptionKeys::enzdes::arg_sweep_interface];
231  arg_sweep_cutoff_ = basic::options::option[basic::options::OptionKeys::enzdes::arg_sweep_cutoff];
232  score_only_ = basic::options::option[basic::options::OptionKeys::enzdes::enz_score];
233  repack_only_ = basic::options::option[basic::options::OptionKeys::enzdes::enz_repack];
234  cut1_ = basic::options::option[basic::options::OptionKeys::enzdes::cut1];
235  cut2_ = basic::options::option[basic::options::OptionKeys::enzdes::cut2];
236  cut3_ = basic::options::option[basic::options::OptionKeys::enzdes::cut3];
237  cut4_ = basic::options::option[basic::options::OptionKeys::enzdes::cut4];
238  if ( basic::options::option[basic::options::OptionKeys::packing::resfile].user() ) {
239  resfilename_ = basic::options::option[basic::options::OptionKeys::packing::resfile].value().at(1);
240  }
241 }
242 
243 void
245 {
246  detect_design_interface_ = true; //Using DetectProteinLigandInterface implies you want to.
247  score_only_ = false; //Using DetectProteinLigandInterface implies you're doing more than scoring.
248  if( tag->hasOption("repack_only") ) repack_only_ = tag->getOption< bool >( "repack_only", false );
249  cut1_ = tag->getOption< core::Real >( "cut1", 6.0 );
250  cut2_ = tag->getOption< core::Real >( "cut2", 8.0 );
251  cut3_ = tag->getOption< core::Real >( "cut3", 10.0 );
252  cut4_ = tag->getOption< core::Real >( "cut4", 12.0 );
253  arg_sweep_cutoff_ = tag->getOption< core::Real >( "arg_sweep_cutoff", 3.7 );
254  design_ = tag->getOption< bool >( "design", 1 );
255  resfilename_ = tag->getOption< std::string >( "resfile", "");
256  no_design_cys_ = ! ( tag->getOption< bool >( "design_to_cys", 0 ) );
257  if( tag->hasOption("segment_interface") ) add_observer_cache_segs_to_interface_ = tag->getOption< bool >( "segment_interface", true );
258 
259  if( tag->hasOption("catres_interface") ) catalytic_res_part_of_interface_ = tag->getOption< bool >( "catres_interface", true );
260  if( tag->hasOption("arg_sweep_interface") ) arg_sweep_interface_ = tag->getOption< bool >( "arg_sweep_interface", true );
261  if( tag->hasOption("catres_only_interface")) catres_only_ = tag->getOption< bool >( "catres_only_interface", true );
262  if( tag->hasOption("target_cstids")) {
263  use_cstid_list_ = true;
264  cstid_list_ = tag->getOption< std::string >( "target_cstids", "" );
265  }
266 
267 }
268 
269 /// @brief Change a packer task in some way. The input pose is the one to which the input
270 /// task will be later applied.
272 Pose const & pose,
273 PackerTask & task) const
274 {
275 
276  // First read the resfile, setting the appropriate operations in the task
277  // Note that "AUTO" tags will be processed later by detect_design_interface
278  if( ! resfilename_.empty() ){
279  tr.Info << "Reading resfile input from: " << resfilename_ << std::endl;
281  resfile_read.apply( pose, task );
282  if( !design_ ){
283  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
285  }
286  }
287  } // end (if resfile)
288 
289  // detect design interface, only at positions marked "AUTO" in resfile if there is a resfile
291  utility::vector1< bool > repack_res( pose.total_residue(), false );
292  utility::vector1< bool > design_res( pose.total_residue(), false );
293  utility::vector1< bool > detect_res( pose.total_residue() );
294  core::Real cut1(cut1_), cut2(cut2_), cut3(cut3_), cut4(cut4_);
295 
296  if ( cut1 < 0.0 || cut2 < cut1 || cut3 < cut2 || cut4 < cut3 ) {
297  if (cut1 < 0.0) { cut1 = 0.0; }
298  if (cut2 < cut1) { cut2 = cut1; }
299  if (cut3 < cut2) { cut3 = cut2; }
300  if (cut4 < cut3) { cut4 = cut3; }
301  tr.Warning << "WARNING: detect design interface cutpoints should be in ascending order. Was " << cut1_ << " " << cut2_ << " " << cut3_ << " " << cut4_ << "; Reset to " << cut1 << " " << cut2 << " " << cut3 << " " << cut4 << std::endl;
302  }
303  if( !design_ ){
304  cut1 = 0.0;
305  cut2 = 0.0;
306  }
307 
308  std::set< core::Size > interface_target_res = design_target_res_;
309 
310  // if picking neighbors of particular cstids only
311  if ( ( interface_target_res.size() == 0 ) && use_cstid_list_ ){
314  std::unique( trg_res.begin(), trg_res.end() );
315  std::set< core::Size > trg_set( trg_res.begin(), trg_res.end() );
316  interface_target_res = trg_set;
317  }
318 
319  if( ( interface_target_res.size() == 0 ) && (catalytic_res_part_of_interface_ || catres_only_) ){
320  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
321  if( enzutil::is_catalytic_seqpos( pose, i ) ) {
322  if (pose.residue_type( i ).is_ligand() && !catres_only_) interface_target_res.insert( i );
323  if (!pose.residue_type( i ).is_ligand()) interface_target_res.insert( i );
324  }
325  }
326  }
327 
329 
330  if( interface_target_res.size() ==0 && !catres_only_ ){
333  interface_target_res.insert( asymm_ft.downstream_jump_residue( asymm_ft.num_jump() ) );
334  }
335  else interface_target_res.insert( pose.fold_tree().downstream_jump_residue( pose.num_jump() ) );
336  }
337 
338  tr.Info << "Choosing the following residues as targets for detecting interface: ";
339  for( std::set< core::Size >::const_iterator targ_it( interface_target_res.begin()),targ_end(interface_target_res.end());targ_it != targ_end; ++targ_it ){
340  tr.Info << *targ_it << "+";
341  }
342  tr.Info << std::endl;
343 
344  // initialize detect_res vector, specifies whether the designability of a residue should be decided by find_design_interface
345  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
346  if( ! resfilename_.empty() ){
347  if (task.residue_task( i ).has_behavior("AUTO")) {
348  detect_res[i] = true;
349  // tr.Info << "detectable:" << i << std::endl;
350  } else {
351  detect_res[i] = false;
352  // tr.Info << "not detectable:" << i << std::endl;
353  }
354  } // end if (resfile)
355  // if no resfile input, set all to automatic detection
356  else {
357  detect_res[i] = true;
358  }
359  }
360  //Now we have two ways to find interface: typical sphere method, and new arg sweep method (if arginine rotamers can interact with ligand, position is designable)
361  if ( arg_sweep_interface_ == true ) {
362  core::Real arg_sweep_cutoff(arg_sweep_cutoff_);
363  find_design_interface_arg_sweep( pose, interface_target_res, cut1, cut2, cut3, cut4, arg_sweep_cutoff, repack_res, design_res );
364  } else {
365  find_design_interface( pose, interface_target_res, cut1, cut2, cut3, cut4, repack_res, design_res );
366  }
367 
368  //setup the task accordingly
369  //default behavior for design will be everything except cys, and of course we want to leave disulfide bonds untouched
370  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
371  // only do auto-detection if the residue was set to AUTO above in detect_res initialization
372  if (detect_res[i] == true){
373  if( design_res[i] == true) {
376  } else if ( no_design_cys_ ) {
378  if( pose.residue( i ).aa() != core::chemical::aa_cys ) keep_aas[ core::chemical::aa_cys ] = false;
380  }
381  } else if( repack_res[i] == true ){
385  } else {
387  }
388  }
389  } // end pack/design assignment loop
390  } // detect design interface
391 
392 
393 
394  //in case we are only interested in scoring
395  if( score_only_ ) {
396  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
398  }
399  }
400 
401  //in case we are only interested in repacking
402  else if( repack_only_ ) {
403  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
404  if(task.design_residue(i)) {
406  }
407  }
408  }
409 
410  // As a final check print out everything designed
411  tr.Info << "Final Design Shell Residues: ";
412  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
413  if(task.design_residue(i)) {
414  tr.Info << i << ", ";
415  }
416  }
417  tr.Info << std::endl << "Final Repack Shell Residues: ";
418  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
419  if(task.pack_residue(i)) {
420  tr.Info << i << ", ";
421  }
422  }
423  tr.Info << std::endl;
424 
425  //lastly, in case of symmetry the task should be symmetrized by union
427 } //apply
428 
429 void
431  core::pose::Pose const & pose,
432  std::set< core::Size > const & interface_target_res,
433  core::Real cut1,
434  core::Real cut2,
435  core::Real cut3,
436  core::Real cut4,
437  utility::vector1< bool > & repack_res,
438  utility::vector1< bool > & design_res
439 ) const
440 {
441 
442  core::Real cut1_sq = cut1 * cut1;
443  core::Real cut2_sq = cut2 * cut2;
444  core::Real cut3_sq = cut3 * cut3;
445  core::Real cut4_sq = cut4 * cut4;
446 
447  for( std::set< core::Size >::const_iterator targ_it( interface_target_res.begin()),targ_end(interface_target_res.end());
448  targ_it != targ_end; ++targ_it ){
449 
450  repack_res[ *targ_it ] = true;
451  // on protein side, have to do distance check
452  core::conformation::Residue const & targ_rsd = pose.residue( *targ_it );
453  core::Size targ_res_atom_start = 1;
454  if( targ_rsd.is_protein() ){
455  design_res[ *targ_it ] = true; //might be designable
456  repack_res[ *targ_it ] = false;
457  targ_res_atom_start = targ_rsd.first_sidechain_atom();
458  }
459 
460  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
461  if( design_res[i] ) continue; //in case this is already set to design, we don't have to loop over it again
462  if( interface_target_res.find( i ) != interface_target_res.end() ) continue;
463  core::conformation::Residue const & prot_rsd = pose.residue(i);
464  for(core::Size k = targ_res_atom_start, k_end = targ_rsd.nheavyatoms(); k <= k_end; ++k) {
465  core::Vector prot_cb, prot_ca;
466  if( prot_rsd.has("CB") ) prot_cb = prot_rsd.xyz("CB");
467  if( prot_rsd.has("CA") ) prot_ca = prot_rsd.xyz("CA"); // GLY
468  core::Real ca_dist2 = targ_rsd.xyz(k).distance_squared( prot_ca );
469  if( ca_dist2 <= cut4_sq ) {
470  if( ca_dist2 <= cut3_sq ) {
471  if( ca_dist2 <= cut2_sq ) {
472  if( ca_dist2 <= cut1_sq) {
473  design_res[i] = true;
474  repack_res[i] = false;
475  break;
476  } // cut1
477  else if( prot_rsd.has("CB") ) {
478  core::Real cb_dist2 = targ_rsd.xyz(k).distance_squared( prot_cb );
479  // tr.Info << "cb_dist2 is " << cb_dist2 << "; ";
480  if( cb_dist2 < ca_dist2 ) {
481  design_res[i] = true;
482  repack_res[i] = false;
483  break;
484  }
485  else {
486  repack_res[i] = true;
487  }
488  } // end of non-gly residues
489  else if ( prot_rsd.has("2HA") ) { //glycine doesn't have a CB, so use 2HA to get position where CB would be
490  // use the name "cb" to describe the 2HA atom; design if 2HA < CA
491  prot_cb = prot_rsd.xyz("2HA");
492  core::Real cb_dist2 = targ_rsd.xyz(k).distance_squared( prot_cb );
493  if( cb_dist2 < ca_dist2 ) { // 2HA is closer than CA
494  design_res[i] = true;
495  repack_res[i] = false;
496  break;
497  }
498  else { // 2HA is further than CA
499  repack_res[i] = true;
500  }
501  } // end of gly residues
502  else { // Exception handling case for residue without CB or 2HA
503  tr.Info << "Weird residue without CB or 2HA. Watch out! Residue:" << i << std::endl;
504  design_res[i] = false;
505  repack_res[i] = true;
506  break;
507  } // end of exception catching for neither CB nor 2HA
508  } //cut2
509  else {
510  repack_res[i] = true;
511  }
512  } //cut3
513 
514  else if( prot_rsd.has("CB") ) {
515  core::Real cb_dist2 = targ_rsd.xyz(k).distance_squared( prot_cb );
516  if( cb_dist2 < ca_dist2 ) {
517  repack_res[i] = true;
518  }
519  }
520  } //cut4
521  } //loop over target res atoms
522  } //loop over protein residues
523  } //loop over target residues
524 
525  std::string repackres_string(""), designres_string;
526  core::Size num_repack(0), num_design(0);
527  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
528  if( repack_res[i] ){
529  num_repack++;
530  repackres_string = repackres_string + utility::to_string( i ) + "+";
531  }
532  if( design_res[i] ){
533  num_design++;
534  designres_string = designres_string + utility::to_string( i ) + "+";
535  }
536  if( ( repack_res[i] == true) && ( design_res[i] == true ) ) { tr.Info << "Huh? this should not happen. " << std::endl; }
537  }
538 
539  tr.Info << "Design Interface: detected " << num_design << " design-shell residues and " << num_repack << " repack-shell residues, shell sizes cut1-4 used were " << cut1 << " " << cut2 << " " << cut3 << " " << cut4 << std::endl << "Design-shell Residues(pose-numbering): " << designres_string;
540  tr.Info << std::endl << "Repack-shell Residues(pose-numbering): " << repackres_string << std::endl;
541 
542 } //find_design_interface
543 
544 void
546  core::pose::Pose const & pose,
547  std::set< core::Size > const & interface_target_res,
548  core::Real cut1,
549  core::Real cut2,
550  core::Real cut3,
551  core::Real cut4,
552  core::Real arg_sweep_cutoff,
553  utility::vector1< bool > & repack_res,
554  utility::vector1< bool > & design_res
555 ) const
556 {
557  core::Real cut1_sq = cut1 * cut1;
558  core::Real cut2_sq = cut2 * cut2;
559  core::Real cut3_sq = cut3 * cut3;
560  core::Real cut4_sq = cut4 * cut4;
561 
562  for( std::set< core::Size >::const_iterator targ_it( interface_target_res.begin()),targ_end(interface_target_res.end());
563  targ_it != targ_end; ++targ_it ){
564 
565  repack_res[ *targ_it ] = true;
566  // on protein side, have to do distance check
567  core::conformation::Residue const & targ_rsd = pose.residue( *targ_it );
568  core::Size targ_res_atom_start = 1;
569  if( targ_rsd.is_protein() ){
570  design_res[ *targ_it ] = true; //might be designable
571  repack_res[ *targ_it ] = false;
572  targ_res_atom_start = targ_rsd.first_sidechain_atom();
573  }
574 
575  // tr.Info << "Design residues by arg_sweep are: ";
576  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
577  if( design_res[i] ) continue; //in case this is already set to design, we don't have to loop over it again
578  if( interface_target_res.find( i ) != interface_target_res.end() ) continue;
579  core::conformation::Residue const & prot_rsd = pose.residue(i);
580  // Defining private members as magic numbers, shouldn't do this...
581  core::Real contact_threshold_ = arg_sweep_cutoff * arg_sweep_cutoff ; // Originally 3.7*3.7 (13.7)
582  core::Real close_threshold_ = 10. * 10. ;
583  bool base_only_ = false; //Doesn't matter here, chooses between all atoms in residue and sidechain atoms for iterator
584 
585  //Super simple arg sweep interface detection routinue
586  bool close_to_lig( protocols::dna::close_to_dna( prot_rsd, targ_rsd, close_threshold_, base_only_ ) );
587  if( close_to_lig ) {
588  core::Real dis2 = protocols::dna::argrot_dna_dis2( pose, i, prot_rsd, targ_rsd, contact_threshold_, base_only_ ); // i is protein residue id
589  if( dis2 <= contact_threshold_ ) {
590  design_res[i] = true;
591  repack_res[i] = false;
592  // tr.Info << i << ", ";
593  continue; //If arg_sweep finds design_res, go onto next resi
594  }
595  }
596 // tr.Info << "on protein resi number " << i << " , close_to_lig is " << close_to_lig << " and dis2 from arginine rotamer sweep is " << dis2 << std::endl ;
597  for(core::Size k = targ_res_atom_start, k_end = targ_rsd.nheavyatoms(); k <= k_end; ++k) { //Now looping over atoms in ligand, I don't need to do that
598  core::Vector prot_cb, prot_ca;
599  if( prot_rsd.has("CB") ) prot_cb = prot_rsd.xyz("CB");
600  if( prot_rsd.has("CA") ) prot_ca = prot_rsd.xyz("CA"); // GLY
601  core::Real ca_dist2 = targ_rsd.xyz(k).distance_squared( prot_ca );
602  if( ca_dist2 <= cut4_sq ) {
603  if( ca_dist2 <= cut3_sq ) {
604  if( ca_dist2 <= cut2_sq ) {
605  if( ca_dist2 <= cut1_sq) {
606  design_res[i] = false;
607  repack_res[i] = true;
608  break;
609  } // cut1
610  else if( prot_rsd.has("CB") ) {
611  core::Real cb_dist2 = targ_rsd.xyz(k).distance_squared( prot_cb );
612  // tr.Info << "cb_dist2 is " << cb_dist2 << "; ";
613  if( cb_dist2 < ca_dist2 ) {
614  design_res[i] = false;
615  repack_res[i] = true;
616  break;
617  }
618  else {
619  repack_res[i] = true;
620  }
621  } // end of non-gly residues
622  else if ( prot_rsd.has("2HA") ) { //glycine doesn't have a CB, so use 2HA to get position where CB would be
623  // use the name "cb" to describe the 2HA atom; design if 2HA < CA
624  prot_cb = prot_rsd.xyz("2HA");
625  core::Real cb_dist2 = targ_rsd.xyz(k).distance_squared( prot_cb );
626  if( cb_dist2 < ca_dist2 ) { // 2HA is closer than CA
627  design_res[i] = false;
628  repack_res[i] = true;
629  break;
630  }
631  else { // 2HA is further than CA
632  repack_res[i] = true;
633  }
634  } // end of gly residues
635  else { // Exception handling case for residue without CB or 2HA
636  tr.Info << "Weird residue without CB or 2HA. Watch out! Residue:" << i << std::endl;
637  design_res[i] = false;
638  repack_res[i] = true;
639  break;
640  } // end of exception catching for neither CB nor 2HA
641  } //cut2
642  else {
643  repack_res[i] = true;
644  }
645  } //cut3
646 
647  else if( prot_rsd.has("CB") ) {
648  core::Real cb_dist2 = targ_rsd.xyz(k).distance_squared( prot_cb );
649  if( cb_dist2 < ca_dist2 ) {
650  repack_res[i] = true;
651  }
652  }
653  } //cut4
654  } //loop over target res atoms
655  } //loop over protein residues
656  } //loop over target residues
657 
658  std::string repackres_string(""), designres_string;
659  core::Size num_repack(0), num_design(0);
660  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
661  if( repack_res[i] ){
662  num_repack++;
663  repackres_string = repackres_string + utility::to_string( i ) + "+";
664  }
665  if( design_res[i] ){
666  num_design++;
667  designres_string = designres_string + utility::to_string( i ) + "+";
668  }
669  if( ( repack_res[i] == true) && ( design_res[i] == true ) ) { tr.Info << "Huh? this should not happen. " << std::endl; }
670  }
671 
672  tr.Info << "Design Interface: detected " << num_design << " design-shell residues and " << num_repack << " repack-shell residues, shell sizes cut1-4 used were " << cut1 << " " << cut2 << " " << cut3 << " " << cut4 << std::endl << "Design-shell Residues(pose-numbering): " << designres_string;
673  tr.Info << std::endl << "Repack-shell Residues(pose-numbering): " << repackres_string << std::endl;
674 
675 } //find_design_interface_arg_sweep
676 
677 void
679 {
680 
681  using namespace basic::options;
682  using namespace basic::options::OptionKeys;
683 
684  option.add_relevant( OptionKeys::packing::resfile );
685 
688 
689  option.add_relevant( OptionKeys::enzdes::detect_design_interface );
690  option.add_relevant( OptionKeys::enzdes::cut1 );
691  option.add_relevant( OptionKeys::enzdes::cut2 );
692  option.add_relevant( OptionKeys::enzdes::cut3 );
693  option.add_relevant( OptionKeys::enzdes::cut4 );
694  option.add_relevant( OptionKeys::enzdes::enz_score );
695  option.add_relevant( OptionKeys::enzdes::enz_repack );
696 
697 }
698 
699 void
701  core::pose::Pose const & pose,
702  std::set< core::Size > & set
703 )
704 {
705  using namespace basic::datacache;
706  using namespace core::pose::datacache;
707 
709 
711  for( core::Size i = 1; i <= segments.size(); ++i ){
712  for( core::Size j = segments[i].first; j < segments[i].second; ++j ) set.insert( j );
713  }
714  }
715 }
716 
717 
719 {
721  catres_packer_weight_=1.0;
722 }
723 
725 
728 {
729  return new ProteinLigandInterfaceUpweighter(*this);
730 }
731 
732 /// @brief Initialize the class based on the command line options.
733 void
735 {
736  lig_packer_weight_ = basic::options::option[basic::options::OptionKeys::enzdes::lig_packer_weight];
737 }
738 
739 void
741 {
742  if( tag->hasOption("interface_weight") ) lig_packer_weight_ = tag->getOption< core::Real >( "interface_weight", 1.0 );
743  if( tag->hasOption("catres_interface_weight") ) catres_packer_weight_ = tag->getOption< core::Real >( "catres_interface_weight", 1.0 );
744 }
745 
746 /// @brief Change a packer task in some way. The input pose is the one to which the input
747 /// task will be later applied.
749 Pose const & pose,
750 PackerTask & task) const
751 {
752  //If applicable, set the ligand weigths to the specified value
753  if( lig_packer_weight_ != 1.0 ){
756  IGreweight->add_reweighter( lig_up );
757 
758  tr.Info << "Packer Energies between ligand and design residues are upweighted by factor " << lig_packer_weight_ << "." << std::endl;
759 
760  } //if different ligand weights are asked for
761  if (catres_packer_weight_ !=1.0){
763  utility::vector1< core::Size > design_residues;
764  for (core::Size ii= 1; ii<=pose.total_residue(); ++ii){
765  if ( enzutil::is_catalytic_seqpos( pose, ii) && pose.residue( ii ).is_protein() ) catres.push_back( ii );
766  else if (task.design_residue( ii )) design_residues.push_back( ii );
767  }
768 
769  core::pack::task::IGEdgeReweighterOP catres_up = new protocols::toolbox::ResidueGroupIGEdgeUpweighter( catres_packer_weight_, catres , design_residues );
770  task.set_IGEdgeReweights()->add_reweighter( catres_up );
771 
772  tr.Info << "Packer Energies between catalytic residues and design residues are upweighted by factor " << catres_packer_weight_ << "." << std::endl;
773  } //if different catalytic-residue weights are asked for
774 
775 } //apply
776 
777 void
779 {
780  basic::options::option.add_relevant( basic::options::OptionKeys::enzdes::lig_packer_weight );
781 }
782 
785 {
786  return new AddRigidBodyLigandConfs;
787 }
788 
790 
792 
795 {
796  return new AddRigidBodyLigandConfs();
797 }
798 
799 /// @details doesn't do anything atm, because the operation right now
800 /// puts lig conformers it finds in the pose at apply time into the task
801 /// this could be expanded to actually having this operation create additional
802 /// conformers
803 void
805 {
806 }
807 
808 void
810  Pose const & pose,
811  PackerTask & task
812 ) const
813 {
814 
815  //std::cout << "starting apply func of AddRigidBodyLigandConfs" << std::endl;
817  if( !enz_obs ) return;
818  //std::cout << "non zero observer given ";
819 
820  std::map< core::Size, utility::vector1< core::conformation::ResidueCOP > > const & rb_map = enz_obs->lig_rigid_body_confs();
821 
822  for( std::map< core::Size, utility::vector1< core::conformation::ResidueCOP > >::const_iterator lig_it = rb_map.begin(); lig_it != rb_map.end(); ++lig_it ){
823 
824  if( !task.being_packed( lig_it->first ) ) continue;
825  if( lig_it->second.size() == 0 ) continue;
826  runtime_assert( pose.residue_type( lig_it->first ).name3() == lig_it->second[1]->type().name3() );
827 
829  rb_rotsetop->set_rigid_body_confs( lig_it->second );
830 
831  //std::cout << " instantiated rotamer set operation, passed it " << lig_it->second.size() << " rb confs for position " << lig_it->first << std::endl;
832 
833  task.nonconst_residue_task( lig_it->first ).append_rotamerset_operation( rb_rotsetop );
834  }
835 }
836 
837 void
839 {
840  basic::options::option.add_relevant( basic::options::OptionKeys::enzdes::run_ligand_motifs );
841 }
842 
844 
846 
849 {
850  return new AddLigandMotifRotamers();
851 }
852 
853 void
855 {
856 /*
857 -dtest 2
858 -r2 0.4
859 -r1 0.6
860 -z1 1.0
861 -z2 0.97
862 -dump_motifs true
863 -output_file output.file
864 -data_file data.file
865 -rotlevel 8
866 -motif_filename Pruned_NoCCC.motifs
867 */
868 //Those are some options I could add, but it's not really necessary--most users will pass those options on the command line. I will eventually make them parseable tags. -mdsmith
869 }
870 
871 void
873  Pose const & pose,
874  PackerTask & task
875 ) const
876 {
878  motif_search->run( pose, task );
879 }
880 
881 }//namespace enzdes
882 }//namespace protocols