Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChiralMover.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 under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/simple_moves/chiral/ChiralMover.cc
11 /// @brief ChiralMover methods implemented
12 /// @author Kevin Drew, kdrew@nyu.edu
13 
14 // Unit Headers
16 // Package Headers
17 
18 // Project Headers
25 #include <core/chemical/Patch.hh>
30 #include <core/pose/Pose.hh>
31 #include <core/pose/util.hh>
32 #include <core/id/AtomID.hh>
33 // Utility Headers
34 #include <numeric/xyz.functions.hh>
35 #include <basic/Tracer.hh>
36 #include <basic/basic.hh>
37 //#include <core/types.hh>
38 
39 // C++ Headers
40 
41 using basic::T;
42 using basic::Error;
43 using basic::Warning;
44 
45 static basic::Tracer TR( "protocols.simple_moves.chiral.ChiralMover" );
46 
47 using namespace core;
48 using namespace conformation;
49 using namespace chemical;
50 using namespace core::id;
51 
52 namespace protocols {
53 namespace simple_moves {
54 namespace chiral {
55 
56 
57 std::pair< std::string, std::string > L2DChiralData[] = {
58  std::make_pair("A04","D04"),
59  std::make_pair("A05","D05"),
60  std::make_pair("A06","D06"),
61  std::make_pair("A07","D07"),
62  std::make_pair("A12","D12"),
63  std::make_pair("A20","D20"),
64  std::make_pair("A24","D24"),
65  std::make_pair("A30","D30"),
66  std::make_pair("A31","D31"),
67  std::make_pair("A33","D33"),
68  std::make_pair("A34","D34"),
69  std::make_pair("A43","D43"),
70  std::make_pair("A44","D44"),
71  std::make_pair("A45","D45"),
72  std::make_pair("A48","D48"),
73  std::make_pair("A68","D68"),
74  std::make_pair("A69","D69"),
75  std::make_pair("A78","D78"),
76  std::make_pair("A80","D80"),
77  std::make_pair("A82","D82"),
78  std::make_pair("A83","D83"),
79  std::make_pair("A84","D84"),
80  std::make_pair("A91","D91"),
81  std::make_pair("A92","D92"),
82  std::make_pair("A94","D94"),
83  std::make_pair("A96","D96"),
84  std::make_pair("A97","D97"),
85  std::make_pair("A98","D98"),
86  std::make_pair("A99","D99"),
87  std::make_pair("ABA","DABA"),
88  std::make_pair("ALA","DALA"),
89  std::make_pair("APA","DAPA"),
90  std::make_pair("ARG","DARG"),
91  std::make_pair("ASN","DASN"),
92  std::make_pair("ASP","DASP"),
93  std::make_pair("B00","E00"),
94  std::make_pair("B01","E01"),
95  std::make_pair("B02","E02"),
96  std::make_pair("B03","E03"),
97  std::make_pair("B04","E04"),
98  std::make_pair("B05","E05"),
99  std::make_pair("B06","E06"),
100  std::make_pair("B07","E07"),
101  std::make_pair("B12","E12"),
102  std::make_pair("B19","E19"),
103  std::make_pair("B21","E21"),
104  std::make_pair("B27","E27"),
105  std::make_pair("B28","E28"),
106  std::make_pair("B30","E30"),
107  std::make_pair("B31","E31"),
108  std::make_pair("B35","E35"),
109  std::make_pair("B36","E36"),
110  std::make_pair("B38","E38"),
111  std::make_pair("B40","E40"),
112  std::make_pair("B44","E44"),
113  std::make_pair("B47","E47"),
114  std::make_pair("B48","E48"),
115  std::make_pair("B49","E49"),
116  std::make_pair("B50","E50"),
117  std::make_pair("B51","E51"),
118  std::make_pair("B53","E53"),
119  std::make_pair("B54","E54"),
120  std::make_pair("B56","E56"),
121  std::make_pair("B57","E57"),
122  std::make_pair("B58","E58"),
123  std::make_pair("B59","E59"),
124  std::make_pair("B60","E60"),
125  std::make_pair("B61","E61"),
126  std::make_pair("B62","E62"),
127  std::make_pair("B63","E63"),
128  std::make_pair("B67","E67"),
129  std::make_pair("B74","E74"),
130  std::make_pair("B92","E92"),
131  std::make_pair("B93","E93"),
132  std::make_pair("B94","E94"),
133  std::make_pair("B95","E95"),
134  std::make_pair("B96","E96"),
135  std::make_pair("B97","E97"),
136  std::make_pair("B99","E99"),
137  std::make_pair("C00","F00"),
138  std::make_pair("C01","F01"),
139  std::make_pair("C02","F02"),
140  std::make_pair("C03","F03"),
141  std::make_pair("C04","F04"),
142  std::make_pair("C05","F05"),
143  std::make_pair("C11","F11"),
144  std::make_pair("C12","F12"),
145  std::make_pair("C15","F15"),
146  std::make_pair("C16","F16"),
147  std::make_pair("C20","F20"),
148  std::make_pair("C26","F26"),
149  std::make_pair("C27","F27"),
150  std::make_pair("C30","F30"),
151  std::make_pair("C36","F36"),
152  std::make_pair("C40","F40"),
153  std::make_pair("C41","F41"),
154  std::make_pair("C42","F42"),
155  std::make_pair("C43","F43"),
156  std::make_pair("C53","F53"),
157  std::make_pair("C54","F54"),
158  std::make_pair("C55","F55"),
159  std::make_pair("C60","F60"),
160  std::make_pair("C61","F61"),
161  std::make_pair("C80","F80"),
162  std::make_pair("C81","F81"),
163  std::make_pair("C83","F83"),
164  std::make_pair("C84","F84"),
165  std::make_pair("C85","F85"),
166  std::make_pair("C86","F86"),
167  std::make_pair("C87","F87"),
168  std::make_pair("C88","F88"),
169  std::make_pair("C89","F89"),
170  std::make_pair("C90","F90"),
171  std::make_pair("C91","F91"),
172  std::make_pair("C92","F92"),
173  std::make_pair("C93","F93"),
174  std::make_pair("C94","F94"),
175  std::make_pair("CYD","DCYD"),
176  std::make_pair("CYS","DCYS"),
177  std::make_pair("GLN","DGLN"),
178  std::make_pair("GLU","DGLU"),
179  std::make_pair("HIS","DHIS"),
180  std::make_pair("HIS_D","DHIS_D"),
181  std::make_pair("HLU","DHLU"),
182  std::make_pair("HPR","DHPR"),
183  std::make_pair("HTY","DHTY"),
184  std::make_pair("ILE","DILE"),
185  std::make_pair("LEU","DLEU"),
186  std::make_pair("LYS","DLYS"),
187  std::make_pair("MAL","DMAL"),
188  std::make_pair("MET","DMET"),
189  std::make_pair("MPA","DMPA"),
190  std::make_pair("MTP","DMTP"),
191  std::make_pair("NLU","DNLU"),
192  std::make_pair("NVL","DNVL"),
193  std::make_pair("PHE","DPHE"),
194  std::make_pair("PRO","DPRO"),
195  std::make_pair("SER","DSER"),
196  std::make_pair("THR","DTHR"),
197  std::make_pair("TRP","DTRP"),
198  std::make_pair("TYR","DTYR"),
199  std::make_pair("VAL","DVAL")
200  };
201 
202 //kdrew: convert data to map
203 std::map<std::string, std::string> L2DChiralMap(L2DChiralData, L2DChiralData + sizeof L2DChiralData / sizeof L2DChiralData [0]);
204 
205 
206 std::pair< std::string, std::string > D2LChiralData[] = {
207  std::make_pair("D04","A04"),
208  std::make_pair("D05","A05"),
209  std::make_pair("D06","A06"),
210  std::make_pair("D07","A07"),
211  std::make_pair("D12","A12"),
212  std::make_pair("D20","A20"),
213  std::make_pair("D24","A24"),
214  std::make_pair("D30","A30"),
215  std::make_pair("D31","A31"),
216  std::make_pair("D33","A33"),
217  std::make_pair("D34","A34"),
218  std::make_pair("D43","A43"),
219  std::make_pair("D44","A44"),
220  std::make_pair("D45","A45"),
221  std::make_pair("D48","A48"),
222  std::make_pair("D68","A68"),
223  std::make_pair("D69","A69"),
224  std::make_pair("D78","A78"),
225  std::make_pair("D80","A80"),
226  std::make_pair("D82","A82"),
227  std::make_pair("D83","A83"),
228  std::make_pair("D84","A84"),
229  std::make_pair("D91","A91"),
230  std::make_pair("D92","A92"),
231  std::make_pair("D94","A94"),
232  std::make_pair("D96","A96"),
233  std::make_pair("D97","A97"),
234  std::make_pair("D98","A98"),
235  std::make_pair("D99","A99"),
236  std::make_pair("DABA","ABA"),
237  std::make_pair("DALA","ALA"),
238  std::make_pair("DAPA","APA"),
239  std::make_pair("DARG","ARG"),
240  std::make_pair("DASN","ASN"),
241  std::make_pair("DASP","ASP"),
242  std::make_pair("E00","B00"),
243  std::make_pair("E01","B01"),
244  std::make_pair("E02","B02"),
245  std::make_pair("E03","B03"),
246  std::make_pair("E04","B04"),
247  std::make_pair("E05","B05"),
248  std::make_pair("E06","B06"),
249  std::make_pair("E07","B07"),
250  std::make_pair("E12","B12"),
251  std::make_pair("E19","B19"),
252  std::make_pair("E21","B21"),
253  std::make_pair("E27","B27"),
254  std::make_pair("E28","B28"),
255  std::make_pair("E30","B30"),
256  std::make_pair("E31","B31"),
257  std::make_pair("E35","B35"),
258  std::make_pair("E36","B36"),
259  std::make_pair("E38","B38"),
260  std::make_pair("E40","B40"),
261  std::make_pair("E44","B44"),
262  std::make_pair("E47","B47"),
263  std::make_pair("E48","B48"),
264  std::make_pair("E49","B49"),
265  std::make_pair("E50","B50"),
266  std::make_pair("E51","B51"),
267  std::make_pair("E53","B53"),
268  std::make_pair("E54","B54"),
269  std::make_pair("E56","B56"),
270  std::make_pair("E57","B57"),
271  std::make_pair("E58","B58"),
272  std::make_pair("E59","B59"),
273  std::make_pair("E60","B60"),
274  std::make_pair("E61","B61"),
275  std::make_pair("E62","B62"),
276  std::make_pair("E63","B63"),
277  std::make_pair("E67","B67"),
278  std::make_pair("E74","B74"),
279  std::make_pair("E92","B92"),
280  std::make_pair("E93","B93"),
281  std::make_pair("E94","B94"),
282  std::make_pair("E95","B95"),
283  std::make_pair("E96","B96"),
284  std::make_pair("E97","B97"),
285  std::make_pair("E99","B99"),
286  std::make_pair("F00","C00"),
287  std::make_pair("F01","C01"),
288  std::make_pair("F02","C02"),
289  std::make_pair("F03","C03"),
290  std::make_pair("F04","C04"),
291  std::make_pair("F05","C05"),
292  std::make_pair("F11","C11"),
293  std::make_pair("F12","C12"),
294  std::make_pair("F15","C15"),
295  std::make_pair("F16","C16"),
296  std::make_pair("F20","C20"),
297  std::make_pair("F26","C26"),
298  std::make_pair("F27","C27"),
299  std::make_pair("F30","C30"),
300  std::make_pair("F36","C36"),
301  std::make_pair("F40","C40"),
302  std::make_pair("F41","C41"),
303  std::make_pair("F42","C42"),
304  std::make_pair("F43","C43"),
305  std::make_pair("F53","C53"),
306  std::make_pair("F54","C54"),
307  std::make_pair("F55","C55"),
308  std::make_pair("F60","C60"),
309  std::make_pair("F61","C61"),
310  std::make_pair("F80","C80"),
311  std::make_pair("F81","C81"),
312  std::make_pair("F83","C83"),
313  std::make_pair("F84","C84"),
314  std::make_pair("F85","C85"),
315  std::make_pair("F86","C86"),
316  std::make_pair("F87","C87"),
317  std::make_pair("F88","C88"),
318  std::make_pair("F89","C89"),
319  std::make_pair("F90","C90"),
320  std::make_pair("F91","C91"),
321  std::make_pair("F92","C92"),
322  std::make_pair("F93","C93"),
323  std::make_pair("F94","C94"),
324  std::make_pair("DCYD","CYD"),
325  std::make_pair("DCYS","CYS"),
326  std::make_pair("DGLN","GLN"),
327  std::make_pair("DGLU","GLU"),
328  std::make_pair("DHIS","HIS"),
329  std::make_pair("DHIS_D","HIS_D"),
330  std::make_pair("DHLU","HLU"),
331  std::make_pair("DHPR","HPR"),
332  std::make_pair("DHTY","HTY"),
333  std::make_pair("DILE","ILE"),
334  std::make_pair("DLEU","LEU"),
335  std::make_pair("DLYS","LYS"),
336  std::make_pair("DMAL","MAL"),
337  std::make_pair("DMET","MET"),
338  std::make_pair("DMPA","MPA"),
339  std::make_pair("DMTP","MTP"),
340  std::make_pair("DNLU","NLU"),
341  std::make_pair("DNVL","NVL"),
342  std::make_pair("DPHE","PHE"),
343  std::make_pair("DPRO","PRO"),
344  std::make_pair("DSER","SER"),
345  std::make_pair("DTHR","THR"),
346  std::make_pair("DTRP","TRP"),
347  std::make_pair("DTYR","TYR"),
348  std::make_pair("DVAL","VAL")
349  };
350 
351 //kdrew: convert data to map
352 std::map<std::string, std::string> D2LChiralMap(D2LChiralData, D2LChiralData + sizeof D2LChiralData / sizeof D2LChiralData [0]);
353 
354 
355 
357 {
358  std::string const base_name( residue_type_base_name( restype ) );
359  std::map< std::string, std::string >::iterator it2 = D2LChiralMap.find( base_name );
360  TR << "residue base_name: " << base_name << " is_d_chiral: " << (it2 != D2LChiralMap.end() ) << std::endl;
361  return ( it2 != D2LChiralMap.end() );
362 }
364 {
365  std::string const base_name( residue_type_base_name( restype ) );
366  std::map< std::string, std::string >::iterator it2 = L2DChiralMap.find( base_name );
367  TR << "residue base_name: " << base_name << " is_l_chiral: " << (it2 != L2DChiralMap.end() ) << std::endl;
368  return ( it2 != L2DChiralMap.end() );
369 }
370 
371 
373 {
374  //kdrew: first letters of a residuetype name (before '_p') are the letter code for the aa and is what is stored in the map
375  //std::string base_name;
376  //std::string patch_name;
377 
378  //kdrew: use for finding base_name instead of substr
380  std::string const patch_name( residue_type_all_patches_name( rt ) );
381  TR << "base_name: " << base_name << " patch_name: " << patch_name << std::endl;
382 
383  //kdrew: is residuetype patched?
384  //Size base_end_pos = rt.name().find("_p");
385  //TR << "base_end_pos: " << base_end_pos << std::endl;
386  //if( base_end_pos != std::string::npos )
387  //{
388  // base_name = rt.name().substr( 0, base_end_pos );
389  // //kdrew: the remaining porition of the string is the patch, reapply this porition to the end of the mapped string
390  // patch_name = rt.name().substr( base_end_pos, rt.name().size() );
391  //}
392  ////kdrew: if not patched just use the residuetype name
393  //else
394  //{
395  // base_name = rt.name();
396  // patch_name = "";
397  //}
398 
399  TR << "restype: " << rt.name() << " " << rt.aa() << std::endl;
400  std::string chiral_name;
401 
402  std::map< std::string, std::string >::iterator it = L2DChiralMap.find( base_name );
403  if ( it != L2DChiralMap.end() && chirality != L_CHIRALITY )
404  {
405  chiral_name = it->second;
406  TR << "chiral_name: " << chiral_name << std::endl;
407  chiral_name.append( patch_name );
408  TR << "chiral_name(patched): " << chiral_name << std::endl;
409  ResidueTypeSetCAP fa_standard(ChemicalManager::get_instance()->residue_type_set(FA_STANDARD));
410  ResidueType const & d_rsd_type( fa_standard->name_map( chiral_name ) );
411  return d_rsd_type;
412  }
413  else
414  {
415  TR << " not found in L2D map, checking D2L" << std::endl;
416  std::map< std::string, std::string >::iterator it2 = D2LChiralMap.find( base_name );
417  if ( it2 != D2LChiralMap.end() && chirality != D_CHIRALITY )
418  {
419  chiral_name = it2->second;
420  TR << "chiral_name: " << chiral_name << std::endl;
421  chiral_name.append( patch_name );
422  TR << "chiral_name(patched): " << chiral_name << std::endl;
423  ResidueTypeSetCAP fa_standard(ChemicalManager::get_instance()->residue_type_set(FA_STANDARD));
424  ResidueType const & d_rsd_type( fa_standard->name_map( chiral_name ) );
425  return d_rsd_type;
426  }
427  else
428  {
429  TR << " not found in D2L" << std::endl;
430  TR << " possibly achiral (ex GLY) or not listed in map" << std::endl;
431  return rt;
432  }
433  }
434 
435 }
436 
437 /*
438 kdrew: the apply function changes a single residue's chirality
439 pose: pose to make change to
440 chiral_seq_pos: position of residue to change chirality
441 */
442 void ChiralMover::apply( core::pose::Pose & pose )
443 {
444  using numeric::conversions::radians;
445  using numeric::conversions::degrees;
446 
447  //kdrew: assert for validity of parameters
448  //runtime_assert ( chiral_seq_pos_ != 1 );
449 
450  Real phi_angle = pose.phi( chiral_seq_pos_ );
451  Real psi_angle = pose.psi( chiral_seq_pos_ );
452 
453  TR << "phi_angle: " << phi_angle << " psi_angle: " << psi_angle << std::endl;
454 
455  //kdrew: get residue type
456  ResidueType rtype = pose.residue_type( chiral_seq_pos_ );
457  TR << "Current residue type: " << rtype.name() << std::endl;
458  //kdrew: get chiral residue type
459  ResidueType const & chiral_rtype = get_chiral_residue_type( rtype, chirality_ );
460  TR << "Flipped residue type: " << chiral_rtype.name() << " " << chiral_rtype.aa() << std::endl;
461  if( chiral_rtype.name() == rtype.name() )
462  {
463  TR << " not making chiral change" << std::endl;
464  return;
465  }
466  //kdrew: mutate to chiral residue type
467  conformation::Residue replace_res ( chiral_rtype, true );
468  pose.replace_residue( chiral_seq_pos_ , replace_res, true );
469  //pose.dump_pdb( "rosetta_out_chiral_preidealized.pdb" );
470 
471  //kdrew: idealize alpha carbon hydrogen
472  core::conformation::ResidueOP iires = pose.residue( chiral_seq_pos_ ).clone();
474  pose.replace_residue( chiral_seq_pos_, *iires, false );
475 
476  //pose.dump_pdb( "rosetta_out_chiral_postidealized.pdb" );
477  pose.set_phi( chiral_seq_pos_, (-1.0 * phi_angle ) );
478  //pose.dump_pdb( "rosetta_out_chiral_moved_phi.pdb" );
479  pose.set_psi( chiral_seq_pos_, (-1.0 * psi_angle ) );
480  //pose.dump_pdb( "rosetta_out_chiral_moved_phi_psi.pdb" );
481 
482  TR << "chiral phi_angle: " << pose.phi( chiral_seq_pos_ ) << " chiral psi_angle: " << pose.psi( chiral_seq_pos_ ) << std::endl;
483 
484  TR<< "exiting apply" << std::endl;
485 }
486 
488 ChiralMover::get_name() const {
489  return "ChiralMover";
490 }
491 
492 ///@brief
493 ChiralMover::ChiralMover(
494  core::Size chiral_seq_position
495  ): Mover(), chiral_seq_pos_( chiral_seq_position ), chirality_( FLIP_CHIRALITY )
496 {
497  Mover::type( "ChiralMover" );
498 }
499 
501  core::Size chiral_seq_position,
502  Chirality chirality
503  ): Mover(), chiral_seq_pos_( chiral_seq_position ), chirality_( chirality )
504 {
505  Mover::type( "ChiralMover" );
506 }
507 
509 
510 }//chiral
511 }//simple_moves
512 }//protocols
513