BALL  1.5.0
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 
286  void setInsertionCode(char insertion_code);
287 
293  void unsetInsertionCode();
294 
298  char getInsertionCode() const;
299 
303  Size countPDBAtoms() const;
304 
308  void prepend(PDBAtom& atom);
309 
313  void append(PDBAtom& atom);
314 
318  void insert(PDBAtom& atom);
319 
324  void insertBefore(PDBAtom& atom, Composite& before);
325 
330  void insertAfter(PDBAtom& atom, Composite& after);
331 
335  bool remove(PDBAtom& atom);
336 
340  void spliceBefore(Residue& residue);
341 
345  void spliceAfter(Residue& residue);
346 
350  void splice(Residue& residue);
351 
353 
356 
361  bool isAminoAcid() const;
362 
368  bool isTerminal() const;
369 
375  bool isNTerminal() const;
376 
382  bool isCTerminal() const;
383 
385 
388  virtual bool isResidue() const { return true; }
391 
395 
400  virtual bool isValid() const;
401 
408  virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
409 
411 
412  // --- EXTERNAL ITERATORS
413 
416 
417 
418  private:
419 
420  AtomContainer* getAtomContainer(Position position);
421 
422  const AtomContainer* getAtomContainer(Position position) const;
423 
424  Size countAtomContainers() const;
425 
426  void prepend(AtomContainer& atom_container);
427 
428  void append(AtomContainer& atom_container);
429 
430  void insert(AtomContainer& atom_container);
431 
432  void insertBefore(AtomContainer& atom_container, Composite& composite);
433 
434  void insertAfter(AtomContainer& atom_container, Composite& composite);
435 
436  void spliceBefore(AtomContainer& atom_container);
437 
438  void spliceAfter(AtomContainer& base_ragment);
439 
440  void splice(AtomContainer& AtomContainer);
441 
442  bool remove(AtomContainer& AtomContainer);
443 
444  bool isSuperAtomContainerOf(const AtomContainer& atom_container) const;
445 
448 
449  // --- ATTRIBUTES
450 
451  String id_;
452 
453  char insertion_code_;
454  };
455 
456  template <class ResidueContainerType>
457  const Residue* getNTerminal(const ResidueContainerType& residue_container)
458  {
459  ResidueConstIterator res_it(residue_container.beginResidue());
460  for (; res_it != residue_container.endResidue(); ++res_it)
461  {
462  if (res_it->isAminoAcid() == true)
463  {
464  return &(*res_it);
465  }
466  }
467 
468  return 0;
469  }
470 
471  template <class ResidueContainerType>
472  const Residue* getCTerminal(const ResidueContainerType& residue_container)
473  {
474  ResidueConstReverseIterator res_it(residue_container.rbeginResidue());
475  for (; res_it != residue_container.rendResidue(); ++res_it)
476  {
477  // Look for the last residue marked as amino acid
478  if (res_it->isAminoAcid() == true)
479  {
480  return &(*res_it);
481  }
482  }
483 
484  return 0;
485  }
486 
487 } // namespace BALL
488 
489 #endif // BALL_KERNEL_RESIDUE_H
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
This returns the unmodified residue name only.
Definition: residue.h:79
Property
The number of predefined properties for AtomContainer.
Definition: atomContainer.h:42
BALL_EXPORT AtomContainerList atomContainers(const AtomContainer &fragment, bool selected_only=false)
#define BALL_RESIDUE_DEFAULT_ID
Definition: residue.h:21
Add the residue variant extensions (e.g. &#39;-C&#39; for C-terminal residues)
Definition: residue.h:81
#define BALL_EXPORT
Definition: COMMON/global.h:50
std::reverse_iterator< ResidueConstIterator > ResidueConstReverseIterator
Definition: constants.h:12
#define BALL_RESIDUE_DEFAULT_INSERTION_CODE
Definition: residue.h:22
const Residue * getCTerminal(const ResidueContainerType &residue_container)
Definition: residue.h:472
const Residue * getNTerminal(const ResidueContainerType &residue_container)
Definition: residue.h:457
BALL_EXPORT bool operator==(const String &s1, const String &s2)
#define BALL_KERNEL_DEFINE_ITERATOR_CREATORS(Type)
Definition: iterator.h:25
#define BALL_CREATE_DEEP(name)
Definition: create.h:26
#define BALL_DECLARE_STD_ITERATOR_WRAPPER(container, type, method_name)