Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Residue.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 Residue.hh
11 /// @author Phil Bradley
12 
13 
14 #ifndef INCLUDED_core_conformation_Residue_hh
15 #define INCLUDED_core_conformation_Residue_hh
16 
17 
18 // Unit headers
20 
21 // Package headers
25 
28 #include <core/chemical/Atom.hh>
29 #include <core/chemical/Orbital.hh>
30 
31 
32 // Project headers
33 #include <core/chemical/AA.hh>
35 #include <core/chemical/ResidueType.hh> // also defines AtomIndices == vector1< Size >
41 #include <core/types.hh>
42 
43 // Utility headers
44 // AUTO-REMOVED #include <utility/vector1.hh>
45 #include <utility/pointer/access_ptr.hh>
46 #include <utility/pointer/owning_ptr.hh>
47 #include <utility/pointer/ReferenceCount.hh>
48 #include <numeric/xyzVector.hh>
49 #include <numeric/xyzMatrix.fwd.hh>
50 
51 // C++ headers
52 #include <map>
53 #include <iosfwd>
54 #include <limits>
55 
56 //#include <basic/options/keys/orbitals.OptionKeys.gen.hh>
57 // AUTO-REMOVED #include <basic/options/option.hh>
58 // AUTO-REMOVED #include <core/chemical/AtomType.hh>
59 
60 #include <utility/vector1.hh>
61 
62 
63 
64 namespace core {
65 namespace conformation {
66 
67 #ifdef USEBOOSTSERIALIZE
68 void add_cloned_ligand_rotamer_library( core::chemical::ResidueType & new_res, core::chemical::ResidueType const & base_res );
69 #endif
70 
71 ///@brief Instance Residue class, used for placed residues and rotamers
72 /**
73  This class is designed to be lightweight. It holds a const-reference ("rsd_type_")
74  to a ResidueType object for access to information common to all instances
75  of a single type, eg. Alanine or Thymine. Residue stores any data unique
76  to a placed residue or rotamer, currently:
77 
78  - a vector1 of Atoms which hold the positions (and also the atom-types for
79  fast access during scoring);
80 
81  - the sequence position and chain, both integers
82 
83  - the backbone and sidechain torsion angles (of course backbone torsions are
84  not unique to a rotamer, and the chi angles are derivable from the coordinates,
85  but storing them in the residue is convenient for scoring purposes).
86 
87  - the coordinates of an interaction center or centroid, used eg. in the
88  knowledge-based fullatom pair term ("actcoord_"). Maybe this will also
89  hold the centroid position for centroid-mode scoring??
90 
91  **/
92 
94 
95 public:
99 
100 public:
101 
102  /// @brief constructors
103  /// Residue( Residue const & ); // user defined copy ctor to avoid #including PseudoBond.hh
104  /// Residue const & operator = ( Residue const & ) // user defined assignment operator for same reason
105  Residue( ResidueType const & rsd_type_in, bool const dummy_arg );
106 // this is for boost serialize
107  Residue( ResidueType const & rsd_type_in, bool const /*dummy_arg*/, bool const /*dummy_arg2*/ ) :
108  utility::pointer::ReferenceCount(), rsd_type_(rsd_type_in) {}
109 
110  /// @brief Rotamer-style constructor; orients ideal coords onto backbone of current_rsd
111  Residue(
112  ResidueType const & rsd_type_in,
113  Residue const & current_rsd,
114  Conformation const & conformation,
115  bool preserve_c_beta = false
116  );
117 
118  Residue( Residue const & src );
119 
120  ~Residue();
121 
122  ///@brief Copy this residue( allocate actual memory for it )
123  ResidueOP
124  clone() const;
125 
126  //////////////////////////////////////////////////////////////////////
127  //////////////////////////////////////////////////////////////////////
128  //////////////////////////////////////////////////////////////////////
129  ///////////////// Atom Functions ////////////////////////
130  //////////////////Atom Functions /////////////////////////
131  //////////////////////////////////////////////////////////////////////
132  //////////////////////////////////////////////////////////////////////
133 
134  /// @brief Returns the AtomType of this residue's atom with index number <atomno>
135  ///
136  /// example(s):
137  /// residue.atom_type(3)
138  /// See also:
139  /// Residue
140  /// Residue.atom_index
141  /// AtomType
142  /// Pose
143  AtomType const &
144  atom_type( int const atomno ) const
145  {
146  return rsd_type_.atom_type( atomno );
147  }
148 
149  /// @brief Returns the AtomTypeSet of this residue
150  ///
151  /// example(s):
152  /// residue.atom_type_set()
153  /// See also:
154  /// Residue
155  /// Residue.atom_type_index
156  /// AtomType
157  /// Pose
158  chemical::AtomTypeSet const &
160  {
161  return rsd_type_.atom_type_set();
162  }
163 
164  /// @brief Returns the atom_type_index of this residue's atom with index number <atomno>
165  /// atom_type_index is used to query this atom's AtomType from an AtomTypeSet,
166  /// example: AtomTypeSet[atom_type_index] = AtomType
167  ///
168  /// example(s):
169  /// residue.atom_type_index(3)
170  /// See also:
171  /// Residue
172  /// Residue.atom_index
173  /// AtomType
174  /// Pose
175  Size
176  atom_type_index( Size const atomno ) const;
177 
178  /// @brief Returns the atom charge of this residue's atom with index number <atomno>
179  ///
180  /// example(s):
181  /// residue.atomic_charge(3)
182  /// See also:
183  /// Residue
184  /// Residue.atom_index
185  /// Pose
186  Real
187  atomic_charge( int const atomno ) const;
188 
189  /// @brief Check if atom is virtual.
190  bool
191  is_virtual( Size const & atomno ) const;
192 
193  /// @brief Check if residue is virtual.
194  bool
196  {
197  return rsd_type_.is_virtual_residue();
198  }
199 
200  /// @brief Returns the index number of the <atm> in this residue
201  /// example: residue.atom_index("CA") returns 2 for a normal amino acid
202  ///
203  /// example(s):
204  /// residue.atom_index("CA")
205  /// See also:
206  /// Residue
207  /// AtomType
208  /// Pose
209  Size
210  atom_index( std::string const & atm ) const
211  {
212  return rsd_type_.atom_index( atm );
213  }
214 
215  /// @brief Returns the number of atoms in this residue
216  ///
217  /// example(s):
218  /// residue.natoms()
219  /// See also:
220  /// Residue
221  /// Pose
222  Size
223  natoms() const
224  {
225  return rsd_type_.natoms();
226  }
227 
228  /// @brief number of hbond_donors
229  Size
231  {
232  return rsd_type_.n_hbond_acceptors();
233  }
234 
235  /// @brief number of hbond_donors
236  Size
238  {
239  return rsd_type_.n_hbond_donors();
240  }
241 
242  /// @brief Returns the number of heavyatoms in this residue
243  ///
244  /// example(s):
245  /// residue.nheavyatoms()
246  /// See also:
247  /// Residue
248  /// Pose
249 
250  Size
251  nheavyatoms() const
252  {
253  return rsd_type_.nheavyatoms();
254  }
255 
256 
257  // NOTE: AtomIndices == vector1< Size >
258 
259  /// @brief Returns the AtomIndices of this residue's polar hydrogens
260  /// @note: AtomIndices == vector1< Size >
261  ///
262  /// example(s):
263  /// residue.Hpos_polar()
264  /// See also:
265  /// Residue
266  /// Residue.atoms
267  /// Residue.Hpol_index
268  /// Residue.Hpos_apolar
269  /// Pose
270  AtomIndices const &
271  Hpos_polar() const
272  {
273  return rsd_type_.Hpos_polar();
274  }
275 
276 
277  /// @brief Returns the AtomIndices of this residue's backbone atoms
278  /// @note: heavyatoms and hydrogens, AtomIndices == vector1< Size >
279  ///
280  /// example(s):
281  /// residue.all_bb_atoms()
282  /// See also:
283  /// Residue
284  /// Residue.atoms
285  /// Pose
286  AtomIndices const &
287  all_bb_atoms() const {
288  return rsd_type_.all_bb_atoms();
289  }
290 
291  /// @brief Returns the AtomIndices of this residue's aromatic hydrogens
292  /// @note: AtomIndices == vector1< Size >
293  ///
294  /// example(s):
295  /// residue.Haro_index()
296  /// See also:
297  /// Residue
298  /// Residue.atoms
299  /// Residue.Hpol_index
300  /// Pose
301  AtomIndices const &
302  Haro_index() const{
303  return rsd_type_.Haro_index();
304  }
305 
306  /// @brief Returns the AtomIndices of this residue's polar hydrogens
307  /// @note: AtomIndices == vector1< Size >
308  ///
309  /// example(s):
310  /// residue.Hpol_index()
311  /// See also:
312  /// Residue
313  /// Residue.atoms
314  /// Residue.Hpol_index
315  /// Residue.Hpos_apolar
316  /// Residue.Hpos_polar
317  /// Pose
318  AtomIndices const &
319  Hpol_index() const{
320  return rsd_type_.Hpol_index();
321  }
322 
323  /// @brief Returns the AtomIndices of this residue's apolar hydrogens
324  /// @note: AtomIndices == vector1< Size >
325  ///
326  /// example(s):
327  /// residue.Hpos_apolar()
328  /// See also:
329  /// Residue
330  /// Residue.atoms
331  /// Residue.Hpol_index()
332  /// Residue.Hpos_polar
333  /// Pose
334  AtomIndices const &
335  Hpos_apolar() const
336  {
337  return rsd_type_.Hpos_apolar();
338  }
339 
340  /// @brief Returns the AtomIndices of this residue's polar sidechain hydrogens
341  /// @note: AtomIndices == vector1< Size >
342  ///
343  /// example(s):
344  /// residue.Hpos_polar_sc()
345  /// See also:
346  /// Residue
347  /// Residue.atoms
348  /// Residue.Hpol_index
349  /// Residue.Hpos_polar
350  /// Pose
351  AtomIndices const &
353  {
354  return rsd_type_.Hpos_polar_sc();
355  }
356 
357 
358 
359 
360  /// @brief Returns the AtomIndices of this residue's h-bond acceptor atoms
361  /// @note: AtomIndices == vector1< Size >
362  ///
363  /// example(s):
364  /// residue.accpt_pos()
365  /// See also:
366  /// Residue
367  /// Residue.accpt_pos_sc
368  /// Residue.atoms
369  /// Pose
370  AtomIndices const &
371  accpt_pos() const
372  {
373  return rsd_type_.accpt_pos();
374  }
375 
376  /// @brief Returns the AtomIndices of this residue's sidechain h-bond acceptor atoms
377  /// @note: AtomIndices == vector1< Size >
378  ///
379  /// example(s):
380  /// residue.accpt_pos_sc()
381  /// See also:
382  /// Residue
383  /// Residue.accpt_pos
384  /// Residue.atoms
385  /// Pose
386  AtomIndices const &
387  accpt_pos_sc() const
388  {
389  return rsd_type_.accpt_pos_sc();
390  }
391 
392  /// @brief Is a particular atom a heavy atom with chemically bound polar hydrogens? (i.e. a donor heavy atom)
393  bool
396  }
397 
398  /// @brief Is a particular atom a heavy atom acceptor?
399  bool
401  return rsd_type_.heavyatom_is_an_acceptor( ind );
402  }
403 
404  /// @brief Is a particular atom a polar hydrogen?
405  bool
407  return rsd_type_.atom_is_polar_hydrogen( ind );
408  }
409 
410 
411  ///@brief Returns this residue's Atoms (const), a vector1 of Atom objects
412  ///
413  /// example(s):
414  /// residue.atoms()
415  /// See also:
416  /// Residue
417  /// Pose
418  Atoms const &
419  atoms() const
420  {
421  return atoms_;
422  }
423 
424  ///@brief Returns this residue's Atoms (non-const), a vector1 of Atom objects
425  ///
426  /// example(s):
427  /// residue.atoms()
428  /// See also:
429  /// Residue
430  /// Pose
431  Atoms &
433  {
434  return atoms_;
435  }
436 
437  /// @brief begin interator, to iterate over atoms
438  Atoms::iterator atom_begin() { return atoms_.begin(); }
439  /// @brief end interator, to iterate over atoms
440  Atoms::iterator atom_end () { return atoms_.end (); }
441 
442  Atoms::const_iterator atom_begin() const { return atoms_.begin(); }
443  Atoms::const_iterator atom_end () const { return atoms_.end (); }
444 
445  /// @brief should be safe, given the atom ordering rules?
446  Atoms::const_iterator sidechainAtoms_begin() const
447  {
448  return atoms_.begin() + first_sidechain_atom() - 1;
449  }
450  Atoms::const_iterator heavyAtoms_end() const
451  {
452  return atoms_.begin() + nheavyatoms();
453  }
454 
455  /// @brief Returns this residue's Atom with index number <atm_index> (const)
456  /// @note: Atom object is xyz and atom_type
457  ///
458  /// example(s):
459  /// residue.atom(3)
460  /// See also:
461  /// Residue
462  /// Residue.atoms
463  /// Pose
464  Atom const &
465  atom( Size const atm_index ) const
466  {
467  return atoms_[ atm_index ];
468  }
469 
470  /// @brief Returns this residue's Atom with index number <atm_index> (non-const)
471  /// @note: Atom object is xyz and atom_type
472  ///
473  /// example(s):
474  /// residue.atom(3)
475  /// See also:
476  /// Residue
477  /// Residue.atoms
478  /// Pose
479  Atom &
480  atom( Size const atm_index )
481  {
482  return atoms_[ atm_index ];
483  }
484 
485 
486  /// @brief Returns this residue's Atom with name <atm_name> (const)
487  /// @note: Atom object is xyz and atom_type, slower but safer than hard-coding an integer index in code where you need a specific atom
488  ///
489  /// example(s):
490  /// residue.atom(3)
491  /// See also:
492  /// Residue
493  /// Residue.atoms
494  /// Pose
495  Atom const &
496  atom( std::string const & atm_name ) const
497  {
498  return atoms_[ atom_index( atm_name ) ];
499  }
500 
501  /// @brief Returns this residue's Atom with name <atm_name> (non-const)
502  /// @note: Atom object is xyz and atom_type, slower but safer than hard-coding an integer index in code where you need a specific atom
503  ///
504  /// example(s):
505  /// residue.atom(3)
506  /// See also:
507  /// Residue
508  /// Residue.atoms
509  /// Pose
510  Atom &
511  atom( std::string const & atm_name )
512  {
513  return atoms_[ atom_index( atm_name ) ];
514  }
515 
516  /// @brief Returns the position of this residue's atom with index number <atm_index>
517  /// @note: position is a Vector
518  ///
519  /// example(s):
520  /// residue.xyz(3)
521  /// See also:
522  /// Residue
523  /// Residue.atom
524  /// Residue.atoms
525  /// Residue.set_xyz
526  /// Pose
527  Vector const &
528  xyz( Size const atm_index ) const;
529 
530  /// @brief Returns the position of this residue's atom with name <atm_name>
531  /// @note: position is a Vector
532  ///
533  /// example(s):
534  /// residue.xyz("CA")
535  /// See also:
536  /// Residue
537  /// Residue.atom
538  /// Residue.atoms
539  /// Residue.set_xyz
540  /// Pose
541  Vector const &
542  xyz( std::string const & atm_name ) const;
543 
544 
545  /// @brief Sets the position of this residue's atom with index number <atm_index>
546  ///
547  /// example(s):
548  ///
549  /// See also:
550  /// Residue
551  /// Residue.atom
552  /// Residue.atoms
553  /// Residue.xyz
554  /// Pose
555  void
556  set_xyz( core::Size const atm_index, Vector const & xyz_in );
557 
558  /// @brief Sets the position of this residue's atom with name <atm_name>
559  ///
560  /// example(s):
561  ///
562  /// See also:
563  /// Residue
564  /// Residue.atom
565  /// Residue.atoms
566  /// Residue.xyz
567  /// Pose
568  void
569  set_xyz( std::string const & atm_name, Vector const & xyz_in );
570 
571  /// @brief Returns the index number of the last backbone heavyatom
572  /// @note The heavyatoms come first in atom ordering,
573  /// first backbone then sidechain, hydrogens follow the order
574  /// of their attached heavyatom.
575  ///
576  /// example(s):
577  /// residue.last_backbone_atom()
578  /// See also:
579  /// Residue
580  /// Residue.atom
581  /// Residue.atoms
582  /// Residue.first_sidechain_atom
583  /// Pose
584  Size
586  {
587  return rsd_type_.last_backbone_atom();
588  }
589 
590  /// @brief Returns the index number of the first sidechain heavyatom
591  ///
592  /// example(s):
593  /// residue.first_sidechain_atom()
594  /// See also:
595  /// Residue
596  /// Residue.atom
597  /// Residue.atoms
598  /// Residue.last_backbone_atom
599  /// Pose
600  Size
602  {
604  }
605 
606  /// @brief Returns the index number of the first sidechain hydrogen
607  ///
608  /// example(s):
609  /// residue.first_sidechain_hydrogen()
610  /// See also:
611  /// Residue
612  /// Residue.atom
613  /// Residue.atoms
614  /// Residue.first_sidechain_atom
615  /// Pose
616  Size
618  {
620  }
621 
622 
623  /// @brief Returns the index number of the first hydrogen attached to the atom
624  /// with index number <atom>
625  ///
626  /// example(s):
627  /// residue.attached_H_begin()
628  /// See also:
629  /// Residue
630  /// Residue.atom
631  /// Residue.atoms
632  /// Residue.attached_H_end
633  /// Pose
634  Size
635  attached_H_begin( int const atom ) const
636  {
637  return rsd_type_.attached_H_begin( atom );
638  }
639 
640  /// @brief Returns the index number of the last hydrogen attached to the atom
641  /// with index number <atom>
642  ///
643  /// example(s):
644  /// residue.attached_H_end()
645  /// See also:
646  /// Residue
647  /// Residue.atom
648  /// Residue.atoms
649  /// Residue.attached_H_begin
650  /// Pose
651  Size
652  attached_H_end( int const atom ) const
653  {
654  return rsd_type_.attached_H_end( atom );
655  }
656 
657  /// @brief Returns the AtomIndices of the first hydrogen attached to each heavyatom
658  ///
659  /// example(s):
660  /// residue.attached_H_begin()
661  /// See also:
662  /// Residue
663  /// Residue.atom
664  /// Residue.atoms
665  /// Residue.attached_H_end
666  /// Residue.nheavyatoms
667  /// Pose
668  AtomIndices const &
670  {
671  return rsd_type_.attached_H_begin();
672  }
673 
674  /// @brief Returns the AtomIndices of the last hydrogen attached to each heavyatom
675  ///
676  /// example(s):
677  /// residue.attached_H_end()
678  /// See also:
679  /// Residue
680  /// Residue.atom
681  /// Residue.atoms
682  /// Residue.attached_H_begin
683  /// Residue.nheavyatoms
684  /// Pose
685  AtomIndices const &
687  {
688  return rsd_type_.attached_H_end();
689  }
690 
691 
692  /// @brief Returns the index number of this residue's atom which connects to
693  /// the residue before it in sequence
694  /// @note: polymers only, example: for an amino acid, residue.lower_connect_atom() = atom_index("N")
695  ///
696  /// example(s):
697  /// residue.lower_connect_atom()
698  /// See also:
699  /// Residue
700  /// Residue.atom
701  /// Residue.atoms
702  /// Residue.upper_connect_atom
703  /// Pose
704  Size
706  {
707  return rsd_type_.lower_connect_atom();
708  }
709 
710  /// @brief Returns the index number of this residue's atom which connects to
711  /// the residue after it in sequence
712  /// @note: polymers only, example: for an amino acid, residue.upper_connect_atom() = atom_index("C")
713  ///
714  /// example(s):
715  /// residue.upper_connect_atom()
716  /// See also:
717  /// Residue
718  /// Residue.atom
719  /// Residue.atoms
720  /// Residue.lower_connect_atom
721  /// Pose
722  Size
724  {
725  return rsd_type_.upper_connect_atom();
726  }
727 
728  /// @brief Returns the index number of this residue's atom connected to the <other> Residue
729  ///
730  /// example(s):
731  ///
732  /// See also:
733  /// Residue
734  /// Residue.atom
735  /// Residue.atoms
736  /// Residue.lower_connect_atom
737  /// Residue.upper_connect_atom
738  /// Pose
739 
740  Size
741  connect_atom( Residue const & other ) const;
742 
743  /// @brief Returns the shortest path distance from <atom> to any other atom in this residue
744  ///
745  /// example(s):
746  ///
747  /// See also:
748  /// Residue
749  /// Residue.atom
750  /// Residue.atoms
751  /// Pose
753  path_distance( int atom ) const
754  {
755  return rsd_type_.path_distance( atom );
756  }
757 
758  /// @brief Returns the shortest path distance for any atom pair in this residue
759  /// example: path_distances()[atom1][atom2]
760  ///
761  /// example(s):
762  ///
763  /// See also:
764  /// Residue
765  /// Residue.atom
766  /// Residue.atoms
767  /// Residue.path_distance
768  /// Pose
771  {
772  return rsd_type_.path_distances();
773  }
774  /// @brief Returns the number of bonds separating atom <at1> from <at2>
775  ///
776  /// example(s):
777  ///
778  /// See also:
779  /// Residue
780  /// Residue.atom
781  /// Residue.atoms
782  /// Residue.path_distance
783  /// Pose
784  int
785  path_distance( int at1, int at2 ) const
786  {
787  return rsd_type_.path_distance( at1, at2 );
788  }
789 
790  /// @brief Returns true if this residue's atom with index number <atomno> is a backbone atom
791  ///
792  /// example(s):
793  /// residue.atom_is_backbone(3)
794  /// See also:
795  /// Residue
796  /// Residue.all_bb_atoms
797  /// Residue.atom
798  /// Residue.atoms
799  /// Pose
800  bool
801  atom_is_backbone( int const atomno ) const
802  {
803  return rsd_type_.atom_is_backbone( atomno );
804  }
805 
806  /// @brief Returns true if this residue's atom with index number <atomno> is a hydrogen
807  ///
808  /// example(s):
809  /// residue.atom_is_backbone(3)
810  /// See also:
811  /// Residue
812  /// Residue.all_bb_atoms
813  /// Residue.atom
814  /// Residue.atoms
815  /// Pose
816  bool
817  atom_is_hydrogen( Size const atomno ) const
818  {
819  return rsd_type_.atom_is_hydrogen( atomno );
820  }
821 
822 
823  /// @brief Returns the atom index of the <atomno> atom's base atom
824  Size
825  atom_base( int const atomno ) const
826  {
827  return rsd_type_.atom_base( atomno );
828  }
829 
830  /// @brief Returns the atom index of the <atomno> atom's second base atom
831  /// note: abase2 is this atom's first bonded neighbor other than
832  /// this atom's base atom (unless it has only one neighbor)
833  Size
834  abase2( int const atomno ) const
835  {
836  return rsd_type_.abase2( atomno );
837  }
838 
839  /// @brief Returns the AtomIndices for all bonded neighbor atoms of <atm>
840  AtomIndices const &
841  bonded_neighbor( int const atm ) const
842  {
843  return rsd_type_.bonded_neighbor( atm );
844  }
845 
846  /// @brief Returns the number of chi angles this residue has
847  ///
848  /// example(s):
849  /// residue.nchi()
850  /// See also:
851  /// Residue
852  /// Pose
853  /// Pose.chi
854  /// Pose.set_chi
855  Size
856  nchi() const
857  {
858  return rsd_type_.nchi();
859  }
860 
861 
862  /// @brief Returns the AtomIndices of this residue's mainchain atoms
863  AtomIndices const &
865  {
866  return rsd_type_.mainchain_atoms();
867  }
868 
869  /// @brief ??? Returns the number of the residue's mainchain atoms
870  Size
871  mainchain_atom( Size const atm ) const
872  {
873  return rsd_type_.mainchain_atom( atm );
874  }
875 
876  /// @brief Returns the number of the residue's mainchain atoms
877  Size
879  {
880  return rsd_type_.mainchain_atoms().size();
881  }
882 
883 
884  /// @brief Returns the AtomIndices of atoms that will be used to define this residue's actcoord.
885  AtomIndices const &
887  {
888  return rsd_type_.actcoord_atoms();
889  }
890 
891 
892  /// @brief Return coordinates for building an atom from ideal internal coordinates,
893  /// used for building missing atoms
894  Vector
896  int const atomno,
897  Conformation const & conformation // necessary for context, eg the C of the preceding residue for HN
898  ) const
899  {
900  return icoor( atomno ).build( *this, conformation );
901  }
902 
903  /// @brief Returns the index number of this residue's atom used as a center for neighbor definition
904  /// example: C-beta atom for some amino acids
905  Size
906  nbr_atom() const
907  {
908  return rsd_type_.nbr_atom();
909  }
910 
911  /// @brief Returns the distance cutoff value used as a radius for neighbor definition
912  Real
913  nbr_radius() const
914  {
915  return rsd_type_.nbr_radius();
916  }
917 
918  ///
919  Vector const &
920  nbr_atom_xyz() const
921  {
922  return atoms_[ rsd_type_.nbr_atom() ].xyz();
923  }
924 
925 
926  //////////////////////////////////////////////////////////////////////
927  //////////////////////////////////////////////////////////////////////
928  //////////////////////////////////////////////////////////////////////
929  ///////////////// Orbital Functions //////////////////////
930  //////////////// Orbital Functions //////////////////////
931  //////////////////////////////////////////////////////////////////////
932  //////////////////////////////////////////////////////////////////////
933 
934  /// @brief
935  AtomIndices const &
937  {
939  }
940 
941  //Vector const
942  //orbital_xyz(Size const orbital_index) const;
943 
944 
945  Vector
946  build_orbital_xyz( Size const orbital_index ) const
947  {
948 /* core::chemical::orbitals::ICoorOrbitalData orb_icoor(rsd_type_.orbital_icoor_data(orbital_index));
949  Vector stub1_xyz(this->atom(orb_icoor.stub1()).xyz());
950  Vector stub2_xyz(this->atom(orb_icoor.stub2()).xyz());
951  Vector stub3_xyz(this->atom(orb_icoor.stub3()).xyz());
952  Vector orbital_vector(orb_icoor.build(stub1_xyz, stub2_xyz, stub3_xyz));
953 
954  //return orbitals_[ orbital_index ].xyz();
955  return orbital_vector;*/
956 
958  Vector stub1_xyz(this->atom(orb_icoor.get_stub1()).xyz());
959  Vector stub2_xyz(this->atom(orb_icoor.get_stub2()).xyz());
960  Vector stub3_xyz(this->atom(orb_icoor.get_stub3()).xyz());
961 
962  Vector orbital_vector(orb_icoor.build(stub1_xyz, stub2_xyz, stub3_xyz));
963  return orbital_vector;
964  }
965 
966 
967  Vector const &
968  orbital_xyz( Size const orbital_index ) const
969  {
970  return orbitals_[orbital_index].xyz();
971  }
972 
973  void
974  set_orbital_xyz( core::Size const orbital_index, Vector const & xyz_in )
975  {
976  orbitals_[ orbital_index ].xyz( xyz_in );
977  orbitals_[orbital_index].type(rsd_type_.orbital(orbital_index).orbital_type_index() );
978  }
979 
980 
981  /// @brief Returns the number of orbitals in this residue
982  Size
983  n_orbitals() const
984  {
985  return rsd_type_.n_orbitals();
986  }
987 
988 
990  bonded_orbitals(int const atm) const{
991  return rsd_type_.bonded_orbitals(atm);
992  }
993 
994 
995  std::string const &
996  orbital_name(int const orbital_index) const{
997  return rsd_type_.orbital(orbital_index).name();
998  }
999 
1001  orbital_type(int const orbital_index) const{
1002  return rsd_type_.orbital_type(orbital_index);
1003  }
1004 
1005  Size
1006  orbital_type_index( Size const orbital_index ) const
1007  {
1008  return orbitals_[ orbital_index ].type();
1009  }
1010 
1011  void
1013  for(
1016  atoms_with_orb_index_end = rsd_type_.atoms_with_orb_index().end();
1017  atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
1018  ){
1020  for(
1022  orbital_index = orbital_indices.begin(),
1023  orbital_index_end = orbital_indices.end();
1024  orbital_index != orbital_index_end; ++orbital_index
1025  ){
1026  Vector orb_xyz(this->build_orbital_xyz(*orbital_index));
1027  this->set_orbital_xyz(*orbital_index, orb_xyz );
1028  }
1029  }
1030  }
1031 
1032 
1033  //////////////////////////////////////////////////////////////////////
1034  //////////////////////////////////////////////////////////////////////
1035  //////////////////////////////////////////////////////////////////////
1036  ///////////////// Residue Functions //////////////////////
1037  //////////////// Residue Functions //////////////////////
1038  //////////////////////////////////////////////////////////////////////
1039  //////////////////////////////////////////////////////////////////////
1040 
1041 
1042  /// @brief Returns a ResidueOP for creating a rotamer of this residue
1043  /// Temporary hack until Residue hierarchy is worked out
1044  ResidueOP
1046  {
1047  return clone();
1048  }
1049 
1050  /// @brief Returns a ResidueOP for creating a copy of residue, same as clone()
1051  /// Temporary hack until Residue hierarchy is worked out
1052  ResidueOP
1054  {
1055  return clone();
1056  }
1057 
1058  /// @brief Returns this residue's ResidueType
1059  ///
1060  /// example(s):
1061  /// residue.type()
1062  /// See also:
1063  /// Residue
1064  /// Residue.atom_type
1065  ResidueType const &
1066  type() const
1067  {
1068  return rsd_type_;
1069  }
1070 
1071  /// @brief Returns this residue's ResidueTypeSet
1072  chemical::ResidueTypeSet const &
1074  {
1075  return rsd_type_.residue_type_set();
1076  }
1077 
1078 
1079  ///@brief Returns this residue's upper_connection
1080  /// a ResidueConnection has internal coords info
1081  /// on how to build the atom in the next residue which
1082  /// connects to this residue
1085  {
1086  return rsd_type_.upper_connect();
1087  }
1088 
1089  /// @brief Returns this residue's lower_connection
1090  /// a ResidueConnection has internal coords info
1091  /// on how to build the atom in the previous residue which
1092  /// connects to this residue
1095  {
1096  return rsd_type_.lower_connect();
1097  }
1098 
1099  /// Returns true if ???
1100  bool connections_match( Residue const & other ) const;
1101 
1102  /// @brief Returns the number of ResidueConnections on this residue
1103  /// including polymeric residue connections
1104  Size
1106  {
1108  }
1109 
1110  /// @brief Returns the number of polymeric ResidueConnections on this residue
1111  Size
1114  }
1115 
1116  /// @brief Returns the number of non-polymeric ResidueConnections on this residue
1117  Size
1120  }
1121 
1122 
1123  /// @brief Returns this residue's ResidueConnection
1124  /// a ResidueConnection has internal coords info
1125  /// on how to build the atom in a different residue which
1126  /// connects to this residue
1128  residue_connection( int const resconn_index ) const
1129  {
1130  return rsd_type_.residue_connection( resconn_index );
1131  }
1132 
1133  Size
1134  residue_connect_atom_index( Size const resconn_id ) const {
1135  return rsd_type_.residue_connect_atom_index( resconn_id );
1136  }
1137 
1138 
1139  Size
1140  connected_residue_at_resconn( Size const resconn_index ) const {
1141  return connect_map_[ resconn_index ].resid();
1142  }
1143 
1145  connect_map( Size resconn_index ) const {
1146  return connect_map_[ resconn_index ];
1147  }
1148 
1149  void
1151 
1152  void
1153  copy_residue_connections_from( Residue const & src );
1154 
1155  bool
1156  has_incomplete_connection() const;
1157 
1158  /// @brief Returns true is <atomno> has complete connectivity?
1159  bool
1161  core::Size const atomno
1162  ) const;
1163 
1164  bool
1165  connection_incomplete( Size resconnid ) const;
1166 
1168  actual_residue_connection( Size resconnid ) const {
1169  return connect_map_[ resconnid ];
1170  }
1171 
1172  /// @brief Returns the residue number of a residue connected to this residue
1173  /// with ResidueConnection <resconn_index> ?
1174  Size
1175  residue_connection_partner( Size const resconn_index ) const
1176  {
1177  return connect_map_[ resconn_index ].resid();
1178  }
1179 
1180  /// attempt to take residue connection info from src_rsd
1181  void
1182  copy_residue_connections( Residue const & src_rsd );
1183 
1184 
1185  /// @brief Returns the residue number of a residue connected to this residue
1186  /// with ResidueConnection <resconn_index> ?
1187  Size
1188  residue_connection_conn_id( Size const resconn_index ) const
1189  {
1190  return connect_map_[ resconn_index ].connid();
1191  }
1192 
1193 
1194  /// @brief set a connection to this residue by adding its partner's residue number
1195  void
1197  Size const resconn_index, // ie, our connid
1198  Size const otherres,
1199  Size const other_connid
1200  );
1201 
1202  /// @brief Distance between a potential residue connection match and the position of the expected atom
1203  Distance
1205  conformation::Conformation const & conf,
1206  Size const resconn_index,
1207  Vector const matchpoint
1208  ) const;
1209 
1210  /// @brief Am I bonded to other?
1211  /// Meaningful for arbitrary topologies (e.g. circular peptides, disulfides)
1212  bool
1213  is_bonded( Residue const & other ) const;
1214 
1215  /// @brief Do I have any pseudobonds to other?
1216  bool
1217  is_pseudo_bonded( Residue const & other ) const
1218  {
1219  return is_pseudo_bonded( other.seqpos() );
1220  }
1221 
1222  /// @brief Am I bonded to other?
1223  /// Looks at all residue connections as opposed to doing arithmetic
1224  bool
1225  is_bonded( Size const other_index ) const;
1226 
1227  /// @brief Do I have any pseudobonds to other?
1228  bool
1229  is_pseudo_bonded( Size const other_index ) const
1230  {
1231  return pseudobonds_.find( other_index ) != pseudobonds_.end();
1232  }
1233 
1234  /// @brief Am I polymer bonded to other?
1235  bool
1236  is_polymer_bonded( Residue const & other ) const;
1237 
1238  /// @brief Am I polymer-bonded to other? checks lower and upper connections
1239  bool
1240  is_polymer_bonded( Size const other_index ) const;
1241 
1242 
1243  /// @brief Returns the vector1 of resconn ids that connect this residue to other
1244  utility::vector1< Size > const &
1245  connections_to_residue( Residue const & other ) const
1246  {
1247  return connections_to_residue( other.seqpos() );
1248  }
1249 
1250  /// @brief Returns the vector1 of resconn ids that connect this residue to other
1251  utility::vector1< Size > const &
1252  connections_to_residue( Size const other_resid ) const
1253  {
1254  assert( connections_to_residues_.find( other_resid ) != connections_to_residues_.end() );
1255  return connections_to_residues_.find( other_resid )->second;
1256  }
1257 
1259  get_pseudobonds_to_residue( Size resid ) const;
1260 
1261  std::map< Size, PseudoBondCollectionCOP > const &
1262  pseudobonds() const {
1263  return pseudobonds_;
1264  }
1265 
1266 
1267  void
1269 
1270 
1271 
1272  /// @brief Returns the chi rotamers available for this residue's chi angle <chino>
1274  chi_rotamers( Size const chino ) const
1275  {
1276  return rsd_type_.chi_rotamers( chino );
1277  }
1278 
1279 
1280 
1281 
1282 
1283  /// @brief atom indices for bonded neighbors to which atom-tree connections are disallowed.
1284  AtomIndices const &
1285  cut_bond_neighbor( int const atm ) const
1286  {
1287  return rsd_type_.cut_bond_neighbor( atm );
1288  }
1289 
1290 
1291  /// @brief Returns the number of atoms bonded to <atomno> in all residues?
1292  core::Size
1294  core::Size const atomno,
1295  bool virt = false
1296  ) const;
1297 
1298 
1299  /// @brief Convenience synonym for bonded_neighbor
1300  AtomIndices const &
1301  nbrs( int const atm ) const
1302  {
1303  return rsd_type_.bonded_neighbor( atm );
1304  }
1305 
1306 
1307  /// @brief Returns the mainchain torsion angles of this residue (const)
1308  ///
1309  /// example(s):
1310  /// residue.mainchain_torsions()
1311  /// See also:
1312  /// Residue
1313  /// Pose
1314  /// Pose.omega
1315  /// Pose.phi
1316  /// Pose.psi
1317  utility::vector1< Real > const &
1319  {
1320  return mainchain_torsions_;
1321  }
1322 
1323  /// @brief Returns the mainchain torsion angles of this residue (non-const)
1326  {
1327  return mainchain_torsions_;
1328  }
1329 
1330  /// @brief Sets the mainchain torsion angles of this residue to <torsions>
1331  ///
1332  /// example(s):
1333  /// residue.mainchain_torsions()
1334  /// See also:
1335  /// Residue
1336  /// Pose
1337  /// Pose.set_omega
1338  /// Pose.set_phi
1339  /// Pose.set_psi
1340  void
1342  mainchain_torsions_ = torsions;
1343  }
1344 
1345  /// @brief Returns the chi torsion angles of this residue (const)
1346  ///
1347  /// example(s):
1348  /// residue.chi()
1349  /// See also:
1350  /// Residue
1351  /// Residue.nchi
1352  /// Pose
1353  /// Pose.chi
1354  utility::vector1< Real > const &
1355  chi() const
1356  {
1357  return chi_;
1358  }
1359 
1360  /// @brief Returns the chi torsion angles of this residue (non-const)
1363  {
1364  return chi_;
1365  }
1366 
1367  /// @brief Sets the chi torsion angles of this residue
1368  ///
1369  /// CAUTION: This function does not cause updating to any internal coordinate data.
1370  /// See Residue::set_chi() and Residue::set_all_chi() functions for
1371  /// versions which handle coordinate updates.
1372  ///
1373  /// example(s):
1374  ///
1375  /// See also:
1376  /// Residue
1377  /// Pose
1378  /// Pose.set_chi
1379  void
1380  chi( utility::vector1< Real > const & chis ) {
1381  chi_ = chis;
1382  }
1383 
1384 
1385  /// @brief Returns the AtomIndices of each four atom set defining a chi angle
1387  chi_atoms() const
1388  {
1389  return rsd_type_.chi_atoms();
1390  }
1391 
1392  /// @brief Returns the AtomIndices of the four atoms defining
1393  /// this residue's <chino> chi angle
1394  AtomIndices const &
1395  chi_atoms( int const chino ) const
1396  {
1397  return rsd_type_.chi_atoms( chino );
1398  }
1399 
1400  /// @brief Returns a specific mainchain torsion angle for this residue
1401  /// example: mainchain_torsion(2) will be the psi angle for an amino acid
1402  ///
1403  /// example(s):
1404  /// residue.mainchain_torsion(2)
1405  /// See also:
1406  /// Residue
1407  /// Pose
1408  /// Pose.omega
1409  /// Pose.phi
1410  /// Pose.psi
1411  Real
1412  mainchain_torsion( Size const torsion ) const
1413  {
1414  return mainchain_torsions_[ torsion ];
1415  }
1416 
1417 
1418 
1419  /// @brief get a specific chi torsion angle
1420  ///
1421  /// example(s):
1422  /// residue.chi(1)
1423  /// See also:
1424  /// Residue
1425  /// Pose
1426  /// Pose.chi
1427  Real
1428  chi( Size const chino ) const
1429  {
1430  return chi_[ chino ];
1431  }
1432 
1433  /// @brief Returns the sequence position of this residue
1434  Size
1435  seqpos() const
1436  {
1437  return seqpos_;
1438  }
1439 
1440  /// @brief Returns the sequence separation distance between this residue and <other>
1441  /// @note: magnitude of distance only
1442  Size
1443  polymeric_sequence_distance( Residue const & other ) const
1444  {
1445  if ( ! is_polymer() || ! other.is_polymer() ) return Size( -1 );
1446  return ( chain_ == other.chain() ?
1447  ( seqpos_ <= other.seqpos_ ? other.seqpos_ - seqpos_ : seqpos_ - other.seqpos_ ) : Size( -1 ) );
1448  }
1449 
1450  /// @brief Returns the sequence separation distance between this residue and <other>
1451  /// positive if the other residue is downstream in sequence
1452  int
1454  {
1455  if ( ! is_polymer() || ! other.is_polymer() ) return std::numeric_limits<int>::max();
1456  return ( chain_ == other.chain() ? other.seqpos_ - seqpos_ : std::numeric_limits<int>::max() );
1457  }
1458 
1459  /// @brief Sets this residue's sequence position to <setting>
1460  void
1461  seqpos( Size const setting )
1462  {
1463  seqpos_ = setting;
1464  }
1465 
1466  /// @brief Returns this residue's chain id
1467  core::Size
1468  chain() const
1469  {
1470  return chain_;
1471  }
1472 
1473  /// @brief Sets this residue's chain id
1474  void
1475  chain( int const setting )
1476  {
1477  chain_ = setting;
1478  }
1479 
1480  /// @brief does this residue require an actcoord?
1481  bool
1483  {
1484  return rsd_type_.requires_actcoord();
1485  }
1486 
1487 
1488 
1489  /// @brief Updates actcoord for this residue
1490  void
1491  update_actcoord();
1492 
1493 
1494 
1495  /// @brief Returns the coordinates used for pairE calculations (amino acids only)
1496  Vector const &
1497  actcoord() const
1498  {
1499  return actcoord_;
1500  }
1501 
1502  /// @brief Returns the coordinates used for pairE calculations (amino acids only)
1503  Vector &
1505  {
1506  return actcoord_;
1507  }
1508 
1509  /// @brief Updates the sequence numbers for this residue and the numbers
1510  /// stored about its non-polymer connections
1511  /// called by our owning conformation when the sequence numbers are remapped
1512  void
1514 
1515 
1516 
1517  /////////////
1518  // properties
1519 
1520  /// @brief Returns true if this residue is a polymer
1521  bool
1522  is_polymer() const
1523  {
1524  return rsd_type_.is_polymer();
1525  }
1526 
1527  /// @brief Returns true if this residue is an amino acid
1528  bool
1529  is_protein() const
1530  {
1531  return rsd_type_.is_protein();
1532  }
1533 
1534  /// @brief Returns true if this residue is a DNA residue
1535  bool
1536  is_DNA() const
1537  {
1538  return rsd_type_.is_DNA();
1539  }
1540 
1541  /// @brief Returns true if this residue is a RNA residue
1542  bool
1543  is_RNA() const
1544  {
1545  return rsd_type_.is_RNA();
1546  }
1547 
1548  /// @brief Returns true if this residue is a nucleic acid
1549  bool
1550  is_NA() const
1551  {
1552  return rsd_type_.is_NA();
1553  }
1554 
1555  /// @brief Returns true if this residue is a carbohydrate
1556  bool
1558  {
1559  return rsd_type_.is_carbohydrate();
1560  }
1561 
1562  /// @brief Returns true if this residue is a ligand
1563  bool
1564  is_ligand() const
1565  {
1566  return rsd_type_.is_ligand();
1567  }
1568 
1569 
1570  /// @brief Returns true if this residue is a surface residue
1571  bool
1572  is_surface() const
1573  {
1574  return rsd_type_.is_surface();
1575  }
1576 
1577 
1578 
1579  /// @brief Returns true if the residue has side chain orbitals
1580  bool
1582  {
1583  return rsd_type_.has_sc_orbitals();
1584  }
1585 
1586 
1587  /// @brief Returns true if the residue is polar
1588  bool
1589  is_polar() const
1590  {
1591  return rsd_type_.is_polar();
1592  }
1593 
1594  /// @briefReturns true if the residue is apolar
1595  /// @note: apolar is classified as NOT polar, aromatic, or charged
1596  bool
1597  is_apolar() const
1598  {
1600  return false;
1601  }else {
1602  return true;
1603  }
1604  }
1605 
1606 
1607  /// @brief Returns true if the residue is charged
1608  bool
1609  is_charged() const
1610  {
1611  return rsd_type_.is_charged();
1612  }
1613 
1614  /// @brief Returns true if the residue is aromatic
1615  bool
1616  is_aromatic() const
1617  {
1618  return rsd_type_.is_aromatic();
1619  }
1620 
1621  ///@brief residue is coarse (used for RNA right now)
1622  bool
1623  is_coarse() const
1624  {
1625  return rsd_type_.is_coarse();
1626  }
1627 
1628  /// @brief Returns true if the residue has a terminus variant
1629  bool
1630  is_terminus() const
1631  {
1632  return rsd_type_.is_terminus();
1633  }
1634 
1635  /// @brief Return true if the residue has an upper terminus variant
1636  bool
1638  {
1639  return rsd_type_.is_upper_terminus();
1640  }
1641 
1642  /// @brief Returns true if the residue has a lower terminus variant
1643  bool
1645  {
1646  return rsd_type_.is_lower_terminus();
1647  }
1648 
1649  /// @brief Returns true if the chi angles of another residue all fall within 5 deg
1650  bool
1651  is_similar_rotamer( Residue const & other ) const;
1652 
1653  /// @brief Returns true if the aa residue types are the same
1654  bool
1655  is_similar_aa( Residue const & other ) const
1656  {
1657 
1658  if (rsd_type_.aa() != other.aa()){
1659  return false;
1660  }
1661  else {
1662  return true;
1663  }
1664  }
1665 
1666 
1667  /// @brief Returns true if the residue has <property>
1668  /// Generic property access -- SLOW!!!!!
1669  bool
1670  has_property( std::string const & property ) const
1671  {
1672  return rsd_type_.has_property( property );
1673  }
1674 
1675  /// @brief Generic variant access -- SLOW!!!!!
1676  bool
1677  has_variant_type( chemical::VariantType const & variant_type ) const
1678  {
1679  return rsd_type_.has_variant_type( variant_type );
1680  }
1681 
1682  /////////////////////////////
1683  /// @brief Returns the name of this residue's atom with index number <atm>
1684  std::string const &
1685  atom_name( int const atm ) const
1686  {
1687  return rsd_type_.atom_name( atm );
1688  }
1689 
1690  /// @brief Returns the mm_atom_name of this residue's atom with index number <atom>
1691  std::string const &
1692  mm_atom_name(int const atom) const
1693  {
1694  return rsd_type_.atom(atom).mm_name();
1695  }
1696 
1697  /// @brief Returns this residue's ResidueType name
1698  /// @note: for proteins, this will be the amino acid type and variant type
1699  std::string const &
1700  name() const
1701  {
1702  return rsd_type_.name();
1703  }
1704 
1705  /// @brief Returns this residue's 3-letter representation
1706  /// @note: for proteins, this will be the 3-letter amino acid code
1707  std::string const &
1708  name3() const
1709  {
1710  return rsd_type_.name3();
1711  }
1712 
1713  /// @brief Returns this residue's 1-letter representation
1714  /// @note: for proteins, this will be the 1-letter amino acid code
1715  char
1716  name1() const
1717  {
1718  return rsd_type_.name1();
1719  }
1720 
1721  /// @brief Returns this residue's AA type, if any
1722  /// Used for knowledge-based scores, dunbrack, etc. could be "aa_unk"
1723  /// AA is enumeration
1724  chemical::AA const &
1725  aa() const
1726  {
1727  return rsd_type_.aa();
1728  }
1729 
1730 
1731  /// @brief Returns the internal coordinates of this residue's atom with index number <atm>
1732  chemical::AtomICoor const &
1733  icoor( int const atm ) const
1734  {
1735  return rsd_type_.icoor( atm );
1736  }
1737 
1738  ///fpd bondlength analog to set_chi
1739  /// like set_chi, assumes changes propagate to atomtree
1740  /// keyed off of chi#, so we only allow distances corresponding to chi angles to refine
1741  /// distance corresponds to the distance between atoms 3 and 4 defining the chi
1742  /// chino==0 ==> CA-CB distance, which allows us to refine ALA CB position for example
1743  void
1744  set_d( int const chino, Real const setting );
1745 
1746  ///fpd bondangle analog to set_chi
1747  /// same idea as set_d
1748  void
1749  set_theta( int const chino, Real const setting );
1750 
1751  /// @brief Sets this residue's chi angle <chino> to <setting>
1752  /// assuming that changes propagate according to the atom_base tree
1753  void
1754  set_chi( int const chino, Real const setting );
1755 
1756  /// @brief Sets all of this residue's chi angles using the set_chi function
1757  /// (wrapper function)
1758  void
1759  set_all_chi( utility::vector1< Real > const & chis );
1760 
1761 
1762  /// @brief Returns true if this residue has an atom named <atm>
1763  bool
1764  has( std::string const & atm ) const
1765  {
1766  return rsd_type_.has( atm );
1767  }
1768 
1769  /// @brief Builds coordinates for atoms missing from this residue
1770  /// assuming ideal internal coordinates
1771  void
1773  utility::vector1< bool > missing,
1774  Conformation const & conformation
1775  );
1776 
1777  /// @brief Selects three atoms for orienting this residue
1778  void
1780  Size & center,
1781  Size & nbr1,
1782  Size & nbr2
1783  ) const;
1784 
1785  /// @brief Orient our coords onto those of <src>, using the atoms from select_orient_atoms
1786  void
1787  orient_onto_residue( Residue const & src );
1788 
1789  /// @brief Orient our coords onto those of <src>, using the three atom pairs specified in the input
1790  /// @param atom_pairs
1791  // Atom pairs used for alignment of the form:
1792  // { src_center : center, src_nbr1 : nbr1, src_nbr2 : nbr1 }
1793  void
1795  Residue const & src,
1796  utility::vector1< std::pair< std::string, std::string > > const & atom_pairs
1797  );
1798 
1799  /// @brief Place this rotamer at the sequence position occupied by <src>
1800  /// by reorienting the ideal side chain coordinates to match
1801  void
1802  place(
1803  Residue const & src,
1804  Conformation const & conformation,
1805  bool preserve_c_beta = false
1806  );
1807 
1808  /// @brief Applies a transform of the form Rx + v, where R is a rotation
1809  /// matrix, V is a vector, and x is the original position in xyz space
1810  void
1813  Vector v
1814  );
1815 
1816  /// @brief Return the RNA_residueType object. This is RNA specific.
1818  RNA_type() const{
1819  return rsd_type_.RNA_type();
1820  }
1821 
1822  /// @brief Return the CarbohydrateInfo object containing sugar-specific properties for this residue.
1824 
1825 
1826 #ifdef USEBOOSTSERIALIZE
1827  /// unfortunate, but we must use const_cast here to turn off the serialize flag in restype
1828  void serialized(bool) {
1829  using namespace core::chemical;
1831 
1832  // recurse
1833  std::vector< ResidueType const * > serialized_restypes;
1834  ResidueType const * current_res = &(rsd_type_);
1835  while( current_res->serialized_ ) {
1836  current_res->serialized_ = false;
1837  // check the base_restype of current restype
1838  if( current_res->base_restype_name() == "" )
1839  break;
1840  current_res = &(restype_set->name_map( current_res->base_restype_name()));
1841  }
1842  }
1843 #endif
1844 
1845 
1846  /////////////////////////////////////////////////////////////////////////////
1847  // private methods
1848  /////////////////////////////////////////////////////////////////////////////
1849 
1850 private:
1851 
1852  /// @brief Updates connections_to_residues_ using connect_map_
1853  void
1855 
1856 
1857  /// @brief apply transform of rotation R and translation V for all atoms downstream
1858  /// @note note this is not for general atom tree folding. only used in set_chi in which
1859  /// changes for a chi angle is fast propagated within one residue and not to invoke
1860  /// folding the whole atom tree.
1861  void
1863  int const atomno,
1864  numeric::xyzMatrix< Real > const & R,
1865  Vector const & v
1866  );
1867 
1868 
1869  void
1871 
1872  /// @brief Assignment operator does not work for class Residue.
1873  /// This function is intentionally unimplemented and private.
1874  Residue const &
1875  operator = ( Residue const & rhs );
1876 
1877  /// @brief Orient coords onto those of <src>, using the specified atoms
1878  void orient_onto_residue(
1879  Residue const & src,
1880  Size center, Size nbr1, Size nbr2,
1881  Size src_center, Size src_nbr1, Size src_nbr2);
1882 
1883  /////////////////////////////////////////////////////////////////////////////
1884  // data
1885  /////////////////////////////////////////////////////////////////////////////
1886 
1887 private:
1888 
1889  /// @brief our Residue type
1890  //-- should be CAP, perhaps?
1892 
1893  /// @brief our conformation atoms (not kinematic atom pointers) with xyz positiona and atom type
1895 
1897 
1898 
1899  /// @brief the sequence position
1901 
1902  /// @brief the chain id number, starting from 1
1904 
1905  /// @brief our chi (sidechain) torsion angles
1907 
1908  /// @brief our (possibly empty) backbone torsion angles
1910 
1911  /// @brief the action coordinate, an interaction centroid for knowledge-based terms like fa-pair
1912  /// in fact, only for fa-pair
1914 
1915 
1916 
1917 
1918  /////////////////////////////////
1919  /// Inter-residue connection data
1920 
1921  /// @brief true if is_polymer() and either upper_connect or lower_connect (if they exist)
1922  /// do not connect to seqpos()+1 or seqpos()-1
1924 
1925  /// @brief map between connection ids on this residue and the
1926  /// connection points on other residues to which its bonded
1928 
1929  /// @brief lists for each connected residue of the connection points on this residue
1930  /// that connect the pair.
1931  std::map< Size, utility::vector1< Size > > connections_to_residues_;
1932 
1933  /// @brief other residues within 4 bonds (connected through PseudoBonds)
1934  /// may include this residue (intra-residue pseudo-bonds)
1935  std::map< Size, PseudoBondCollectionCOP > pseudobonds_;
1936 
1937 #ifdef USEBOOSTSERIALIZE
1938 private:
1939  friend class boost::serialization::access;
1940  template<class Archive>
1941  void serialize(Archive &ar, const unsigned int file_version) {}
1942  template<class Archive> friend void save_construct_data( Archive & ar, const Residue * t, const unsigned int file_version);
1943  template<class Archive> friend void load_construct_data( Archive & ar, Residue * t, const unsigned int file_version);
1944 #endif
1945 };
1946 
1947 std::ostream & operator << ( std::ostream & os, Residue const & res );
1948 
1949 #ifdef USEBOOSTSERIALIZE
1950 template<class Archive>
1951 inline void save_construct_data(
1952  Archive & ar, const Residue * t, const unsigned int file_version
1953 ){
1954  using namespace core::chemical;
1955 
1956  ar & t->rsd_type_.residue_type_set().name();
1958 
1959  ar & t->rsd_type_.name();
1960 
1961  // Ok storing the restype is quite complicated if it isn't part of fa_standard set
1962  // every restype is based off either the root restype, or some derived restype
1963  // eg ASP_connectOD1_connectOD2 is based off ASP_connectOD1 which is based off ASP
1964  // the depth of the inheritance is arbitrary( enzdes stuff uses up to 8 deep?)
1965  // also, each restype can be already serialized, so we should check for that
1966  // recursion would be nice, but we have a lot of permissions issues and templating issues
1967 
1968  // check if top level restype is 1) not part of a set and 2) is not already serialized
1969  std::vector< ResidueType const * > serialized_restypes;
1970  ResidueType const * current_res = &(t->rsd_type_);
1971  while( current_res->nondefault_ && !current_res->serialized_ ) {
1972  serialized_restypes.push_back( current_res );
1973  // check the base_restype of current restype
1974  if( current_res->base_restype_name_ == "" )
1975  break;
1976  current_res = &(restype_set->name_map( current_res->base_restype_name_));
1977  }
1978 
1979  // store how many restypes this residue will actually hold
1980  int serialized_restypes_size = serialized_restypes.size();
1981  ar & serialized_restypes_size;
1982 
1983 
1984  // and then for every restype, store everything we need to recreate it
1985  // we won't actually serialize the restype since its usually a clone with some small modifications
1986  for( std::vector< ResidueType const * >::reverse_iterator itr = serialized_restypes.rbegin(); itr < serialized_restypes.rend(); itr++ ) {
1987  ar & (**itr).name();
1988  ar & (**itr).base_restype_name_;
1989  ar & (**itr).n_non_polymeric_residue_connections_;
1990  ar & (**itr).residue_connections_;
1991  ar & (**itr).atom_2_residue_connection_map_;
1992  ar & (**itr).variant_types_;
1993  ar & (**itr).icoor_;
1994  ar & (**itr).atom_base_;
1995  ar & (**itr).xyz_;
1996  // mark this restype as serialized so if its used later in this pose, its not serialized again
1997  // this will fail horribly if residue is serialized directly, because serialized(false) is called one level up
1998  // but w.e, can figure that out later
1999  (**itr).serialized_ = true;
2000  }
2001  // store the rest of Residue
2002  ar & t->atoms_;
2003  ar & t->seqpos_;
2004  ar & t->seqpos_;
2005  ar & t->chain_;
2006  ar & t->chi_;
2007  ar & t->mainchain_torsions_;
2008  ar & t->actcoord_;
2009  ar & t->nonstandard_polymer_;
2010  ar & t->connect_map_;
2011  ar & t->connections_to_residues_;
2012  ar & t->pseudobonds_;
2013 }
2014 
2015 template<class Archive>
2016 inline void load_construct_data(
2017  Archive & ar, Residue * t, const unsigned int file_version
2018 ){
2019  using namespace core::chemical;
2020 
2021  std::string restypeset_name;
2022  ar >> restypeset_name;
2024 
2025  std::string this_restype_name;
2026  ar & this_restype_name;
2027 
2028  int serialized_restypes_size;
2029  ar & serialized_restypes_size;
2030 
2031  for( int i = 0 ; i < serialized_restypes_size; i++ ) {
2032  // even if we already have the restype, we have to deserialize it :(
2033  std::string restype_name;
2034  ar & restype_name;
2035 
2036  std::string base_restype_name;
2037  ar & base_restype_name;
2038  ResidueType const & base_res = restype_set->name_map( base_restype_name);
2039  ResidueTypeOP new_restype;
2040  new_restype = base_res.clone();
2041  new_restype->name( restype_name );
2042  new_restype->nondefault_ = true;
2043  new_restype->base_restype_name_ = base_restype_name;
2044 
2045  ar & new_restype->n_non_polymeric_residue_connections_;
2046  ar & new_restype->residue_connections_;
2047  ar & new_restype->atom_2_residue_connection_map_;
2048  ar & new_restype->variant_types_;
2049  ar & new_restype->icoor_;
2050  ar & new_restype->atom_base_;
2051  ar & new_restype->xyz_;
2052  if( !restype_set->has_name(restype_name) ) {
2053  new_restype->finalize();
2054  restype_set->add_residue_type( new_restype);
2055  // gotta add rotamer library for it if its a ligand
2056  if( new_restype->is_ligand() ) {
2057  core::conformation::add_cloned_ligand_rotamer_library( *new_restype, base_res );
2058  }
2059  }
2060  }
2061 
2062  // inplace constructor
2063  ::new(t) core::conformation::Residue( restype_set->name_map(this_restype_name), true, true);
2064  // and then set all the other member vars
2065  ar & t->atoms_;
2066  ar & t->seqpos_;
2067  ar & t->seqpos_;
2068  ar & t->chain_;
2069  ar & t->chi_;
2070  ar & t->mainchain_torsions_;
2071  ar & t->actcoord_;
2072  ar & t->nonstandard_polymer_;
2073  ar & t->connect_map_;
2074  ar & t->connections_to_residues_;
2075  ar & t->pseudobonds_;
2076 }
2077 
2078 #endif
2079 } // conformation
2080 } // core
2081 
2082 #endif