Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
H3CterInsert.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/H3CterInsert.cc
12 /// @brief Build a homology model of an antibody2
13 /// @detailed
14 ///
15 ///
16 /// @author Jianqing Xu ( xubest@gmail.com )
17 
18 
20 
23 #include <basic/options/keys/in.OptionKeys.gen.hh>
24 #include <basic/options/option.hh>
25 #include <basic/Tracer.hh>
26 #include <numeric/numeric.functions.hh>
27 #include <numeric/random/random.hh>
28 #include <utility/exit.hh>
29 #include <utility/io/izstream.hh>
30 #include <utility/pointer/owning_ptr.hh>
36 
37 
38 
39 static numeric::random::RandomGenerator RG(19810606);
40 
41 static basic::Tracer TR("protocols.antibody2.H3CterInsert");
42 using namespace core;
43 
44 
45 
46 namespace protocols {
47 namespace antibody2 {
48 
49 
50 
51 
52 
53 H3CterInsert::H3CterInsert() : Mover()
54 {
55  user_defined_ = false;
56 }
57 
58 
59 
60 H3CterInsert::H3CterInsert(antibody2::AntibodyInfoOP antibody_info, bool camelid ) : Mover()
61 {
62  user_defined_ = true;
63  init(antibody_info, camelid, false);
64 }
65 
66 
67 
68 
69 // H3CterInsert default destructor
71 
72 
73 
74 
75 void H3CterInsert::init(AntibodyInfoOP antibody_info, bool camelid, bool benchmark)
76 {
77  Mover::type( "H3CterInsert" );
78 
79  set_default();
80 
81  if ( user_defined_ ) {
82  is_camelid_ = camelid;
83  benchmark_ = benchmark;
84  ab_info_= antibody_info;
85  }
86 
87  // setup_objects();
88 
90 
91 }
92 
93 
94 
95 
96 
98  is_camelid_ = false;
99  benchmark_ = false;
100 }
101 
102 
103 //void H3CterInsert::setup_objects(){
104 //}
105 
106 
107 
108 //void H3CterInsert::finalize_setup(core::pose::Pose & pose ){
109 
110 //}
111 
112 
113 
115 {
116 
117 // finalize_setup(pose);
118 
119 
120 
121 
122  TR << "Inserting CDR H3 C-ter Fragments" << std::endl;
123 
124  Size loop_begin(0), loop_end(0), cutpoint(0);
125 
126 
127 
128  loop_begin = ab_info_->get_CDR_loop(h3).start()-1; //JQX: to match R2_Antibody
129  cutpoint = ab_info_->get_CDR_loop(h3).cut(); // keep the cutpoint unchanged
130  loop_end = ab_info_->get_CDR_loop(h3).stop()+2; //JQX: to match R2_Antibody
131 
132  pose.fold_tree( * ab_info_->setup_simple_fold_tree(loop_begin, cutpoint, loop_end, pose) );
133  TR<<pose.fold_tree()<<std::endl;
134 
135  bool success = false;
136  while(success == false){
137 
139  Size random_H3_ter(0);
140  random_H3_ter = RG.random_range( 1, H3_base_library_.size() );
141  f = H3_base_library_[ random_H3_ter ];
142  // TR<<H3_base_library_.size()<<std::endl;
143  // f = H3_base_library_[ 1 ]; //JQX: a test case to match R2_Antibody
144  //JQX: realize R2_antibody the fragment data was vector, not vector1
145  //JQX: in another word, R2->20 match R3->21
146  //TODO:
147  //JQX: for the M18 case, the H3_base_library_[ 30 ] has a problem in both R2 and R3
148  // OK, this is due to the database used omega-phi-psi, but Rosetta use phi-psi-omega
149  // the omega is the the omega of last residue
150  //TR<<f<<std::endl;
151 
152  //inserting base dihedrals
153  Size cter_insertion_pos( is_camelid_ ? 4 : 2 ); // not sure why 4 for camelid
154 
155 
156  if( (ab_info_->get_CDR_loop(h3).stop()-cter_insertion_pos) <= ab_info_->get_CDR_loop(h3).start() )
157  {
158  TR << "H3 LOOP IS TOO SHORT: CAN NOT USE C-TERM INFORMATION"<< std::endl;
159  }
160  else {
161  f.apply( pose, ab_info_->get_CDR_loop(h3).stop() - cter_insertion_pos, ab_info_->get_CDR_loop(h3).stop() + 1 );
162 
163  }
164 
165  //JQX: it seems movemap is not required..... kind of weird, but it works! maybe there's a default movemap
166 
167 
168  success = CDR_H3_cter_filter(pose, ab_info_);
169  //JQX: this seems ridiculous, right? You are inserting a kinked or extended structure, why you want
170  // to check again? The reason is that ... the H3_CTERM files is wrong! It is supposed to be
171  // phi-psi-omega, but the info there is omega-phi-psi, in another word, it is using a wrong omega.
172  // If the H3_CTERM file is fixed, this filter is certainly not necessary for sure.
173  }
174 
175 
176  TR << "Finished Inserting CDR H3 C-ter Fragments" << std::endl;
177 
178  return;
179 
180 
181 
182 
183 }
184 
185 
186 
187 
189  return "H3CterInsert";
190 }
191 
192 
193 
194 
195 
196 
197 
198  /// FIXME: JQX the get_CDR_loop is so weird here
200 {
201  using namespace fragment;
202 
203  std::string const path = basic::options::option[ basic::options::OptionKeys::in::path::path ]()[1];
204 
205  TR << "Reading CDR H3 C-ter Fragments" << std::endl;
206 
207  bool is_kinked = false;
208  bool is_extended = false;
209  if (ab_info_->get_Predicted_H3BaseType() == Kinked) is_kinked = true;
210  if (ab_info_->get_Predicted_H3BaseType() == Extended) is_extended = true;
211 
212 
213  // extract single letter aa codes for the chopped loop residues
214  TR<< ab_info_->get_CDR_loop(h3)<<std::endl;
215 
216  Size cdr_h3_size = ( ab_info_->get_CDR_loop(h3).stop() - ab_info_->get_CDR_loop(h3).start() ) + 1;
217 
218  TR<<"cdr_h3_size="<<cdr_h3_size<<std::endl;
219  utility::vector1< char > aa_1name = ab_info_->get_CDR_Sequence_with_Stem(h3,2,2);
220 
221  TR<<"aa_1name.size()="<<aa_1name.size()<<std::endl;
222 
223  std::string tttttt="";
224  for(Size i=1;i<=aa_1name.size();i++){
225  tttttt+=aa_1name[i];
226  }
227  TR<<tttttt<<std::endl;
228 
229 
230 
231 
232 
233  // used only when no length & kink match are found
234  utility::vector1< FragData > H3_base_library_seq_kink;
235 
236  // used only when no (length & kink) or (length & seq) are found
237  utility::vector1< FragData > H3_base_library_kink;
238 
239 
240  // file is read in from where other contraints are supposed to exist
241  if( ab_info_->is_Camelid() ){
242  H3_ter_library_filename_ = path+"camelid_H3_CTERM";
243  }
244  else{
245  H3_ter_library_filename_ = path+"H3_CTERM";
246  }
247 
248  // Read the file defined by command line option
249  utility::io::izstream H3_ter_library_stream( H3_ter_library_filename_ );
250 
251  // Check to see if file exists
252  if ( !H3_ter_library_stream ) {
253  TR << "[Error]: Could not open H3 base library file: "
254  << H3_ter_library_filename_ << std::endl
255  << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" << std::endl;
256  std::exit( EXIT_FAILURE );
257  }
258 
259  std::string pdb_name;
260  std::string res_no;
261  char res_name;
262  Real phi(0.0);
263  Real psi(0.0);
264  Real omega(0.0);
265  Size H3_length(0);
266  Real resolution(0.0);
267  std::string base_type;
268 
269  Size pdb_H3_length = cdr_h3_size;
270  Size h3_base_frag_size( ab_info_->is_Camelid() ? 6 : 4 );
271 
272  bool end_not_reached(true);
273  while(end_not_reached){
274  bool seq_match( true );
275  bool base_match( false );
276 
277  FragData f;
278  f.set_valid( true );
279 
280  for ( Size i = 1; i <= h3_base_frag_size; ++i ) {
281  H3_ter_library_stream >> pdb_name >> res_no >> res_name
282  >> omega >> phi >> psi
283  >> H3_length >> resolution >> base_type
284  >> std::skipws;
285 
286  if(H3_ter_library_stream.eof()) {
287  end_not_reached = false;
288  break;
289  }
290 
291  if( res_name != aa_1name[aa_1name.size() - 5 + i] ){
292  seq_match = false;
293  }
294  //TR<<res_name<<" .vs. "<<aa_1name[aa_1name.size() - 5 + i]<<" "<<seq_match<<std::endl;
295 
297  new BBTorsionSRFD( 3, 'L', res_name ) ); // 3 protein torsions
298 
299  // ugly numbers 1-3, but pose.set_phi also uses explicit numbers
300  res_torsions->set_torsion ( 1, phi );
301  res_torsions->set_torsion ( 2, psi );
302  res_torsions->set_torsion ( 3, omega );
303  res_torsions->set_secstruct ( 'L' );
304  f.add_residue( res_torsions );
305  }
306 
307 
308  //regular antibody
309  if( ab_info_->is_Camelid() == false) {
310  if( is_kinked && base_type == "KINK" ){
311  base_match = true;
312  }
313  else if( is_extended && base_type == "EXTENDED" ){
314  base_match = true;
315  }
316  else if( !is_kinked && !is_extended && base_type == "NEUTRAL" ){
317  base_match = true;
318  }
319  }
320  //camelid antibody
321  else {
322  if( is_extended && base_type == "EXTENDED" ){
323  base_match = true;
324  }
325  else if( ( is_kinked && base_type == "KINK" ) || ( is_kinked && base_type == "EXTENDED" ) ){
326  base_match = true;
327  }
328  else if( !is_kinked && !is_extended ){
329  base_match = true;
330  }
331  }
332 
333 
334  //camelid antibody
335  if( ab_info_->is_Camelid() && end_not_reached && base_match ){
336 
337  H3_base_library_.push_back( f );
338  }
339 
340  // regular antibody
341  else if( end_not_reached && (H3_length==pdb_H3_length) && base_match ){
342  //TR<< "111111111111 H3_length = "<<H3_length<<" pdb_h3_length="<<pdb_H3_length<<" base_match="<<base_match<<std::endl;
343  //TR<<pdb_name<<" "<<omega<<" "<<phi<<" "<<psi<<std::endl;
344 
345  H3_base_library_.push_back( f );
346  }
347 
348 
349  if( end_not_reached && seq_match && base_match ){
350 
351  H3_base_library_seq_kink.push_back( f );
352  }
353  if( end_not_reached && base_match ){
354 
355  H3_base_library_kink.push_back( f );
356  }
357  }
358 
359 
360 
361 
362  //for (int i=1;i<=H3_base_library_.size();i++) {
363  // TR<<H3_base_library_[i]<<std::endl;
364  //}
365 
366  H3_ter_library_stream.close();
367  H3_ter_library_stream.clear();
368 
369  // if no match found based on sequence and kink match criterion
370  // then choose based on size and kink match criterion
371  // if still no match, then choose based only on kink
372  if( H3_base_library_.size() == 0 ) {
373  H3_base_library_ = H3_base_library_seq_kink;
374  }
375  if( H3_base_library_.size() == 0 ) {
376  H3_base_library_ = H3_base_library_kink;
377  }
378 
379  TR << "Finished reading CDR H3 C-ter Fragments" << std::endl;
380  return;
381 
382 
383 }
384 
385 
386 
387 
388 
389 
390 
391 
392 
393 
394 
395 
396 
397 
398 
399 
400 
401 }//antibody2
402 }//protocols
403 
404 
405 
406 
407