Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SeedSetupMover.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
11 /// @brief mover to set up packer task and movemap for seededabinitio
12 /// @author Eva-Maria Strauch (evas01@u.washington.edu)
13 
14 // Unit headers
18 
19 #include <protocols/moves/Mover.hh>
21 #include <core/pose/selection.hh>
23 
24 #include <boost/foreach.hpp>
25 
33 
35 #include <core/types.hh>
36 
37 //scoring
39 
40 #define foreach BOOST_FOREACH
41 
42 #include <basic/Tracer.hh>
45 
46 // Project headers
47 #include <core/pose/Pose.hh>
48 #include <utility/tag/Tag.hh>
49 #include <utility/string_util.hh>
50 
53 #include <utility/vector0.hh>
54 #include <utility/vector1.hh>
55 #include <basic/options/keys/OptionKeys.hh>
56 
57 
58 namespace protocols {
59  namespace seeded_abinitio {
60 
61  using namespace core;
62 
63  static basic::Tracer TR( "protocols.seeded_abinitio.SeedSetupMover" );
64 
67  {
69  }
70 
73  return new SeedSetupMover;
74  }
75 
78  {
79  return "SeedSetupMover";
80  }
81 
83 
85  protocols::moves::Mover( SeedSetupMoverCreator::mover_name() ){
86  //movemap options
87  chi_chain1_ = false;
88  chi_chain2_ = false;
89 
90  //packer tasks options
91  packtask_ = false;//until it is more stable
92  repack_target_ = true;
93  repack_foldpose_ = true;
94  design_target_ = false;
95  design_foldpose_ = true;
96  allow_all_aas_ = false;
97  norepack_res_ = "";
98  design_res_ = "" ;
99  //clearing containers
100  //task_factory_->clear();
101  }
102 
105  return( protocols::moves::MoverOP( new SeedSetupMover( *this ) ) );
106 }
107 
111 }
112 
113 void
115  task_factory_ = tf;
116 }
117 
118 
120  if( task_factory_ )
121  task_factory_->clear();
122 }
123 
124 /*
125 void
126 SeedSetupMover::clear_task(){
127  task_ = NULL;
128 }
129 */
130 
131 /// getters
134  return task_factory_;
135 }
136 
137 
139  bool is_part_of_this = false;
140  for( core::Size i = 1; i <= vec.size(); i++ )
141  if( i == pos ) is_part_of_this = true;
142  return is_part_of_this;
143 }
144 
145 
146 void
148  protocols::loops::Loops & seeds,
149  utility::vector1< core::Size > & designable_residues, // ){
150  utility::vector1< core::Size > & norepack_res, // ){//,
152 
153  //primitive starting version of the packer tasks for seeded_abinitio
154  //eventually, this shoudl be more sophisticated
155 
156  using namespace core::pack::task;
157  using namespace core::pack::task::operation;
158  using namespace protocols::toolbox::task_operations;
159 
160  Size num_chains = pose.conformation().num_chains();
161 
162 
163  ///////////////////////////////
164  ///1. set repacking behavior:
165  ///////////////////////////////
166 
167  TR<<"disallowing target chain(s) to repack" << std::endl;
168  if( num_chains > 1 && repack_target_ ){
170  Size chains_norepack = num_chains;
171  if( repack_foldpose_ ){
172  chains_norepack -= 1;
173  TR << "allowing repacking of fold pose" <<std::endl;
174  }
175  for ( Size chain = 1; chain <= chains_norepack ; chain++ ){
176  pcfr->chain( chain );
177  //pcfr.apply( pose, *tasks );
178  }
179  tf->push_back( pcfr );
180  }
181 
182  /// disallow specified residues to repack:
183  if ( norepack_res.size() != 0 ){
184  TR.Debug<<"disallow " << norepack_res.size() << " to repack " <<std::endl;
185  using namespace protocols::toolbox::task_operations;
187  prfr->set_residues( norepack_res );
188  tf->push_back( prfr );
189  }
190 
191 /*
192  /// disallow specified residues to repack:
193  foreach ( const Size res , norepack_res ){
194  using namespace core::pack::task::operation;
195  PreventRepackingOP pr = new PreventRepacking;
196  pr->include_residue( res );
197  tf->push_back( pr );
198  }
199 */
200  /// do not repack disulfides
202  tf->push_back( nrd );
203 
204 
205  //////////////////////////////////
206  /// 2. restrict design:
207  //////////////////////////////////
208 
209  if( !design_target_ ){
211  for ( Size chain = 1; chain <= num_chains - 1 ; chain++ )
212  rctr->chain( chain );
213  tf->push_back( rctr );
214  }
215  if( design_target_ )
216  TR<<"WARNING, are you sure you want to design the target chains? designing target chain" << std::endl;
217 
218 
219  /// setting up design restrictions for new fold pose with seeds:
220  if( design_foldpose_ ){
222  residues.clear();
223 
224  for( core::Size i = pose.conformation().chain_begin( num_chains ); i <= pose.total_residue(); i++ ){
225  bool allow_design( false );
226  if( !seeds.is_loop_residue( i ) || is_part( designable_residues, i ) ){
227  TR.Debug<<"is not seed: "<< i << " allow design" << std::endl;
228  allow_design = true;
229  }
230  if( !allow_design )
231  residues.push_back( i );
232  }
233 
234  if( residues.size() ){
235  TR.Debug<<"The following residues will be repacked only: ";
236  foreach( core::Size const res, residues )
237  TR.Debug<<res<<", ";
238  TR.Debug<<std::endl;
240  rrtr->set_residues( residues );
241  tf->push_back( rrtr );
242  }
243  }
244 }
245 
246 
248  core::pose::Pose & pose,
249  core::kinematics::MoveMapOP & movemap,
250  protocols::loops::Loops & seeds,
251  bool chi_chain1,
252  bool chi_chain2,
253  bool interface_chi1,
254  bool,
255  core::Real interface_distance_cutoff
256  ){
257 
258  using namespace basic::options;
259  using namespace basic::options::OptionKeys;
260  Size num_chains = pose.conformation().num_chains();
261 
262  movemap->set_bb( false );
263  movemap->set_chi( false );
264  movemap->set_jump( false );
265 
266  //setting chi to true if specified
267  if( num_chains > 1 ){
268 
269  //setting up interface object
270  //multy chain possible, make jump a variable
271  Size rb_jump = 1;
272  //kinematics::FoldTree ori_ft = pose.fold_tree();
273  pose.update_residue_neighbors(); // o/w fails assertion `graph_state_ == GOOD`
274  protocols::scoring::Interface interface_obj(rb_jump );
275  interface_obj.distance( interface_distance_cutoff );
276  interface_obj.calculate( pose );
277  //protocols::scoring::Interface interface_obj(rb_jump);
278 
279  TR<<"disallowing all chains to be movable but the last one" <<std::endl;
280  for ( Size i = 1; i <= pose.conformation().chain_end( num_chains - 1 ); ++i ){
281  //to be safe
282  movemap->set_bb( i , false );
283  movemap->set_chi( i, false );
284  if( chi_chain1 ){
285  movemap->set_chi( i, true );
286  }
287  if(interface_chi1 && interface_obj.is_interface(i))
288  movemap->set_chi( i, true );
289  //TR.Debug<<"i: "<<i << ", bb: "<< movemap->get_bb(i)<<", chi: "<<movemap->get_chi(i)<< std::endl;
290  }
291  }
292  //iterating through the last chain (this is the one that gets folded, and allowing the different degrees of freedom
293  for ( Size pos = pose.conformation().chain_begin( num_chains ); pos <= pose.conformation().chain_end( num_chains ) ; pos++){
294  if (!seeds.is_loop_residue( pos )){
295  movemap->set_bb( pos, true );
296  movemap->set_chi(pos, true );
297  }
298  if( seeds.is_loop_residue( pos ) && chi_chain2 )
299  movemap->set_chi( true );
300  }
301 
302  TR<<"setting movemap method:"<<std::endl;
303  for( Size i = 1 ; i <=pose.total_residue(); ++i ){
304  TR.Debug<<"i: "<<i<<", bb: "<< movemap->get_bb(i)<< ", chi: "<<movemap->get_chi(i)<<std::endl;
305  }
306 
307  //option for movable residues within the seeds?
308  //coudl be something like so:
309  //<movableSeed_residues N=1 C=1/>
310 } //end define movemap
311 
312 ///adjustment since parse time specified residues are different numbered than run time residues
315  std::string design_residues ){
316 
317  utility::vector1< std::string > const design_keys( utility::string_split( design_residues, ',' ) );
319 
320  foreach( std::string const key, design_keys ){
321  core::Size const resnum( core::pose::parse_resnum( key, pose ));
322  TR.Debug<<"design within seed, residue: "<< key <<", parsed: "<< resnum <<std::endl;
323  design_res.push_back( resnum);
324  TR<<"allowing design for "<<key<<std::endl;
325  }
326  //TR.Debug<<"runtime designable: " << design_res <<std::endl;
327  return design_res;
328 }//end parsing design residues
329 
330 void
332 
333  using namespace core::pack;
334  using namespace core::pack::task;
335 
336  /// re-parsing seed residues at runtime since they might have changed within the trajectory due to length changes
337 
338  /// 1. re-parsing the input elements
339  utility::vector1 <Size > designable_residues_motif;
340  all_seeds_ = parse_seeds( pose , seed_vector_ );
341  designable_residues_motif = adjust_des_residues( pose , design_res_);
342  utility::vector1 <Size> norepack_residues = adjust_des_residues( pose, norepack_res_ );
343 
344  /// 2. set movemap
346 
347  /// 3. compute new task operations for seeds and target
348 
349  //reset taskfactory
351 
352  // todo: write setters adn getters for teh private variables....
353  // very hacky and inconsistent use of private variables
354  if( packtask_ ){
355  set_packerTasks_target_and_seeds( pose, all_seeds_ , designable_residues_motif , norepack_residues , task_factory_ ); //, repack_target_, design_foldpose_, design_target_ )
356 
357  //TR<<"at the end of apply movemap:"<<std::endl;
358  for( Size i = 1 ; i <= pose.total_residue(); ++i ){
359  TR.Debug <<"position: "<< i <<", bb: "<< movemap_->get_bb(i)<< ", chi: "<<movemap_->get_chi(i)<<std::endl;
360  }
361 
362  PackerTaskOP ptask = task_factory_->create_task_and_apply_taskoperations( pose );
363  if( design_ )
364  pack_rotamers( pose, *scorefxn_repack_ , ptask );
365  }
366 
367  TR.flush();
368 }//end apply
369 
373 }
374 
375 void
378  protocols::filters::Filters_map const & /*filters*/,
380  core::pose:: Pose const & pose){
381 
382  TR<<"SeedSetupMover has been invoked"<<std::endl;
383 
384  //adding the movemap to the datamap
387 
388  //adding the taskfactory to the datamap
389  //task_factory_ = new core::pack::task::TaskFactory;
390  //temporarily inactivating this option.....
391  //task_factory( protocols::rosetta_scripts::parse_task_operations( tag, data, task_factory_ ) );
392 
393  chi_chain2_ = tag->getOption< bool >("chi_chain2", 0 );
394  chi_chain1_ = tag->getOption< bool >("chi_chain1", 0 );
395 
396  interface_chi1_ = tag->getOption< bool >("interface_chi1", 0 );
397  interface_chi2_ = tag->getOption< bool >("interface_chi2", 0 );
398  interface_distance_cutoff_ = tag->getOption< core::Real >("interface_distance_cutoff" , 8 );
399 
400  //repacking for packer tasks options
401  repack_target_ = tag->getOption< bool >("repack_target", 1 );
402  repack_foldpose_ = tag->getOption< bool >("repack_foldpose", 1 );
403 
404  //for design option for packertasks
405  design_target_ = tag->getOption< bool >("design_target", 0 );
406  design_foldpose_ = tag->getOption< bool >("design_foldpose", 1 );
407  allow_all_aas_ = tag->getOption< bool >("allow_all_aas", 0 );
408 
409  /// this mover can perform repacking and design mover -- which is not recommaned
410  std::string scorefxn_repack = tag->getOption<std::string>( "scorefxn_repack", "score12" );
411  std::string scorefxn_minimize = tag->getOption<std::string>( "scorefxn_minimize", "score12" );
412  using namespace core::scoring;
413 
414  scorefxn_repack_ = new ScoreFunction( *data.get< ScoreFunction * >( "scorefxns", scorefxn_repack ) );
415  scorefxn_minimize_ = new ScoreFunction( *data.get< ScoreFunction * >( "scorefxns", scorefxn_minimize ) );
416  design_ = tag->getOption< bool >( "design" , 0 );
417 
418  /// read input seeds
419  utility::vector0< TagPtr > const branch_tags( tag->getTags() );
420  foreach( TagPtr const btag, branch_tags ){
421 
422  if( btag->getName() == "Seeds" ) { //need an assertion for the presence of these or at least for the option file
423 
424  std::string const beginS( btag->getOption<std::string>( "begin" ) );
425  std::string const endS( btag->getOption<std::string>( "end" ) );
426  std::pair <std::string,std::string> seedpair;
427  seedpair.first = beginS;
428  TR.Debug <<"parsing seeds: " << beginS << " " <<endS <<std::endl;
429  seedpair.second = endS;
430  seed_vector_.push_back( seedpair );
431  }//end seeds
432  }//end b-tags
433 
434  //allow design within the seed/motif
435  if( tag->hasOption( "allow_design" ) ){
436  design_res_ = tag->getOption< std::string >( "allow_design" );
437  }
438 
439  //dont allow these residues to repack
440  if( tag->hasOption( "norepack_res" ) ){
441  norepack_res_ = tag->getOption< std::string >( "norepack_res" );
442  }
443 
444  if( tag->hasOption("packtask") ){
445  packtask_ = tag->getOption< bool >( "packtask" );
446  TR<<"packer task factory set to: " << std::endl;
447  }
448 
449  }//end parse my tag
450 
451  }
452 }//protocol
453 
454