Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DesignProteinBackboneAroundDNA.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 DesignProteinBackboneAroundDNA.cc
11 /// @brief performs a round flexible backbone sampling/design. (Interim(?) encapsulation of some loose code in a mover class.)
12 /// @author ashworth
13 
16 
19 #include <basic/options/option.hh>
27 #include <core/pose/Pose.hh>
28 #include <core/pose/PDBInfo.hh>
31 #include <basic/Tracer.hh>
32 
35 #include <protocols/loops/Loop.hh>
36 #include <protocols/loops/Loops.hh>
43 #include <utility/tag/Tag.hh>
44 #include <utility/vector1.hh>
45 using utility::vector1;
46 
47 #include <sstream>
48 #include <set>
49 #include <iostream>
50 
51 // option key includes
52 
53 #include <basic/options/keys/backrub.OptionKeys.gen.hh>
54 #include <basic/options/keys/dna.OptionKeys.gen.hh>
55 #include <basic/options/keys/MonteCarlo.OptionKeys.gen.hh>
56 #include <basic/options/keys/loops.OptionKeys.gen.hh>
57 #include <basic/options/keys/packing.OptionKeys.gen.hh>
58 #include <basic/options/keys/run.OptionKeys.gen.hh>
59 
60 #include <utility/vector0.hh>
61 #include <utility/keys/Key3Vector.hh>
62 #include <iterator>
63 
64 
65 namespace protocols {
66 namespace dna {
67 
68 using namespace core;
69  using namespace basic::options;
70  using namespace pack;
71  using namespace task;
72  using namespace operation;
73  using namespace pose;
74  using namespace scoring;
75 
76 using basic::t_warning;
77 using basic::t_info;
78 using basic::t_debug;
79 using basic::t_trace;
80 static basic::Tracer TR( "protocols.dna.DesignProteinBackboneAroundDNA", t_info );
81 
84 {
86 }
87 
91 }
92 
95 {
96  return "DesignProteinBackboneAroundDNA";
97 }
98 
100  protocols::simple_moves::PackRotamersMover( DesignProteinBackboneAroundDNACreator::mover_name() ),
101  type_("ccd"),
102  gapspan_( option[ OptionKeys::loops::gapspan ]() ),
103  spread_( option[ OptionKeys::loops::spread ]() ),
104  cycles_outer_( option[ OptionKeys::run::cycles_outer ]() ),
105  cycles_inner_( option[ OptionKeys::run::cycles_inner ]() ),
106  repack_rate_( option[ OptionKeys::run::repack_rate ]() ),
107  temp_initial_( option[ OptionKeys::MonteCarlo::temp_initial ]() ),
108  temp_final_( option[ OptionKeys::MonteCarlo::temp_final ]() ),
109  designable_second_shell_( option[ OptionKeys::dna::design::designable_second_shell ]() )
110 {}
111 
113  std::string const & type,
114  ScoreFunctionCOP scorefxn
115 ) :
116  protocols::simple_moves::PackRotamersMover( DesignProteinBackboneAroundDNACreator::mover_name() ),
117  type_(type),
118  gapspan_( option[ OptionKeys::loops::gapspan ]() ),
119  spread_( option[ OptionKeys::loops::spread ]() ),
120  cycles_outer_( option[ OptionKeys::run::cycles_outer ]() ),
121  cycles_inner_( option[ OptionKeys::run::cycles_inner ]() ),
122  repack_rate_( option[ OptionKeys::run::repack_rate ]() ),
123  temp_initial_( option[ OptionKeys::MonteCarlo::temp_initial ]() ),
124  temp_final_( option[ OptionKeys::MonteCarlo::temp_final ]() ),
125  designable_second_shell_( option[ OptionKeys::dna::design::designable_second_shell ]() )
126 {
127  score_function( scorefxn );
128 }
129 
131 
132 void
134  targeted_dna_ = defs;
135 }
136 
137 DnaDesignDefOPs const &
139 
140 void
142 {
143  if ( ! task_factory() ) {
144  TaskFactoryOP new_tf( new TaskFactory );
145  new_tf->push_back( new InitializeFromCommandline );
146  if ( option[ OptionKeys::packing::resfile ].user() ) new_tf->push_back( new ReadResfile );
148  rest->set_base_only( option[ OptionKeys::dna::design::base_contacts_only ]() );
149  rest->copy_targeted_dna( targeted_dna_ );
150  new_tf->push_back( rest );
151  task_factory( new_tf );
152  }
153 
154  // make a list of moveable positions as indicated by the primary TaskFactory
155  PackerTaskOP ptask = task_factory()->create_task_and_apply_taskoperations( pose );
156 
157  std::set< Size > packing_positions;
158  vector1< Size > design_positions;
159  for ( Size pos(1); pos < ptask->total_residue(); ++pos ) {
160  if ( ! pose.residue_type(pos).is_protein() ) continue;
161  if ( ptask->being_packed( pos ) ) packing_positions.insert( pos );
162  if ( ptask->being_designed( pos ) ) design_positions.push_back( pos );
163  }
164  if ( design_positions.empty() ) {
165  TR << "WARNING: no designable positions" << std::endl;
166  if ( packing_positions.empty() ) {
167  TR << "WARNING: no packable positions either" << std::endl;
168  } else {
169  TR << "using packable positions instead of designable positions "
170  << "to define movable backbone regions" << std::endl;
171  design_positions.insert( design_positions.begin(),
172  packing_positions.begin(), packing_positions.end() );
173  }
174  }
175 
176  // debug a.k.a. level 400 output
177  std::copy( design_positions.begin(), design_positions.end(),
178  std::ostream_iterator<Size>(TR(t_debug),",") );
179 
180  //this 'second-shell' TaskFactory will be used for packer operations during the backbone protocols
181  TaskFactoryOP task_factory2 = new TaskFactory;
182 
183  task_factory2->push_back( new IncludeCurrent );
184  // the following will disable packing outside of the neighborhood around design_positions
185 
188  task_factory2->push_back( nbop );
189 
190  // option-dependent designable second shell
191  if ( ! designable_second_shell_ ) task_factory2->push_back( new RestrictToRepacking );
192 
193  // prevent DNA packing/designing
194  task_factory2->push_back(
196 
197  // make loops
198  loops::LoopsOP loops_to_move = new Loops();
199 
200  loops::loops_around_residues( *loops_to_move, pose, design_positions, gapspan_, spread_ );
201  if ( loops_to_move->size() == 0 ) {
202  TR << "WARNING: no loop regions were defined, aborting backbone design" << std::endl;
203  return;
204  }
205  set_loop_info( pose, *loops_to_move );
206 
207  // rewrite foldtree to fix loop termini (prevents propagation of movement beyond loop)
208  kinematics::FoldTree ft_new, ft_orig( pose.fold_tree() );
209  loops::fold_tree_from_loops( pose, *loops_to_move, ft_new );
210  pose.fold_tree( ft_new );
211 
212  // finally call backbone movement protocol
213  if ( type_ == "ccd" ) {
214  ccd( pose, loops_to_move, task_factory2 ); // creates chainbreaks
215  } else if ( type_ == "backrub" ) {
216  backrub( pose, loops_to_move, task_factory2 ); // conservative
217  } else {
218  TR << "Unknown backbone movement type: " << type_ << '\n';
219  }
220 
221  loops::remove_cutpoint_variants( pose ); // purpose, exactly?
222  pose.fold_tree( ft_orig ); // restore original fold tree
223 }
224 
228 }
229 
230 ///@brief parse XML (specifically in the context of the parser/scripting scheme)
232  TagPtr const tag,
233  moves::DataMap & datamap,
234  protocols::filters::Filters_map const & filters,
235  moves::Movers_map const & movers,
236  Pose const & pose
237 )
238 {
239  if ( tag->hasOption("type") ) type_ = tag->getOption< std::string >("type");
240  if ( tag->hasOption("gapspan") ) gapspan_ = tag->getOption< Size >("gapspan");
241  if ( tag->hasOption("spread") ) spread_ = tag->getOption< Size >("spread");
242  if ( tag->hasOption("cycles_outer") ) cycles_outer_ = tag->getOption<Size>("cycles_outer");
243  if ( tag->hasOption("cycles_inner") ) cycles_inner_ = tag->getOption<Size>("cycles_inner");
244  if ( tag->hasOption("repack_rate") ) repack_rate_ = tag->getOption<Size>("repack_rate");
245  if ( tag->hasOption("temp_initial") ) temp_initial_ = tag->getOption<Real>("temp_initial");
246  if ( tag->hasOption("temp_final") ) temp_final_ = tag->getOption<Real>("temp_final");
247  if ( tag->hasOption("designable_second_shell") )
248  designable_second_shell_ = tag->getOption<bool>("designable_second_shell");
249  // the following are calls to PackRotamersMover methods
250  parse_score_function( tag, datamap, filters, movers, pose );
251  parse_task_operations( tag, datamap, filters, movers, pose );
252 }
253 
254 ///@brief required in the context of the parser/scripting scheme
257 {
259 }
260 
261 ///@brief required in the context of the parser/scripting scheme
264 {
265  return new DesignProteinBackboneAroundDNA( *this );
266 }
267 
268 ////////////////////////////////////////////////////////////////////////////////////////////////////
269 // private methods
270 void
272 {
273  // clear out (any) pre-existing string info (from previous apply calls)
274  info().clear();
275  // store information about the loops that were modeled
276  for ( Loops::const_iterator loop( loops.begin() ), end( loops.end() );
277  loop != end; ++loop ) {
278  Size const start( loop->start() ), cut( loop->cut() ), stop( loop->stop() );
279  std::ostringstream loopinfo;
280  loopinfo << "REMARK loop: ";
281  if ( pose.pdb_info() ) {
282  loopinfo << pose.pdb_info()->chain( start ) << "-" << pose.pdb_info()->number( start ) << ">"
283  << pose.pdb_info()->chain( cut ) << "-" << pose.pdb_info()->number( cut ) << ">"
284  << pose.pdb_info()->chain( stop ) << "-" << pose.pdb_info()->number( stop );
285  } else {
286  loopinfo << pose.chain( start ) << "-" << start << ">"
287  << pose.chain( cut ) << "-" << cut << ">"
288  << pose.chain( stop ) << "-" << stop;
289  }
290  info().push_back( loopinfo.str() );
291  }
292 }
293 
294 void
296  Pose & pose,
297  loops::LoopsOP const loops,
298  TaskFactoryCOP task_factory2
299 )
300 {
302  refine_ccd.outer_cycles( cycles_outer_ );
303  refine_ccd.max_inner_cycles( cycles_inner_ );
304  refine_ccd.repack_period( repack_rate_ );
305  refine_ccd.temp_initial( temp_initial_ );
306  refine_ccd.temp_final( temp_final_ );
307  refine_ccd.set_native_pose( new Pose( pose ) );
308  refine_ccd.set_task_factory( task_factory2 );
309  refine_ccd.apply( pose );
310 }
311 
312 void
314  Pose & pose,
315  loops::LoopsOP const loops,
316  TaskFactoryCOP task_factory2
317 )
318 {
319  ScoreFunctionOP br_scorefxn( score_function()->clone() );
320  br_scorefxn->set_weight( mm_bend, 0.5 );
321  // pivot atoms default to "CA" so that non-protein atoms are not considered during backrub scoring
322  methods::EnergyMethodOptions emo( br_scorefxn->energy_method_options() );
323  emo.bond_angle_central_atoms_to_score( option[ OptionKeys::backrub::pivot_atoms ] );
324  br_scorefxn->set_energy_method_options( emo );
325 
327  // read known and unknown optimization parameters from the database
328  backrubmover.branchopt().read_database();
329 
330  // this mover appears to require a separate copy of the input pose
331  PoseCOP input_pose = new Pose( pose );
332  backrubmover.set_input_pose( input_pose ); // virtual funtion in Mover base class
333 
334  // set up backrub segments
335  backrubmover.clear_segments();
336 
337  for ( Loops::const_iterator loop( loops->begin() ), end( loops->end() );
338  loop != end; ++loop ) {
339  Size const start( loop->start() ), stop( loop->stop() );
340  backrubmover.add_segment(
341  id::AtomID( pose.residue_type( start ).atom_index(" CA "), start ),
342  id::AtomID( pose.residue_type( stop ).atom_index(" CA "), stop )
343  );
344  }
345 
346  // read MonteCarlo / cycles options
347  Real const dtemp( ( temp_final_ - temp_initial_ ) / cycles_outer_ );
348 
349  for ( Size i(1); i <= cycles_outer_; ++i ) {
350  moves::MonteCarlo mc( pose, *br_scorefxn, temp_initial_ + dtemp*i );
351 
352  for ( Size j(1); j <= cycles_inner_; ++j ) {
353  backrubmover.apply( pose );
354  mc.boltzmann( pose );
355  if ( ( j % repack_rate_ ) == 0 ) {
356  PackerTaskOP ptask =
357  task_factory2->create_task_and_apply_taskoperations( pose );
358  pack_rotamers( pose, *br_scorefxn, ptask );
359  mc.boltzmann( pose );
360  }
361  }
362  mc.show_counters();
363  pose = mc.last_accepted_pose();
364  }
365 }
366 
367 } // namespace dna
368 } // namespace protocols