Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MotifDnaPacker.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 
12 
17 #include <protocols/dna/util.hh>
20 // AUTO-REMOVED #include <protocols/dna/RotamerDNAHBondFilter.hh>
22 // AUTO-REMOVED #include <protocols/dna/SeparateDnaFromNonDna.hh>
28 #include <protocols/motifs/Motif.hh> // REQUIRED FOR WINDOWS
29 // AUTO-REMOVED #include <protocols/motifs/BuildPosition.hh> // REQUIRED FOR WINDOWS
30 
31 //#include <devel/blab/opte/sidechain_relax.hh>
32 //#include <devel/blab/motif/MotifData.hh>
33 //#include <devel/blab/motif/util.hh>
34 //#include <devel/blab/motif/util_classes.hh>
35 //#include <devel/blab/motif/loop_rebuild.hh>
36 //#include <devel/blab/motif/loop_rebuild_movers.hh>
37 //#include <devel/blab/loops/util.hh>
38 //#include <devel/dna/util.hh>
39 // AUTO-REMOVED #include <numeric/random/random.hh>
40 
41 #include <core/types.hh>
45 
47 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
48 // AUTO-REMOVED #include <core/kinematics/MoveMap.hh>
49 // AUTO-REMOVED #include <core/optimization/MinimizerOptions.hh>
50 // AUTO-REMOVED #include <core/optimization/AtomTreeMinimizer.hh>
51 // AUTO-REMOVED #include <core/pack/pack_rotamers.hh>
52 // AUTO-REMOVED #include <core/pack/interaction_graph/InteractionGraphBase.hh>
55 //#include <core/pack/task/TaskOperation.hh>
59 // AUTO-REMOVED #include <core/pack/rotamer_set/RotamerSets.hh>
60 #include <core/pose/Pose.hh>
61 #include <core/pose/util.hh>
62 #include <core/pose/PDBInfo.hh>
64 // AUTO-REMOVED #include <core/scoring/dna/setup.hh>
66 
67 #include <basic/options/option.hh>
68 #include <basic/options/keys/dna.OptionKeys.gen.hh>
69 #include <basic/options/keys/motifs.OptionKeys.gen.hh>
70 #include <basic/options/keys/packing.OptionKeys.gen.hh>
71 // AUTO-REMOVED #include <basic/options/keys/run.OptionKeys.gen.hh>
72 // AUTO-REMOVED #include <basic/options/keys/out.OptionKeys.gen.hh>
73 
74 //#include <basic/tracer.hh>
75 #include <basic/Tracer.hh>
76 
77 #include <utility/vector0.hh>
78 #include <utility/vector1.hh>
79 #include <utility/string_util.hh>
80 // AUTO-REMOVED #include <utility/io/izstream.hh>
81 // AUTO-REMOVED #include <utility/io/ozstream.hh>
82 // AUTO-REMOVED #include <utility/tag/Tag.hh>
83 // AUTO-REMOVED #include <utility/tools/make_vector1.hh>
84 
85 // ObjexxFCL Headers
86 #include <ObjexxFCL/string.functions.hh> // lead_zero_string_of
87 
88 // c++ headers
89 #include <vector> // for rot_to_pack
90 #include <iostream>
91 #include <sstream>
92 
93 
94 //Auto using namespaces
95 namespace ObjexxFCL { namespace fmt { } } using namespace ObjexxFCL::fmt; // AUTO USING NS
96 //Auto using namespaces end
97 
98 
99 namespace protocols {
100 namespace motifs {
101 
102 int const PRECISION(3); // number of decimal places for floating point numbers
103 
104 using utility::vector1;
105 using utility::string_split;
106 using namespace core;
107  using namespace chemical;
108  using namespace conformation;
109  using namespace optimization;
110  using namespace basic::options;
111  using namespace pack;
112  using namespace task;
113  using namespace operation;
114  using namespace pose;
115  using namespace scoring;
116 using namespace protocols::dna;
117 
118 using namespace ObjexxFCL;
119  using namespace ObjexxFCL::fmt;
120 
121 using basic::t_warning;
122 using basic::t_info;
123 using basic::t_debug;
124 static basic::Tracer TR("devel.motifs.MotifDnaPacker");
125 
127 MotifDnaPackerCreator::keyname() const
128 {
129  return MotifDnaPackerCreator::mover_name();
130 }
131 
133 MotifDnaPackerCreator::create_mover() const
134 {
135  return new MotifDnaPacker;
136 }
137 
139 MotifDnaPackerCreator::mover_name()
140 {
141  return "MotifDnaPacker";
142 }
143 
144 ////////////////////////////////////////////////////////////////////////////////////////////////////
145 ///@brief lightweight default constructor
146 MotifDnaPacker::MotifDnaPacker()
147  : protocols::moves::Mover("MotifDnaPacker"),
148  dna_packer_(0),
149  motif_search_(0),
150  scorefxn_(0),
151  pdboutput_(0),
152  targeted_dna_(0),
153  run_motifs_(false),
154  expand_motifs_(false),
155  aromatic_motifs_(false),
156  minimize_dna_(false),
157  special_rotweight_(-40.0),
158  num_repacks_(5),
159  flex_dna_sugar_(false),
160  dna_design_(false)
161 {
162  init_options();
163 }
164 
165 ///@brief functional constructor
167  ScoreFunctionOP scorefxn_in,
168  bool minimize,
169  std::string filename_root
170 ) : protocols::moves::Mover("MotifDnaPacker"),
171  scorefxn_( scorefxn_in ),
172  run_motifs_(false),
173  expand_motifs_(false),
174  aromatic_motifs_(false),
175  minimize_dna_(false),
176  special_rotweight_(-40.0),
177  num_repacks_(5),
178  flex_dna_sugar_(false),
179  dna_design_(false)
180 {
181  init_options();
182  filename_root_ = filename_root;
183  dna_packer_ = new DnaInterfacePacker( scorefxn_in, minimize, filename_root );
185  motif_search_ = motif_search;
186  pdboutput_ = new PDBOutput;
187 }
188 
189 ///@brief destructor
191 
192 ///@brief required in the context of the parser/scripting scheme
195 {
196  return new MotifDnaPacker;
197 }
198 
199 ///@brief required in the context of the parser/scripting scheme
202 {
203  return new MotifDnaPacker( *this );
204 }
205 
209 }
210 
211 ////////////////////////////////////////////////////////////////////////////////////////////////////
212 /// @begin MotifDnaPacker::apply
213 /// @brief
214 /// @author sthyme
215 void
217 {
218  init_standard( pose );
219 
220  TaskFactoryOP taskfactory = new TaskFactory;
221  taskfactory->push_back( new InitializeFromCommandline );
222  if( option[ OptionKeys::packing::resfile ].user() ) {
223  taskfactory->push_back( new ReadResfile );
224  }
225 
226  utility::vector1< core::Size > protein_positions, dna_positions, dna_design_positions, preventrepack;
228  core::Size nres( pose.total_residue() );
229  for ( Size p_index(1); p_index<=nres; ++p_index ) {
230  if ( pose.residue_type( p_index ).is_DNA() ) {
231  dna_positions.push_back( p_index );
232  }
233  if ( pose.residue_type( p_index ).is_protein() ) {
234  protein_positions.push_back( p_index );
235  } else {
236  preventrepack.push_back( p_index );
237  }
238  }
239 
240  bool target_dna_empty( false );
241  if( ! targeted_dna_.empty() ) {
242  dna_design_positions = protocols::motifs::defs2vector( pose, targeted_dna_ );
244  utility::vector1< core::Size > complete_ddps;
245  for( Size i(1); i<=dna_design_positions.size(); ++i ) {
246  complete_ddps.push_back(dna_design_positions[i]);
247  complete_ddps.push_back(partner[dna_design_positions[i]]);
248  }
249  base_partners.push_back( complete_ddps );
250  } else {
251  target_dna_empty = true;
253  utility::vector1< core::Size > complete_design_positions;
254  for( Size i(1); i<=( dna_positions.size() / 2 ); ++i ) {
256  if( partner[dna_positions[i]] != 0 ) {
257  pair.push_back( dna_positions[i] );
258  pair.push_back( partner[dna_positions[i]] );
259  }
260  if( ! pair.empty() ) {
261  base_partners.push_back( pair );
262  }
263  }
264  // NEED THE INPUTS HERE TO BE FROM THE OPTIONS? OR DEFAULT AND SPREAD TO ALL DNAIFs
266  protocols::dna::DnaInterfaceFinderOP complete_interface_ = new protocols::dna::DnaInterfaceFinder( 10 * 10, 3.9 * 3.9, 6., true );
267  complete_interface_->determine_protein_interface( pose, protein_positions, dna_positions );
268  //// rdtpdi->set_reference_pose( starting_pose_ );
269  rdtpdi->copy_interface( complete_interface_ );
270  rdtpdi->set_forget_chains_and_interface( false );
271  TaskFactoryOP taskfactory0 = new TaskFactory( *taskfactory );
272  taskfactory0->push_back( rdtpdi );
273  PackerTaskOP ptask_ = taskfactory0->create_task_and_apply_taskoperations( pose );
274  for ( core::Size j(1); j<=nres; ++j ) {
275  if ( !pose.residue_type(j).is_protein() ) continue;
276  ResidueLevelTask const & rtask( ptask_->residue_task(j) );
277  if ( rtask.being_designed() ) {
278  complete_design_positions.push_back(j);
279  }
280  }
281  if( run_motifs_ ) {
282  motif_search_->run( pose, complete_design_positions );
283  }
284  }
285 
286  for( Size bp(1); bp<=base_partners.size(); ++bp ) {
287  pose = *starting_pose_;
288  utility::vector1< core::Size > design_positions;
289  std::map< core::Size, pack::rotamer_set::Rotamers > rotamer_map;
290  std::map< core::Size, std::set< std::string > > types_map;
291  std::set< core::Size > src_pos;
292  std::list< std::string > info_lines;
293  std::stringstream info_lines_str;
294  // NEED THE INPUTS HERE TO BE FROM THE OPTIONS? OR DEFAULT AND SPREAD TO ALL DNAIFs
295  protocols::dna::DnaInterfaceFinderOP interface_ = new protocols::dna::DnaInterfaceFinder( 10 * 10, 3.9 * 3.9, 6., true );
296  interface_->determine_protein_interface( pose, protein_positions, base_partners[bp] );
298  // need or not??
299 ////// rdtpdi->set_reference_pose( starting_pose_ );
300  rdtpdi2->copy_interface( interface_ );
301 
302  DnaChainsOP dna_chains = new DnaChains;
303  find_basepairs( pose, *dna_chains );
304  DnaDesignDefOPs targetdefs;
305  for( Size i(1); i<=(base_partners[bp].size()); ++i ) {
306  if( dna_chains->is_top(base_partners[bp][i]) ) {
307  std::stringstream def;
308  def << pose.pdb_info()->chain( base_partners[bp][i]) << "." << pose.pdb_info()->number(base_partners[bp][i]) << "." << pose.residue(base_partners[bp][i]).name3();
309  DnaDesignDefOP target = new DnaDesignDef( def.str() );
310  targetdefs.push_back( target );
311  }
312  }
313  rdtpdi2->set_forget_chains_and_interface( false );
314  TaskFactoryOP taskfactory1 = new TaskFactory( *taskfactory );
315  TaskFactoryOP taskfactory2 = new TaskFactory( *taskfactory );
316 
317  targeted_dna_ = targetdefs;
318  if( ! dna_design_ ) {
319  rdtpdi2->copy_targeted_dna( targetdefs );
320  } else {
321  utility::vector1< Size > restricted_DNA;
322  for( Size d(1) ; d <= dna_positions.size(); ++d ) {
323  bool r_DNA( true );
324  for( Size i(1); i<=(base_partners[bp].size()); ++i ) {
325  if ( dna_positions[d] == base_partners[bp][i] ) {
326  r_DNA = false;
327  }
328  }
329  if( r_DNA ) {
330  restricted_DNA.push_back( dna_positions[d] );
331  }
332  }
334  fixedDNA->residue_indices( restricted_DNA );
335  fixedDNA->op( new PreventRepackingRLT );
337  taskfactory1->push_back( fixedDNA );
338  taskfactory1->push_back( wrc );
339  taskfactory2->push_back( fixedDNA );
340  taskfactory2->push_back( wrc );
341  }
342 
343  taskfactory1->push_back( rdtpdi2 );
344  taskfactory2->push_back( rdtpdi2 );
345  PackerTaskOP ptask_ = taskfactory2->create_task_and_apply_taskoperations( pose );
346  for ( core::Size j(1); j<=nres; ++j ) {
347  if ( !pose.residue_type(j).is_protein() ) continue;
348  ResidueLevelTask const & rtask( ptask_->residue_task(j) );
349  if ( rtask.being_designed() ) {
350  design_positions.push_back(j);
351  std::stringstream numberandchain;
352  numberandchain << pose.pdb_info()->number( j ) << pose.pdb_info()->chain( j );
353  info_lines_str << numberandchain.str() << ",";
354  }
355  }
356  info_lines.push_back( info_lines_str.str() );
357 
358  if ( design_positions.empty() ) continue;
359 
360  std::string mot_name3( "NOMotifs" );
361  std::stringstream filename;
362  filename << filename_root_ << "_" << mot_name3;
363 
364  core::Real zero_special_rotweight( -0.0 );
365  scorefxn_->set_weight( special_rot, ( zero_special_rotweight ) );
366 
367  dna_packer_->task_factory( taskfactory1 );
368  dna_packer_->set_filename_root( filename.str() );
369  dna_packer_->apply( pose );
370 
371  bool const overwrite_old_info(true);
372  pdboutput_->add_info( "REMARK DESIGNED POSITIONS " + filename_root_ + ":", info_lines, !overwrite_old_info );
373  pdboutput_->score_function( *scorefxn_ );
374  (*pdboutput_)(pose, dna_packer_->pdbname() + ".pdb");
375 
376  dna_packer_->clear_initialization();
377 
378  if ( run_motifs_ && ( ! target_dna_empty ) ) {
379  motif_search_->run( pose, design_positions );
380  if( option[ OptionKeys::motifs::quick_and_dirty ].user() ) break;
381  run_motifs( pose, design_positions, src_pos, rotamer_map, types_map, info_lines, taskfactory1 );
382  } else {
383  if( option[ OptionKeys::motifs::quick_and_dirty ].user() ) break;
384  run_motifs( pose, design_positions, src_pos, rotamer_map, types_map, info_lines, taskfactory1 );
385  }
386  if ( run_motifs_ && expand_motifs_ ) {
387  if( option[ OptionKeys::motifs::quick_and_dirty ].user() ) break;
388  expand_motifs( pose, design_positions, src_pos, rotamer_map, types_map, info_lines, taskfactory1 );
389  }
390  if ( run_motifs_ && aromatic_motifs_ ) {
391  if( option[ OptionKeys::motifs::quick_and_dirty ].user() ) break;
392  aromatic_motifs( pose, design_positions, src_pos, rotamer_map, types_map, info_lines, taskfactory1 );
393  }
394  }
395 }
396 
397 void
399 {
400  //protocols::motifs::make_dna_mutations( pose );
401  starting_pose_ = new pose::Pose( pose );
402  pdboutput_->reference_pose( *starting_pose_ );
403  if ( option[ OptionKeys::dna::design::dna_defs ].user() ) {
405  } else if ( option[ OptionKeys::motifs::target_dna_defs ].user() ) {
406  utility::vector1< std::string > str_def( option[ OptionKeys::motifs::target_dna_defs ]().vector() );
408  }
409  dna_packer_->reference_pose( *starting_pose_ );
410  // Don't need pdbs output without the dna minimization, want the pdboutput to all come from this code
411  //dna_packer_->pdboutput( pdboutput_ );
412 }
413 
414 /*void
415 MotifDnaPacker::minimize_dna( Pose & pose )
416 {
417 
418  using namespace devel::blab::motif;
419 
420  core::Size const nres( pose.total_residue() );
421  MotifData & md( get_nonconst_motif_data( pose ) );
422  utility::vector1< core::Size > flexandcut = protocols::motifs::defs2vector( pose, targeted_dna_ );
423  sort( flexandcut.begin(), flexandcut.end() );
424  md.clear();
425  MotifData::Segment & flex_dna( md.segment("FLEX_DNA") );
426  MotifData::Segment & cutpoint_dna( md.segment("CUTPOINT_DNA") );
427  if ( flexandcut.empty() ) {
428  flex_dna = get_motif_data( pose ).segment( "FLEX_DNA" );
429  cutpoint_dna = get_motif_data( pose ).segment( "CUTPOINT_DNA" );
430  } else {
431  Size fac1( flexandcut[1] - 1 );
432  Size fac2( flexandcut[flexandcut.size()] + 1 );
433  if ( fac1 != 0 ) {
434  if ( (! pose.residue(fac1).is_terminus()) && pose.residue(fac1).is_DNA() ) {
435  flex_dna.push_back(fac1);
436  cutpoint_dna.push_back(fac1);
437  }
438  }
439  for ( Size i(1); i<=flexandcut.size(); ++i ) {
440  if ( ! pose.residue(flexandcut[i]).is_terminus() ) {
441  flex_dna.push_back(flexandcut[i]);
442  cutpoint_dna.push_back(flexandcut[i]);
443  }
444  }
445  if( ! (fac2>pose.total_residue() ) ) {
446  if ( (! pose.residue( fac2 ).is_terminus()) && pose.residue( fac2 ).is_DNA() ) {
447  flex_dna.push_back( fac2 );
448  cutpoint_dna.push_back( fac2 );
449  }
450  }
451  }
452 
453  // figure out interface positions
454  // new way to figure out interface in order to avoid having to include /apps/phil/interface.hh
455  utility::vector1< bool > is_interface_protein( nres, false );
456  core::pack::task::TaskFactoryOP tf = new core::pack::task::TaskFactory( *(dna_packer_->task_factory()) );
457  core::pack::task::PackerTaskOP ptask_ = tf->create_task_and_apply_taskoperations( pose );
458  for( core::Size j(1); j<=ptask_->total_residue(); ++j ) {
459  if ( !pose.residue_type(j).is_protein() ) continue;
460  ResidueLevelTask const & rtask( ptask_->residue_task(j) );
461  if( rtask.being_designed() || rtask.being_packed() ) {
462  is_interface_protein[j] = true;
463  }
464  }
465 
466  utility::vector1< bool > is_flex_dna( nres, false );
467  for ( MotifData::Segment::const_iterator pos = flex_dna.begin(); pos != flex_dna.end(); ++pos ) {
468  is_flex_dna[ *pos ] = is_flex_dna[ scoring::dna::retrieve_base_partner_from_pose( pose )[ *pos ] ] = true;
469  }
470 
471  /// choose a dna "loop", which just means choosing a random cutpoint in the dna, from the CUTPOINT_DNA segment
472  protocols::loops::Loop const dna_loop( devel::blab::motif::setup_dna_loop_with_random_cutpoint( pose ) );
473  protocols::loops::Loop const protein_loop;*/ // an empty loop
474  //setup_loop_rebuild_fold_tree( pose, protein_loop, dna_loop, false /*anchor_dna_jumps_in_backbone*/,
475  // ( numeric::random::uniform() < 0.5 ) );
476 /* setup_loop_rebuild_cutpoint_variants( pose, protein_loop );
477  // which positions should be repacked/designed ?
478  utility::vector1< Size > const designable_positions( get_motif_data( pose ).segment("DESIGN_PROTEIN", true ) );
479  utility::vector1< bool > is_mutable( protocols::motifs::bools_from_sizes( nres, designable_positions ) ),
480  is_chimin_flexible( nres, false ), is_chimove_flexible( nres, false ), is_bb_flexible( nres, false ),
481  is_jump_flexible( nres, false );
482 
483  for ( core::Size i=1; i<= nres; ++i ) {
484  is_chimin_flexible[i] = is_flex_dna[i] || is_interface_protein[i];
485  is_chimove_flexible[i] = is_interface_protein[i] || is_mutable[i];
486  is_jump_flexible[i] = is_flex_dna[i];
487  is_bb_flexible[i] = is_flex_dna[i];
488  }
489 
490  utility::vector1< core::Real > aa_bias;
491  core::Size outer_cycles( 10 );
492  bool const ramp_repulsive( false ), skip_mutation_moves_in_first_cycle( false ), dry_run( false );
493  devel::blab::opte::motifpacker_dna_minimize( *scorefxn_, aa_bias, is_bb_flexible, is_chimin_flexible,
494  is_chimove_flexible, is_mutable, is_jump_flexible,
495  outer_cycles, dry_run, ramp_repulsive,
496  skip_mutation_moves_in_first_cycle,*/
497  //pose, 0, false, flex_dna_sugar_/*update_pose_after_sequence_change_mover=0, vary_omega=false, flex_dna_sugar=false*/);
498 //}
499 
500 void
502 {
503  if( option[ OptionKeys::motifs::run_motifs ].user() ) run_motifs_ = true;
504  if( option[ OptionKeys::motifs::expand_motifs ].user() ) expand_motifs_ = true;
505  if( option[ OptionKeys::motifs::aromatic_motifs ].user() ) aromatic_motifs_ = true;
506  if( option[ OptionKeys::motifs::special_rotweight ].user() ) special_rotweight_ = option[ OptionKeys::motifs::special_rotweight ]();
507  if( option[ OptionKeys::motifs::num_repacks ].user() ) num_repacks_ = option[ OptionKeys::motifs::num_repacks ]();
508  if( option[ OptionKeys::motifs::minimize_dna ].user() ) minimize_dna_ = true;
509  if( option[ OptionKeys::motifs::flex_sugar ].user() ) flex_dna_sugar_ = true;
510  //if( option[ OptionKeys::motifs::quick_and_dirty ].user() );
511  if( option[ OptionKeys::motifs::target_dna_defs ].user() ) dna_design_ = true;
512 }
513 
514 void
516  Pose & pose,
517  utility::vector1< core::Size > & design_positions,
518  std::set< core::Size > & src_pos,
519  std::map< core::Size, pack::rotamer_set::Rotamers > & rotamer_map,
520  std::map< core::Size, std::set< std::string > > & types_map,
521  std::list< std::string > & info_lines,
522  pack::task::TaskFactoryOP taskfactory
523 )
524 {
525  for( core::Size i(1); i <= design_positions.size(); ++i ) {
526  std::set< std::string > name3set;
527  pack::rotamer_set::Rotamers motif_rotamers( motif_search_->bp_rotamers( design_positions[i] ) );
528  src_pos.insert( design_positions[i] );
529  pack::rotamer_set::Rotamers variant_rotamers;
530  if ( ! motif_rotamers.empty() ) {
531  for( core::Size rot(1); rot <= motif_rotamers.size(); ++rot ) {
533  variant_rotamers.push_back( variant_rot );
534  name3set.insert( (motif_rotamers[rot])->name3() );
535  }
536  rotamer_map[design_positions[i]] = variant_rotamers;
537  if( (! expand_motifs_) && (! aromatic_motifs_) ) {
539  ms_rsoop->set_new_rots( variant_rotamers );
540  taskfactory->push_back( new AppendRotamerSet( ms_rsoop ) );
541  }
542  }
543  types_map[design_positions[i]] = name3set;
544  }
545  std::string tag("");
546  if( (! expand_motifs_) && (! aromatic_motifs_) ) {
547  std::stringstream mot_name;
548  bool special_rotweight_zero( true );
549  if( special_rotweight_zero ) {
550  core::Real zero_special_rotweight( -0.0000000001 );
551  scorefxn_->set_weight( special_rot, ( zero_special_rotweight ) );
552  mot_name << "ZPW";
553  std::string mot_name3( mot_name.str() );
554  std::stringstream filename;
555  filename << filename_root_ << "_" << mot_name3;
556  dna_packer_->task_factory( taskfactory );
557  dna_packer_->set_filename_root( filename.str() );
558  dna_packer_->apply( pose );
559  /*if ( minimize_dna_ ) {
560  minimize_dna( pose );
561  tag = "_min";
562  }*/
563  bool const overwrite_old_info(true);
564  pdboutput_->add_info( "REMARK DESIGNED POSITIONS " + filename_root_ + ":", info_lines, !overwrite_old_info );
565  pdboutput_->score_function( *scorefxn_ );
566  (*pdboutput_)(pose, dna_packer_->pdbname() + tag + ".pdb");
567 
568  dna_packer_->clear_initialization();
569  }
570  pose = *starting_pose_;
571  core::Real special_rotweight( special_rotweight_ );
572  for ( core::Size trial(0); trial < num_repacks_; ++trial ) {
573  core::Real special_rotweight2 = ( special_rotweight / 2 );
574  scorefxn_->set_weight( special_rot, ( special_rotweight2 /*(trial+1)*/ ) );
575  special_rotweight = special_rotweight2;
576  std::stringstream filename;
577  filename << filename_root_ << "_" << lead_zero_string_of( trial, 4 );
578  dna_packer_->task_factory( taskfactory );
579  dna_packer_->set_filename_root( filename.str() );
580  dna_packer_->apply( pose );
581  /*if ( minimize_dna_ ) {
582  minimize_dna( pose );
583  }*/
584  bool const overwrite_old_info(true);
585  pdboutput_->add_info( "REMARK DESIGNED POSITIONS " + filename_root_ + ":", info_lines, !overwrite_old_info );
586  pdboutput_->score_function( *scorefxn_ );
587  (*pdboutput_)(pose, dna_packer_->pdbname() + tag + ".pdb");
588 
589  dna_packer_->clear_initialization();
590  }
591  }
592 }
593 
594 void
596  Pose & pose,
597 //mjo commenting out 'design_positions' because it is unused and causes a warning
598  utility::vector1< core::Size > & /*design_positions*/,
599  std::set< core::Size > & src_pos,
600  std::map< core::Size, pack::rotamer_set::Rotamers > & rotamer_map,
601  std::map< core::Size, std::set< std::string > > & types_map,
602  std::list< std::string > & info_lines,
603  pack::task::TaskFactoryOP taskfactory
604 )
605 {
606  for( std::map< core::Size, pack::rotamer_set::Rotamers >::const_iterator it( rotamer_map.begin() ),
607  end( rotamer_map.end() ); it != end; ++it ) {
608  std::string tag("");
609  std::set< std::string > name3s( types_map[it->first] );
610  std::set< core::Size > current_pos( src_pos );
611  current_pos.erase( it->first );
612  for( std::set< std::string >::const_iterator it2( name3s.begin() ),
613  end2( name3s.end() ); it2 != end2; ++it2 ) {
614  pose = *starting_pose_;
615  TaskFactoryOP my_tf2;
616  my_tf2 = new TaskFactory( *taskfactory );
617  pack::rotamer_set::Rotamers restricted_rotamers;
618  pack::rotamer_set::Rotamers src_rotamers( it->second );
619  for( core::Size rot2(1); rot2 <= src_rotamers.size(); ++rot2 ) {
620  if( src_rotamers[rot2]->name3() != *it2 ) continue;
621  restricted_rotamers.push_back( src_rotamers[rot2] );
622  }
623  utility::vector1< bool > keep_aas( num_canonical_aas, false );
624  keep_aas[ chemical::aa_from_name(*it2) ] = true;
625  my_tf2->push_back( new RestrictAbsentCanonicalAAS( it->first, keep_aas ) );
627  ms_rsoop->set_new_rots( restricted_rotamers );
628  my_tf2->push_back( new AppendRotamerSet( ms_rsoop ) );
629 
630  for( std::set< core::Size >::const_iterator it3( current_pos.begin() ),
631  end3( current_pos.end() ); it3 != end3; ++it3 ) {
632  if( rotamer_map[*it3].empty() ) continue;
633  pack::rotamer_set::Rotamers other_rotamers;
634  for( core::Size it4(1); it4<=(rotamer_map[*it3]).size(); ++it4 ) {
635  other_rotamers.push_back( rotamer_map[*it3][it4] );
636  }
638  ms_rsoop2->set_new_rots( other_rotamers );
639  my_tf2->push_back( new AppendRotamerSet( ms_rsoop2 ) );
640  }
641 
642  std::stringstream mot_name;
643  mot_name << *it2 << "_" << pose.pdb_info()->chain(it->first) << pose.pdb_info()->number(it->first);
644  std::string mot_name2( mot_name.str() );
645 
646  bool special_rotweight_zero( true );
647  if( special_rotweight_zero ) {
648  core::Real zero_special_rotweight( -0.0000000001 );
649  scorefxn_->set_weight( special_rot, ( zero_special_rotweight ) );
650  mot_name << "_ZPW";
651  std::string mot_name3( mot_name.str() );
652  std::stringstream filename;
653  filename << filename_root_ << "_" << mot_name3;
654  dna_packer_->task_factory( taskfactory );
655  dna_packer_->set_filename_root( filename.str() );
656  dna_packer_->apply( pose );
657  /*if ( minimize_dna_ ) {
658  minimize_dna( pose );
659  tag = "_min";
660  }*/
661  bool const overwrite_old_info(true);
662  pdboutput_->add_info( "REMARK DESIGNED POSITIONS " + filename_root_ + ":", info_lines, !overwrite_old_info );
663  pdboutput_->score_function( *scorefxn_ );
664  (*pdboutput_)(pose, dna_packer_->pdbname() + tag + ".pdb");
665 
666  dna_packer_->clear_initialization();
667  }
668  pose = *starting_pose_;
669  core::Real special_rotweight( special_rotweight_ );
670  for ( core::Size trial(0); trial < num_repacks_; ++trial ) {
671  core::Real special_rotweight2 = ( special_rotweight / 2 );
672  scorefxn_->set_weight( special_rot, ( special_rotweight2 /*(trial+1)*/ ) );
673  special_rotweight = special_rotweight2;
674  std::stringstream filename;
675  filename << filename_root_ << "_" << mot_name2 << "_" << lead_zero_string_of( trial, 4 );
676  dna_packer_->task_factory( my_tf2 );
677  dna_packer_->set_filename_root( filename.str() );
678  dna_packer_->apply( pose );
679  /*if ( minimize_dna_ ) {
680  minimize_dna( pose );
681  }*/
682 
683  bool const overwrite_old_info(true);
684  pdboutput_->add_info( "REMARK DESIGNED POSITIONS " + filename_root_ + ":", info_lines, !overwrite_old_info );
685  pdboutput_->score_function( *scorefxn_ );
686  (*pdboutput_)(pose, dna_packer_->pdbname() + tag + ".pdb");
687 
688  dna_packer_->clear_initialization();
689  }
690 
691  }
692  }
693 }
694 
695 void
697  Pose & pose,
698  utility::vector1< core::Size > & design_positions,
699  std::set< core::Size > & src_pos,
700  std::map< core::Size, pack::rotamer_set::Rotamers > & rotamer_map,
701  std::map< core::Size, std::set< std::string > > & types_map,
702  std::list< std::string > & info_lines,
703  pack::task::TaskFactoryOP taskfactory
704 )
705 {
706  for( std::map< core::Size, pack::rotamer_set::Rotamers >::const_iterator it( rotamer_map.begin() ),
707  end( rotamer_map.end() ); it != end; ++it ) {
708  std::string tag("");
709  std::set< std::string > name3s( types_map[it->first] );
710  std::set< core::Size > current_pos( src_pos );
711  current_pos.erase( it->first );
712  bool aromatics( false );
713  std::set< std::string > name3_arom;
714  for( std::set< std::string >::const_iterator zt( name3s.begin() ),
715  end2( name3s.end() ); zt != end2; ++zt ) {
716  if( *zt == "TYR" || *zt == "PHE" || *zt == "TRP" ) {
717  aromatics = true;
718  name3_arom.insert( *zt );
719  }
720  }
721  if( !aromatics ) {
722  continue;
723  }
724  for( std::set< std::string >::const_iterator it2( name3_arom.begin() ),
725  end2( name3_arom.end() ); it2 != end2; ++it2 ) {
726  pose = *starting_pose_;
727  TaskFactoryOP my_tf2;
728  my_tf2 = new TaskFactory( *taskfactory );
729  pack::rotamer_set::Rotamers restricted_rotamers;
730  pack::rotamer_set::Rotamers src_rotamers( it->second );
731  for( core::Size rot2(1); rot2 <= src_rotamers.size(); ++rot2 ) {
732  if( src_rotamers[rot2]->name3() != *it2 ) continue;
733  restricted_rotamers.push_back( src_rotamers[rot2] );
734  }
735  utility::vector1< bool > keep_aas( num_canonical_aas, false );
736  keep_aas[ chemical::aa_from_name(*it2) ] = true;
737  my_tf2->push_back( new RestrictAbsentCanonicalAAS( it->first, keep_aas ) );
739  ms_rsoop->set_new_rots( restricted_rotamers );
740  my_tf2->push_back( new AppendRotamerSet( ms_rsoop ) );
741 
742  for( std::set< core::Size >::const_iterator it3( current_pos.begin() ),
743  end3( current_pos.end() ); it3 != end3; ++it3 ) {
744  if( rotamer_map[*it3].empty() ) continue;
745  pack::rotamer_set::Rotamers other_rotamers;
746  for( core::Size it4(1); it4<=(rotamer_map[*it3]).size(); ++it4 ) {
747  other_rotamers.push_back( rotamer_map[*it3][it4] );
748  }
750  ms_rsoop2->set_new_rots( other_rotamers );
751  my_tf2->push_back( new AppendRotamerSet( ms_rsoop2 ) );
752  }
753 
754  std::stringstream mot_name;
755  mot_name << *it2 << "_" << pose.pdb_info()->chain(it->first) << pose.pdb_info()->number(it->first);
756  std::string mot_name2( mot_name.str() );
757 
758  bool special_rotweight_zero( true );
759  if( special_rotweight_zero ) {
760  core::Real zero_special_rotweight( -0.0000000001 );
761  scorefxn_->set_weight( special_rot, ( zero_special_rotweight ) );
762  mot_name << "_ZPW";
763  std::string mot_name3( mot_name.str() );
764  std::stringstream filename;
765  filename << filename_root_ << "_" << mot_name3;
766  dna_packer_->task_factory( taskfactory );
767  dna_packer_->set_filename_root( filename.str() );
768  dna_packer_->apply( pose );
769  /*if ( minimize_dna_ ) {
770  minimize_dna( pose );
771  tag = "_min";
772  }*/
773  bool const overwrite_old_info(true);
774  pdboutput_->add_info( "REMARK DESIGNED POSITIONS " + filename_root_ + ":", info_lines, !overwrite_old_info );
775  pdboutput_->score_function( *scorefxn_ );
776  (*pdboutput_)(pose, dna_packer_->pdbname() + tag + ".pdb");
777 
778  dna_packer_->clear_initialization();
779  }
780  pose = *starting_pose_;
781  core::Real special_rotweight( special_rotweight_ );
782  for ( core::Size trial(0); trial < num_repacks_; ++trial ) {
783  core::Real special_rotweight2 = ( special_rotweight / 2 );
784  scorefxn_->set_weight( special_rot, ( special_rotweight2 /*(trial+1)*/ ) );
785  special_rotweight = special_rotweight2;
786  std::stringstream filename;
787  filename << filename_root_ << "_" << mot_name2 << "_" << lead_zero_string_of( trial, 4 );
788  dna_packer_->task_factory( my_tf2 );
789  dna_packer_->set_filename_root( filename.str() );
790  dna_packer_->apply( pose );
791  /*if ( minimize_dna_ ) {
792  minimize_dna( pose );
793  }*/
794 
795  bool const overwrite_old_info(true);
796  pdboutput_->add_info( "REMARK DESIGNED POSITIONS " + filename_root_ + ":", info_lines, !overwrite_old_info );
797  pdboutput_->score_function( *scorefxn_ );
798  (*pdboutput_)(pose, dna_packer_->pdbname() + tag + ".pdb");
799 
800  dna_packer_->clear_initialization();
801  }
802 
803  }
804  }
805  aromatic_motifs_ = false;
806  run_motifs( pose, design_positions, src_pos, rotamer_map, types_map, info_lines, taskfactory );
807 }
808 
809 } // namespace motifs
810 } // namespace protocols