Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PatchOperation.hh
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
11 /// @author Phil Bradley
12 /// see patch.cc to understand whats going on
13 
14 #ifndef INCLUDED_core_chemical_PatchOperation_hh
15 #define INCLUDED_core_chemical_PatchOperation_hh
16 
17 
18 // // Unit headers
20 
21 // // Package headers
23 
24 //Tracer header
25 #include <basic/Tracer.hh>
26 
27 // ObjexxFCL headers
28 #include <ObjexxFCL/string.functions.hh>
29 
30 #include <utility/vector1.hh>
31 
32 
33 
34 
35 namespace core {
36 namespace chemical {
37 
38 static basic::Tracer TR_PatchOperations("core.chemical.PatchOperations.hh");
39 
40 
41 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42 
43 /// @brief A single operation that needs to be applied in a residue patch
45 public:
46  ///@brief Automatically generated virtual destructor for class deriving directly from ReferenceCount
47  virtual ~PatchOperation();
48 
49  /// @brief Returns TR_PatchOperationsUE to signal failure
50  virtual
51  bool
52  apply( ResidueType & rsd ) const = 0;
53 };
54 
55 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
56 /// @brief delete an atom
57 class DeleteAtom : public PatchOperation {
58 public:
59 
60  /// @brief constructor
61  DeleteAtom( std::string const & atom_name_in ) :
62  atom_name_( atom_name_in )
63  {}
64 
65  /// @brief delete an atom from ResidueType rsd
66  bool
67  apply( ResidueType & rsd ) const
68  {
69 
70  if ( !rsd.has( atom_name_ ) ) {
71  TR_PatchOperations.Debug << "DeleteAtom::apply failed: " << rsd.name() << " is missing atom " << atom_name_ << std::endl;
72  return true; // failure
73  } else {
74  //std::cout << "DeleteAtom::apply: deleting: " << atom_name_ << std::endl;
75  rsd.delete_atom( atom_name_ );
76  }
77  return false;
78  }
79 
80 private:
81  /// name of the atom to be deleted
83 };
84 
85 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
86 /// @brief set an atom as backbone heavy atom
88 public:
89  /// @brief constructor
90  SetBackboneHeavyatom( std::string const & atom_name_in ) :
91  atom_name_( atom_name_in )
92  {}
93 
94  /// set an atom in ResidueType rsd as backbone heavy atom
95  bool
96  apply( ResidueType & rsd ) const
97  {
98  if ( !rsd.has( atom_name_ ) ) {
99  TR_PatchOperations.Debug << "SetBackboneHeavyatom::apply failed: " << rsd.name() << " is missing atom " << atom_name_ <<
100  std::endl;
101  return true; // failure
102  } else {
103  //std::cout << "SetBackboneHeavyatom::apply: " << atom_name_ << std::endl;
105  }
106  return false;
107  }
108 
109 private:
110  // name of the atom to be set
112 };
113 
114 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115 /// @brief set an atom as polymer connection
117 public:
118 
119  /// @brief constructor the type of connection is "LOWER" or "UPPER"
120  SetPolymerConnectAtom( std::string const & atom_name_in, std::string const & upper_lower_in ) :
121  atom_name_( atom_name_in )
122  {
123  if ( upper_lower_in == "LOWER" ) {
124  upper_lower_ = -1;
125  } else if ( upper_lower_in == "UPPER" ) {
126  upper_lower_ = 1;
127  } else {
128  utility_exit_with_message( "SetPolymerConnectAtom: unrecognized switch "+upper_lower_in );
129  }
130  }
131 
132  /// @brief set an atom in ResidueType rsd as a polymer connection atom
133  bool
134  apply( ResidueType & rsd ) const
135  {
136  if ( atom_name_ == "NONE" || rsd.has( atom_name_ ) ) {
137  //std::cout << "SetPolymerConnectAtom::apply: " << atom_name_ << ' ' << upper_lower_ << std::endl;
138  if ( upper_lower_ == -1 ) {
140  } else {
141  assert( upper_lower_ == 1 );
143  }
144  } else {
145  TR_PatchOperations.Debug << "SetPolymerConnectAtom::apply failed: " << rsd.name() << " is missing atom " << atom_name_ <<
146  std::endl;
147  return true; // failure
148  }
149  return false;
150  }
151 
152 private:
153  /// "NONE" to delete the connection by setting its atomno to ZERO
155  /// -1 for lower connection, 1 for upper connection
157 };
158 
159 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
160 class AddConnect : public PatchOperation {
161 public:
162 
163  // c-tor
164  AddConnect( std::string const & connect_atom,
165  Real const phi, Real const theta, Real const d,
166  std::string const & parent_atom,
167  std::string const & angle_atom,
168  std::string const & torsion_atom
169  ):
170  connect_atom_( connect_atom ),
171  phi_( phi ), theta_( theta ), d_( d ),
172  parent_atom_ ( parent_atom ),
173  angle_atom_ ( angle_atom ),
174  torsion_atom_( torsion_atom )
175  {}
176 
177 
178  /// add a property
179  bool
180  apply( ResidueType & rsd ) const
181  {
182  if ( !rsd.has( connect_atom_ ) ||
183  !rsd.has( parent_atom_ ) ||
184  !rsd.has( angle_atom_ ) ||
185  !rsd.has( torsion_atom_ ) ) return true; // failure!
186 
187  Size const connid( rsd.add_residue_connection( connect_atom_ ) );
188  rsd.set_icoor( "CONN"+ObjexxFCL::string_of( connid ), phi_, theta_, d_, parent_atom_, angle_atom_, torsion_atom_ );
189  return false;
190  }
191 
192 private:
194  Real const phi_;
195  Real const theta_;
196  Real const d_;
200 
201 
202 
203 };
204 
205 
206 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
207 /// @brief add a property to ResidueType
208 class AddProperty : public PatchOperation {
209 public:
210 
211  /// constructor
212  AddProperty( std::string const & property_in ):
213  property_( property_in )
214  {}
215 
216  /// add a property
217  bool
218  apply( ResidueType & rsd ) const
219  {
220  rsd.add_property( property_ );
221  //TR_PatchOperations.Debug << "AddProperty::apply: " << property_ << std::endl;
222  return false;
223  }
224 
225 private:
226  /// property to be added
228 };
229 
230 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
231 /// @brief delete a property from ResidueType
232 /// Added by Andy M. Chen in June 2009
233 /// This is needed for deleting properties, which occurs in certain PTM's (e.g. methylation)
234 
236 public:
237 
238  /// constructor
239  DeleteProperty( std::string const & property_in ):
240  property_( property_in )
241  {}
242 
243  /// add a property
244  bool
245  apply( ResidueType & rsd ) const
246  {
247  rsd.delete_property( property_ );
248  //std::cout << "DeleteProperty::apply: " << property_ << std::endl;
249  return false;
250  }
251 
252 private:
253  /// property to be added
255 };
256 
257 
258 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
259 /// @brief Add a chi angle to ResidueType
260 /// Added by Andy M. Chen in June 2009
261 /// This is needed for PTM's, which often result in one or more extra chi angles
262 
263 class AddChi : public PatchOperation {
264 public:
265 
266  /// constructor
268  Size const & chino_in, std::string const & atom1_in, std::string const & atom2_in,
269  std::string const & atom3_in, std::string const & atom4_in
270  ):
271  chino_( chino_in ), atom1_( atom1_in ), atom2_( atom2_in ), atom3_( atom3_in ), atom4_( atom4_in )
272  {}
273 
274  /// add a chi angle
275  bool
276  apply( ResidueType & rsd ) const
277  {
278  if ( !rsd.has( atom1_ ) || !rsd.has( atom2_ ) || !rsd.has( atom3_ ) || !rsd.has( atom4_ ) )
279  {
280  TR_PatchOperations.Debug << "AddChi::apply failed: " << rsd.name() << " is missing atom(s) " << atom1_ << ' '
281  << rsd.has( atom1_ ) << ' ' << atom2_ << ' ' << rsd.has( atom2_ ) << atom3_ << ' '
282  << rsd.has( atom3_ ) << atom4_ << ' ' << rsd.has( atom4_ ) << std::endl;
283  return true; // failure
284  }
285  else
286  {
287  rsd.add_chi( chino_, atom1_ , atom2_, atom3_, atom4_ );
288  //std::cout << "AddChi::apply: " << atom1_ << ' ' << atom2_
289  // << ' ' << atom3_ << ' ' << atom4_ << std::endl;
290  return false;
291  }
292  return false;
293  }
294 
295 
296 private:
297  /// atoms between which a chi angle is added
303 };
304 
305 class AddProtonChi : public PatchOperation {
306 public:
307 
308  /// constructor
310  Size const & chino_in, utility::vector1<core::Real> const & samples, utility::vector1<core::Real> const & extrasamples
311  ):
312  chino_( chino_in ), samples_(samples), extrasamples_(extrasamples)
313  {}
314 
315  /// add a proton chi angle
316  bool
317  apply( ResidueType & rsd ) const
318  {
320  return false;
321  }
322 
323 private:
324  /// atoms between which a chi angle is added
328 };
329 
330 
331 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
332 /// @brief Redefine a chi angle
333 /// Added by Andy M. Chen in June 2009
334 /// This is needed for certain PTM's
335 
336 class RedefineChi : public PatchOperation {
337 public:
338 
339  /// constructor
341  Size const & chino_in, std::string const & atom1_in, std::string const & atom2_in,
342  std::string const & atom3_in, std::string const & atom4_in
343  ):
344  chino_( chino_in ), atom1_( atom1_in ), atom2_( atom2_in ), atom3_( atom3_in ), atom4_( atom4_in )
345  {}
346 
347  /// redefine a chi angle
348  bool
349  apply( ResidueType & rsd ) const
350  {
351  if ( !rsd.has( atom1_ ) || !rsd.has( atom2_ ) || !rsd.has( atom3_ ) || !rsd.has( atom4_ ) )
352  {
353  TR_PatchOperations.Debug << "RedefineChi::apply failed: " << rsd.name() << " is missing atom(s) " << atom1_ << ' '
354  << rsd.has( atom1_ ) << ' ' << atom2_ << ' ' << rsd.has( atom2_ ) << atom3_ << ' '
355  << rsd.has( atom3_ ) << atom4_ << ' ' << rsd.has( atom4_ ) << std::endl;
356  return true; // failure
357  }
358  else
359  {
361  //std::cout << "RedefineChi::apply: " << atom1_ << ' ' << atom2_
362  // << ' ' << atom3_ << ' ' << atom4_ << std::endl;
363  return false;
364  }
365  return false;
366  }
367 
368 
369 private:
370  /// atoms between which a chi angle is added
376 };
377 
378 
379 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
380 /// @brief Add a rotamer sample to a chi angle of the ResidueType
381 /// Added by Andy M. Chen in June 2009
382 /// This is needed for PTM's
383 
385 public:
386 
387  /// constructor
389  Size const & chino_in, Real const & mean_in, Real const & sdev_in
390  ):
391  chino_( chino_in ), mean_( mean_in ), sdev_( sdev_in )
392  {}
393 
394  /// add a rotamer sample
395  bool
396  apply( ResidueType & rsd ) const
397  {
398  rsd.add_chi_rotamer( chino_, mean_ , sdev_ );
399  //std::cout << "AddChiRotamer::apply: " << chino_ << ' ' << mean_
400  // << ' ' << sdev_ << std::endl;
401  return false;
402  }
403 
404 
405 private:
406  /// atoms between which a chi angle is added
410 };
411 
412 
413 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
414 /// @brief add an atom to ResidueType
415 class AddAtom : public PatchOperation {
416 public:
417 
418  /// constructor
420  std::string const & atom_name_in,
421  std::string const & atom_type_name_in,
422  std::string const & mm_atom_type_name_in,
423  Real const charge
424  ):
425  atom_name_( atom_name_in ),
426  atom_type_name_( atom_type_name_in ),
427  mm_atom_type_name_( mm_atom_type_name_in ),
428  charge_( charge )
429  {}
430 
431  /// add an atom
432  bool
433  apply( ResidueType & rsd ) const
434  {
436  //std::cout << "AddAtom::apply: " << atom_name_ << ' ' << atom_type_name_ << ' ' << mm_atom_type_name_ << ' ' <<
437  // charge_ << std::endl;
438  return false;
439  }
440 
441 private:
445  Real const charge_;
446 };
447 
448 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
449 /// @brief add a bond to ResidueType
450 class AddBond : public PatchOperation {
451 public:
452 
453  /// constructor
455  std::string const & atom1_in,
456  std::string const & atom2_in
457  ):
458  atom1_( atom1_in ),
459  atom2_( atom2_in )
460  {}
461 
462  /// add a bond
463  bool
464  apply( ResidueType & rsd ) const
465  {
466  if ( !rsd.has( atom1_ ) || !rsd.has( atom2_ ) ) {
467  TR_PatchOperations.Debug << "AddBond::apply failed: " << rsd.name() << " is missing atom(s) " << atom1_ << ' ' <<
468  rsd.has( atom1_ ) << ' ' << atom2_ << ' ' << rsd.has( atom2_ ) << std::endl;
469  return true; // failure
470  } else {
471  //TR_PatchOperations.Debug << "AddBond::apply: " << atom1_ << ' ' << atom2_ << std::endl;
472  rsd.add_bond( atom1_, atom2_ );
473  }
474  return false;
475  }
476 
477 private:
478  /// atoms between which a bond is added
481 
482 };
483 
484 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
485 /// @brief set an atom's charge
487 public:
488 
489  /// constructor
491  std::string const & atom_name_in,
492  Real const charge_in
493  ):
494  atom_name_( atom_name_in ),
495  charge_( charge_in )
496  {}
497 
498  /// set an atom's charge
499  bool
500  apply( ResidueType & rsd ) const;
501 
502 private:
503  /// atom's name
505  /// atom's charge
507 };
508 
509 
510 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
511 /// @brief set atom's chemical type
512 class SetAtomType : public PatchOperation {
513 public:
514  /// constructor
516  std::string const & atom_name_in,
517  std::string const & atom_type_name_in
518  ):
519  atom_name_( atom_name_in ),
520  atom_type_name_( atom_type_name_in )
521  {}
522 
523  /// set atom's chemical type
524  bool
525  apply( ResidueType & rsd ) const
526  {
527  if ( !rsd.has( atom_name_ ) ) {
528  TR_PatchOperations.Debug << "SetAtomType::apply failed: " << rsd.name() << " is missing atom: " << atom_name_ << std::endl;
529  return true; // failure
530  } else {
531  //std::cout << "SetAtomType::apply: " << atom_name_ << ' ' << atom_type_name_ << std::endl;
533  }
534  return false;
535  }
536 
537 private:
538  /// atom's name
540  /// atom's type name
542 };
543 
544 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
545 /// @brief set atom's chemical type
546 class SetIO_String : public PatchOperation {
547 public:
548  /// constructor
550  std::string const & name3,
551  char const name1
552  ):
553  name3_( name3 ),
554  name1_( name1 )
555  {}
556 
557  /// set atom's chemical type
558  bool
559  apply( ResidueType & rsd ) const
560  {
561  rsd.name3( name3_ );
562  rsd.name1( name1_ );
563  return false;
564  }
565 
566 private:
568  char const name1_;
569 };
570 
571 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
572 /// @brief set atom's MM chemical type
574 public:
575  /// constructor
577  std::string const & atom_name_in,
578  std::string const & mm_atom_type_name_in
579  ):
580  atom_name_( atom_name_in ),
581  mm_atom_type_name_( mm_atom_type_name_in )
582  {}
583 
584  /// set atom's chemical type
585  bool
586  apply( ResidueType & rsd ) const
587  {
588  if ( !rsd.has( atom_name_ ) ) {
589  TR_PatchOperations.Debug << "SetAtomType::apply failed: " << rsd.name() << " is missing atom: " << atom_name_ << std::endl;
590  return true; // failure
591  } else {
592  //std::cout << "SetAtomType::apply: " << atom_name_ << ' ' << mm_atom_type_name_ << std::endl;
594  }
595  return false;
596  }
597 
598 private:
599  /// atom's name
601  /// atom's type name
603 };
604 
605 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
606 /// @brief set an atom's AtomICoord
607 class SetICoor : public PatchOperation {
608 public:
609  /// constructor
611  std::string const & atom_in,
612  Real const phi_in,
613  Real const theta_in,
614  Real const d_in,
615  std::string const & stub1_in,
616  std::string const & stub2_in,
617  std::string const & stub3_in
618  ):
619  atom_( atom_in ),
620  phi_( phi_in ),
621  theta_( theta_in ),
622  d_( d_in ),
623  stub1_( stub1_in ),
624  stub2_( stub2_in ),
625  stub3_( stub3_in )
626  {}
627 
628  /// set an atom's AtomICoord
629  bool
630  apply( ResidueType & rsd ) const;
631 
632 private:
633  /// atom's name
635  /// AtomICoord data
642 };
643 
644 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
645 /// @brief add a mainchain atom before the first mainchain atom
647 public:
648  /// @brief constructor
649  PrependMainchainAtom( std::string const & atom_name_in ) :
650  atom_name_( atom_name_in )
651  {}
652 
653  /// @brief set an atom to be the first mainchain atom
654  bool
655  apply( ResidueType & rsd ) const
656  {
657  if ( !rsd.has( atom_name_ ) ) {
658  TR_PatchOperations.Debug << "PrependMainchainAtom::apply failed: " << rsd.name() << " is missing atom " << atom_name_ << std::endl;
659  return true; // failure
660  } else {
661  AtomIndices const & old_mainchain_atoms( rsd.mainchain_atoms() );
662  AtomIndices new_mainchain_atoms;
663  new_mainchain_atoms.push_back( rsd.atom_index( atom_name_ ) );
664  for ( Size i = 1; i <= old_mainchain_atoms.size(); ++i ) {
665  new_mainchain_atoms.push_back( old_mainchain_atoms[i] );
666  }
667  rsd.set_mainchain_atoms( new_mainchain_atoms );
668  }
669  return false;
670  }
671 
672 private:
674 };
675 
676 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
677 /// @brief add a mainchain atom after the last mainchain atom
679 public:
680  /// @brief constructor
681  AppendMainchainAtom( std::string const & atom_name_in ) :
682  atom_name_( atom_name_in )
683  {}
684 
685  /// @brief set an atom to be the last mainchain atom
686  bool
687  apply( ResidueType & rsd ) const
688  {
689  if ( !rsd.has( atom_name_ ) ) {
690  TR_PatchOperations.Debug << "AppendMainchainAtom::apply failed: " << rsd.name() << " is missing atom " << atom_name_ << std::endl;
691  return true; // failure
692  } else {
693  AtomIndices new_mainchain_atoms( rsd.mainchain_atoms() );
694  new_mainchain_atoms.push_back( rsd.atom_index( atom_name_ ) );
695  rsd.set_mainchain_atoms( new_mainchain_atoms );
696  }
697  return false;
698  }
699 
700 private:
702 };
703 
704 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
705 /// @brief set the residue neighbor atom
706 class SetNbrAtom : public PatchOperation {
707 public:
708  /// @brief constructor
709  SetNbrAtom( std::string const & atom_name_in ) :
710  atom_name_( atom_name_in )
711  {}
712 
713  /// @brief set the residue neighbor atom
714  bool
715  apply( ResidueType & rsd ) const
716  {
717  if ( !rsd.has( atom_name_ ) ) {
718  TR_PatchOperations.Debug << "SetNbrAtom::apply failed: " << rsd.name() << " is missing atom " << atom_name_ << std::endl;
719  return true; // failure
720  } else {
721  rsd.nbr_atom( atom_name_ );
722  }
723  return false;
724  }
725 
726 private:
728 };
729 
730 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
731 /// @brief set the residue neighbor radius
732 class SetNbrRadius : public PatchOperation {
733 public:
734  /// @brief constructor
735  SetNbrRadius( Real const & radius ) :
736  radius_( radius )
737  {}
738 
739  /// @brief set the residue neighbor atom
740  bool
741  apply( ResidueType & rsd ) const
742  {
743  rsd.nbr_radius( radius_ );
744  return false;
745  }
746 
747 private:
749 };
750 
751 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
752 /// @brief Set orient atom selection mode.
754  public:
755  SetOrientAtom(bool force_nbr_atom_orient):
756  force_nbr_atom_orient_(force_nbr_atom_orient)
757  {}
758 
759  bool
760  apply( ResidueType & rsd ) const
761  {
763  return false;
764  }
765 
766  private:
768 };
769 
770 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
771 /// @brief set the path to a rotamer library for an NCAA that is not in dunbrack
773 public:
774  /// @brief constructor
775  NCAARotLibPath( std::string const & path_in ) :
776  path_( path_in )
777  {}
778 
779  /// @brief set the NCAA rotamer library path in the residue type
780  bool
781  apply( ResidueType & rsd ) const
782  {
784  rsd.set_use_ncaa_rotlib( true );
785  return false;
786  }
787 
788 private:
790 };
791 
792 /// @brief Virtual constructor, returns 0 if no match
795 
796 
797 
798 } // chemical
799 } // core
800 
801 
802 
803 #endif