Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AntibodyModelerProtocol.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/AntibodyModelerProtocol.cc
12 /// @brief Build a homology model of an antibody2
13 /// @detailed
14 ///
15 ///
16 /// @author Jianqing Xu ( xubest@gmail.com )
17 
18 #include <protocols/jobdist/JobDistributors.hh> // SJF Keep first for mpi
22 #include <core/io/pdb/pose_io.hh>
30 #include <core/pose/PDBInfo.hh>
31 #include <core/pose/util.hh>
32 #include <core/scoring/Energies.hh>
39 #include <core/pose/util.hh>
41 #include <basic/datacache/BasicDataCache.hh>
42 #include <basic/datacache/DiagnosticData.hh>
43 #include <basic/options/option.hh>
44 #include <basic/options/keys/antibody.OptionKeys.gen.hh>
45 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
46 #include <basic/options/keys/in.OptionKeys.gen.hh>
47 #include <basic/options/keys/out.OptionKeys.gen.hh>
48 #include <basic/options/keys/run.OptionKeys.gen.hh>
49 #include <basic/prof.hh>
50 #include <basic/Tracer.hh>
53 #include <protocols/jd2/Job.hh>
64 
65 #include <ObjexxFCL/format.hh>
66 #include <ObjexxFCL/string.functions.hh>
67 using namespace ObjexxFCL::fmt;
68 
69 
70 
71 
72 using basic::T;
73 using basic::Error;
74 using basic::Warning;
75 
76 static basic::Tracer TR("protocols.antibody2.AntibodyModelerProtocol");
77 using namespace core;
78 
79 namespace protocols {
80 namespace antibody2 {
81 
82 // default constructor
83 AntibodyModelerProtocol::AntibodyModelerProtocol() : Mover() {
84  user_defined_ = false;
85  init();
86 }
87 
88 // default destructor
90 
91 //clone
94  return( new AntibodyModelerProtocol() );
95 }
96 
97 
98 
100 {
101  Mover::type( "AntibodyModelerProtocol" );
102 
103  set_default();
105  setup_objects();
106 }
107 
108 
109 
111 {
112  TR << "Setting Up defaults.........." << std::endl;
113  model_h3_ = true;
114  h3_filter_ = true;
115  cter_insert_ = true;
116  snugfit_ = true;
117  LH_repulsive_ramp_ = true;
118  refine_h3_ = true;
119  flank_residue_min_ = true;
120  middle_pack_min_ = true;
121 
122  bad_nter_ = true;
123  benchmark_ = false;
124  camelid_ = false;
125  camelid_constraints_ = false;
126  use_csts_ = false;
127  constrain_vlvh_qq_ = false;
128  constrain_cter_ = false;
129 
130  cst_weight_ = 0.0;
131  cen_cst_ = 10.0;
132  high_cst_ = 100.0; // if changed here, please change at the end of AntibodyModeler as well
135 
136  sc_min_ = false;
137  rt_min_ = false;
138 
139  h3_perturb_type_ = "legacy_perturb_ccd"; // legacy_perturb_ccd, kic, ccd
140  h3_refine_type_ = "legacy_refine_ccd"; // legacy_refine, kic, ccd
141 
142  cdr_constraint_ = NULL;
143 }
144 
145 
146 
148 {
149  using namespace basic::options;
150 
151  option.add_relevant( OptionKeys::antibody::model_h3 );
152  option.add_relevant( OptionKeys::antibody::snugfit );
153  option.add_relevant( OptionKeys::antibody::camelid );
154  option.add_relevant( OptionKeys::antibody::camelid_constraints );
155  option.add_relevant( OptionKeys::run::benchmark );
156  option.add_relevant( OptionKeys::constraints::cst_weight );
157  option.add_relevant( OptionKeys::constraints::cst_file );
158  option.add_relevant( OptionKeys::antibody::constrain_vlvh_qq );
159  option.add_relevant( OptionKeys::antibody::constrain_cter );
160  option.add_relevant( OptionKeys::in::file::native );
161  option.add_relevant( OptionKeys::antibody::refine_h3 );
162  option.add_relevant( OptionKeys::antibody::h3_filter );
163  option.add_relevant( OptionKeys::antibody::cter_insert );
164  option.add_relevant( OptionKeys::antibody::sc_min);
165  option.add_relevant( OptionKeys::antibody::rt_min);
166  option.add_relevant( OptionKeys::antibody::flank_residue_min);
167  //option.add_relevant( OptionKeys::antibody::flank_residue_size);
168  option.add_relevant( OptionKeys::antibody::remodel);
169  option.add_relevant( OptionKeys::antibody::refine);
170  //option.add_relevant( OptionKeys::antibody::middle_pack_min);
171  option.add_relevant( OptionKeys::antibody::h3_filter_tolerance);
172  option.add_relevant( OptionKeys::antibody::bad_nter);
173 }
174 
175 
176 
177 
178 
180 {
181  using namespace basic::options;
182  using namespace basic::options::OptionKeys;
183 
184  TR << "Start Reading and Setting Options ..." << std::endl;
185 
186  if ( option[OptionKeys::antibody::model_h3].user() ){
187  set_ModelH3( option[OptionKeys::antibody::model_h3]() );
188  }
189  if ( option[ OptionKeys::antibody::snugfit ].user() ){
190  set_SnugFit( option[ OptionKeys::antibody::snugfit ]() );
191  }
192  if ( option[ OptionKeys::antibody::refine_h3 ].user() ){
193  set_refine_h3( option[ OptionKeys::antibody::refine_h3 ]() );
194  }
195  if ( option[ OptionKeys::antibody::cter_insert ].user() ){
196  set_CterInsert( option[ OptionKeys::antibody::cter_insert ]() );
197  }
198 
199 
200  if ( option[ OptionKeys::antibody::h3_filter ].user() ) {
201  set_H3Filter ( option[ OptionKeys::antibody::h3_filter ]() );
202  }
203  if ( option[ OptionKeys::antibody::h3_filter_tolerance ].user() ){
204  set_H3Filter_Tolerance( option[ OptionKeys::antibody::h3_filter_tolerance ]() );
205  }
206  if ( option[ OptionKeys::antibody::flank_residue_min ].user() ) {
207  set_flank_residue_min ( option[ OptionKeys::antibody::flank_residue_min ]() );
208  }
209  if ( option[ OptionKeys::run::benchmark ].user() ){
210  set_BenchMark( option[ OptionKeys::run::benchmark ]() );
211  }
212  if ( option[ OptionKeys::constraints::cst_weight ].user() ) {
213  set_cst_weight( option[ OptionKeys::constraints::cst_weight ]() );
214  }
215  if ( option[ OptionKeys::constraints::cst_file].user() ){
216  set_use_constraints( option[ OptionKeys::constraints::cst_file ].user() ); // .user here??
217  }
218  if ( option[ OptionKeys::antibody::constrain_cter ].user() ){
219  set_constrain_cter( option[ OptionKeys::antibody::constrain_cter ]() );
220  }
221  if ( option[ OptionKeys::antibody::constrain_vlvh_qq ].user() ){
222  set_constrain_vlvh_qq( option[ OptionKeys::antibody::constrain_vlvh_qq ]() );
223  }
224  if ( option[ OptionKeys::antibody::sc_min ].user() ) {
225  set_sc_min( option[ OptionKeys::antibody::sc_min ]() );
226  }
227  if ( option[ OptionKeys::antibody::rt_min ].user() ) {
228  set_rt_min( option[ OptionKeys::antibody::rt_min ]() );
229  }
230  if ( option[ OptionKeys::antibody::remodel ].user() ) {
231  set_perturb_type( option[ OptionKeys::antibody::remodel ]() );
232  }
233  if ( option[ OptionKeys::antibody::refine ].user() ) {
234  set_refine_type( option[ OptionKeys::antibody::refine ]() );
235  }
236  if ( option[ OptionKeys::antibody::bad_nter].user() ){
237  set_bad_nter(option[ OptionKeys::antibody::bad_nter]() );
238  }
239  //if ( option[ OptionKeys::antibody::middle_pack_min].user() ){
240  // set_middle_pack_min( option[ OptionKeys::loops::refine ] )
241  //}
242 
243  //set native pose if asked for
244  if ( option[ OptionKeys::in::file::native ].user() ) {
245  core::pose::PoseOP native_pose = new core::pose::Pose();
246  core::import_pose::pose_from_pdb( *native_pose, option[ OptionKeys::in::file::native ]() );
247  set_native_pose( native_pose );
248  }
249  else{
250  set_native_pose(NULL);
251  }
252 
253 
254  TR << "Finish Reading and Setting Options !!!" << std::endl;
255 }
256 
257 
258 
259 void
261 
263 
264  if(use_csts_){
265  if ( cst_weight_ == 0.0 ) cst_weight_ = 1.0;
266  }
267 
268  // setup all the scoring functions
273  if(constrain_vlvh_qq_){
275  }
277  loop_scorefxn_centroid_->set_weight( scoring::chainbreak, 10./3. );
278  //loop_scorefxn_centroid_->set_weight( scoring::atom_pair_constraint, cen_cst_ );
280  loop_scorefxn_highres_->set_weight( scoring::chainbreak, 1.0 );
282  if(constrain_cter_){
284  }
285 }
286 
288 {
289  using namespace protocols::moves;
291 }
292 
293 
295 {
296  return "AntibodyModelerProtocol";
297 }
298 
299 
300 
301 
303 {
304  TR<<"AAAAAAAA cst_weight: "<<cst_weight_<<std::endl;
305  if( cst_weight_ != 0.00 ) {
307  cdr_constraint_->apply( pose );
308  }
309 
310  // check for native and input pose
311  if ( !get_input_pose() ) {
312  pose::PoseOP input_pose = new pose::Pose(pose);
313  set_input_pose( input_pose ); // JQX: pass the input_pose to the mover.input_pose_
314  }
315 
316 
317  pose::PoseOP native_pose;
318  if ( !get_native_pose() ) {
319  TR << "Danger Will Robinson! Native is an impostor!" << std::endl;
320  TR << " 'native_pose' is just a copy of the 'input_pose' " << std::endl;
321  TR << " since you didn't sepcifiy the native pdb name"<<std::endl;
322  native_pose = new pose::Pose(pose);
323  } else {
324  native_pose = new pose::Pose( *get_native_pose() );
325  }
326 
327  pose::set_ss_from_phipsi( *native_pose ); // JQX: this is the secondary structure from the native pose
328 
329  set_native_pose( native_pose ); // pass the native pose to the mover.native_pose_
330 
331  ab_info_ = new AntibodyInfo(pose);
332 
333  pose.fold_tree( * ab_info_->get_FoldTree_AllCDRs(pose) ) ;
334  TR<<*ab_info_<<std::endl;
335 
336  //AntibodyInfoOP native_ab_info = new AntibodyInfo(*native_pose,camelid_);
337 
338  //core::pack::task::PackerTaskOP my_task2(tf_->create_task_and_apply_taskoperations(pose));
339  //TR<<*my_task2<<std::endl; exit(-1);
340 
341 
342 }
343 
344 
345 
346 //APPLY
348 
349  using namespace chemical;
350  using namespace id;
351  using namespace scoring;
352  using namespace core::scoring::constraints;
353  using namespace protocols::moves;
354 
355 
356  // the default inital secstruct is all "L" loop!
357  pose::Pose start_pose_ = pose;
358 
359 
360 
363  }
364 
365  finalize_setup(pose);
366 
367 
368 
369 
370  basic::prof_reset();
372  // utility::exit( EXIT_FAILURE, __FILE__, __LINE__);
373 
374  pose::set_ss_from_phipsi( pose );
375 
376 
377  // display constraints and return
378  if( camelid_constraints_ ) {
380  return;
381  }
382 
383 
384  // Step 1: model the cdr h3 in centroid mode
385  // JQX notes: pay attention to the way it treats the stems when extending the loop
386  if(model_h3_){
388  model_cdrh3->set_perturb_type(h3_perturb_type_); //legacy_perturb_ccd, ccd, kic
389  if(cter_insert_ ==false) { model_cdrh3->turn_off_cter_insert(); }
390  if(h3_filter_ ==false) { model_cdrh3->turn_off_H3_filter(); }
391  model_cdrh3->set_bad_nter(bad_nter_);
392  model_cdrh3->apply( pose );
393  //pose.dump_pdb("1st_finish_model_h3.pdb");
394 
395  }
396 
397 
398  //if(middle_pack_min_){
399  CDRsMinPackMinOP cdrs_min_pack_min = new CDRsMinPackMin(ab_info_);
400  if(sc_min_) cdrs_min_pack_min->set_sc_min(true);
401  if(rt_min_) cdrs_min_pack_min->set_rt_min(true);
402  cdrs_min_pack_min -> apply(pose);
403  //}
404 
405 
406  // Step 2: SnugFit: relieve the clashes between L-H
407  if ( snugfit_ ) {
409  // it has default movemap, tf, and fold_tree
410  if (!LH_repulsive_ramp_) {refine_beta_barrel-> turn_off_repulsive_ramp();}
411  if(sc_min_) { refine_beta_barrel->set_sc_min(true); }
412  if(rt_min_) { refine_beta_barrel->set_rt_min(true); }
413  refine_beta_barrel->apply(pose);
414  //pose.dump_pdb("2nd_finish_snugfit.pdb");
415  }
416 
417 
418 
419  // Step 3: Full Atom Relax
420  if(refine_h3_){
422  cdr_highres_refine_ -> set_refine_mode(h3_refine_type_);
423  cdr_highres_refine_ -> set_h3_filter(h3_filter_);
424  cdr_highres_refine_ -> set_num_filter_tries(h3_filter_tolerance_);
425  cdr_highres_refine_ -> set_flank_relax(flank_residue_min_);
426  if (flank_residue_min_) cdr_highres_refine_->set_flank_size(flank_residue_size_);
427  cdr_highres_refine_ -> pass_start_pose(start_pose_);
428  cdr_highres_refine_ -> apply(pose);
429  //pose.dump_pdb("3rd_finish_h3_refine.pdb");
430  }
431 
432  //FoldTree, MoveMap, TaskFactory and Variants will be taken care of inside
433  cdrs_min_pack_min -> apply(pose);
434  //pose.dump_pdb("4th_final_min_pack_min.pdb");
435 
436 
437 
438 
439  // Step 4: Store the homolgy models
440 
441  // align pose to native pose
442  pose::Pose native_pose = *get_native_pose();
443  antibody2::AntibodyInfoOP native_ab_info = new AntibodyInfo(native_pose);
444  align_to_native( pose, native_pose, ab_info_, native_ab_info );
445 
446 
447  pose.fold_tree( * ab_info_->get_FoldTree_AllCDRs(pose) ) ;
448 
449  // Redefining CDR H3 cutpoint variants
450  loops::remove_cutpoint_variants( pose, true );
452 
453  // Final score (with constraints) before jd2 output the results
454  if(constrain_vlvh_qq_){
456  }
457  ( *loop_scorefxn_highres_ )( pose );
458 
459 
460 
461  // the specific constraint terms for output in the log file
462  Real atom_pair_constraint_score = pose.energies().total_energies()[ core::scoring::atom_pair_constraint ];
463  Real dihedral_constraint_score = pose.energies().total_energies()[ core::scoring::dihedral_constraint ];
464 
465  TR<< " atom_pair_constraint_score= "<<atom_pair_constraint_score<<std::endl;
466  TR<< " dihedral_constraint_score= "<<dihedral_constraint_score<<std::endl;
467 
468 
469 
470 
471 
472  job->add_string_real_pair("H3_RMS", global_loop_rmsd( pose, *get_native_pose(), ab_info_->get_CDR_in_loopsop(h3) ));
473  job->add_string_real_pair("H2_RMS", global_loop_rmsd( pose, *get_native_pose(), ab_info_->get_CDR_in_loopsop(h2) ));
474  job->add_string_real_pair("H1_RMS", global_loop_rmsd( pose, *get_native_pose(), ab_info_->get_CDR_in_loopsop(h1) ));
475  if( camelid_ == false ) {
476  job->add_string_real_pair("L3_RMS", global_loop_rmsd( pose, *get_native_pose(), ab_info_->get_CDR_in_loopsop(l3) ));
477  job->add_string_real_pair("L2_RMS", global_loop_rmsd( pose, *get_native_pose(), ab_info_->get_CDR_in_loopsop(l2) ));
478  job->add_string_real_pair("L1_RMS", global_loop_rmsd( pose, *get_native_pose(), ab_info_->get_CDR_in_loopsop(l1) ));
479  }
480  //job->add_string_real_pair("AP_constraint", atom_pair_constraint_score);
481  job->add_string_real_pair("VL_VH_angle", vl_vh_packing_angle( pose, ab_info_ ));
482 
484 
485  basic::prof_show();
486 
487 
488  TR<<"Antibody Modeling Protocol Finished!!!!"<<std::endl<<std::endl<<std::endl;
489 }// end apply
490 
491 
492 
493 
494 
495 
496 
497 
498 
499 
500 
501 
502 
503 
505 {
506 
507  // Detecting di-sulfide bond
508 
509  Size H1_Cys(0), H3_Cys(0);
510 
511  if( pose.residue( pose.pdb_info()->pdb2pose('H',32 ) ).name3() == "CYS" ){
512  H1_Cys = pose.pdb_info()->pdb2pose( 'H', 32 );
513  }
514  else if( pose.residue( pose.pdb_info()->pdb2pose('H',33 ) ).name3() == "CYS" ){
515  H1_Cys = pose.pdb_info()->pdb2pose( 'H', 33 );
516  }
517 
518  for( Size ii = ab_info_->get_CDR_loop(h3).start(); ii <= ab_info_->get_CDR_loop(h3).stop(); ii++ ){
519  if( pose.residue(ii).name3() == "CYS" ) {
520  H3_Cys = ii;
521  }
522  }
523 
524  if( ( H1_Cys != 0 ) && ( H3_Cys != 0 ) ){
525  TR << "CONSTRAINTS: "<< "AtomPair CA " << H1_Cys << " CA " << H3_Cys
526  << " BOUNDED 4.0 6.1 0.6 BOND; mean 5.6 sd 0.6" << std::endl;
527  }
528 
529  // Specifying extended kink
530 
531  Size hfr_46(0), h3_closest(0);
532  hfr_46 = pose.pdb_info()->pdb2pose( 'H', 46 );
533  if( ab_info_->get_Predicted_H3BaseType() == Extended ) h3_closest = ab_info_->get_CDR_loop(h3).stop() - 5;
534  if( h3_closest != 0 ) {
535  TR << "CONSTRAINTS: " << "AtomPair CA " << hfr_46 << " CA " << h3_closest
536  << " BOUNDED 6.5 9.1 0.7 DISTANCE; mean 8.0 sd 0.7" << std::endl;
537  }
538 
539  return;
540 } // display_constraint_residues
541 
542 
543 
544 
545 
546 
547 
548 
549 
550 
551 
552 /// @details Show the complete setup of the antibody modeler protocol
553 void AntibodyModelerProtocol::show( std::ostream & out ) {
556  }
557  out << *this;
558 }
559 
560 std::ostream & operator<<(std::ostream& out, const AntibodyModelerProtocol & ab_m ){
561  using namespace ObjexxFCL::fmt;
562 
563  // All output will be 80 characters - 80 is a nice number, don't you think?
564  std::string line_marker = "///";
565  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
566  out << line_marker << std::endl;
567  out << line_marker << A( 47, "Rosetta 3 Antibody Modeler" ) << space( 27 ) << line_marker << std::endl;
568  out << line_marker << space( 74 ) << line_marker << std::endl;
569 
570  // Display the state of the antibody modeler protocol that will be used
571  out << line_marker << " camelid : " << ab_m.camelid_ << std::endl;
572  out << line_marker << std::endl;
573  out << line_marker << " ****** model_h3 : " << ab_m.model_h3_ << std::endl;
574  out << line_marker << " h3_perturb_type = '"<< ab_m.h3_perturb_type_<<"'"<< std::endl;
575  out << line_marker << " cter_insert = " << ab_m.cter_insert_ << std::endl;
576  out << line_marker << " h3_filter = " << ab_m.h3_filter_ << std::endl;
577  out << line_marker << std::endl;
578  out << line_marker << " ****** snugfit : " << ab_m.snugfit_ << std::endl;
579  out << line_marker << " LH_repulsive_ramp = " << ab_m.LH_repulsive_ramp_ << std::endl;
580  out << line_marker << std::endl;
581  out << line_marker << " ****** refine_h3 : " << ab_m.refine_h3_ << std::endl;
582  out << line_marker << " h3_refine_type = '"<< ab_m.h3_refine_type_<<"'" << std::endl;
583  out << line_marker << " h3_filter = " << ab_m.h3_filter_ << std::endl;
584  out << line_marker << " h3_filter_tolerance = " << ab_m.h3_filter_tolerance_ << std::endl;
585  out << line_marker << std::endl;
586  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
587  return out;
588 }
589 
590 
591 
592 
593 
594 
595 
596 
597 
598 } // end antibody2
599 } // end protocols
600