BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
residue.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_KERNEL_RESIDUE_H
6 #define BALL_KERNEL_RESIDUE_H
7 
8 #ifndef BALL_KERNEL_FRAGMENT_H
9 # include <BALL/KERNEL/fragment.h>
10 #endif
11 
12 #ifndef BALL_KERNEL_PDBATOMITERATOR_H
14 #endif
15 
16 #ifndef BALL_KERNEL_RESIDUEITERATOR_H
18 #endif
19 
20 
21 #define BALL_RESIDUE_DEFAULT_ID ""
22 #define BALL_RESIDUE_DEFAULT_INSERTION_CODE ' '
23 
24 namespace BALL
25 {
26  class Chain;
27  class Protein;
28  class SecondaryStructure;
29 
37  : public Fragment
38  {
39  public:
40 
42 
43 
46 
48  enum Property
49  {
51  PROPERTY__NON_STANDARD = Fragment::NUMBER_OF_PROPERTIES + 1,
68 
70  NUMBER_OF_PROPERTIES
71  };
72 
77  {
82  // Add the residue ID separated by a colon
84  // Add the residue ID and the residue extension
85  ADD_VARIANT_EXTENSIONS_AND_ID
86  };
87 
89 
90 
94 
96  Residue();
97 
99  Residue(const Residue& residue, bool deep = true);
100 
102  Residue
103  (const String& name,
104  const String& id = BALL_RESIDUE_DEFAULT_ID,
105  char insertion_code = BALL_RESIDUE_DEFAULT_INSERTION_CODE);
106 
108  virtual ~Residue();
109 
111  virtual void clear();
112 
114  virtual void destroy();
115 
117 
120 
124  void persistentWrite(PersistenceManager& pm, const char* name = 0) const;
125 
129  void persistentRead(PersistenceManager& pm);
130 
132 
135 
141  void set(const Residue& residue, bool deep = true);
142 
145  Residue& operator = (const Residue& residue);
146 
149  void get(Residue& residue, bool deep = true) const;
150 
153  void swap(Residue& residue);
154 
156 
161  bool operator == (const Residue& residue) const;
162 
166  bool operator != (const Residue& residue) const;
167 
168 
172 
185  String getFullName(FullNameType type = ADD_VARIANT_EXTENSIONS) const;
186 
190  bool hasTorsionPhi() const;
191 
195  Angle getTorsionPhi() const;
196 
200  bool hasTorsionPsi() const;
201 
205  Angle getTorsionPsi() const;
206 
210  bool hasTorsionOmega() const;
211 
215  Angle getTorsionOmega() const;
216 
221  Protein* getProtein();
222 
227  const Protein* getProtein() const;
228 
233  Chain* getChain();
234 
239  const Chain* getChain() const;
240 
245  SecondaryStructure* getSecondaryStructure();
246 
251  const SecondaryStructure* getSecondaryStructure() const;
252 
258  PDBAtom* getPDBAtom(Position position);
259 
265  const PDBAtom* getPDBAtom(Position position) const;
266 
270  void setID(const String& id);
271 
275  const String& getID() const;
276 
280  void setInsertionCode(char insertion_code);
281 
285  char getInsertionCode() const;
286 
290  Size countPDBAtoms() const;
291 
295  void prepend(PDBAtom& atom);
296 
300  void append(PDBAtom& atom);
301 
305  void insert(PDBAtom& atom);
306 
311  void insertBefore(PDBAtom& atom, Composite& before);
312 
317  void insertAfter(PDBAtom& atom, Composite& after);
318 
322  bool remove(PDBAtom& atom);
323 
327  void spliceBefore(Residue& residue);
328 
332  void spliceAfter(Residue& residue);
333 
337  void splice(Residue& residue);
338 
340 
343 
348  bool isAminoAcid() const;
349 
355  bool isTerminal() const;
356 
362  bool isNTerminal() const;
363 
369  bool isCTerminal() const;
370 
372 
375  virtual bool isResidue() const { return true; }
378 
382 
387  virtual bool isValid() const;
388 
395  virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
396 
398 
399  // --- EXTERNAL ITERATORS
400 
402  BALL_DECLARE_STD_ITERATOR_WRAPPER(Residue, PDBAtom, pdbAtoms)
403 
404 
405  private:
406 
407  AtomContainer* getAtomContainer(Position position);
408 
409  const AtomContainer* getAtomContainer(Position position) const;
410 
411  Size countAtomContainers() const;
412 
413  void prepend(AtomContainer& atom_container);
414 
415  void append(AtomContainer& atom_container);
416 
417  void insert(AtomContainer& atom_container);
418 
419  void insertBefore(AtomContainer& atom_container, Composite& composite);
420 
421  void insertAfter(AtomContainer& atom_container, Composite& composite);
422 
423  void spliceBefore(AtomContainer& atom_container);
424 
425  void spliceAfter(AtomContainer& base_ragment);
426 
427  void splice(AtomContainer& AtomContainer);
428 
429  bool remove(AtomContainer& AtomContainer);
430 
431  bool isSuperAtomContainerOf(const AtomContainer& atom_container) const;
432 
434  BALL_DECLARE_STD_ITERATOR_WRAPPER(Residue, AtomContainer, atomContainers)
435 
436  // --- ATTRIBUTES
437 
438  String id_;
439 
440  char insertion_code_;
441  };
442 
443  template <class ResidueContainerType>
444  const Residue* getNTerminal(const ResidueContainerType& residue_container)
445  {
446  ResidueConstIterator res_it(residue_container.beginResidue());
447  for (; res_it != residue_container.endResidue(); ++res_it)
448  {
449  if (res_it->isAminoAcid() == true)
450  {
451  return &(*res_it);
452  }
453  }
454 
455  return 0;
456  }
457 
458  template <class ResidueContainerType>
459  const Residue* getCTerminal(const ResidueContainerType& residue_container)
460  {
461  ResidueConstReverseIterator res_it(residue_container.rbeginResidue());
462  for (; res_it != residue_container.rendResidue(); ++res_it)
463  {
464  // Look for the last residue marked as amino acid
465  if (res_it->isAminoAcid() == true)
466  {
467  return &(*res_it);
468  }
469  }
470 
471  return 0;
472  }
473 
474 } // namespace BALL
475 
476 #endif // BALL_KERNEL_RESIDUE_H
#define BALL_KERNEL_DEFINE_ITERATOR_CREATORS(Type)
Definition: iterator.h:25
const Residue * getNTerminal(const ResidueContainerType &residue_container)
Definition: residue.h:444
const Residue * getCTerminal(const ResidueContainerType &residue_container)
Definition: residue.h:459
Property
The number of predefined properties for AtomContainer.
Definition: atomContainer.h:42
#define BALL_RESIDUE_DEFAULT_INSERTION_CODE
Definition: residue.h:22
#define BALL_RESIDUE_DEFAULT_ID
Definition: residue.h:21
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
#define BALL_CREATE_DEEP(name)
Definition: create.h:26
#define BALL_DECLARE_STD_ITERATOR_WRAPPER(container, type, method_name)
BALL_SIZE_TYPE Size
BALL_EXPORT bool operator==(const String &s1, const String &s2)
std::reverse_iterator< ResidueConstIterator > ResidueConstReverseIterator
Add the residue variant extensions (e.g. '-C' for C-terminal residues)
Definition: residue.h:81
BALL_EXPORT AtomContainerList atomContainers(const AtomContainer &fragment, bool selected_only=false)
#define BALL_EXPORT
Definition: COMMON/global.h:50
BALL_SIZE_TYPE Position
This returns the unmodified residue name only.
Definition: residue.h:79