Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TaskOperations.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 core/pack/task/operation/TaskOperations.cc
11 /// @brief
12 /// @author Andrew Leaver-Fay (leaverfa@email.unc.edu)
13 
14 // Unit Headers
17 
18 // Project Headers
26 #include <core/pose/Pose.hh>
27 #include <core/pose/PDBInfo.hh>
28 #include <core/pose/selection.hh>
32 #include <basic/options/option.hh>
33 #include <basic/Tracer.hh>
34 #include <boost/foreach.hpp>
35 #define foreach BOOST_FOREACH
36 
37 // Utility Headers
38 #include <utility/exit.hh>
39 #include <utility/io/izstream.hh>
40 #include <utility/string_util.hh>
41 #include <utility/tag/Tag.hh>
42 
43 // basic headers
44 #include <basic/resource_manager/ResourceManager.hh>
45 
46 // option key includes
47 #include <basic/options/keys/packing.OptionKeys.gen.hh>
48 
49 #include <utility/vector0.hh>
50 #include <utility/vector1.hh>
51 
52 
53 
54 namespace core {
55 namespace pack {
56 namespace task {
57 namespace operation {
58 
59 using basic::t_warning;
60 using basic::t_info;
61 using basic::t_debug;
62 static basic::Tracer TR("core.pack.task.operation.TaskOperations",t_info);
63 using namespace utility::tag;
64 
65 /// BEGIN RestrictToRepacking
66 
68 
70 {
71  return new RestrictToRepacking;
72 }
73 
75 {
76  return new RestrictToRepacking( *this );
77 }
78 
79 void
81 {
82  task.restrict_to_repacking();
83 }
84 
85 void
87 {}
88 
89 void
90 RestrictToRepacking::parse_def( utility::lua::LuaObject const & ) {}
91 
92 /// BEGIN RestrictResidueToRepacking
94 
96 {
97  return new RestrictResidueToRepacking;
98 }
99 
101 {
102  return new RestrictResidueToRepacking( *this );
103 }
104 
105 void
107 {
108  for(utility::vector1< core::Size >::const_iterator it(residues_to_restrict_to_repacking_.begin()), end(residues_to_restrict_to_repacking_.end());
109  it != end; ++it)
110  {
111  //assert( *it ); //begin/end can't return NULL anyway?
113  }
114  return;
115 }
116 
117 void
118 RestrictResidueToRepacking::include_residue( core::Size resid ) { residues_to_restrict_to_repacking_.push_back(resid); }
119 
120 void
121 RestrictResidueToRepacking::clear() { residues_to_restrict_to_repacking_.clear(); }
122 
123 void
125 {
126  include_residue( tag->getOption< core::Size >( "resnum", 0 ) );
127 }
128 
129 /// BEGIN RestrictAbsentCanonicalAAS
131  : parent(),
132  resid_(1)
133 {
134  keep_aas_.assign( chemical::num_canonical_aas, false );
135 }
136 
138  :
139  parent()
140 {
141  keep_aas( keep );
142  include_residue( resid );
143 }
144 
146 
148 {
149  return new RestrictAbsentCanonicalAAS;
150 }
151 
153 {
154  return new RestrictAbsentCanonicalAAS( *this );
155 }
156 
157 void
159 {
160  if( resid_ == 0 ){// restrict all residues
161  for( core::Size i( 1 ); i <= task.total_residue(); ++i ) {
163  }
164  }
165  else
167 }
168 
169 void
171 {
172  using namespace chemical;
173  runtime_assert( keep_aas_.size() == num_canonical_aas );
174  utility::vector1< bool > canonical_aas_to_keep( num_canonical_aas, false );
175  foreach( char const c, keep ){
176  if ( oneletter_code_specifies_aa( c ) ) {
177  //std::cout << "Keeping amino acid " << c << std::endl;
178  canonical_aas_to_keep[ aa_from_oneletter_code( c ) ] = true;
179  } else {
180  TR << "aa letter " << c << " does not not correspond to a canonical AA"<<std::endl;
181  utility_exit();
182  }
183  }
184  keep_aas( canonical_aas_to_keep );
185 }
186 
187 // if an amino acid is not present (false) in the boolean vector, then do not allow it at this position. The boolean vector is a 20-length vector in alphabetical order by one-letter code.
188 void
190 {
191  runtime_assert( keep.size() == chemical::num_canonical_aas );
192  keep_aas_ = keep;
193  //for ( Size ii = 1; ii <= keep_aas_.size(); ++ii ) {
194  // std::cout << " keeping " << ii << " " << " ? " << keep_aas_[ ii ] << std::endl;
195  //}
196 }
197 
198 void
200 {
201  resid_ = resid;
202 }
203 
204 void
206 {
207  include_residue( tag->getOption< core::Size >( "resnum", 0 ) );
208  keep_aas( tag->getOption< std::string >( "keep_aas" ) );
209 }
210 
211 
212 //BEGIN DisallowIfNonnative
214  disallowed_aas_ ( chemical::num_canonical_aas, false ),
215  allowed_aas_( invert_vector( disallowed_aas_ ) )
216 {}
217 
219  disallowed_aas_( disallowed_aas ),
220  allowed_aas_( invert_vector(disallowed_aas) )
221 {}
222 
224  residue_selection_( res_selection ),
225  disallowed_aas_( disallowed_aas ),
226  allowed_aas_( invert_vector(disallowed_aas) )
227 {}
228 
230 
232 {
233  return new DisallowIfNonnative;
234 }
235 
237 {
238  return new DisallowIfNonnative( *this );
239 }
240 
242  allowed_aas_.clear();
243  disallowed_aas_.clear();
244  residue_selection_.clear();
245 }
246 
247 //private function to invert disallowed aas into allowed aas
250  utility::vector1< bool > inverted_vec;
251  for(core::Size ii=1; ii<=disallowed_aas_.size(); ii++ ){
252  inverted_vec.push_back( ! disallowed_aas[ii] );
253  }
254  return inverted_vec;
255 }
256 
257 void DisallowIfNonnative::apply( pose::Pose const &, PackerTask & task ) const
258 {
259  runtime_assert( allowed_aas_.size() == chemical::num_canonical_aas );
260  if ( residue_selection_.empty() ){ //if no residue defined then do all residues
261  for (core::Size ii = 1; ii<= task.total_residue(); ii++)
263  }
264  else{ //if a residue is defined then do only on that residue
265  for(core::Size jj = 1; jj <= residue_selection_.size(); jj++ )
267  }
268 }
269 
270 //helper functions for DisallowIfNonnative
271 void
273  runtime_assert( cannonical_disallowed.size() == chemical::num_canonical_aas );
274  disallowed_aas_ = cannonical_disallowed;
275  allowed_aas_ = invert_vector( disallowed_aas_ );
276 }
278  using namespace chemical;
280  for ( std::string::const_iterator it( aa_string.begin() ), end( aa_string.end() );
281  it != end; ++it ) {
282  if ( oneletter_code_specifies_aa( *it ) ) {
283  aa_vector[ aa_from_oneletter_code( *it ) ] = true;
284  } else {
285  std::ostringstream os;
286  os << "aa letter " << *it << " does not not correspond to a canonical AA";
287  utility_exit_with_message( os.str() );
288  }
289  }
290  disallowed_aas_ = aa_vector;
292 }
293  //functions to restrict what residues are looked at by operation
294  //selections are additive
296  //chrisk: default to all residues if bogus seqpos 0 passed (e.g. through rosetta_scripts)
297  if( resid != 0 ) residue_selection_.push_back( resid );
298 }
300  for(core::Size ii=1; ii<=residues.size(); ii++)
301  residue_selection_.push_back( residues[ii] );
302 }
303 
305 {
306  restrict_to_residue( tag->getOption< core::Size >( "resnum", 0 ) );
307  disallow_aas( tag->getOption< std::string >( "disallow_aas" ) );
308 }
309 void DisallowIfNonnative::parse_def( utility::lua::LuaObject const & def) {
310  restrict_to_residue( def["resnum"] ? def["resnum"].to<core::Size>() : 0 );
311  disallow_aas( def["disallow_aas"].to<std::string>());
312 }
313 
314 //BEGIN RotamerExplosion
316 
317 RotamerExplosion::RotamerExplosion( core::Size const resid, ExtraRotSample const sample_level, core::Size const chi ) :
318  resid_( resid ),
319  chi_( chi ),
320  sample_level_( sample_level )
321 {}
322 
324 
326 {
327  return new RotamerExplosion;
328 }
329 
331 {
332  return( new RotamerExplosion( *this ) );
333 }
334 
335 void
337 {
338  ResidueLevelTask & restask( task.nonconst_residue_task( resid_ ) );
339  if( chi_ > 0 ) restask.or_ex1_sample_level( sample_level_ );
340  if( chi_ > 1 ) restask.or_ex2_sample_level( sample_level_ );
341  if( chi_ > 2 ) restask.or_ex3_sample_level( sample_level_ );
342  if( chi_ > 3 ) restask.or_ex4_sample_level( sample_level_ );
343  restask.or_include_current( false ); //not that this call does anything...
344 }
345 
346 void
348 {
349  resid( tag->getOption< core::Size >( "resnum" ) );
350  chi( tag->getOption< core::Size >( "chi" ) );
351  sample_level( EX_THREE_THIRD_STEP_STDDEVS );// hardcoded and ugly, but this is probably too much to expect the user to set
352 }
353 
354 void
356 {
357  resid_ = r;
358 }
359 
360 void
362 {
363  chi_ = c;
364 }
365 
366 void
368 {
369  sample_level_ = s;
370 }
371 
372 
373 /// BEGIN InitializeFromCommandline
374 
376 
378 {
379  return new InitializeFromCommandline;
380 }
381 
383 {
384  return new InitializeFromCommandline( *this );
385 }
386 
387 void
389 {
391 }
392 
393 void
395 {
396 }
397 
398 void
399 InitializeFromCommandline::parse_def( utility::lua::LuaObject const &) {}
400 
401 /// BEGIN InitializeFromCommandline
402 
404 
406 {
408 }
409 
411 {
412  return new InitializeExtraRotsFromCommandline( *this );
413 }
414 
415 void
417 {
419 }
420 
421 
422 /// BEGIN IncludeCurrent
423 
425 
427 {
428  return new IncludeCurrent;
429 }
430 
432 {
433  return new IncludeCurrent( *this );
434 }
435 
436 void
438 {
439  task.or_include_current(true);
440 }
441 
442 void
443 IncludeCurrent::parse_def( utility::lua::LuaObject const & ) {}
444 
445 /// BEGIN ExtraRotamersGeneric
446 
448  ex1_(false),
449  ex2_(false),
450  ex3_(false),
451  ex4_(false),
452  ex1aro_(false),
453  ex2aro_(false),
454  ex1aro_exposed_(false),
455  ex2aro_exposed_(false),
456  ex1_sample_level_( NO_EXTRA_CHI_SAMPLES ),
457  ex2_sample_level_( NO_EXTRA_CHI_SAMPLES ),
458  ex3_sample_level_( NO_EXTRA_CHI_SAMPLES ),
459  ex4_sample_level_( NO_EXTRA_CHI_SAMPLES ),
460  ex1aro_sample_level_( NO_EXTRA_CHI_SAMPLES ),
461  ex2aro_sample_level_( NO_EXTRA_CHI_SAMPLES ),
462  ex1aro_exposed_sample_level_( NO_EXTRA_CHI_SAMPLES ),
463  ex2aro_exposed_sample_level_( NO_EXTRA_CHI_SAMPLES ),
464  exdna_sample_level_( NO_EXTRA_CHI_SAMPLES ),
465  extrachi_cutoff_( EXTRACHI_CUTOFF_LIMIT )
466 {}
467 
469 
471 {
472  return new ExtraRotamersGeneric;
473 }
474 
476 {
477  return new ExtraRotamersGeneric( *this );
478 }
479 
480 void
482 {
483  ex1_ = tag->getOption<bool>("ex1", false);
484  ex2_ = tag->getOption<bool>("ex2", false);
485  ex3_ = tag->getOption<bool>("ex3", false);
486  ex4_ = tag->getOption<bool>("ex4", false);
487  ex1aro_ = tag->getOption<bool>("ex1aro", false);
488  ex2aro_ = tag->getOption<bool>("ex2aro", false);
489  ex1aro_exposed_ = tag->getOption<bool>("ex1aro_exposed", false);
490  ex2aro_exposed_ = tag->getOption<bool>("ex2aro_exposed", false);
491 
492  ex1_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("ex1_sample_level", NO_EXTRA_CHI_SAMPLES));
493  ex2_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("ex2_sample_level", NO_EXTRA_CHI_SAMPLES));
494  ex3_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("ex3_sample_level", NO_EXTRA_CHI_SAMPLES));
495  ex4_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("ex4_sample_level", NO_EXTRA_CHI_SAMPLES));
496  ex1aro_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("ex1aro_sample_level", NO_EXTRA_CHI_SAMPLES));
497  ex2aro_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("ex2aro_sample_level", NO_EXTRA_CHI_SAMPLES));
498  ex1aro_exposed_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("ex1aro_exposed_sample_level", NO_EXTRA_CHI_SAMPLES));
499  ex2aro_exposed_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("ex2aro_exposed_sample_level", NO_EXTRA_CHI_SAMPLES));
500  exdna_sample_level_ = static_cast<ExtraRotSample>(tag->getOption<Size>("exdna_sample_level", NO_EXTRA_CHI_SAMPLES));
501 
502  extrachi_cutoff_ = tag->getOption<Size>("extrachi_cutoff", EXTRACHI_CUTOFF_LIMIT);
503 }
504 
505 
506 void
508 {
509  for(Size i=1; i <= task.total_residue(); ++i){
510  ResidueLevelTask & res_task(task.nonconst_residue_task(i));
511  res_task.or_ex1(ex1_);
512  res_task.or_ex2(ex2_);
513  res_task.or_ex3(ex3_);
514  res_task.or_ex4(ex4_);
515  res_task.or_ex1aro(ex1aro_);
516  res_task.or_ex2aro(ex2aro_);
517  res_task.or_ex1aro_exposed(ex1aro_exposed_);
518  res_task.or_ex2aro_exposed(ex2aro_exposed_);
519  res_task.or_ex1_sample_level(ex1_sample_level_);
520  res_task.or_ex2_sample_level(ex2_sample_level_);
521  res_task.or_ex3_sample_level(ex3_sample_level_);
522  res_task.or_ex4_sample_level(ex4_sample_level_);
523  res_task.or_ex1aro_sample_level(ex1aro_sample_level_);
524  res_task.or_ex2aro_sample_level(ex2aro_sample_level_);
525  res_task.or_ex1aro_exposed_sample_level(ex1aro_exposed_sample_level_);
526  res_task.or_ex2aro_exposed_sample_level(ex2aro_exposed_sample_level_);
527  res_task.or_exdna_sample_level(exdna_sample_level_);
528  res_task.and_extrachi_cutoff(extrachi_cutoff_);
529  }
530 }
531 
532 /// BEGIN ReadResfile
533 
535 {
536 }
537 
539  parent(),
540  resfile_filename_( filename )
541 {}
542 
544 
546 {
547  return new ReadResfile;
548 }
549 
551 {
552  return new ReadResfile( *this );
553 }
554 
555 void
556 ReadResfile::apply( pose::Pose const & pose, PackerTask & task ) const
557 {
558  using namespace basic::resource_manager;
559  using namespace basic::options;
560  using namespace basic::options::OptionKeys;
561  if ( resfile_filename_.empty() ) {
562  /// only apply the read-resfile command if a resfile has been supplied, either through the
563  /// resource manager, or through the command line
564  if ( ResourceManager::get_instance()->has_option( packing::resfile ) || option[ packing::resfile ].user() ) {
565  parse_resfile(pose, task, ResourceManager::get_instance()->get_option( packing::resfile )[ 1 ] );
566  } /// else -- do not change the input PackerTask at all. Noop.
567  } else {
568  parse_resfile(pose, task, resfile_filename_ );
569  }
570 }
571 
572 /// @brief Assign the filename from the ResourceManager, if a resfile has been assigned for the
573 /// current job, and fall back on the options system, if a resfile has not been assigned.
574 void
576 {
577  using namespace basic::resource_manager;
578  using namespace basic::options;
579  using namespace basic::options::OptionKeys;
580  if ( ResourceManager::get_instance()->has_option( packing::resfile ) || option[ packing::resfile ].user() ) {
581  resfile_filename_ = ResourceManager::get_instance()->get_option( packing::resfile )[ 1 ];
582  } else {
583  resfile_filename_ = "";
584  }
585 }
586 
587 void
589 {
591 }
592 
594 {
595  return resfile_filename_;
596 }
597 
598 void
600 {
601  if ( tag->hasOption("filename") ) resfile_filename_ = tag->getOption<std::string>("filename");
602  // special case: if "COMMANDLINE" string specified, use commandline option setting.
603  // This is wholy unneccessary of course. In the absence of a specified filename, the command line
604  // will be read from, anyways.
605  // if no filename is given, then the ReadResfile command will read either from the ResourceManager
606  // or from the packing::resfile option on the command line.
607  if ( resfile_filename_ == "COMMANDLINE" ) default_filename();
608 }
609 
610 void
611 ReadResfile::parse_def( utility::lua::LuaObject const & def) {
612  if( def["filename"] ) resfile_filename_ = def["filename"].to<std::string>();
613  // special case: if "COMMANDLINE" string specified, use commandline option setting
614  if ( resfile_filename_ == "COMMANDLINE" ) default_filename();
615 }
616 
617 /// BEGIN ReadResfileAndObeyLengthEvents
619  parent(),
620  apply_default_commands_to_inserts_(false)
621 {}
622 
624  parent( filename ),
625  apply_default_commands_to_inserts_(false)
626  {}
627 
629 
631 {
633 }
634 
636 {
637  return new ReadResfileAndObeyLengthEvents( *this );
638 }
639 
640 
641 /// @details IMPORTANT: only use this if any length changes are
642 /// not reflected in the pose's pdb info, such as seems to be the case after vlb
643 /// not quite certain on the ideal approach yet. it's prolly best
644 /// to parse the resfile, and then apply the ResfileCommands to the
645 /// remapped residues. this necessitates getting the ResfileContents.
646 /// the code under 2. here is some duplication of ResfileReader::parse_resfile/parse_resfile_string,
647 /// ideally this and ResfileReader should be refactored a bit
648 void
650  pose::Pose const & pose,
651  PackerTask & ptask ) const
652 {
653 
654  //1. get the length change that the pose was exposed to
655  //safeguard
657  parent::apply( pose, ptask );
658  return;
659  }
661  pose::datacache::LengthEventCollectorCOP lencollect( utility::pointer::static_pointer_cast< pose::datacache::LengthEventCollector const >( len_obs ) );
662 
663  utility::vector1< core::conformation::signals::LengthEvent > const & events( lencollect->events() );
665  for( Size i =1; i <= events.size(); ++i ){
666  smaps.push_back( core::id::SequenceMapping( events[i] ) );
667  }
669  fullsmap->reverse();
670 
671  //2. get the resfile contents, we should probably
672  //refactor ResfileReader a little bit to replace the
673  //following block by one call
674  std::string resfile_string;
675  utility::io::izstream file( this->filename() );
676  if (!file ) utility_exit_with_message( "Cannot open file " + this->filename() );
677  utility::slurp( file, resfile_string );
678  std::istringstream resfile(resfile_string);
679  ResfileContents contents( pose, resfile );
680 
681 
682  //3. apply the ResfileCommands to the remapped seqpos
683  for ( Size ii = 1; ii <= ptask.total_residue(); ++ii ) {
684  Size ii_resfile_seqpos( (*fullsmap)[ii] );
685 
686  if( !ii_resfile_seqpos && !apply_default_commands_to_inserts_ ) continue;
687 
688  std::list< ResfileCommandCOP > const & ii_command_list( this->resfile_commands( ii_resfile_seqpos, contents, ptask) );
689 
690  for ( std::list< ResfileCommandCOP >::const_iterator
691  iter = ii_command_list.begin(), iter_end = ii_command_list.end();
692  iter != iter_end; ++iter ) {
693  (*iter)->residue_action( ptask, ii );
694  }
695  } //loop over all task residues
696 
697 } //ReadResfileAndObeyLengthEvents::apply(
698 
699 void
701 {
702  parent::parse_tag( tag );
703  if ( tag->hasOption("default_commands_for_inserts") )
704  apply_default_commands_to_inserts_ = tag->getOption<bool>("default_commands_for_inserts",1);
705 }
706 
707 /// @details note: this function will return default commands for
708 /// resfile_seqpos == 0
709 std::list< ResfileCommandCOP > const &
711  core::Size const resfile_seqpos,
712  ResfileContents const & contents,
713  PackerTask const & ptask ) const
714 {
715  if( (resfile_seqpos == 0) || ( resfile_seqpos > ptask.total_residue()) ){
716  return contents.default_commands();
717  }
718  return (contents.specialized_commands_exist_for_residue( resfile_seqpos ) ?
719  contents.commands_for_residue( resfile_seqpos ) : contents.default_commands() );
720 }
721 
722 
723 /// BEGIN SetRotamerCouplings
724 
726 {}
727 
729 {}
730 
732 :
733  parent(),
734  rotamer_couplings_( src.rotamer_couplings_ )
735 {}
736 
737 SetRotamerCouplings const &
739 {
741  return *this;
742 }
743 
745 {
746  return new SetRotamerCouplings;
747 }
748 
750 {
751  return new SetRotamerCouplings( *this );
752 }
753 
754 void
756 {
758 }
759 
760 void
762 {
763  rotamer_couplings_ = couplings;
764 }
765 
766 /// BEGIN SetRotamerLinks
767 
769 {}
770 
772 {}
773 
775 :
776  parent(),
777  rotamer_links_( src.rotamer_links_ )
778 {}
779 
780 SetRotamerLinks const &
782 {
784  return *this;
785 }
786 
788 {
789  return new SetRotamerLinks;
790 }
791 
793 {
794  return new SetRotamerLinks( *this );
795 }
796 
797 void
799 {
801 }
802 
803 void
805 {
806  rotamer_links_ = links;
807 }
808 
809 /// BEGIN AppendRotamer
810 
812  : rotamer_operation_(0)
813 {}
814 
816 {}
817 
819  : rotamer_operation_( rotamer_operation )
820 {}
821 
823 : parent(), rotamer_operation_( src.rotamer_operation_ )
824 {}
825 
827 {
828  return new AppendRotamer;
829 }
830 
832 {
833  return new AppendRotamer( *this );
834 }
835 
836 void
838 {
840 }
841 
842 void
844  rotamer_set::RotamerOperationOP rotamer_operation
845 )
846 {
847  rotamer_operation_ = rotamer_operation;
848 }
849 
850 
851 /// BEGIN AppendRotamerSet
852 
854  : rotamer_set_operation_(0)
855 {}
856 
858 {}
859 
861  : rotamer_set_operation_( rotamer_set_operation )
862 {}
863 
865 : parent(), rotamer_set_operation_( src.rotamer_set_operation_ )
866 {}
867 
869 {
870  return new AppendRotamerSet;
871 }
872 
874 {
875  return new AppendRotamerSet( *this );
876 }
877 
878 void
880 {
882 }
883 
884 void
886  rotamer_set::RotamerSetOperationOP rotamer_set_operation
887 )
888 {
889  rotamer_set_operation_ = rotamer_set_operation;
890 }
891 
892 
893 /// BEGIN AppendResidueRotamerSet
894 
896  : parent(),
897  resnum_(0),
898  rotamer_set_operation_(0)
899 {}
900 
902 {}
903 
905  rotamer_set::RotamerSetOperationOP rotamer_set_operation )
906  : resnum_(resnum),
907  rotamer_set_operation_( rotamer_set_operation )
908 {}
909 
911  : parent(src),
912  resnum_( src.resnum_ ),
913  rotamer_set_operation_( src.rotamer_set_operation_ )
914 {}
915 
917 {
918  return new AppendResidueRotamerSet;
919 }
920 
922 {
923  return new AppendResidueRotamerSet( *this );
924 }
925 
926 void
928 {
930 }
931 
932 void
934 {
935  resnum_ = resnum;
936 }
937 
938 void
940 {
941  rotamer_set_operation_ = rotamer_set_operation;
942 }
943 
944 
945 /// BEGIN PreserveCBeta
946 
948 
950 {
951  return new PreserveCBeta;
952 }
953 
955 {
956  return new PreserveCBeta( *this );
957 }
958 
959 void
961 {
962  task.or_preserve_c_beta( true );
963 }
964 
965 /// BEGIN PreventRepacking
967 
969 {
970  return new PreventRepacking;
971 }
972 
974 {
975  return new PreventRepacking( *this );
976 }
977 
978 void
979 PreventRepacking::apply( pose::Pose const & pose, PackerTask & task ) const
980 {
983  residues_to_prevent.insert(residues_to_prevent.end(),res.begin(),res.end());
984 
985  for(utility::vector1< core::Size >::const_iterator it(residues_to_prevent.begin()), end(residues_to_prevent.end());
986  it != end; ++it)
988  return;
989 }
990 
991 void
993 
994 void
996 
997 void
999 {
1000  residue_selection_ = tag->getOption<std::string>("resnum","0");
1001 }
1002 
1003 
1004 // BEGIN RestrictYSDesign
1006 RestrictYSDesign::RestrictYSDesign() : gly_switch_( false ) {}
1008  parent(), YSresids_( src.YSresids_ ), gly_switch_( src.gly_switch_ )
1009 {}
1011  gly_switch_ = false;
1012  YSresids_ = resids;
1013 }
1014 
1015 void
1017  utility::vector1<bool> restrict_to_aa( 20, false );
1018  for( utility::vector1<core::Size>::const_iterator res_it=YSresids_.begin(); res_it!=YSresids_.end(); ++res_it ) {
1019  if( gly_switch_ ) restrict_to_aa[chemical::aa_from_name( "GLY" )] = true;;
1020  restrict_to_aa[chemical::aa_from_name( "TYR" )] = true;
1021  restrict_to_aa[chemical::aa_from_name( "SER" )] = true;
1022  task.nonconst_residue_task(*res_it).restrict_absent_canonical_aas( restrict_to_aa );
1023  }
1024 }
1025 
1027 {
1028  return new RestrictYSDesign;
1029 }
1030 
1032  return new RestrictYSDesign( *this );
1033 }
1034 
1035 void
1036 RestrictYSDesign::include_resid( core::Size const resid ) { YSresids_.push_back(resid); }
1037 
1038 void
1039 RestrictYSDesign::include_gly( bool const gly ) { gly_switch_ = gly; }
1040 
1041 
1042 //////////////////////////////////////////////////////
1043 // This class could easily be expanded to handle sample_level, etc.
1044 // Someone has probably already written this, and should replace this
1045 // dinky thing.
1047  resid_( 0 ), // default apply to all residues
1048  chi_( 0 ),
1049  level_( 0 )
1050 {}
1051 
1053  resid_( resid ),
1054  chi_( chi ),
1055  level_( level )
1056 {}
1057 
1059 
1061 {
1062  return new ExtraRotamers;
1063 }
1064 
1066 {
1067  return( new ExtraRotamers( *this ) );
1068 }
1069 
1070 void
1072 {
1073  if ( resid_ != 0 ) {
1074  ResidueLevelTask & restask( task.nonconst_residue_task( resid_ ) );
1075  if( chi_ == 1 ) restask.or_ex1( ExtraRotSample( level_ ) );
1076  if( chi_ == 2 ) restask.or_ex2( ExtraRotSample( level_ ) );
1077  if( chi_ == 3 ) restask.or_ex3( ExtraRotSample( level_ ) );
1078  if( chi_ == 4 ) restask.or_ex4( ExtraRotSample( level_ ) );
1079  } else {
1080  // apply to all residues
1081  TR << "Enabling extra rotamers for chi " << chi_ << " at all positions" << std::endl;
1082  for ( Size ii = 1; ii <= p.total_residue(); ++ii ) {
1083  ResidueLevelTask & restask( task.nonconst_residue_task( ii ) );
1084  if( chi_ == 1 ) restask.or_ex1( ExtraRotSample( level_ ) );
1085  if( chi_ == 2 ) restask.or_ex2( ExtraRotSample( level_ ) );
1086  if( chi_ == 3 ) restask.or_ex3( ExtraRotSample( level_ ) );
1087  if( chi_ == 4 ) restask.or_ex4( ExtraRotSample( level_ ) );
1088  }
1089  }
1090 }
1091 
1093 {
1094  if ( tag->hasOption("resid") ) {
1095  resid_ = tag->getOption< core::Size >( "resid" );
1096  } else {
1097  resid_ = 0; // apply to all residues
1098  }
1099 
1100  if ( ! tag->hasOption("chi") ) {
1101  utility_exit_with_message("ExtraRotamers Task Operation requires the chi option");
1102  }
1103  chi_ = tag->getOption< core::Size >("chi");
1104  if ( chi_ > 4 ) {
1105  utility_exit_with_message("ExtraRotamers Task Operation given a value for chi outside of legal range 1-4. Given value of " + utility::to_string(chi_) );
1106  }
1107  if ( tag->hasOption("level") ) {
1108  level_ = tag->getOption< core::Size >("level");
1110  utility_exit_with_message( "ExtraRotamers Task Operation gien a value for level outside of legal range 1-" + utility::to_string( core::Size( ExtraRotSampleCardinality ) ) + ". Given value of " + utility::to_string( level_ ) );
1111 
1112  }
1113  }
1114 }
1115 
1116 //////////////////////////////////////////////////////
1117 // This class could easily be expanded ...
1118 // Someone has probably already written this, and should replace this
1119 // dinky thing.
1121 
1122 ExtraChiCutoff::ExtraChiCutoff( core::Size const resid, core::Size const extrachi_cutoff):
1123  resid_( resid ),
1124  extrachi_cutoff_( extrachi_cutoff )
1125 {}
1126 
1128 
1130 {
1131  return new ExtraChiCutoff;
1132 }
1133 
1135 {
1136  return( new ExtraChiCutoff( *this ) );
1137 }
1138 
1139 void
1141 {
1142  if ( resid_ != 0 ) {
1144  } else {
1145  //appy to all residues
1146  TR << "Enabling extrachi cutoff at all positions" << std::endl;
1147  for ( Size ii = 1; ii <= p.total_residue(); ++ii ) {
1149  }
1150  }
1151 }
1152 
1154 {
1155  if ( tag->hasOption("resid") ) {
1156  resid_ = tag->getOption< core::Size >( "resid" );
1157  } else {
1158  resid_ = 0; // apply to all residues
1159  }
1160 
1161  if ( ! tag->hasOption("extrachi_cutoff") ) {
1162  utility_exit_with_message("ExtraChiCutoff Task Operation requires the extrachi_cutoff option");
1163  }
1164  extrachi_cutoff_ = tag->getOption< core::Size >("extrachi_cutoff");
1165 }
1166 
1167 
1168 } //namespace operation
1169 } //namespace task
1170 } //namespace pack
1171 } //namespace core