Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RefineOneCDRLoop.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
6 // (c) under license. The Rosetta software is developed by the contributing
7 // (c) members of the Rosetta Commons. For more information, see
8 // (c) http://www.rosettacommons.org. Questions about this can be addressed to
9 // (c) University of Washington UW TechTransfer, email:license@u.washington.edu
10 
11 /// @file protocols/antibody2/RefineOneCDRLoop.cc
12 /// @brief Build a homology model of an antibody2
13 /// @detailed
14 ///
15 ///
16 /// @author Jianqing Xu (xubest@gmail.com)
17 
18 
19 
22 #include <basic/Tracer.hh>
27 #include <core/scoring/Energies.hh>
29 #include <protocols/loops/Loop.hh>
30 #include <protocols/loops/Loops.hh>
32 #include <core/pose/Pose.hh>
38 
39 
41 //JQX:: this header file took care of the "CUTPOINT_LOWER" options below
42 
43 
44 
45 
46 
47 using basic::T;
48 using basic::Error;
49 using basic::Warning;
50 
51 static basic::Tracer TR("protocols.antibody2.RefineOneCDRLoop");
52 
53 
54 
55 
56 using namespace core;
57 namespace protocols {
58 namespace antibody2 {
59 
60 
61 
62 
63 // default constructor
64 RefineOneCDRLoop::RefineOneCDRLoop( ) : Mover() {}
65 
67  user_defined_ = false;
68  ab_info_ = antibody_info;
69  init();
70 }
71 
72 
73 RefineOneCDRLoop::RefineOneCDRLoop( AntibodyInfoOP antibody_info, std::string refine_mode ) : Mover() {
74  user_defined_ = false;
75  ab_info_ = antibody_info;
76  refine_mode_ = refine_mode;
77  init();
78 }
79 
80 
82  std::string refine_mode,
84  ) : Mover() {
85  user_defined_ = true;
87  ab_info_ = antibody_info;
88  refine_mode_ = refine_mode;
89  scorefxn_ = new scoring::ScoreFunction(*scorefxn);
90 
91  init();
92 }
93 
94 
96  AntibodyCDRNameEnum const & cdr_loop_name,
97  std::string refine_mode,
99  ) : Mover() {
100  user_defined_ = true;
101  ab_info_ = antibody_info;
102  cdr_loop_name_ = cdr_loop_name;
103  refine_mode_ = refine_mode;
104  scorefxn_ = new scoring::ScoreFunction(*scorefxn);
105 
106  init();
107 }
108 
109 
110 
112  set_default();
113 }
114 
115 
116 
117 
118 
120 {
121  cdr_loop_name_ = h3;
122  flank_size_ = 2;
123  H3_filter_ = true;
124  flank_relax_ = true;
125  high_cst_ = 100.0;
126  num_filter_tries_ = 20;
127 
128  if(!user_defined_){
129  refine_mode_ = "legacy_refine_ccd";
130  cdr_loop_name_ = h3;
132  scorefxn_->set_weight( scoring::chainbreak, 1.0 );
133  scorefxn_->set_weight( scoring::overlap_chainbreak, 10./3. );
135  }
136 }
137 
138 
139 
140 // default destructor
142 
143 //clone
145  return( new RefineOneCDRLoop() );
146 }
147 
148 
149 
151  return "RefineOneCDRLoop";
152 }
153 
155  scorefxn_ = new core::scoring::ScoreFunction(*scorefxn);
156 }
157 
158 
160  start_pose_ = start_pose;
161 }
162 
163 
164 
165 
166 
168 
169  //JQX: make sure the pose and the scoring function is on the same resolution
170  if ( pose.is_fullatom() != scorefxn_->has_nonzero_weight( core::scoring::fa_rep )){
171  utility_exit_with_message("the resultions of the 'pose' and the 'scoring function' don't match!");
172  }
173 
174  if(refine_mode_ == "legacy_centroid_refine_ccd"){
176  legacy_centroid_refine_ccd -> apply(pose);
177  } //the legacy centroid_refine_ccd method
178 
179  else if( refine_mode_ == "legacy_refine_ccd" ){
180  H3RefineCCDOP legacy_refine_ccd = new H3RefineCCD(ab_info_, cdr_loop_name_, scorefxn_);
181  legacy_refine_ccd -> pass_start_pose(start_pose_);
182  if (!flank_relax_) { legacy_refine_ccd->turn_off_flank_relax();}
183  legacy_refine_ccd -> apply(pose);
184  } // the legacy refine_ccd method
185 
186  else{
187  /// FIXME: JQX this should be fixed by a simple loops object
188  loops::Loop one_cdr_loop = ab_info_->get_CDR_loop(cdr_loop_name_);
189 
190  if(flank_relax_){
191  // JQX: The idea is to minimize the flanking residues backbones on each stems,
192  // but only minimization, no perturbation (small, shear, etc ..) to them.
193  // The fold_tree should be set correctly for the MinMover (or AtomTreeMinimizer).
194  // Will this special fold_tree affect perturbation? I don't think so. It doesn't really matter
195  // 2 or 3 residues before loop_begin or after loop_end, as long as the cut point is in
196  // the middle and the loop is within two jumps points.
197  simple_fold_tree( pose, one_cdr_loop.start()- 1 - flank_size_, one_cdr_loop.cut(), one_cdr_loop.stop() + 1 + flank_size_ );
198  }
199  else{
200  simple_fold_tree( pose, one_cdr_loop.start()- 1, one_cdr_loop.cut(), one_cdr_loop.stop() + 1 );
201  }
202  //JQX: be careful, no fold_tree operations are conducted in the two movers below.
203 
204  loops::LoopsOP pass_loops = new loops::Loops();
205  pass_loops->add_loop( one_cdr_loop );
206 
207 
208  core::Size itry=1;
209  core::Real best_score=0.0;
210  core::pose::Pose best_pose;
211  std::stringstream Num; std::string str_num;
212  core::pose::Pose pose_before_refine = pose; //JQX: save the current pose before doing any refinement
213 
214  if(refine_mode_ == "refine_ccd"){
216  if(get_native_pose()) { refine_ccd.set_native_pose( get_native_pose() ); }
217  if(flank_relax_) { refine_ccd.set_flank_residue_min(flank_relax_); }
218  while (itry<=num_filter_tries_){
219  TR<<" Trying Refinement ................. "<<itry<<std::endl;
220  pose = pose_before_refine;
221  refine_ccd.apply( pose );
222 
223  Num<<itry; Num>>str_num; Num.str(""); Num.clear();
224 
225  if(H3_filter_){
226  if( CDR_H3_cter_filter(pose, ab_info_) ) { break;}
227  else{
228  if( pose.energies().total_energy() <= best_score ){
229  best_score = pose.energies().total_energy();
230  best_pose = pose;
231  }
232  }
233 
234  }
235  else {break;}
236  if(itry==num_filter_tries_) { pose=best_pose; }
237 
238  itry++;
239  }
240  }
241 
242  else if(refine_mode_ == "refine_kic"){
243  //loops.remove_terminal_loops( pose );
245  if(get_native_pose()) { refine_kic.set_native_pose( get_native_pose() ); }
246  if(flank_relax_) { refine_kic.set_flank_residue_min(flank_relax_); }
247  while (itry<=num_filter_tries_ ){
248  TR<<" Trying Refinement ................. "<<itry<<std::endl;
249  pose = pose_before_refine;
250  refine_kic.apply( pose );
251  Num<<itry; Num>>str_num; Num.str(""); Num.clear();
252 
253  if(H3_filter_){
254  if( CDR_H3_cter_filter(pose, ab_info_) ) { break;}
255  else{
256  if( pose.energies().total_energy() <= best_score ){
257  best_score = pose.energies().total_energy();
258  best_pose = pose;
259  }
260  }
261  }
262  else {break;}
263  if(itry==num_filter_tries_) { pose=best_pose; }
264 
265  itry++;
266  }
267  }
268 
269  else{
270  utility_exit_with_message("the refinement method is not available!");
271  }
272 
273  }// refine_CCD or refine_KIC
274 
275 
276 }//apply
277 
278 
279 
280 
281 
282 
283 
284 } // namespace antibody2
285 } // namespace protocols
286 
287