Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MatchConstraintFileInfo.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file IO-functionality for enzyme and matching Constraints
12 /// @brief
13 /// @author Florian Richter, floric@u.washington.edu, may 2009
14 
15 // Unit headers
17 
18 //package headers
23 
24 //#include <protocols/enzdes/EnzConstraintIO.hh>
25 //#include <protocols/enzdes/EnzConstraintParameters.hh>
26 
27 // Project headers
29 //#include <core/chemical/AA.hh> //needed to convert one letter AA codes
30 #include <core/chemical/ResidueTypeSet.hh> //have to include complete file
31 //#include <core/pose/Pose.hh>
32 //#include <core/id/AtomID.hh>
33 //#include <basic/options/option.hh>
34 //#include <core/id/SequenceMapping.hh>
35 #include <core/chemical/Patch.hh>
37 #include <core/pose/util.hh>
38 #include <basic/basic.hh>
39 //#include <core/io/pdb/pose_io.hh> //debug only include
40 //#include <core/pack/dunbrack/RotamerLibrary.hh> //debug only include
41 //#include <utility/io/izstream.hh> //debug only include
42 
43 // numeric headers
44 #include <numeric/HomogeneousTransform.hh>
45 
46 // Utility Headers
47 #include <utility/io/izstream.hh>
48 #include <utility/string_util.hh>
49 #include <iostream>
50 #include <fstream>
51 #include <string>
52 #include <sstream>
53 
54 #include <basic/Tracer.hh>
55 
56 
57 // option key includes
58 // AUTO-REMOVED #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
59 
60 // AUTO-REMOVED #include <basic/options/keys/enzdes.OptionKeys.gen.hh>// Why was it auto-removed? Can I put it back in?
61 
62 // AUTO-REMOVED #include <stdlib.h>
63 
64 #include <utility/vector1.hh>
65 
66 
67 
68 static basic::Tracer tr("protocols.toolbox.match_enzdes_util.MatchConstraintFileIfo");
69 
70 namespace protocols {
71 namespace toolbox{
72 namespace match_enzdes_util{
73 
74 
75 /// @brief function to go through a list of restypes and
76 /// reduce them to chemically identical ones based on the same base_name
77 /// i.e. this function gets rid of the variant redundancy
78 void
80  std::set< core::chemical::ResidueTypeCOP > & restype_subset,
83 {
84 
85  using namespace core::chemical;
86 
87  std::set< std::string > basename_set;
88 
89  for( core::Size i = 1; i <= restypes.size(); ++i ){
90 
91  std::string basename = residue_type_base_name( *(restypes[i]) );
92 
93  if( basename_set.find( basename ) == basename_set.end() ){
94 
95  basename_set.insert( basename );
96 
97  restype_subset.insert( &restype_set->name_map( basename ) );
98 
99  }
100  }
101 }
102 
103 
104 
106  std::string tag ) :
107  tag_(tag), function_tag_( "default" ), ideal_val_(0.0), tolerance_(0.0), periodicity_(360.0),
108  force_const_(0.0), num_steps_(0), step_size_(0.0)
109 {}
110 
112  core::Real ideal_val,
113  core::Real tolerance,
114  core::Real force_k,
115  core::Real periodicity
116 ) :
117 tag_(""), function_tag_("default"), ideal_val_(ideal_val), tolerance_(tolerance),
118 periodicity_(periodicity), force_const_(force_k), num_steps_(0), step_size_(0.0)
119 {}
120 
122 
123 bool
124 GeomSampleInfo::read_data( std::istringstream & line_stream )
125 {
126 
128 
129  std::string buffer("");
130 
131  while( true ){
132  line_stream >> buffer;
133  if ( line_stream.fail() ) break;
134  fields.push_back( buffer );
135  }
136 
137  if( fields.size() < 4 ){
138 
139  tr << "Not enough fields detected for constraint " << tag_ << "." << std::endl;
140  return false;
141  };
142 
143 
144  ideal_val_ = (core::Real ) atof( fields[1].c_str() );
145  tolerance_ = (core::Real ) atof( fields[2].c_str() );
146  force_const_ = (core::Real ) atof( fields[3].c_str() );
147  periodicity_ = (core::Real ) atof( fields[4].c_str() );
148 
149  if( (tag_ != "distanceAB:") && ((periodicity_ < 1.0) || (periodicity_ > 360.0)) ){ //safeguard against stupid input
150  std::cerr << "Error: illegal periodicity value of " << periodicity_ << " requested for degree of freedom " << tag_ << "." << std::endl;
151  utility_exit_with_message("Illegal periodicity value given. Value must be between 1.0 and 360.0 degrees.");
152  }
153 
154  if( fields.size() > 4 ){
155 
156  //we have to test if fields[5] is an integer
157  std::istringstream f5;
158  f5.clear();
159  f5.str( fields[5] );
160 
161  f5 >> num_steps_;
162  if( f5.bad() ) num_steps_ = 0;
163 
164  //num_steps_ = (core::Size ) atoi( fields[5].c_str() );
165  //tr << "for tag " << tag_ << "fields[5] is |" << fields[5] << "| and num_steps is " << num_steps_ << std::endl;
166  }
167 
168  if( fields[ fields.size() ] == "PERIODIC" ) function_tag_ = "PERIODIC";
169 
170  if( num_steps_ != 0 ) step_size_ = tolerance_ / num_steps_;
171 
172  tr.Debug << "data read for GeomSampleInfo with tag " << tag_ << ": ideal_value(" << ideal_val_ << "), tolerance(" << tolerance_ << "), force_k(" << force_const_ << "), periodicity(" << periodicity_ << "), num_steps(" << num_steps_ << "), step size(" << step_size_ << "), function_tag(" << function_tag_ << ")." << std::endl;
173 
174 
175  //some safeguards against retared user input
176  if( (tolerance_ == 0.0 ) && (num_steps_ != 0 ) ){
177 
178  num_steps_ = 0;
179 
180  tr << "WARNING: tolerance for constraint " << tag_ << " specified to be 0, yet num_steps specified to be non-0. Ignoring input and setting num_steps to 0." << std::endl;
181  }
182 
183  return true;
184 
185 }
186 
187 
190 {
191 
192  core::Size num_ideal_val(1);
193 
194  bool distance( tag_ == "distanceAB:");
195 
196  //1. figure out the number of ideal values
197  if ( (!distance ) && ( periodicity_ != 360.0 ) ) {
198  num_ideal_val = static_cast< Size > ( 360.0 / periodicity_ );
199  }
200 
201 
202  //2. explicity create all the ideal values
203  std::list< core::Real > ideal_values;
204 
205  //to make sure that there are no duplications
206  //through user input of unforeseen weirdness
207  std::set< core::Real > seen_values;
208 
209  for( int i = (int) -( num_ideal_val/2) ; i <= (int) ( num_ideal_val/2); ++i ){
210 
211  core::Real val = ideal_val_ + ( i * periodicity_ );
212 
213  if( !distance) val = basic::unsigned_periodic_range( val, 360.0 );
214 
215  if( seen_values.find( val ) == seen_values.end() ){
216  ideal_values.push_back( val );
217  seen_values.insert( val );
218  }
219  }
220 
221  //sort from lowest to highest because apl sez so
222  ideal_values.sort();
223 
224  //clear this bc it will be used again
225  seen_values.clear();
226 
227  //3. build up the diversification samples around each dihedral value
229  samples.clear();
230 
231  tr.Debug << "ideal values for gsi with tag " << tag_ << ", ideal_val " << ideal_val_ << ", and periodicity " << periodicity_ << "are :";
232 
233  for( std::list< core::Real >::const_iterator val_it = ideal_values.begin();
234  val_it != ideal_values.end(); ++val_it ){
235 
236  tr.Debug << *val_it << ", ";
237 
238  for( int i = (int) -num_steps_; i <= (int) num_steps_; ++i ){
239 
240  core::Real val = *val_it + ( i * step_size_ );
241 
242  if( !distance) val = basic::unsigned_periodic_range( val, 360.0 );
243 
244  if( seen_values.find( val ) == seen_values.end() ){
245  samples.push_back( val );
246  seen_values.insert( val );
247  }
248  }
249  } //over all ideal values
250 
251  tr.Debug << std::endl << " the generated samples are: ";
252 
253  for( core::Size i = 1; i <= samples.size(); ++i ){
254  tr.Debug << samples[i] << ", ";
255  }
256  tr.Debug << std::endl;
257 
258  return samples;
259 
260 }
261 
262 
263 
265  core::Size index,
267 : index_( index ), is_covalent_(false),
268  dis_U1D1_( NULL ), ang_U1D2_(NULL), ang_U2D1_(NULL),
269  tor_U1D3_(NULL), tor_U3D1_(NULL), tor_U2D2_(NULL),
270  restype_set_( restype_set ), native_ (false)
271 {
272  allowed_seqpos_.clear();
273  enz_template_res_.clear();
274 }
275 
277 
278 
281 {
282 
284 
285  EnzCstTemplateResCOP template_res = this->enz_cst_template_res( which_cstres );
286 
287  for( EnzCstTemplateRes::RestypeToTemplateAtomsMap::const_iterator restype_it = template_res->atom_inds_for_restype_begin(), restype_end = template_res->atom_inds_for_restype_end();
288  restype_it != restype_end; ++restype_it ){
289 
290  to_return.push_back( restype_it->first );
291  }
292 
293  return to_return;
294 }
295 
298  core::Size which_cstres,
299  core::Size which_template_atom,
300  core::chemical::ResidueType const & restype ) const
301 {
302 
303  std::map< core::Size, EnzCstTemplateResOP >::const_iterator map_it = enz_template_res_.find( which_cstres );
304 
305  if ( map_it == enz_template_res_.end() ){
306  utility_exit_with_message( "template res with code blabla not found in MatchConstraintFileInfo ");
307  }
308 
309  return map_it->second->atom_inds_for_restype( which_template_atom, &restype );
310 
311 }
312 
315 {
316 
317  std::map< core::Size, EnzCstTemplateResOP >::const_iterator map_it = enz_template_res_.find( template_res );
318 
319  if ( map_it == enz_template_res_.end() ){
320  utility_exit_with_message( "template res with code blabla not found in MatchConstraintFileInfo ");
321  }
322 
323  return map_it->second;
324 }
325 
326 
327 //protocols::match::ExternalGeomSamplerCOP
328 //MatchConstraintFileInfo::exgs() const {
329 // return exgs_;
330 //}
331 
332 
333 
334 bool
335 MatchConstraintFileInfo::read_data( utility::io::izstream & data )
336 {
337  std::istringstream line_stream;
338 
339  std::string line, key(""), tag(""),res3;
340  core::Size map_id(0);
341 
342  //std::cerr << "calling read data for mcfi " << std::endl;
343 
344  while( !data.eof() ){
345 
346  key = ""; tag = "";
347  getline(data,line);
348 
349  utility::vector1< std::string > comment_split = utility::string_split( line, '#' );
350  if( comment_split[1] == "" ) continue;
351  line_stream.clear();
352  line_stream.str( comment_split[1] );
353  line_stream >> key;
354 
355  //std::cerr << "reading shit, line is " << line << ", key is " << key;
356  //Kui Native 110809
357  if ( key == "NATIVE"){
358  native_ = true;
359  }
360  else if ( key == "TEMPLATE::" ) {
361  line_stream >> tag;
362  //tr.Info << "tag is: " << tag << " ";
363  if( tag == "ATOM_MAP:") {
364 
365  line_stream >> map_id;
366 
367  std::map< core::Size, EnzCstTemplateResOP >::iterator map_it = enz_template_res_.find( map_id );
368 
369  if( map_it == enz_template_res_.end() ){
370 
371  std::pair< core::Size, EnzCstTemplateResOP > to_insert( map_id, new EnzCstTemplateRes( restype_set_ ) );
372 
373  enz_template_res_.insert( to_insert );
374 
375  map_it = enz_template_res_.find( map_id );
376  map_it->second->set_param_index( map_id );
377  }
378 
379  map_it->second->read_params( line_stream );
380  }
381 
382  //std::cerr << " end of file line, tag was " << tag << std::endl;
383  }
384 
385 
386  else if ( key == "CONSTRAINT::") {
387  line_stream >> tag;
388 
389  GeomSampleInfoOP gs_info = new GeomSampleInfo( tag );
390 
391  if( !gs_info->read_data( line_stream ) ) return false;
392 
393  if (tag == "distanceAB:"){
394 
395  dis_U1D1_ = gs_info;
396 
397  //old convention to declare covalency in file
398  if( dis_U1D1_->periodicity() == 1.0 ) is_covalent_ = true;
399  else is_covalent_ = false;
400  }
401 
402  else if (tag == "angle_A:") ang_U1D2_ = gs_info;
403 
404  else if (tag == "angle_B:") ang_U2D1_ = gs_info;
405 
406  else if (tag == "torsion_A:") tor_U1D3_ = gs_info;
407 
408  else if (tag == "torsion_AB:") tor_U2D2_ = gs_info;
409 
410  else if (tag == "torsion_B:") tor_U3D1_ = gs_info;
411 
412  else{
413  std::cerr << "The following line in the cst file with key " << key << " was not recognized and will be ignored: " << std::endl << line << std::endl;
414  }
415 
416  //std::cerr << " end of file line, tag was " << tag << std::endl;
417 
418  } //if key==CONSTRAINT
419 
420  else if ( key == "ALGORITHM_INFO::" ) {
421 
422  line_stream >> tag;
423 
424  if( !this->process_algorithm_info( tag, data ) ) return false;
425 
426  }
427 
428  else if ( key == "CST::END") return true;
429 
430  else if ( key != "" ){
431  std::cerr << "The following line in the cst file with key " << key << " was not recognized and will be ignored: " << std::endl << line << std::endl;
432  }
433 
434  } //while ( !data.eof )
435 
436  //if we get to here, that means the cstfile is corrupted
437 
438  return false;
439 
440 } //read_data
441 
442 
443 void
445 {
446 
447 
448  for( std::map< core::Size, EnzCstTemplateResOP >::iterator map_it = enz_template_res_.begin();
449  map_it != enz_template_res_.end(); ++map_it ) {
450 
451  utility::vector1< std::string > const & res_name3s =
452  map_it->second->allowed_res_types();
453 
454  std::set< core::chemical::ResidueTypeCOP > restypes_this_res;
455 
456  for( core::Size j = 1; j <= res_name3s.size(); ++j ) {
457 
459  restype_set_->name3_map( res_name3s[j] );
460 
461  add_relevant_restypes_to_subset( restypes_this_res, all_restypes_this_name3, restype_set_ );
462 
463  }
464 
465  for( std::set< core::chemical::ResidueTypeCOP >::iterator set_it = restypes_this_res.begin();
466  set_it != restypes_this_res.end(); ++set_it ){
467 
468  map_it->second->determine_atom_inds_for_restype( *set_it );
469  }
470 
471  } //loop over all Enz_cst_template-res
472 
473 }
474 
475 
476 std::list< core::conformation::ResidueCOP >
478  core::Size const target_template,
480 ) const
481 {
482  runtime_assert( enz_template_res_.size() == 2 );
483  core::Size const invrot_template( target_template == 1 ? 2 : 1 );
484 
485  //the exgs created based on the cst file info might be wrong if we have to create inverse rotamers
486  //of a residue that is the upstream residue in the cstfile
487  bool flip_exgs_upstream_downstream_samples( false );
488  if( invrot_template == this->upstream_res() ) flip_exgs_upstream_downstream_samples = true;
489 
490  std::list< core::conformation::ResidueCOP > to_return;
491  core::Size rotcount_buffer(0);
492 
493  //1. loop over all allowed restypes of the inverse template
494  utility::vector1< core::chemical::ResidueTypeCOP > invrot_restypes(this->allowed_restypes( invrot_template ));
495 
496  //if we're dealing with backbone interaction, only build glycine rotamers
497  bool backbone_interaction(false);
498  if( this->is_backbone( invrot_template ) ){
499  backbone_interaction = true;
500  invrot_restypes.clear();
501  invrot_restypes.push_back( &(restype_set_->name_map("ALA")) );
502  tr << "Only Ala inverse rotamers will be built because it is a backbone interaction." << std::endl;
503  }
504  for( core::Size ii =1; ii <= invrot_restypes.size(); ++ii ){
505 
506  //2 get the relevant atoms through wich the orientation of the two residues
507  //is defined in the constraint file
508  utility::vector1< utility::vector1< core::Size > > target_template_atom_inds(3), invrot_template_atom_inds(3);
509  for( core::Size atct = 1; atct <= 3; ++atct ){
510  target_template_atom_inds[atct] = this->template_atom_inds( target_template, atct, target_conf->type() );
511  invrot_template_atom_inds[atct] = this->template_atom_inds( invrot_template, atct, *(invrot_restypes[ii]) );
512  }
513 
514  //3. loop over all possible combinations of atoms in the present residue and the inverse rotamer
515  for( core::Size jj = 1; jj <= target_template_atom_inds[1].size(); ++jj ){
516  utility::vector1< core::Size > targ_ats(3);
517  targ_ats[1] = target_template_atom_inds[1][jj]; targ_ats[2] = target_template_atom_inds[2][jj]; targ_ats[3] = target_template_atom_inds[3][jj];
518  for( core::Size kk = 1; kk <= invrot_template_atom_inds[1].size(); ++kk ){
519 
520  utility::vector1< core::Size > invrot_ats(3);
521  invrot_ats[1] = invrot_template_atom_inds[1][kk]; invrot_ats[2] = invrot_template_atom_inds[2][kk]; invrot_ats[3] = invrot_template_atom_inds[3][kk];
522 
523  //4. hand off to other function so code stays readable
524  std::list<core::conformation::ResidueCOP > inv_rots_this_combo = this->inverse_rotamers_against_residue( *target_conf, invrot_restypes[ii], targ_ats, invrot_ats, flip_exgs_upstream_downstream_samples, backbone_interaction );
525  to_return.splice( to_return.end(), inv_rots_this_combo );
526 
527  } // kk loop over all possible atoms in the inverse rotamer
528  } //jj loop over all possible atoms in the present residue
529  tr << to_return.size() - rotcount_buffer << " inverse rotamers were created for restype " << invrot_restypes[ii]->name() << "." << std::endl;
530  rotcount_buffer = to_return.size();
531  } //ii loop over all allowed restypes of the inverse template
532  return to_return;
533 }
534 
535 std::list< core::conformation::ResidueCOP >
537  core::conformation::Residue const & target_conf,
538  core::chemical::ResidueTypeCOP invrot_restype,
539  utility::vector1< core::Size > const & target_ats,
540  utility::vector1< core::Size > const & invrot_ats,
541  bool const flip_exgs_upstream_downstream_samples,
542  bool const backbone_interaction
543 ) const
544 {
545  //using namespace protocols::match::downstream;
546 
547  std::list< core::conformation::ResidueCOP > to_return;
548 
549  utility::vector1< core::conformation::ResidueCOP > rotamers( core::pack::rotamer_set::bb_independent_rotamers( invrot_restype, true ) ); //This is getting the residue specific inverse rotamers
550 
551 // bool no_theozyme_inverse_rotamers( basic::options::option[ basic::options::OptionKeys::enzdes::no_theozyme_inverse_rotamers ]() );
552 // if( no_theozyme_inverse_rotamers ) get rid of rotamers ;
553 
554  runtime_assert( rotamers.size() > 0 );
555  tr << rotamers.size() << " bbindependent rotamers for Residue " << rotamers[1]->type().name() << "." << std::endl;
556 
557  //note: if we have a backbone interaction, this means we need to diversify
558  //the phi value of the rotamer
559  if( backbone_interaction ){
560  runtime_assert( (rotamers.size() == 1) && (rotamers[1]->name3() == "ALA") );
561  this->diversify_backbone_only_rotamers( rotamers );
562  }
563  core::Size inv_oat1(0), inv_oat2(0), inv_oat3(0);
564  rotamers[1]->select_orient_atoms( inv_oat1, inv_oat2, inv_oat3 );
565 
566  utility::vector1< LigandConformer > invrot_conformers;
567  for( core::Size rotcount(1); rotcount <= rotamers.size(); ++rotcount ){
568  invrot_conformers.push_back( LigandConformer() );
569  invrot_conformers[ rotcount ].initialize_from_residue( invrot_ats[1], invrot_ats[2], invrot_ats[3], inv_oat1, inv_oat2, inv_oat3, *(rotamers[rotcount]));
570  }
571 
572  ExternalGeomSampler exgs( *(this->create_exgs()) );
573  //runtime_assert( exgs );
574 
575  //apparently we have to do some stuff with the sampler
576  exgs.set_dis_D1D2( invrot_conformers[1].atom1_atom2_distance() );
577  exgs.set_dis_D2D3( invrot_conformers[1].atom2_atom3_distance() );
578  exgs.set_ang_D1D2D3( invrot_conformers[1].atom1_atom2_atom3_angle() );
579  if( flip_exgs_upstream_downstream_samples ) exgs.flip_upstream_downstream_samples();
580  exgs.precompute_transforms();
581 
582  HTReal ht_start( target_conf.xyz(target_ats[3]), target_conf.xyz(target_ats[2]), target_conf.xyz(target_ats[1]) );
583 
584  for ( Size ii = 1; ii <= exgs.n_tor_U3D1_samples(); ++ii ) {
585  HTReal ht_ii = ht_start * exgs.transform( HT_tor_U3D1, ii );
586  for ( Size jj = 1; jj <= exgs.n_ang_U2D1_samples(); ++jj ) {
587  HTReal ht_jj = ht_ii * exgs.transform( HT_ang_U2D1, jj );
588  for ( Size kk = 1; kk <= exgs.n_dis_U1D1_samples(); ++kk ) {
589  HTReal ht_kk = ht_jj;
590  ht_kk.walk_along_z( exgs.dis_U1D1_samples()[ kk ] );
591  for ( Size ll = 1; ll <= exgs.n_tor_U2D2_samples(); ++ll ) {
592  HTReal ht_ll = ht_kk * exgs.transform( HT_tor_U2D2, ll );
593  for ( Size mm = 1; mm <= exgs.n_ang_U1D2_samples(); ++mm ) {
594  HTReal ht_mm = ht_ll * exgs.transform( HT_ang_U1D2, mm );
595  for ( Size nn = 1; nn <= exgs.n_tor_U1D3_samples(); ++nn ) {
596  HTReal ht_nn = ht_mm * exgs.transform( HT_tor_U1D3, nn );
597 
598  for( core::Size rotcount(1); rotcount <= rotamers.size(); ++rotcount ){
599  core::conformation::ResidueOP rot = new core::conformation::Residue( *(rotamers[rotcount]) );
600  for( core::Size atm = 1; atm <= rot->natoms(); ++atm ){
601  rot->set_xyz( atm, invrot_conformers[rotcount].coordinate_in_D3_frame( atm, ht_nn ) );
602  }
603  to_return.push_back( rot );
604  } //loop over all rotamers
605  } //nn sampler
606  } //mm sampler
607  }// ll sampler
608  } //kk sampler
609  } // jj sampler
610  } //ii sampler
611  return to_return;
612 }
613 
614 /// @details
615 /// helper function to keep code readable
616 /// for rotamers that make backbone interactions,
617 /// as opposed to sidechain interactions only, the default
618 /// phi (-150) that comes out of the bb-indep rotamers function
619 /// has an influence on what fragments in sampling can overlap
620 /// with this rotamer. thus we'll put in more samples to allow
621 /// for more diversity
622 /// the implementation is quite clumsy, make a one residue pose
623 /// add the chainbreak variant, set the chi, return the residue
624 /// but there's no easier way to simply rotate around a bond.
625 /// additional samples will be put at a phi of -60 and 70,
626 /// i.e. other regions observed in ramachandran plot
627 void
629 {
630  //core::conformation::ResidueOP changeres( rotamers[1]->clone() );
631  core::pose::Pose dummy_pose;
632  dummy_pose.append_residue_by_jump( *(rotamers[1]), (core::Size) 0 );
634  dummy_pose.set_phi( 1, -60.0 );
635  rotamers.push_back( core::pose::remove_variant_type_from_residue( dummy_pose.residue(1), core::chemical::CUTPOINT_UPPER, dummy_pose ) );
636  dummy_pose.set_phi( 1, 70.0 );
637  rotamers.push_back( core::pose::remove_variant_type_from_residue( dummy_pose.residue(1), core::chemical::CUTPOINT_UPPER, dummy_pose ) );
638 }
639 
640 bool
642  std::string tag,
643  utility::io::izstream & data
644 ){
645 
646  // according to apl's request, only allow prespecified tags
647  // if you want to read in data for additional tags, you have
648  // to specify those here
649  if( ( tag != "match") && ( tag != "match_positions" ) && ( tag != "test") && ( tag != "invrot_tree" ) ){
650  utility_exit_with_message("Tag "+tag+" not a legal option for ALGORITHM_INFO block.");
651  }
652 
653  if( algorithm_inputs_.find( tag ) != algorithm_inputs_.end() ){
654  tr << "Error: tag " << tag << " was found twice in the same cstfile block." << std::endl;
655  return false;
656  }
657 
659 
660  while( !data.eof() ){
661 
662  std::string line("");
663 
664  getline(data,line);
665 
666  //if ( line == "ALGORITHM_INFO::END"){
667  if( utility::trimmed_compare( line, "ALGORITHM_INFO::END") ){
668 
669  if( alg_strings.size() != 0 ){
670 
672 
673  }
674 
675  else tr << "WARNING: ALGORITHM_INFO block for " << tag << " seemed to contain no information." << std::endl;
676 
677  return true;
678  }
679 
680  utility::vector1< std::string > comment_split = utility::string_split( line, '#' );
681 
682  if( comment_split[1] != "" ) alg_strings.push_back( comment_split[1] );
683 
684  } //while( !data.eof() ){
685 
686  tr << "Error, when reading algorithm info block with tag " << tag << ", no ALGORITHM_INFO::END line was found." << std::endl;
687 
688  return false;
689 
690 } //process algorithm_info
691 
692 
693 
694 
697 {
698 
700 
701  utility::vector1< std::string > tags_undefined_gsi;
702 
703  if( dis_U1D1_ ) exgs->set_dis_U1D1_samples( dis_U1D1_->create_sample_vector() );
704  else tags_undefined_gsi.push_back( "distanceAB:" );
705 
706  if( ang_U1D2_ ) exgs->set_ang_U1D2_samples( ang_U1D2_->create_sample_vector() );
707  else tags_undefined_gsi.push_back( "angle_A:" );
708 
709  if( ang_U2D1_ ) exgs->set_ang_U2D1_samples( ang_U2D1_->create_sample_vector() );
710  else tags_undefined_gsi.push_back( "angle_B:" );
711 
712  if( tor_U1D3_ ) exgs->set_tor_U1D3_samples( tor_U1D3_->create_sample_vector() );
713  else tags_undefined_gsi.push_back( "torsion_A:" );
714 
715  if( tor_U2D2_ ) exgs->set_tor_U2D2_samples( tor_U2D2_->create_sample_vector() );
716  else tags_undefined_gsi.push_back( "torsion_AB:" );
717 
718  if( tor_U3D1_ ) exgs->set_tor_U3D1_samples( tor_U3D1_->create_sample_vector() );
719  else tags_undefined_gsi.push_back( "torsion_B:" );
720 
721  if( tags_undefined_gsi.size() != 0 ){
722 
723  tr << "WARNING: could not create external geom sampler from file input because not all 6 necessary degrees of freedom are specified.\n The following DOFs are missing specifications: ";
724 
725  for( core::Size i = 1; i <= tags_undefined_gsi.size(); ++i ){
726  tr << tags_undefined_gsi[i] << ", ";
727  }
728  tr << "." << std::endl;
729 
730  //std::cerr << "setting external geom sampler to null pointer" << std::endl;
731  exgs = NULL;
732  }
733 
734  return exgs;
735 
736 }
737 
738 
739 
742  : restype_set_( restype_set )
743 {
744  mcfis_.clear();
745 }
746 
748 
749 /// @brief temporary implementation for now, only one MCFI supported
750 bool
751 MatchConstraintFileInfoList::read_data( utility::io::izstream & data )
752 {
753 
754  //std::cerr << "calling read data for mcfi list " << std::endl;
755  //active_mcfi_ = 1;
756 
757  //mcfis_.clear();
758 
759  core::Size new_index = mcfis_.size() + 1;
760 
762 
763  if( mcfi->read_data( data ) ){
764 
765  mcfi->process_data();
766 
767  mcfis_.push_back( mcfi );
768 
770 
771  return true;
772  }
773 
774  return false;
775 }
776 
777 
780 
781  std::map< core::chemical::ResidueTypeCOP, utility::vector1< MatchConstraintFileInfoCOP > >::const_iterator mcfi_it = mcfis_for_restype_.find( restype );
782 
783  if( mcfi_it == mcfis_for_restype_.end() ){
784  utility_exit_with_message( " could not find mcfi list for given restype" );
785  }
786 
787  return mcfi_it->second;
788 
789 }
790 
791 std::list< core::conformation::ResidueCOP >
793  core::Size const target_template,
794  core::conformation::ResidueCOP target_conf ) const
795 {
796  std::list< core::conformation::ResidueCOP > to_return;
797  for( core::Size i = 1; i <= mcfis_.size(); ++i ){
798  if( mcfis_[i]->num_enz_cst_template_res() != 2 ){
799  tr << "Can't create inverse rotamers for mcfi " << i << " because it has more or less than 2 template res." << std::endl;
800  continue;
801  }
802  //core::Size const invrot_template( target_template == 1 ? 2 : 1 );
803  if( std::find( mcfis_[i]->allowed_res_name3s( target_template ).begin(), mcfis_[i]->allowed_res_name3s( target_template ).end(), target_conf->name3() ) == mcfis_[i]->allowed_res_name3s( target_template ).end() ){
804  tr << "Can't create inverse rotamers for mcfi " << i << " because it doesn't contain target template for residue " << target_conf->name3() << "." << std::endl;
805  continue;
806  }
807  std::list< core::conformation::ResidueCOP > mcfi_invrots( mcfis_[i]->inverse_rotamers_against_residue( target_template, target_conf ) );
808  to_return.splice( to_return.end(), mcfi_invrots );
809  }
810  return to_return;
811 }
812 
813 
814 void
816 {
817 
818  upstream_restypes_.clear();
819 
820  mcfis_for_restype_.clear();
821 
823  gly_vec.push_back("GLY");
824 
825  std::set< core::chemical::ResidueTypeCOP > restype_temp_set;
826 
827  for( core::Size i =1 ; i <= mcfis_.size(); ++i){
828 
829  bool is_backbone( mcfis_[i]->is_backbone( mcfis_[i]->upstream_res() ) );
830 
831  //in case the mcfi is a backbone interaction, only allow glycine as the restype
832  //for this mcfi
833  utility::vector1< std::string > const & res_name3s( is_backbone ? gly_vec : mcfis_[i]->allowed_res_name3s( mcfis_[i]->upstream_res() ) );
834 
835  std::set< core::chemical::ResidueTypeCOP > restypes_this_mcfi;
836 
837  for( core::Size j = 1; j <= res_name3s.size(); ++j ) {
838 
840  restype_set_->name3_map( res_name3s[j] );
841 
842  add_relevant_restypes_to_subset( restypes_this_mcfi, all_restypes_this_name3, restype_set_ );
843 
844  }
845 
846  //add the restypes_this_mcfi to the total set of upstream residue
847  //(if they haven't already been added)
848  for( std::set< core::chemical::ResidueTypeCOP >::iterator set_it = restypes_this_mcfi.begin();
849  set_it != restypes_this_mcfi.end(); ++set_it ){
850 
851  //build the restype_to_mcfi mapping
852  std::map< core::chemical::ResidueTypeCOP, utility::vector1< MatchConstraintFileInfoCOP > >::iterator res_mcfi_it = mcfis_for_restype_.find( *set_it );
853 
854  if( res_mcfi_it == mcfis_for_restype_.end() ){
855 
856  std::pair<core::chemical::ResidueTypeCOP, utility::vector1< MatchConstraintFileInfoCOP > > to_insert ( *set_it, utility::vector1< MatchConstraintFileInfoCOP >() );
857 
858  mcfis_for_restype_.insert( to_insert );
859 
860  res_mcfi_it = mcfis_for_restype_.find( *set_it );
861 
862  }
863 
864  res_mcfi_it->second.push_back( mcfis_[i] );
865  //restype_to_mcfi mapping updated
866 
867  if( restype_temp_set.find( *set_it ) == restype_temp_set.end() ){
868  restype_temp_set.insert( *set_it );
869  }
870 
871  } //loop over restypes this mcfi
872 
873  } //loop over all mcfis
874 
875 
876  //finally put all the restypes into the storage vector
877  for( std::set< core::chemical::ResidueTypeCOP >::iterator set_it = restype_temp_set.begin();
878  set_it != restype_temp_set.end(); ++set_it ){
879 
880  upstream_restypes_.push_back( *set_it );
881 
882  }
883 }
884 
885 
886 
887 
888 }
889 }//enzdes
890 }//protocols