Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RestrictToInterfaceVectorOperation.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 protocols/toolbox/task_operations/RestrictToInterfaceVectorOperation.cc
11 /// @brief TaskOperation class that finds an interface based on:
12 /// core/pack/task/operation/util/interface_vector_calculate.hh
13 /// and leaves it mobile in the PackerTask
14 /// @author Ben Stranges (stranges@unc.edu)
15 
16 // Unit Headers
19 //#include <protocols/toolbox/task_operations/InterfaceTaskOperation.hh> //shouldn't need this
20 // Project Headers
21 #include <core/pose/Pose.hh>
23 //#include <core/kinematics/FoldTree.hh>
25 //#include <protocols/toolbox/pose_metric_calculators/InterfaceVectorDefinitionCalculator.hh>
26 //#include <core/pose/metrics/CalculatorFactory.hh>
27 // AUTO-REMOVED #include <basic/MetricValue.hh>
28 
29 // Utility Headers
30 #include <core/types.hh>
31 #include <utility/vector1_bool.hh>
32 #include <utility/vector1.hh>
33 
34 #include <basic/Tracer.hh>
35 #include <utility/string_util.hh>
36 #include <utility/tag/Tag.hh>
37 
38 // C++ Headers
39 // AUTO-REMOVED #include <set>
40 
41 #include <utility/vector0.hh>
42 
43 
44 using basic::Error;
45 using basic::Warning;
46 static basic::Tracer TR( "protocols.toolbox.TaskOperations.RestrictToInterfaceVectorOperation" );
47 
48 namespace protocols {
49 namespace toolbox {
50 namespace task_operations {
51 
52 ///@details, empty contructor for parser
54  parent(), //inits a jump number 1
55  jump_active_(true),
56  CB_dist_cutoff_( 11.0 ),
57  nearby_atom_cutoff_( 5.5 ),
58  vector_angle_cutoff_( 75.0 ),
59  vector_dist_cutoff_( 9.0 )
60 { }
61 
62 // ///@details this ctor assumes a pregenerated calculator - if you want a particular non-default cutoff distance
63 // RestrictToInterfaceVectorOperation::RestrictToInterfaceVectorOperation( std::string const & calculator )
64 // : parent(), calculator_name_(calculator)
65 // {}
66 
67 ///@brief this ctor will generate the calculator for you (may use defaults)
68 ///if you want to use chain characters make the calculator that way and pass it to the constructor above
70  parent(),
71  jump_active_(false),
72  CB_dist_cutoff_( 11.0 ),
73  nearby_atom_cutoff_( 5.5 ),
74  vector_angle_cutoff_( 75.0 ),
75  vector_dist_cutoff_( 9.0 )
76 {
77  lower_chain(lower_chain_id);
78  upper_chain(upper_chain_id);
79 
80 }
81 
82 //full constructor
84  core::Size const lower_chain_id,
85  core::Size const upper_chain_id,
86  core::Real CB_dist_cutoff,
87  core::Real nearby_atom_cutoff,
88  core::Real vector_angle_cutoff,
89  core::Real vector_dist_cutoff
90 ):
91  parent(),
92  jump_active_(false),
93  CB_dist_cutoff_( CB_dist_cutoff ),
94  nearby_atom_cutoff_( nearby_atom_cutoff ),
95  vector_angle_cutoff_( vector_angle_cutoff ),
96  vector_dist_cutoff_( vector_dist_cutoff )
97 {
98  lower_chain(lower_chain_id);
99  upper_chain(upper_chain_id);
100 }
101 
102 ///@brief this ctor will generate the calculator for you (may use defaults)
103 ///if you want to use chain characters make the calculator that way and pass it to the constructor above
105  parent(),
106  jump_active_(true),
107  CB_dist_cutoff_( 11.0 ),
108  nearby_atom_cutoff_( 5.5 ),
109  vector_angle_cutoff_( 75.0 ),
110  vector_dist_cutoff_( 9.0 )
111 { set_movable_jumps( movable_jumps ); }
112 
113 //full constructor
115  utility::vector1_int const movable_jumps ,
116  core::Real CB_dist_cutoff,
117  core::Real nearby_atom_cutoff,
118  core::Real vector_angle_cutoff,
119  core::Real vector_dist_cutoff
120 ):
121  parent(),
122  jump_active_(true),
123  CB_dist_cutoff_( CB_dist_cutoff ),
124  nearby_atom_cutoff_( nearby_atom_cutoff ),
125  vector_angle_cutoff_( vector_angle_cutoff ),
126  vector_dist_cutoff_( vector_dist_cutoff )
127 { set_movable_jumps( movable_jumps );}
128 
129 
130 
131 //class member functions
133 
136 {
138 }
139 
140 ///@details be warned if you use clone that you'll not get a new interface calculator
142 {
143  return new RestrictToInterfaceVectorOperation( *this );
144 }
145 
146 
147 ///@details apply function, uses inherited functionality
148 void
150 {
151 
152  //if the jump constructor then itterate through jumps, make union
153  if(jump_active_){
154  utility::vector1_bool repack_full(pose.total_residue(), false);
155  for( utility::vector1_int::const_iterator jj = movable_jumps().begin() ; jj != movable_jumps().end() ; ++jj ){
156  //std::cout << "Calculating interface for jump: " <<*jj << std::endl;
157  //run detection based on jump
158  utility::vector1_bool repack =
160  pose,
161  *jj,
166  //add repack true setting to repack_full
167  for(core::Size ii = 1; ii <= repack.size(); ++ii){
168  if(repack[ii])
169  repack_full[ii] = true;
170  }//end add repack to full_repack
171  }//itterate over jumps
172  task.restrict_to_residues(repack_full);
173  }//end if jump active
174 
175  else{ // if using only the two chain case
176  //vector for filling packertask
177  utility::vector1_bool repack_full(pose.total_residue(),false);
178 
179  for(utility::vector1<core::Size>::const_iterator lower_chain_it = lower_chains_.begin();
180  lower_chain_it != lower_chains_.end(); ++lower_chain_it)
181  {
182  core::Size current_lower_chain = *lower_chain_it;
183 
184  for(utility::vector1<core::Size>::const_iterator upper_chain_it = upper_chains_.begin();
185  upper_chain_it != upper_chains_.end(); ++upper_chain_it)
186  {
187  core::Size current_upper_chain = *upper_chain_it;
188  TR.Debug << "calculating_interface between: " << current_lower_chain << " " << current_upper_chain <<std::endl;
189  utility::vector1_bool repack =
191  current_lower_chain, current_upper_chain,
196  for(core::Size ii = 1; ii <=repack.size(); ++ii)
197  {
198  if(repack[ii])
199  {
200  repack_full[ii] = true;
201  }
202  }
203  }
204  }
205 
206  task.restrict_to_residues(repack_full);
207  }
208 
209 
210 }
211 
212 ///@details setters: only exist to pass info from the parser
213 void
215  upper_chains_.clear();
216  upper_chains_.push_back(upper_chain);
217  jump_active_ = false;
218  assert(upper_chains_.size() == 1);
219  //make_name();
220 }
221 
223 {
225  jump_active_ = false;
226 }
227 
228 void
230  lower_chains_.clear();
231  lower_chains_.push_back(lower_chain);
232  jump_active_ = false;
233  assert(lower_chains_.size() == 1);
234  //make_name();
235 }
236 
237 
239 {
241  jump_active_ = false;
242 }
243 
244 //if you want to change the jump use parent class function:
245 //add_movable_jump( int const additional_jump );
246 
247 void
250 }
251 void
254 }
255 void
258 }
259 void
262 }
263 
264 /*
265 void
266 RestrictToInterfaceVectorOperation::setup_interface_chains_from_jumps( core::pose::Pose const & pose ){
267 
268  // This class wouldn't know what to do with more than jump, so we'll assert that there's only one.
269  assert(movable_jumps().size() == 1);
270  lower_chain( pose.chain( pose.fold_tree().jump_edge( *it ).start() ) );
271  upper_chain( pose.chain( pose.fold_tree().jump_edge( *it ).stop() ) );
272 }
273 */
274 
275 ///@details parse_tag function for the parser, sets reasonable values for all options
276 void
278 {
279  if( ( tag->hasOption("chain1_num" ) || tag->hasOption("chain2_num" ) ) && tag->hasOption("jump" ) )
280  utility_exit_with_message( "You can't define chains and jumps" );
281  //use chain numbers if given, otherwise use jump
282  if( tag->hasOption("chain1_num" ) && tag->hasOption("chain2_num" ) ){
283 
284  utility::vector1<core::Size> lower_chains = utility::string_split(tag->getOption<std::string>("chain1_num"),',',core::Size());
285  utility::vector1<core::Size> upper_chains = utility::string_split(tag->getOption<std::string>("chain2_num"),',',core::Size());
286 
287  lower_chain( lower_chains );
288  upper_chain( upper_chains );
289  jump_active_ = false;
290  }
291  //go through the jumps, should probably be a utility function for this
292  else if( tag->hasOption("jump") )
293  {
294  //jump_num( tag->getOption< int >( "jump", 1) );
295  //get a string of comma separated jumps
296  utility::vector1_int jump_vector(0); //init to zero to cause insant problem if nothing passed
297  utility::vector1<std::string> jumps = utility::string_split( tag->getOption<std::string>( "jump" ), ',' );
298  for( utility::vector1<std::string>::const_iterator it = jumps.begin(); it != jumps.end(); ++it ) {
299  // convert to C string, then convert to integer then push back in vector
300  int this_jump(std::atoi( it->c_str() ) );
301  jump_vector.push_back( this_jump );
302  //add_movable_jump (this_jump ); //from parent class
303  TR << "Adding jump: " << this_jump << ", ";
304  }
305  TR << std::endl;
306  assert( jump_vector.size() > 0 );
307  //now set jumps for parent class and locally
308  set_movable_jumps( jump_vector );
309  jump_active_ = true;
310  }//end jumps
311  else
312  utility_exit_with_message( "Need to define either jump OR (chain1_num AND chain2_num)" );
313  //get other possible tags, set default values to something reasonable.
314  CB_dist_cutoff( tag->getOption< core::Real >( "CB_dist_cutoff", 10.0) );
315  nearby_atom_cutoff( tag->getOption< core::Real >( "nearby_atom_cutoff", 5.5) );
316  vector_angle_cutoff( tag->getOption< core::Real >( "vector_angle_cutoff", 75.0) );
317  vector_dist_cutoff( tag->getOption< core::Real >( "vector_dist_cutoff", 9.0 ) );
318 
319 }
320 
321 } //namespace protocols
322 } //namespace toolbox
323 } //namespace task_operations