Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
enzdes_util.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/enzdes_util.cc
11 /// @brief a bunch of utility functions used in enzdes
12 /// @author Florian Richter, floric@u.washington.edu
13 
14 
15 // Unit headers
17 
24 
25 // Project headers
28 
29 #include <core/graph/Graph.hh>
30 #include <core/io/pdb/pose_io.hh>
31 #include <core/pose/Pose.hh>
32 #include <core/pose/PDBInfo.hh>
33 #include <basic/datacache/BasicDataCache.hh>
35 #include <basic/datacache/CacheableString.hh>
36 #include <core/pack/task/TaskFactory.hh> //task shit
43 #include <basic/Tracer.hh>
44 // AUTO-REMOVED #include <core/scoring/dssp/Dssp.hh>
45 // AUTO-REMOVED #include <protocols/ligand_docking/LigandBaseProtocol.hh>
46 // AUTO-REMOVED #include <core/scoring/constraints/BoundConstraint.hh>
47 #include <core/scoring/Energies.hh>
48 // AUTO-REMOVED #include <core/scoring/constraints/ConstraintSet.hh>
49 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
50 #include <basic/options/keys/in.OptionKeys.gen.hh>
51 #include <basic/options/option.hh>
52 // AUTO-REMOVED #include <protocols/ligand_docking/ligand_functions.hh> //for minimizing ligand torsions
53 // AUTO-REMOVED #include <core/kinematics/MoveMap.hh>
54 // AUTO-REMOVED #include <protocols/simple_moves/MinMover.hh>
58 #include <basic/options/keys/docking.OptionKeys.gen.hh>
59 
60 // Utility Headers
61 #include <utility/pointer/ReferenceCount.hh>
62 #include <utility/string_util.hh>
63 // AUTO-REMOVED #include <set>
64 #include <boost/foreach.hpp>
65 #define foreach BOOST_FOREACH
66 
68 #include <core/pose/util.hh>
69 #include <utility/vector1.hh>
70 
71 //Auto Headers
72 #include <core/id/AtomID.hh>
73 
74 namespace protocols {
75 namespace enzdes {
76 namespace enzutil{
77 
78 static basic::Tracer tr("protocols.enzdes.enzdes_util");
79 
80 bool
82  core::pose::Pose const & pose,
83  core::Size const seqpos
84 )
85 {
87  if( !enz_obs) return false;
88  toolbox::match_enzdes_util::EnzdesCstCacheCOP cst_cache( enz_obs->cst_cache() );
89  if( !cst_cache ) return false;
90  for( core::Size i = 1; i <= cst_cache->ncsts(); ++i) {
91  if( cst_cache->param_cache( i )->contains_position( seqpos ) ) return true;
92  }
93  return false;
94 }
95 
96 
99 {
100 
101  using namespace core;
102  utility::vector1< Size > to_return;
103 
105  if( enz_obs ){
106  toolbox::match_enzdes_util::EnzdesCstCacheCOP cst_cache( enz_obs->cst_cache() );
107  if( cst_cache ) to_return = cst_cache->ordered_constrained_positions( pose );
108  }
109 
110  if( to_return.size() == 0 ){
111  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
112  if( pose.residue_type( i ).is_ligand() ) to_return.push_back( i );
113  }
114  }
115  return to_return;
116 }
117 
118 
121  core::pose::Pose const & pose,
122  int which_res
123 )
124 {
125 
126  using namespace core::scoring;
127 
128  EnergyMap const & all_weights = pose.energies().weights();
129  EnergyMap const & scores( which_res == -1 ? pose.energies().total_energies() : pose.energies().residue_total_energies( which_res ) );
130 
131  //if( which_res == -1){ //means we want to know stuff for the whole pose
132  // scores = pose.energies().total_energies();
133  //}
134  //else{ scores = pose.energies().residue_total_energies( which_res ); }
135 
136  return scores[ coordinate_constraint ] * all_weights[ coordinate_constraint ] + scores[atom_pair_constraint] * all_weights[ atom_pair_constraint] +
137  scores[ angle_constraint ] * all_weights[ angle_constraint ] + scores[ dihedral_constraint ] * all_weights[ dihedral_constraint ];
138 
139 }
140 
141 
142 /// @brief convenience function to read in a pose for enzdes
143 /// this function basically just calls pose_from_pdb, but it
144 /// will create an enzdes cacheable observer in the pose,
145 /// also, 1, if a multimodel pdb is requested, if there are different
146 /// ligand positions, these will be saved in the enzdes cacheable observer
147 /// and 2, if option additional_packing_ligand_rb_confs is active, random
148 /// ligand rigid body confs will be generated and added to the cacheable
149 /// observer
150 void
152  core::pose::Pose & pose,
153  std::string const & filename
154 )
155 {
157  core::import_pose::pose_from_pdb( input_poses, filename );
158  runtime_assert( input_poses.size() > 0 );
159  pose = input_poses[1];
161 
162  //now the basic pose is ready. let's see if there are any additional ligands
163  //in multimodel pdbs
164  if( input_poses.size() > 1 ){
165  tr << "PDB " << filename << " is a multimodel pdb containing " << input_poses.size() << " models." << std::endl;
166  utility::vector1< utility::vector1< core::conformation::ResidueOP > > add_residue_confs( pose.total_residue() );
167 
168  for( core::Size i = 2; i <= input_poses.size(); ++i ){
169  for( core::Size j = 1; j <= input_poses[i].total_residue(); ++j){
170  core::Size pdbres( input_poses[i].pdb_info()->number( j ) );
171  char pdbchain( input_poses[i].pdb_info()->chain( j ) );
172  char pdbicode( input_poses[i].pdb_info()->icode( j ) );
173  core::Size orig_seqpos( pose.pdb_info()->pdb2pose( pdbchain, pdbres, pdbicode ) );
174  if( orig_seqpos > 0 ) {
175  core::conformation::ResidueOP newres( input_poses[i].residue(j).clone() );
176  newres->seqpos( orig_seqpos );
177  newres->chain( pose.residue( orig_seqpos ).chain() );
178  add_residue_confs[ orig_seqpos ].push_back( newres );
179  }
180  }
181  }
182  for( core::Size i = 1; i <= pose.total_residue(); ++i ){
183  if( add_residue_confs[i].size() > 0 ){
184  if( pose.residue(i).is_ligand() ){
185  enz_obs->set_rigid_body_confs_for_lig( i, add_residue_confs[i] );
186  tr << "For ligand at seqpos " << i << ", " << add_residue_confs[i].size() << " additional rigid body locations were read in." << std::endl;
187  }
188  }
189  }
190  } //if there was more than one pose
191 
192  //2.
193  if( basic::options::option[basic::options::OptionKeys::enzdes::additional_packing_ligand_rb_confs] > 0 ){
194  GenerateStoredRBConfs rb_generator( basic::options::option[basic::options::OptionKeys::enzdes::additional_packing_ligand_rb_confs], false );
195  rb_generator.apply( pose );
196  }
197 }
198 
199 void
201  utility::vector1< bool > & the_vector,
202  core::Size const min_number_continuous_trues
203 )
204 {
205 
206  if( min_number_continuous_trues > the_vector.size() ){
207  utility_exit_with_message("ridiculous. continuous region is requested to be longer than the actual vector. go play in traffic.\n");
208  }
209 
211 
212  bool in_cont_region = false;
213  core::Size last_cont_begin(0);
214 
215  for( core::Size i = 1; i <= the_vector.size(); ++i){
216 
217  if( ( ! in_cont_region ) && (the_vector[ i ]==true) ) {
218  last_cont_begin = i;
219  in_cont_region = true;
220  //tr << "cont region begin at " << i << ", ";
221  }
222 
223  if ( in_cont_region && (the_vector[ i ]==false ) ){
224  continuous_regions.push_back( std::pair< core::Size, core::Size > ( last_cont_begin, (i - 1) ));
225  in_cont_region = false;
226  //tr << "cont_region end at " << (i-1) << " with last_cont_begin "<< last_cont_begin << std::endl;
227  }
228  }
229  //in case the last residue in the vector is set to true
230  if( in_cont_region ) continuous_regions.push_back( std::pair< core::Size, core::Size > (last_cont_begin, the_vector.size() ) );
231 
232  if( continuous_regions.size() == 0 ){
233  utility_exit_with_message("The passed in vector doesn't have a single element set to true.\n");
234  }
235 
236  for( core::Size j = 1; j<= continuous_regions.size(); ++j){
237  std::pair< core::Size, core::Size > & cur_region = continuous_regions[j];
238 
239  //tr << "processing cont region between " << cur_region.first << " and " << cur_region.second << std::endl;
240  if( cur_region.second - cur_region.first + 1 < min_number_continuous_trues ){
241 
242  //we need to do something
243  core::Size to_fill = min_number_continuous_trues - ( cur_region.second - cur_region.first + 1 );
244 
245  core::Size to_fill_each_side = (to_fill / 2) + 1;
246 
247  core::Size left_gap(0), right_gap(0);
248  core::Size prev_region_first(1), next_region_second( the_vector.size () );
249 
250  if( j == 1 ) left_gap = cur_region.first - 1;
251  else {
252  left_gap = cur_region.first - continuous_regions[ j - 1 ].second - 1;
253  prev_region_first = continuous_regions[ j - 1 ].first;
254  }
255 
256  if( j == continuous_regions.size() ) right_gap = the_vector.size() - cur_region.second;
257  else {
258  right_gap = continuous_regions[ j + 1 ].first - cur_region.second - 1;
259  next_region_second = continuous_regions[ j + 1 ].second;
260  }
261 
262  //tr << "left gap is " << left_gap << " right is " << right_gap << std::endl;
263  core::Size cur_region_tmp_first = cur_region.first - to_fill_each_side;
264  core::Size cur_region_tmp_second = cur_region.second + to_fill_each_side;
265 
266  for( core::Size k = 1; k <= to_fill_each_side; ++k ){
267 
268  if( k <= left_gap ) {
269  the_vector[ cur_region.first - k ] = true;
270  //tr << (cur_region.first - k) << "set true , ";
271 
272  if( k == left_gap) {
273  if( j == 1 )cur_region_tmp_first = 1;
274 
275  else cur_region_tmp_first = continuous_regions[ j -1 ].second + 1;
276 
277 
278  if( ((cur_region.second + k - 1 ) - prev_region_first + 1) >= min_number_continuous_trues){
279  cur_region_tmp_second = cur_region.second + k - 1;
280  //tr << "breaking because of left gap ";
281  break;
282  }
283  }
284  }
285  else if ( ((cur_region.second + k - 1 ) - prev_region_first + 1) >= min_number_continuous_trues){
286  cur_region_tmp_second = cur_region.second + k - 1;
287  break;
288  }
289 
290  if( k <= right_gap ) {
291  the_vector[ cur_region.second + k ] = true;
292  //tr << (cur_region.second + k) << "set true , ";
293 
294  if( k == right_gap ) {
295  if( j == continuous_regions.size() ) cur_region_tmp_second = the_vector.size();
296  else cur_region_tmp_second = continuous_regions[ j + 1 ].first - 1;
297 
298  if( (next_region_second - (cur_region.first - k ) + 1 ) >= min_number_continuous_trues){
299  cur_region_tmp_first = (cur_region.first - k );
300  //tr << "breaking because of right gap ";
301  break;
302  }
303  }
304  }
305  else if( (next_region_second - (cur_region.first - k ) + 1 ) >= min_number_continuous_trues){
306  cur_region_tmp_first = (cur_region.first - k );
307  break;
308  }
309  }
310 
311  cur_region.first = cur_region_tmp_first;
312  cur_region.second = cur_region_tmp_second;
313  //tr << std::endl;
314  } //if we need to fill up this region
315 
316  }
317  //tr << " making vector continuous over." << std::endl;
318 
319 } // make_contiuous_true_regions
320 
321 
324  core::pose::Pose const & pose,
325  core::pack::task::PackerTask const & orig_task
326 )
327 {
328 
329  using namespace core::pack::task;
330 
331  if( orig_task.total_residue() != pose.total_residue() ) utility_exit_with_message("old task and pose don't have same number of residues.");
332 
333  PackerTaskOP mod_task = TaskFactory::create_packer_task( pose );
334  mod_task->initialize_from_command_line();
335 
336  for( core::Size i = 1; i <= pose.total_residue(); ++i ){
337 
338  //first, we need to copy the rotamer and rotamerset operations
339  for( core::pack::rotamer_set::RotamerOperations::const_iterator rot_it = orig_task.residue_task(i).rotamer_operations().begin(); rot_it != orig_task.residue_task(i).rotamer_operations().end(); ++rot_it ){
340  mod_task->nonconst_residue_task( i ).append_rotamer_operation( *rot_it );
341  }
342  for( core::pack::rotamer_set::RotSetOperationListIterator rotset_it = orig_task.residue_task(i).rotamer_set_operation_begin(); rotset_it != orig_task.residue_task(i).rotamer_set_operation_end(); ++rotset_it ){
343  mod_task->nonconst_residue_task( i ).append_rotamerset_operation( *rotset_it );
344  }
345 
346  if( !orig_task.residue_task( i ).being_packed() ) mod_task->nonconst_residue_task(i).prevent_repacking();
347  else if( !orig_task.residue_task( i ).being_designed() ) mod_task->nonconst_residue_task(i).restrict_to_repacking();
348  else{
350 
351  for( ResidueLevelTask::ResidueTypeCOPListConstIter res_it = orig_task.residue_task( i ).allowed_residue_types_begin(); res_it != orig_task.residue_task( i ).allowed_residue_types_end(); ++res_it) {
352 
353  keep_aas[ (*res_it)->aa() ] = true;
354  }
355 
356 
357  //keep_aas[ core::chemical::aa_cys ] = false;
358  mod_task->nonconst_residue_task(i).restrict_absent_canonical_aas( keep_aas );
359  }
360  }
361 
362  if( orig_task.IGEdgeReweights() ) {
363  for( utility::vector1< IGEdgeReweighterOP >::const_iterator it = orig_task.IGEdgeReweights()->reweighters_begin(); it != orig_task.IGEdgeReweights()->reweighters_end(); ++it){
364  mod_task->set_IGEdgeReweights()->add_reweighter( *it );
365  }
366  }
367 
368  return mod_task;
369 } //recreate_task
370 
373 {
375  if( !enz_obs ) return NULL;
376  toolbox::match_enzdes_util::EnzdesCstCacheCOP enzcache( enz_obs->cst_cache() );
377  if( !enzcache ) return NULL;
378  return enzcache->enzcst_io();
379 }
380 
381 void
383  core::pose::Pose & pose,
384  core::Size geomcst
385 )
386 {
387 
388  core::pose::Remarks remarks( pose.pdb_info()->remarks() );
389  core::pose::Remarks newremarks;
390  for( core::Size i = 0; i < remarks.size(); ++i ){
391 
392  std::string chainA(""), chainB(""), resA(""), resB("");
393  core::Size cst_block(0), exgeom_id( 0 );
394  int pdbposA(0), pdbposB(0);
395  if( toolbox::match_enzdes_util::split_up_remark_line( remarks[i].value, chainA, resA, pdbposA, chainB, resB, pdbposB, cst_block, exgeom_id ) ){
396  if( cst_block == geomcst ) continue;
397  }
398  newremarks.push_back( remarks[i] );
399  }
400  pose.pdb_info()->remarks( newremarks );
401 }
402 
403 void
405  core::pose::Pose & pose
406 )
407 {
408  core::pose::Remarks remarks( pose.pdb_info()->remarks() );
409  core::pose::Remarks newremarks;
410 
412 
413  if( cstcache ){
414 
415  for( core::Size i(1); i <= cstcache->ncsts(); ++i){
416  toolbox::match_enzdes_util::EnzdesCstParamCache const & param_cache( *(cstcache->param_cache( i )) );
417  if( param_cache.missing_in_pose() ) continue;
418  std::string chainA(""), chainB(""), resA(""), resB("");
419  int pdbposA(0), pdbposB(0), seqposA(0), seqposB(0);
420 
421  if( param_cache.template_res_cache_size() != 2 ) utility_exit_with_message("Can't build a remark line from a param cache that does not have 2 template res saved.");
422  if( (param_cache.template_res_cache(1)->seqpos_map_size() != 1 ) || (param_cache.template_res_cache(2)->seqpos_map_size() != 1 ) ) utility_exit_with_message("Can't build a remark line from a templateres cahce that does not have 1 position saved.");
423  seqposA = param_cache.template_res_cache(1)->seqpos_map_begin()->first;
424  seqposB = param_cache.template_res_cache(2)->seqpos_map_begin()->first;
425 
426  chainA = pose.pdb_info()->chain( seqposA );
427  chainB = pose.pdb_info()->chain( seqposB );
428  pdbposA = pose.pdb_info()->number( seqposA );
429  pdbposB = pose.pdb_info()->number( seqposB );
430  resA = pose.residue( seqposA ).name3();
431  resB = pose.residue( seqposB ).name3();
432 
434  ri.num = 666;
435  ri.value = toolbox::match_enzdes_util::assemble_remark_line( chainA, resA, pdbposA, chainB, resB, pdbposB, i, 1 );
436  //std::cout << "adding " << ri.value << " to header... " << std::endl;
437  newremarks.push_back( ri );
438  }
439  }
440 
441  //we also have to make sure that no old remark headers remain
442  for( core::Size i = 0; i < remarks.size(); ++i ){
443 
444  std::string chainA(""), chainB(""), resA(""), resB("");
445  core::Size cst_block(0), exgeom_id( 0 );
446  int pdbposA(0), pdbposB(0);
447 
448  if( !toolbox::match_enzdes_util::split_up_remark_line( remarks[i].value, chainA, resA, pdbposA, chainB, resB, pdbposB, cst_block, exgeom_id ) ) newremarks.push_back( remarks[i] );
449  }
450  pose.pdb_info()->remarks( newremarks );
451 }
452 
453 /// @detail function not implemented very slick at the moment, need to find way to compile boost regex library :((
454 /// @detail to extract the pdb code from the pose tag without a regular expression module, some explicit functions
455 /// @detail have been written below
458  using namespace core::pose::datacache;
459 
460  std::string outtag = pose.data().get_const_ptr< basic::datacache::CacheableString >( CacheableDataType::JOBDIST_OUTPUT_TAG )->str();
461 
463 
464  //std::cerr <<"string that's supposed to contain a pdb code is " << outtag << ", found to contain the following pdb tags: " << std::endl;
465 
466  utility::vector1< std::string > tagparts = utility::string_split( outtag, '_' );
467 
468  for( utility::vector1< std::string >::const_iterator it = tagparts.begin(); it != tagparts.end(); ++it){
469 
470  if( it->size() != 4 ) continue;
471  std::string cand_str = *it;
472  //ok, no boost regex, so clumsy implementation to look for pdb code in string
473  if( is_digit( &cand_str[0]) ){
474  if( is_digit( &cand_str[1]) && is_digit( &cand_str[2]) && is_digit ( &cand_str[3] ) ) continue;
475 
476  if( (( is_uppercase_letter( & cand_str[1] )|| is_digit( & cand_str[1] ) )
477  && ( is_uppercase_letter( & cand_str[2] )|| is_digit( & cand_str[2] ) )
478  && ( is_uppercase_letter( & cand_str[3] )|| is_digit( & cand_str[3] ) ) )
479  ||(( is_lowercase_letter( & cand_str[1] )|| is_digit( & cand_str[1] ) )
480  && ( is_lowercase_letter( & cand_str[2] )|| is_digit( & cand_str[2] ) )
481  && ( is_lowercase_letter( & cand_str[3] )|| is_digit( & cand_str[3] ) ) )
482  ){
483 
484  //std::cerr << "yeah, found putative pdb code " << cand_str << std::endl;
485  pdb_matches.push_back( cand_str );
486  }
487  }
488  }
489  /*
490 
491  //assemble regular expression to match pdb codes:
492  //4 char string, first one is a digit, remaining 3 are digits or letters
493  boost::regex pdb_re("\d([a-z]{3}|[A-Z]{3})");
494 
495  boost::regex pdb_re("\d((\d|[a-z]){3}) | \d((\d|[A-Z]){3})");
496  boost::cmatch pdb_rematches;
497 
498  if( boost::regex_match(outtag.c_str(), pdb_rematches, pdb_re) ){
499 
500  for (core::Size i = 1; i < pdb_rematches.size(); i++){
501  pdb_matches.push_back( std::string (pdb_rematches[i].first, pdb_rematches[i].second ) );
502  }
503  }
504 
505  */
506 
507  //for( core::Size i = 1; i <= pdb_matches.size(); ++i) std::cerr << pdb_matches[i] << std::endl;
508 
509  if( pdb_matches.size() == 0 ){
510  std::cerr << "protocols/enzdes/enzdes_util: WARNING: string " << outtag << "does not seem to contain a pdb code, returning N/A. " << std::endl;
511  pdb_matches.push_back( "N/A" );
512  }
513 
514  if( pdb_matches.size() > 1 ){
515  tr << "WARNING WARNING: in tag " << outtag << ", more than 1 pdbcode like pattern has been identified. assuming the first one (" << pdb_matches[1] << ") is the correct one." << std::endl;
516  }
517 
518  return pdb_matches[1];
519 
520  // for( std::vector< std::string >::const_iterator it = tagparts.begin(); it != tagparts.end(); ++it){
521  // if( it->size() != 4 ) continue;
522  //}
523 
524 }
525 
526 bool
527 is_digit( char * cha )
528 {
529 
530  //std::cerr << "comparing " << cha[0] << " to digits. " << std::endl;
531 
532  if( cha[0] == '0' ) return true;
533  else if (cha[0] == '1') return true;
534  else if (cha[0] == '2') return true;
535  else if (cha[0] == '3') return true;
536  else if (cha[0] == '4') return true;
537  else if (cha[0] == '5') return true;
538  else if (cha[0] == '6') return true;
539  else if (cha[0] == '7') return true;
540  else if (cha[0] == '8') return true;
541  else if (cha[0] == '9') return true;
542 
543  return false;
544 }
545 
546 
547 bool
549 {
550 
551  if( cha[0] == 'A' ) return true;
552  else if (cha[0] == 'B') return true;
553  else if (cha[0] == 'C') return true;
554  else if (cha[0] == 'D') return true;
555  else if (cha[0] == 'E') return true;
556  else if (cha[0] == 'F') return true;
557  else if (cha[0] == 'G') return true;
558  else if (cha[0] == 'H') return true;
559  else if (cha[0] == 'I') return true;
560  else if (cha[0] == 'J') return true;
561  else if (cha[0] == 'K') return true;
562  else if (cha[0] == 'L') return true;
563  else if (cha[0] == 'M') return true;
564  else if (cha[0] == 'N') return true;
565  else if (cha[0] == 'O') return true;
566  else if (cha[0] == 'P') return true;
567  else if (cha[0] == 'Q') return true;
568  else if (cha[0] == 'R') return true;
569  else if (cha[0] == 'S') return true;
570  else if (cha[0] == 'T') return true;
571  else if (cha[0] == 'U') return true;
572  else if (cha[0] == 'V') return true;
573  else if (cha[0] == 'W') return true;
574  else if (cha[0] == 'X') return true;
575  else if (cha[0] == 'Y') return true;
576  else if (cha[0] == 'Z') return true;
577 
578  return false;
579 }
580 
581 
582 bool
584 {
585 
586  if( cha[0] == 'a' ) return true;
587  else if (cha[0] == 'b') return true;
588  else if (cha[0] == 'c') return true;
589  else if (cha[0] == 'd') return true;
590  else if (cha[0] == 'e') return true;
591  else if (cha[0] == 'f') return true;
592  else if (cha[0] == 'g') return true;
593  else if (cha[0] == 'h') return true;
594  else if (cha[0] == 'i') return true;
595  else if (cha[0] == 'j') return true;
596  else if (cha[0] == 'k') return true;
597  else if (cha[0] == 'l') return true;
598  else if (cha[0] == 'm') return true;
599  else if (cha[0] == 'n') return true;
600  else if (cha[0] == 'o') return true;
601  else if (cha[0] == 'p') return true;
602  else if (cha[0] == 'q') return true;
603  else if (cha[0] == 'r') return true;
604  else if (cha[0] == 's') return true;
605  else if (cha[0] == 't') return true;
606  else if (cha[0] == 'u') return true;
607  else if (cha[0] == 'v') return true;
608  else if (cha[0] == 'w') return true;
609  else if (cha[0] == 'x') return true;
610  else if (cha[0] == 'y') return true;
611  else if (cha[0] == 'z') return true;
612 
613  return false;
614 }
615 void
617 
618  scorefxn->set_weight(core::scoring::coordinate_constraint, 0.0 );
619  scorefxn->set_weight(core::scoring::atom_pair_constraint, 0.0 );
620  scorefxn->set_weight(core::scoring::angle_constraint, 0.0 );
621  scorefxn->set_weight(core::scoring::dihedral_constraint, 0.0 );
622  scorefxn->set_weight(core::scoring::res_type_constraint, 0.0 );
623 
624 }
625 void
627 
628  if (scorefxn->has_zero_weight( core::scoring::coordinate_constraint ) ) scorefxn->set_weight(core::scoring::coordinate_constraint, 1 );
629  if (scorefxn->has_zero_weight( core::scoring::atom_pair_constraint ) ) scorefxn->set_weight(core::scoring::atom_pair_constraint, 1 );
630  if (scorefxn->has_zero_weight( core::scoring::angle_constraint ) ) scorefxn->set_weight(core::scoring::angle_constraint, 1 );
631  if (scorefxn->has_zero_weight( core::scoring::dihedral_constraint ) ) scorefxn->set_weight(core::scoring::dihedral_constraint, 1 );
632  if( basic::options::option[basic::options::OptionKeys::enzdes::favor_native_res].user() || basic::options::option[ basic::options::OptionKeys::in::file::pssm ].user() ){
633  if (scorefxn->has_zero_weight( core::scoring::res_type_constraint ) )scorefxn->set_weight(core::scoring::res_type_constraint, 1 );
634  }
635 }
636 bool
638  if (scorefxn->has_zero_weight( core::scoring::coordinate_constraint ) && scorefxn->has_zero_weight( core::scoring::atom_pair_constraint ) && scorefxn->has_zero_weight( core::scoring::angle_constraint ) && scorefxn->has_zero_weight( core::scoring::dihedral_constraint ) ) return false;
639  else return true;
640 }
641 
642 void
644 
645  if( basic::options::option[ basic::options::OptionKeys::docking::ligand::old_estat ].user() ){
646  core::scoring::methods::EnergyMethodOptions options_repack( scorefxn->energy_method_options() );
647  options_repack.exclude_protein_protein_hack_elec( basic::options::option[basic::options::OptionKeys::docking::ligand::old_estat ] );
648  scorefxn->set_energy_method_options( options_repack );
649  }
650 }
651 
652 void
654 {
656  if( !cst_cache ) return;
657  cst_cache->enzcst_io()->remove_constraints_from_pose( pose, false, false );
658  toolbox::match_enzdes_util::get_enzdes_observer( pose )->set_cst_cache( NULL );
659 }
660 
661 void
663 {
664  resnums.clear();
665  utility::vector1< std::string > const cstids ( utility::string_split( cstidlist , ',' ) );
666  foreach( std::string const cstid, cstids ){
667  if(cstid=="") continue;
668  core::Size const resnum (get_resnum_from_cstid( cstid, pose) );
669  runtime_assert( resnum>0 && resnum <=pose.total_residue() );
670  resnums.push_back( resnum );
671  }
672  std::unique(resnums.begin(), resnums.end());
673  //tr <<" In util function size of resnums is "<< resnums.size() << std::endl;
674 }
675 /// @brief Extracts residue number from cstid string
676 /// @detail Expects cstid string to be of format [0-9]+[A-Z], where the number is constraint number and trailing letter is temlplate id i.e. either A or B
677 /// - see enzdes style REMARKs format used to specify match type constraint between two residues (template A and template B)
680 {
681  char const templ(cstid[ cstid.length()-1] );
682  runtime_assert(templ == 'A' || templ == 'B');
683  core::Size template_num;
684  if (templ == 'A') template_num = 1;
685  else template_num = 2;
686 
687  std::stringstream ss( cstid.substr( 0, cstid.length() - 1) );
688  core::Size cstnum;
689  ss >> cstnum;
690  //tr << "Cstid " <<cstid <<" parsed as template:"<< templ <<" and cstnum: "<< cstnum<<std::endl;
692  runtime_assert( cst_cache );
693  runtime_assert( cstnum <= cst_cache->ncsts());
694  bool found (false);
695  for (core::Size seqpos =1; seqpos <=pose.total_residue(); ++seqpos){
696  if (cst_cache->param_cache(cstnum)->template_res_cache( template_num )->contains_position( seqpos )) {
697  // tr <<"Cstid "<<cstid<<" corresponds to "<< seqpos <<std::endl;
698  found = true;
699  return seqpos;
700  }
701  }
702  if (!found) utility_exit_with_message("Could not parse " + cstid + "to resnum");
703  return (0); // should not get here
704 }
705 
706 } //enzutil
707 } //enzdes
708 } //protocols