Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OperateOnCertainResidues.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/OperateOnCertainResidues.cc
11 /// @brief class to support the general case of configuring PackerTask at the ResidueLevelTask level in some way, with an optional filter to limit the effects to certain residues
12 /// @author ashworth
13 
14 // Unit Headers
17 
18 
19 #include <core/pose/Pose.hh>
25 
26 #include <basic/Tracer.hh>
27 
28 // Utility Headers
29 #include <utility/tag/Tag.hh>
30 
31 #include <utility/vector0.hh>
32 #include <utility/vector1.hh>
33 
34 
35 namespace core {
36 namespace pack {
37 namespace task {
38 namespace operation {
39 
40 using basic::t_info;
41 using basic::t_debug;
42 static basic::Tracer TR("core.pack.task.operation.OperateOnCertainResidues",t_info);
43 
45  : parent(),
46  op_(0),
47  filter_(0)
48 {}
49 
52  ResFilterOP filter
53 )
54  : parent(),
55  op_( rlto ),
56  filter_( filter )
57 {}
58 
60  : TaskOperation( src )
61 {
62  *this = src;
63 }
64 
67 {
69  if ( src.op_ ) op_ = src.op_->clone();
70  else op_ = 0;
71  if ( src.filter_ ) filter_ = src.filter_->clone();
72  else filter_ = 0;
73  return *this;
74 }
75 
77 
79 {
80  return new OperateOnCertainResidues;
81 }
82 
84 {
85  return new OperateOnCertainResidues( *this );
86 }
87 
88 void
89 OperateOnCertainResidues::apply( Pose const & pose, PackerTask & ptask ) const
90 {
91  Size const nres( pose.total_residue() );
92  runtime_assert( nres == ptask.total_residue() );
93  // local nonconst version of residue indices container allows default applicability over
94  // all residues in input pose (while avoiding code duplication or extra function call)
95  ResidueIndices residue_indices_local;
96  if ( residue_indices_.empty() ) {
97  for ( Size i(1); i <= nres; ++i ) residue_indices_local.push_back(i);
98  } else {
99  residue_indices_local = residue_indices_;
100  }
101  for ( ResidueIndices::const_iterator index( residue_indices_local.begin() ),
102  end( residue_indices_local.end() ); index != end; ++index ) {
103  runtime_assert( *index > 0 && *index <= nres );
104  // skip this residue if there is a filter and it returns false
105  if ( filter_ && ! (*filter_)( pose, *index ) ) continue;
106  op_->apply( ptask.nonconst_residue_task( *index ) );
107  }
108 }
109 
111 {
112  residue_indices_ = indices;
113 }
114 
116 {
117  runtime_assert( op_in );
118  op_ = op_in->clone();
119 }
120 
122 {
123  runtime_assert( filter_in );
124  filter_ = filter_in->clone();
125 }
126 
127 
128 ///@brief tag parsing for factory construction of this class and its children
129 /*!
130 Example Tag syntax for parser as of Summer 2009
131 
132 <OperateOnCertainResidues name=PROTEINnopack>
133  <PreventRepackingRLT/>
134  <ResidueHasProperty property=PROTEIN/>
135 </OperateOnCertainResidues>
136 
137 */
139 {
140  utility::vector0< TagPtr > const subtags( tag->getTags() );
141  for ( utility::vector0< TagPtr >::const_iterator subtag( subtags.begin() ), end( subtags.end() );
142  subtag != end; ++subtag ) {
143  std::string const type( (*subtag)->getName() );
145  if ( rltof && rltof->has_type( type ) ) {
146  op_ = rltof->newRLTO( type );
147  op_->parse_tag( *subtag );
148  TR(t_debug) << "using ResLvlTaskOperation of type " << type << std::endl;
149  continue;
150  }
151  ResFilterFactory * res_filter_factory = ResFilterFactory::get_instance();
152  if ( res_filter_factory && res_filter_factory->has_type( type ) ) {
153  filter_ = res_filter_factory->newResFilter( type );
154  filter_->parse_tag( *subtag );
155  TR(t_debug) << "using ResFilter of type " << type << std::endl;
156  continue;
157  }
158  utility_exit_with_message( type + " is not known to the factories passed to OperateOnCertainResidues." );
159  }
160 }
161 
162 } //namespace operation
163 } //namespace task
164 } //namespace pack
165 } //namespace core