Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ModelCDRH3.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/ModelCDRH3.cc
12 /// @brief models CDR H3 loop using loop modeling
13 /// @detailed
14 ///// @author Jianqing Xu ( xubest@gmail.com )
15 //
16 
17 
21 #include <core/pose/util.hh>
25 #include <basic/Tracer.hh>
26 #include <basic/options/option.hh>
27 #include <basic/options/keys/in.OptionKeys.gen.hh>
29 #include <protocols/loops/Loop.hh>
30 #include <protocols/loops/Loops.hh>
36 #include <utility/exit.hh>
41 #include <core/pose/PDBInfo.hh>
42 
43 
44 
45 static basic::Tracer TR("protocols.antibody2.ModelCDRH3");
46 
47 using namespace core;
48 
49 namespace protocols {
50 namespace antibody2 {
51 
52 ModelCDRH3::ModelCDRH3() : Mover(){}
53 
54 
56 
57 ModelCDRH3::ModelCDRH3( AntibodyInfoOP antibody_info) : Mover(){
58  user_defined_ = false;
59  ab_info_ = antibody_info;
60 
61  init();
62 }
63 
64 
65 
67  core::scoring::ScoreFunctionCOP lowres_scorefxn) : Mover()
68 {
69  user_defined_ = true;
70  ab_info_ = antibody_info;
71  lowres_scorefxn_ = new core::scoring::ScoreFunction(*lowres_scorefxn);
72 
73  init();
74 }
75 
76 
77 
78 
80 {
81  Mover::type( "ModelCDRH3" );
82 
83  set_default();
84 
85  //TODO:
86  //JQX: need to deal with this
87  if( is_camelid_ && ab_info_->get_Predicted_H3BaseType()!=Kinked && ab_info_->get_Predicted_H3BaseType()!=Extended ){
88  c_ter_stem_ = 0;
89  }
90 
93 }
94 
95 
97 {
98  benchmark_ = false;
99  is_camelid_ = false;
100  do_cter_insert_ = true;
101  loops_flag_ = true;
102  dle_flag_ = true;
103  bad_nter_ = true;
104 
105  remodel_ = "legacy_perturb_ccd";
106 
107  c_ter_stem_ = 3;
108  max_cycle_ = 20;
109 
110  cen_cst_ = 10.0;
111 
112 
113  if(!user_defined_)
114  {
116  lowres_scorefxn_->set_weight( scoring::chainbreak, 10./3. );
118  }
119 }
120 
121 
122 
124  lowres_scorefxn_ = new core::scoring::ScoreFunction(*lowres_scorefxn);
125 }
126 
127 
129  tf_ = new pack::task::TaskFactory(*tf);
130 }
131 
132 
133 
135  h3_perturb_ccd_build_->turn_off_H3_filter();
136 }
137 
138 
139 
140 void ModelCDRH3::apply( pose::Pose & pose_in )
141 {
142 
143 
144  TR << "Applying CDR H3 modeler" << std::endl;
145 
146  using namespace core::pose;
147  using namespace core::scoring;
148  using namespace protocols::moves;
149 
150 
151  pose::Pose start_pose = pose_in;
152 
153 
154  /// FIXME: JQX: very redudent here, just get one loops object
155  Size framework_loop_begin( ab_info_->get_CDR_loop(h3).start() );
156  Size framework_loop_end ( ab_info_->get_CDR_loop(h3).stop() );
157  Size cutpoint = ab_info_->get_CDR_loop(h3).cut() ; // keep the cutpoint unchanged
158  Size framework_loop_size = (framework_loop_end - framework_loop_begin) + 1;
159 
160  loops::Loop cdr_h3( framework_loop_begin, framework_loop_end, cutpoint, 0, true );
161  loops::Loop trimmed_cdr_h3(framework_loop_begin, framework_loop_end - c_ter_stem_, cutpoint, 0, true );
162  loops::Loop input_loop;
163 
164  if( framework_loop_size <= 6 ) {
165  do_cter_insert_ = false;
166  TR<<"loop_size <= 6, AUTOMATICALLY TURNING OFF THE C_TERMINAL INSERT"<<std::endl;
167  }
168 
169  if (do_cter_insert_){
170  //JQX: the h3 loop removing the cterminal 3 residues
171  input_loop = trimmed_cdr_h3;
172  }
173  else{
174  //JQX: the original h3 loop
175  input_loop = cdr_h3;
176  }
177 
178  simple_one_loop_fold_tree( pose_in, cdr_h3 );
179 // TR<<"*******************************************"<<std::endl;
180 // TR<<pose_in.fold_tree()<<std::endl;
181 // TR<<"*******************************************"<<std::endl;
182  // switching to centroid mode
185 
186 
187 
188  // Building centroid mode loop
189  to_centroid.apply( pose_in );
190 
191  if(remodel_=="legacy_perturb_ccd"){
192  // some initialization before you do h3 loop modeling
193 // my_LoopMover xxx ;
194 // xxx.set_extended_torsions( pose_in, cdr_h3 );
195  set_extended_torsions( pose_in, cdr_h3 );
196  //pose_in.dump_pdb("extended_idealized_centroid.pdb");
197  //JQX: this function is in loops_main.cc file
198  // firstly, idealize the loop (indealize bonds as well)
199  // phi(-150), all the residue, except the first one
200  // psi(150), all the residue, except the last one
201  // omega(180), all the residue, except the first & last one
202  //JQX: in R2: the function is called "insert_init_frag", which is
203  // in the file "jumping_util.cc". All the phi, psi, omega are
204  // assigned to all the residues. "L" secondary structure is
205  // also assinged. The bonds are idealized using
206  // framework_pose.insert_ideal_bonds(begin-1, end)
207 
208 
209  h3_perturb_ccd_build_->pass_the_loop(input_loop);
210 
211  }
212  else{
213  /// FIXME: JQX very redudent loops defitions
214  // use H3 to define a loops object
215  loops::LoopsOP pass_loops = new loops::Loops();
216  pass_loops->add_loop( input_loop );
217  pass_loops->set_extended(true); // the IndepdentLoopMover will extend the loop
218 
219  // create a LoopMover type based on the string remode_
222  if ( !remodel_mover_ ) { utility_exit_with_message( "Error: no remodel mover defined!" );}
223 
224  // deal with the fragment files if the remodel_ type is not KIC
225  if ( remodel_ != "perturb_kic" ){
227  loops::read_loop_fragments( frag_libs );
228  runtime_assert( frag_libs.size() > 0 );
229  for ( Size i = 1; i <= frag_libs.size(); ++i ) {
230  remodel_mover_->add_fragments( frag_libs[i]) ;
231  }
232  }
233 
234  // if you have native structure to compare, do this
235  if (get_native_pose()) remodel_mover_->set_native_pose(get_native_pose()) ;
236 
237  // scoring function, their default scoring function is the same as specified here, but put it anyway
238  remodel_mover_->set_scorefxn( lowres_scorefxn_ );
239 
240  }
241 
242 
243  /* JQX: the following code is probably not ncessary*/
244  if(bad_nter_){
245  Size unaligned_cdr_loop_begin(0), unaligned_cdr_loop_end(0);
246  std::string const path = basic::options::option[ basic::options::OptionKeys::in::path::path ]()[1];
247  core::import_pose::pose_from_pdb( hfr_pose_, path+"hfr.pdb" );
248  unaligned_cdr_loop_begin = hfr_pose_.pdb_info()->pdb2pose('H', 95) ;
249  unaligned_cdr_loop_end = hfr_pose_.pdb_info()->pdb2pose('H', 103);
250  unaligned_cdr_loop_end -= 1 ;
251 
252  if(framework_loop_size > 4){ //JQX: add this if statement to match R2_antibody
253  pose_in.set_psi (framework_loop_begin - 1, hfr_pose_.psi( unaligned_cdr_loop_begin - 1 ) );
254  pose_in.set_omega(framework_loop_begin - 1, hfr_pose_.omega( unaligned_cdr_loop_begin - 1 ) );
255  }
256  //pose_in.dump_pdb("after_copying_nter.pdb");
257  }
258 
259  antibody2::AntibodyInfoOP starting_antibody;
260  starting_antibody = new AntibodyInfo(*ab_info_);
261  bool closed_cutpoints( false );
262 
263 
264  Size cycle ( 1 );
265  while( !closed_cutpoints && cycle < max_cycle_) {
266  ab_info_ = starting_antibody;
267  if (do_cter_insert_){
268  h3_cter_insert_mover_->apply(pose_in);
269  }
270  //pose_in.dump_pdb("after_c_insert.pdb");
271 
272  if(remodel_=="legacy_perturb_ccd"){
273  h3_perturb_ccd_build_->apply(pose_in);
274  }
275  else{
276  remodel_mover_->apply(pose_in);
277  }
278 
279 
280  closed_cutpoints = cutpoints_separation( pose_in, ab_info_ );
281  ++cycle;
282  } // while( ( cut_separation > 1.9 )
283 
284  TR << "Finished Modeling Centroid CDR H3 loop" << std::endl;
285 
286 
287 
288 
289  //############################# //JQX: this should not be here
290  if( is_camelid_ ){
291  //RefineCDRH1Centroid refine_cdr_centroid( ab_info_->get_CDR_loop(h1) );
292  //refine_cdr_centroid.apply(pose_in);
293  }
294  //#############################
295 
296 
297 
298 
299  to_full_atom.apply( pose_in );
300 
301  utility::vector1<bool> allow_chi_copy( pose_in.total_residue(), true );
302  /// FIXME: JQX very redudent loops defition
303  for( Size ii=ab_info_->get_CDR_loop(h3).start(); ii<=ab_info_->get_CDR_loop(h3).stop(); ii++ ){
304  allow_chi_copy[ii] = false;
305  }
306  //recover sidechains from starting structures except H3
307  protocols::simple_moves::ReturnSidechainMover recover_sidechains( start_pose, allow_chi_copy );
308  recover_sidechains.apply( pose_in );
309 
310  TR << "Finished applying CDR H3 modeler" << std::endl;
311 
312 
313  return;
314 } // ModelCDRH3::apply()
315 
316 
317 
318 
320  return "ModelCDRH3";
321 }
322 
323 
324 //basic::Tracer & my_LoopMover::tr() const{
325 // return TR;
326 //}
327 
328 
329 
330 
331 
332 
333 } // namespace antibody2
334 } // namespace protocols
335 
336 
337