Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GraftCDRLoopsProtocol.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/GraftCDRLoopsProtocol.cc
12 /// @brief Build a homology model of an antibody2
13 /// @detailed
14 ///
15 ///
16 /// @author Jianqing Xu ( xubest@gmail.com )
17 
18 
19 #include <core/io/pdb/pose_io.hh>
20 #include <core/pose/util.hh>
21 #include <core/pose/PDBInfo.hh>
23 #include <core/scoring/Energies.hh>
27 
28 #include <basic/prof.hh>
29 #include <basic/Tracer.hh>
30 #include <basic/options/option.hh>
31 #include <basic/options/keys/antibody.OptionKeys.gen.hh>
32 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
33 #include <basic/options/keys/in.OptionKeys.gen.hh>
34 #include <basic/options/keys/out.OptionKeys.gen.hh>
35 #include <basic/options/keys/run.OptionKeys.gen.hh>
36 
38 #include <protocols/jd2/Job.hh>
41 
45 
53 
54 #include <ObjexxFCL/format.hh>
55 #include <ObjexxFCL/string.functions.hh>
56 using namespace ObjexxFCL::fmt;
57 
58 
59 
60 using basic::T;
61 using basic::Error;
62 using basic::Warning;
63 
64 static basic::Tracer TR("protocols.antibody2.GraftCDRLoopsProtocol");
65 using namespace core;
66 
67 namespace protocols {
68 namespace antibody2 {
69 
70 // default constructor
71 GraftCDRLoopsProtocol::GraftCDRLoopsProtocol() : Mover() {
72  init();
73 }
74 
75 // default destructor
77 
78 //clone
80  return( new GraftCDRLoopsProtocol() );
81 }
82 
83 
84 
86  Mover::type( "GraftCDRLoopsProtocol" );
87 
88  set_default();
91  setup_objects();
92 
93 }
94 
95 
96 
98 {
99  TR << "Setting up default settings to all FALSE" << std::endl;
100  graft_l1_ = false;
101  graft_l2_ = false;
102  graft_l3_ = false;
103  graft_h1_ = false;
104  graft_h2_ = false;
105  graft_h3_ = false;
106  h3_no_stem_graft_=false;
107  packonly_after_graft_=false;
108  benchmark_ = false;
109  camelid_ = false;
110  camelid_constraints_ = false;
111  sc_min_ = false;
112  rt_min_ = false;
113  cst_weight_ = 0.0;
114 
115 }
116 
117 
118 
120 {
121  using namespace basic::options;
122 
123  option.add_relevant( OptionKeys::antibody::camelid );
124  option.add_relevant( OptionKeys::antibody::camelid_constraints );
125  option.add_relevant( OptionKeys::antibody::graft_l1 );
126  option.add_relevant( OptionKeys::antibody::graft_l2 );
127  option.add_relevant( OptionKeys::antibody::graft_l3 );
128  option.add_relevant( OptionKeys::antibody::graft_h1 );
129  option.add_relevant( OptionKeys::antibody::graft_h2 );
130  option.add_relevant( OptionKeys::antibody::graft_h3 );
131  option.add_relevant( OptionKeys::antibody::h3_no_stem_graft );
132  option.add_relevant( OptionKeys::constraints::cst_weight );
133  option.add_relevant( OptionKeys::run::benchmark );
134  option.add_relevant( OptionKeys::in::file::native );
135  //option.add_relevant( OptionKeys::antibody::sc_min);
136  //option.add_relevant( OptionKeys::antibody::rt_min);
137 }
138 
139 
140 
141 
142 
144  using namespace basic::options;
145  using namespace basic::options::OptionKeys;
146  TR << "Reading Options" << std::endl;
147 
148  if ( option[ OptionKeys::antibody::graft_l1 ].user() )
149  set_graft_l1( option[ OptionKeys::antibody::graft_l1 ]() );
150  if ( option[ OptionKeys::antibody::graft_l2 ].user() )
151  set_graft_l2( option[ OptionKeys::antibody::graft_l2 ]() );
152  if ( option[ OptionKeys::antibody::graft_l3 ].user() )
153  set_graft_l3( option[ OptionKeys::antibody::graft_l3 ]() );
154  if ( option[ OptionKeys::antibody::graft_h1 ].user() )
155  set_graft_h1( option[ OptionKeys::antibody::graft_h1 ]() );
156  if ( option[ OptionKeys::antibody::graft_h2 ].user() )
157  set_graft_h2( option[ OptionKeys::antibody::graft_h2 ]() );
158  if ( option[ OptionKeys::antibody::graft_h3 ].user() )
159  set_graft_h3( option[ OptionKeys::antibody::graft_h3 ]() );
160  if ( option[ OptionKeys::antibody::h3_no_stem_graft ].user() )
161  set_h3_stem_graft( option[ OptionKeys::antibody::h3_no_stem_graft ]() );
162  if ( option[ OptionKeys::antibody::packonly_after_graft ].user() )
163  set_packonly_after_graft( option[ OptionKeys::antibody::packonly_after_graft ]() );
164  if ( option[ OptionKeys::antibody::camelid ].user() )
165  set_camelid( option[ OptionKeys::antibody::camelid ]() );
166  if ( option[ OptionKeys::antibody::camelid_constraints ].user() )
167  set_camelid_constraints( option[ OptionKeys::antibody::camelid_constraints ]() );
168  if ( option[ OptionKeys::run::benchmark ].user() )
169  set_benchmark( option[ OptionKeys::run::benchmark ]() );
170  if ( option[ OptionKeys::constraints::cst_weight ].user() )
171  set_cst_weight( option[ OptionKeys::constraints::cst_weight ]() );
172  //if ( option[ OptionKeys::antibody::sc_min_ ].user() ) {
173  // set_sc_min( option[ OptionKeys::antibody::sc_min_ ]() );
174  //}
175  //if ( option[ OptionKeys::antibody::rt_min_ ].user() ) {
176  // set_rt_min( option[ OptionKeys::antibody::rt_min_ ]() );
177  //}
178 
179 
180  //set native pose if asked for
181  if ( option[ OptionKeys::in::file::native ].user() ) {
182  core::pose::PoseOP native_pose = new core::pose::Pose();
183  core::import_pose::pose_from_pdb( *native_pose, option[ OptionKeys::in::file::native ]() );
184  set_native_pose( native_pose );
185  }
186  else{
187  set_native_pose(NULL);
188  }
189 
190 
191 
192  if( camelid_ ) {
193  graft_l1_ = false;
194  graft_l2_ = false;
195  graft_l3_ = false;
196  }
197 
198 }
199 
200 
201 
202 
204 
205  ab_info_ = NULL;
206  ab_t_info_ = NULL;
207 
208  graft_sequence_ = NULL;
209 
210  tf_ = NULL;
211 
213 
214  scorefxn_pack_->set_weight( core::scoring::chainbreak, 1.0 );
215  scorefxn_pack_->set_weight( core::scoring::overlap_chainbreak, 10./3. );
217 
218 }
219 
220 
221 
222 
224  TR<<"AAAAAAAA cst_weight: "<<cst_weight_<<std::endl;
225 
226  // check for native and input pose
227  if ( !get_input_pose() ) {
228  pose::PoseOP input_pose = new pose::Pose(frame_pose); //JQX: QUESTION: why owning pointer here
229  set_input_pose( input_pose ); // JQX: pass the input_pose to the mover.input_pose_
230  }
231 
232 
233  pose::PoseOP native_pose;
234  if ( !get_native_pose() ) {
235  TR << "Danger Will Robinson! Native is an impostor!" << std::endl;
236  TR << " 'native_pose' is just a copy of the 'input_pose' " << std::endl;
237  TR << " since you didn't sepcifiy the native pdb name"<<std::endl;
238  native_pose = new pose::Pose(frame_pose);
239  } else {
240  native_pose = new pose::Pose( *get_native_pose() );
241  }
242 
243  // JQX: this is the secondary structure from the native pose
244  pose::set_ss_from_phipsi( *native_pose );
245 
246  set_native_pose( native_pose ); // pass the native pose to the mover.native_pose_
247 
248 
249  ab_info_ = new AntibodyInfo(frame_pose);
252 
254 
255 
256  TR<<" Checking AntibodyInfo object: "<<std::endl<<*ab_info_<<std::endl<<std::endl;
257  TR<<" Checking Ab_TemplateInfo object: "<<std::endl<<*ab_t_info_<<std::endl<<std::endl;
258 
259  for (AntibodyCDRNameEnum it = start_cdr_loop; it <= ab_info_->get_TotalNumCDRs(); it=AntibodyCDRNameEnum(it+1) ){
260  TR << "Creating movers for " << ab_info_->get_CDR_Name(it) << std::endl;
261  TR << " start (chothia): "<<ab_info_->get_CDR_loop(it).start()<<std::endl;
262  TR << " stop (chothia): "<<ab_info_->get_CDR_loop(it).stop()<<std::endl;
263 
264  GraftOneCDRLoopOP graft_one_cdr = new GraftOneCDRLoop( it, ab_info_, ab_t_info_) ;
265  if(it == h3 && h3_no_stem_graft_){ graft_one_cdr->h3_stem_off(true); }
266  graft_one_cdr->enable_benchmark_mode( benchmark_ );
267  graft_sequence_->add_mover( graft_one_cdr);
268 
269 
270  /*
271  CloseOneCDRLoopOP closeone( new CloseOneCDRLoop( ab_info.get_loop(it->first)->start(),
272  ab_info.get_loop(it->first)->stop() ) );
273  closeone->enable_benchmark_mode( benchmark_ );
274  graft_sequence_->add_mover( closeone );
275  */
276  }
277 
278  // Exact match Aroop's old code in Rosetta 2:
279  // graft all CDRs by superimpose stems, then pack the whole new pose
280 
281  // When do packing, pack the whole pose, but minimize the CDRs
282  tf_ = setup_packer_task(frame_pose);
283 
284  CDRsMinPackMinOP cdrs_min_pack_min = new CDRsMinPackMin(ab_info_);
285  cdrs_min_pack_min -> set_task_factory(tf_);
286  // the tf_ include all the residues, the movemap is to use the deafult one in CDRsMinPackMin, which is the CDRs
287  cdrs_min_pack_min->set_sc_min(sc_min_);
288  cdrs_min_pack_min->set_sc_min(rt_min_);
289  cdrs_min_pack_min -> set_turnoff_minimization(packonly_after_graft_);
290 
291  graft_sequence_->add_mover(cdrs_min_pack_min);
292 
293 }
294 
295 
296 
297 
298 
299 //APPLY
301 
302  using namespace chemical;
303  using namespace id;
304  using namespace scoring;
305  using namespace core::scoring::constraints;
306  using namespace protocols::moves;
307 
308 
309  TR<<" in the apply function "<<std::endl;
310 
311 
312  finalize_setup(frame_pose);
313 
314 
315  basic::prof_reset();
317  // utility::exit( EXIT_FAILURE, __FILE__, __LINE__);
318 
319  pose::set_ss_from_phipsi( frame_pose );
320 
321  // display constraints and return
322  if( camelid_constraints_ ) {
323  display_constraint_residues( frame_pose );
324  return;
325  }
326 
327 
328  Size nres = frame_pose.total_residue();
329 
330  // Storing secondary structure
331  utility::vector1<char> secondary_struct_storage;
332  for( Size i = 1; i <= nres; i++ ) {
333  secondary_struct_storage.push_back( frame_pose.secstruct( i ) );
334  // TR<<"JQX: residue: "<<i<<" secstruct: "<<frame_pose.secstruct(i)<<std::endl;
335  }
336 
337  graft_sequence_->apply( frame_pose );
338 
339  // Recover secondary structures
340  for( Size i = 1; i <= nres; i++ ) frame_pose.set_secstruct( i, secondary_struct_storage[ i ] );
341 
342  // align pose to native pose
343  pose::Pose native_pose;
344  if( get_native_pose() ) native_pose = *get_native_pose();
345  else native_pose = frame_pose;
346 
347  AntibodyInfoOP native_ab_info = new AntibodyInfo( native_pose );
348 
349 
350  align_to_native( frame_pose, native_pose, ab_info_, native_ab_info );
351 
352 
353  basic::prof_show();
354 
355 
356 }// end apply
357 
358 
359 
360 
361 
363  return "GraftCDRLoopsProtocol";
364 }
365 
366 
367 
368 
370  // Detecting di-sulfide bond
371 
372  Size H1_Cys(0), H3_Cys(0);
373 
374  if( pose.residue( pose.pdb_info()->pdb2pose('H',32 ) ).name3() == "CYS" )
375  H1_Cys = pose.pdb_info()->pdb2pose( 'H', 32 );
376  else if( pose.residue( pose.pdb_info()->pdb2pose('H',33 ) ).name3() == "CYS" )
377  H1_Cys = pose.pdb_info()->pdb2pose( 'H', 33 );
378 
379  for( Size ii = ab_info_->get_CDR_loop(h3).start(); ii <= ab_info_->get_CDR_loop(h3).stop(); ii++ )
380 
381  if( pose.residue(ii).name3() == "CYS" ) H3_Cys = ii;
382 
383  if( ( H1_Cys != 0 ) && ( H3_Cys != 0 ) )
384  TR << "CONSTRAINTS: "<< "AtomPair CA " << H1_Cys << " CA " << H3_Cys
385  << " BOUNDED 4.0 6.1 0.6 BOND; mean 5.6 sd 0.6" << std::endl;
386 
387  // Specifying extended kink
388 
389  Size hfr_46(0), h3_closest(0);
390  hfr_46 = pose.pdb_info()->pdb2pose( 'H', 46 );
391  if( ab_info_->get_Predicted_H3BaseType() == Extended ) h3_closest = ab_info_->get_CDR_loop(h3).stop() - 5;
392  if( h3_closest != 0 )
393  TR << "CONSTRAINTS: " << "AtomPair CA " << hfr_46 << " CA " << h3_closest
394  << " BOUNDED 6.5 9.1 0.7 DISTANCE; mean 8.0 sd 0.7" << std::endl;
395 
396  return;
397 } // display_constraint_residues
398 
399 
400 
401 
402 
403 
404 /// @details Show the complete setup of the docking protocol
405 void GraftCDRLoopsProtocol::show( std::ostream & out ) {
406  out << *this;
407 }
408 
409 std::ostream & operator<<(std::ostream& out, const GraftCDRLoopsProtocol & ab_m_2 )
410 {
411  using namespace ObjexxFCL::fmt;
412 
413  // All output will be 80 characters - 80 is a nice number, don't you think?
414  std::string line_marker = "///";
415  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
416  out << line_marker << A( 47, "Rosetta 3 Antibody Modeler" ) << space( 27 ) << line_marker << std::endl;
417  out << line_marker << A( 47, " CDR Assembling " ) << space( 27 ) << line_marker << std::endl;
418  out << line_marker << space( 74 ) << line_marker << std::endl;
419  out << line_marker << " Graft_l1: " << ab_m_2.graft_l1_<<std::endl;
420  out << line_marker << " Graft_l2: " << ab_m_2.graft_l2_<<std::endl;
421  out << line_marker << " Graft_l3: " << ab_m_2.graft_l3_<<std::endl;
422  out << line_marker << " Graft_h1: " << ab_m_2.graft_h1_<<std::endl;
423  out << line_marker << " Graft_h2: " << ab_m_2.graft_h2_<<std::endl;
424  out << line_marker << " Graft_h3: " << ab_m_2.graft_h3_<<std::endl;
425  out << line_marker << " camelid: " << ab_m_2.camelid_ <<std::endl;
426  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
427  return out;
428 }
429 
430 
431 
432 
433 
434 } // end antibody2
435 } // end protocols