Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WobbleMover.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 /// @brief
11 /// @author Oliver Lange
12 
13 // Unit Headers
15 
16 // Package Headers
18 
19 // Project Headers
20 #include <core/fragment/FragSet.hh>
23 #include <core/pose/Pose.hh>
24 #include <basic/Tracer.hh>
25 
26 #include <protocols/loops/Loop.hh>
27 #include <protocols/loops/Loops.hh>
30 
31 // Utility headers
32 #include <numeric/random/random.hh>
33 
34 #include <utility/vector1.hh>
35 
36 
37 // C++ headers
38 
39 static basic::Tracer TR("protocol.abinitio.WobbleMover");
40 
41 namespace protocols {
42 namespace simple_moves {
43 
44 static numeric::random::RandomGenerator RG(490); // <- Magic number, do not change it!
45 
46 using namespace core;
47 using namespace fragment;
48 
53 :
54  protocols::simple_moves::ClassicFragmentMover( fragset, movemap, "WobbleMover" ), // explicit initialization of virtual base class required
55  protocols::simple_moves::SmoothFragmentMover( fragset, movemap, cost, "WobbleMover")
56 {
57  set_defaults();
58 }
59 
63 ) :
64  protocols::simple_moves::ClassicFragmentMover( fragset, movemap, "WobbleMover" ), // explicit initialization of virtual base class required
65  protocols::simple_moves::SmoothFragmentMover( fragset, movemap, new protocols::simple_moves::GunnCost, "WobbleMover")
66 {
67  set_defaults();
68 }
69 
70 /// Copy constructor disabled until the virtual base class
71 /// ClassicFragmentMover's construction is sorted out
72 /*WobbleMover::WobbleMover( WobbleMover const & src ) :
73  Parent( src ),
74  buffer_length_( src.buffer_length_ ),
75  forward_threshold_( src.forward_threshold_ ),
76  backward_threshold_( src.backward_threshold_ )
77 {}*/
78 
80 {}
81 
84  return "WobbleMover";
85 }
86 
88  pose::Pose & pose,
89  protocols::loops::Loops const & loops,
90  kinematics::MoveMap const& mm ) const
91 {
92  // param for ccd_closure
93  int const ccd_cycles = { 100 }; // num of cycles of ccd_moves
94  Real const ccd_tol = { 0.01 }; // criterion for a closed loop
95  bool const rama_check = { true };
96  Real const max_rama_score_increase = { 2.0 }; // dummy number when rama_check is false
97  Real const max_total_delta_helix = { 10.0 }; // max overall angle changes for a helical residue
98  Real const max_total_delta_strand = { 50.0 }; // ... for a residue in strand
99  Real const max_total_delta_loop = { 75.0 }; // ... for a residue in loop
100 
101  // output for ccd_closure
102  Real forward_deviation, backward_deviation; // actually loop closure msd, both dirs
103  Real torsion_delta, rama_delta; // actually torsion and rama score changes, averaged by loop_size
104 
105  //there is only one loop
107  int const loop_begin = it->start();
108  int const loop_end = it->stop();
109  int const cutpoint = it->cut();
110 
111  // ccd close this loop
112  protocols::loops::loop_closure::ccd::fast_ccd_loop_closure( pose, mm, loop_begin, loop_end, cutpoint, ccd_cycles,
113  ccd_tol, rama_check, max_rama_score_increase, max_total_delta_helix,
114  max_total_delta_strand, max_total_delta_loop, forward_deviation,
115  backward_deviation, torsion_delta, rama_delta );
116 
117  return ( backward_deviation < backward_threshold_) && ( forward_deviation < forward_threshold_ );
118 }
119 
120 /// @brief make a wobble move ( smooth move + ccd loop closure )
121 /// @detail NEEDS MORE WORK IF MULTIPLE CHAINS OR JUMPS ARE USED: total_residue!=end of chain
123  Frame const& frame,
124  Size frag_num,
125  kinematics::MoveMap const& movemap,
126  pose::Pose &pose ) const
127 {
128 
129  // define a loop with cut-point, such that fragment is on one side until cut-point and otherside has buffer_ residues.
130  protocols::loops::Loops frag_loop;
131 
132 
133  // if fragment is exactly at start or end of pose it is just inserted without ccd
134  bool use_ccd ( ! ( frame.start() == 1 || frame.end() >= pose.total_residue()-1 ) );
135  kinematics::FoldTree original_tree;
136  TR.Debug << " start : " << frame.start() <<" buffer " << frame.start()-buffer_length_ << " end: " << frame.end() << " total res: " << pose.total_residue() << std::endl;
137  if ( use_ccd ) {
138  // prepare foldtree for ccd
139 
140  bool cut_Cterm; // controls whether cutpoint is at C-terminal side of fragment
141  if ( frame.end() + buffer_length_ >= pose.total_residue() ) { //close to end of pose: cut at Nterm
142  cut_Cterm = false;
143  } else if ( frame.start() <= buffer_length_ ) { //close to start of pose: cut at Cterm
144  cut_Cterm = true;
145  } else { //otherwise random direction
146  cut_Cterm = RG.uniform() >= 0.5 ;
147  };
148 
149  if ( cut_Cterm ) {
150  frag_loop.add_loop( frame.start()-1, frame.end()+buffer_length_, frame.end() );
151  } else {
152  frag_loop.add_loop( frame.start()-buffer_length_, frame.end()+1, frame.start()-1 );
153  };
154 
155  TR.Debug << "loop definitio for wobble move" << std::endl << frag_loop << std::endl;
156 
157  //set fold-tree ( keep original for later )
158  original_tree = pose.fold_tree();
159  TR.Debug << "original " << original_tree << std::endl;
160  kinematics::FoldTree fold_tree;
161  protocols::loops::fold_tree_from_loops( pose, frag_loop, fold_tree );
162  TR.Debug << "for loops " << fold_tree << std::endl;
163  pose.fold_tree( fold_tree );
164 
165  } // ccd preparation
166 
167  //apply fragment
168  bool success = frame.apply( movemap, frag_num, pose );
169  // pose.dump_pdb( "pre_ccd.pdb" );
170 
171  //close loop with ccd
172  if ( success && use_ccd ) {
173  pose::Pose orig_pose = pose;
174  success = ccd_closure( pose, frag_loop, movemap );
175  if ( !success ) pose = orig_pose;
176  };
177 
178  //clean up
179  if ( use_ccd ) pose.fold_tree( original_tree );
180 
181  return success;
182 }
183 
184 } //abinitio
185 } //protocols