00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_KERNEL_RESIDUE_H
00008 #define BALL_KERNEL_RESIDUE_H
00009
00010 #ifndef BALL_KERNEL_FRAGMENT_H
00011 # include <BALL/KERNEL/fragment.h>
00012 #endif
00013
00014 #ifndef BALL_KERNEL_PDBATOMITERATOR_H
00015 # include <BALL/KERNEL/PDBAtomIterator.h>
00016 #endif
00017
00018 #ifndef BALL_KERNEL_RESIDUEITERATOR_H
00019 # include <BALL/KERNEL/residueIterator.h>
00020 #endif
00021
00022
00023 #define BALL_RESIDUE_DEFAULT_ID ""
00024 #define BALL_RESIDUE_DEFAULT_INSERTION_CODE ' '
00025
00026 namespace BALL
00027 {
00028 class Chain;
00029 class Protein;
00030 class SecondaryStructure;
00031
00038 class BALL_EXPORT Residue
00039 : public Fragment
00040 {
00041 public:
00042
00043 BALL_CREATE_DEEP(Residue)
00044
00045
00048
00050 enum Property
00051 {
00053 PROPERTY__NON_STANDARD = Fragment::NUMBER_OF_PROPERTIES + 1,
00055 PROPERTY__AMINO_ACID,
00057 PROPERTY__WATER,
00059 PROPERTY__HAS_SSBOND,
00061 PROPERTY__C_TERMINAL,
00063 PROPERTY__N_TERMINAL,
00069 PROPERTY__CYCLIC,
00070
00072 NUMBER_OF_PROPERTIES
00073 };
00074
00078 enum FullNameType
00079 {
00081 NO_VARIANT_EXTENSIONS,
00083 ADD_VARIANT_EXTENSIONS,
00084
00085 ADD_RESIDUE_ID,
00086
00087 ADD_VARIANT_EXTENSIONS_AND_ID
00088 };
00089
00091
00092
00096
00098 Residue();
00099
00101 Residue(const Residue& residue, bool deep = true);
00102
00104 Residue
00105 (const String& name,
00106 const String& id = BALL_RESIDUE_DEFAULT_ID,
00107 char insertion_code = BALL_RESIDUE_DEFAULT_INSERTION_CODE);
00108
00110 virtual ~Residue();
00111
00113 virtual void clear();
00114
00116 virtual void destroy();
00117
00119
00122
00126 void persistentWrite(PersistenceManager& pm, const char* name = 0) const
00127 throw(Exception::GeneralException);
00128
00132 void persistentRead(PersistenceManager& pm)
00133 throw(Exception::GeneralException);
00134
00136
00139
00145 void set(const Residue& residue, bool deep = true);
00146
00149 Residue& operator = (const Residue& residue);
00150
00153 void get(Residue& residue, bool deep = true) const;
00154
00157 void swap(Residue& residue);
00158
00160
00165 bool operator == (const Residue& residue) const;
00166
00170 bool operator != (const Residue& residue) const;
00171
00172
00176
00189 String getFullName(FullNameType type = ADD_VARIANT_EXTENSIONS) const;
00190
00194 bool hasTorsionPhi() const;
00195
00199 Angle getTorsionPhi() const;
00200
00204 bool hasTorsionPsi() const;
00205
00209 Angle getTorsionPsi() const;
00210
00215 Protein* getProtein();
00216
00221 const Protein* getProtein() const;
00222
00227 Chain* getChain();
00228
00233 const Chain* getChain() const;
00234
00239 SecondaryStructure* getSecondaryStructure();
00240
00245 const SecondaryStructure* getSecondaryStructure() const;
00246
00252 PDBAtom* getPDBAtom(Position position);
00253
00259 const PDBAtom* getPDBAtom(Position position) const;
00260
00264 void setID(const String& id);
00265
00269 const String& getID() const;
00270
00274 void setInsertionCode(char insertion_code);
00275
00279 char getInsertionCode() const;
00280
00284 Size countPDBAtoms() const;
00285
00289 void prepend(PDBAtom& atom);
00290
00294 void append(PDBAtom& atom);
00295
00299 void insert(PDBAtom& atom);
00300
00305 void insertBefore(PDBAtom& atom, Composite& before);
00306
00311 void insertAfter(PDBAtom& atom, Composite& after);
00312
00316 bool remove(PDBAtom& atom);
00317
00321 void spliceBefore(Residue& residue);
00322
00326 void spliceAfter(Residue& residue);
00327
00331 void splice(Residue& residue);
00332
00334
00337
00342 bool isAminoAcid() const;
00343
00349 bool isTerminal() const;
00350
00356 bool isNTerminal() const;
00357
00363 bool isCTerminal() const;
00364
00366
00369
00374 virtual bool isValid() const;
00375
00382 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
00383
00385
00386
00387
00388 BALL_KERNEL_DEFINE_ITERATOR_CREATORS(PDBAtom)
00389
00390
00391 private:
00392
00393 AtomContainer* getAtomContainer(Position position);
00394
00395 const AtomContainer* getAtomContainer(Position position) const;
00396
00397 Size countAtomContainers() const;
00398
00399 void prepend(AtomContainer& atom_container);
00400
00401 void append(AtomContainer& atom_container);
00402
00403 void insert(AtomContainer& atom_container);
00404
00405 void insertBefore(AtomContainer& atom_container, Composite& composite);
00406
00407 void insertAfter(AtomContainer& atom_container, Composite& composite);
00408
00409 void spliceBefore(AtomContainer& atom_container);
00410
00411 void spliceAfter(AtomContainer& base_ragment);
00412
00413 void splice(AtomContainer& AtomContainer);
00414
00415 bool remove(AtomContainer& AtomContainer);
00416
00417 bool isSuperAtomContainerOf(const AtomContainer& atom_container) const;
00418
00419 BALL_KERNEL_DEFINE_ITERATOR_CREATORS(AtomContainer)
00420
00421
00422
00423 String id_;
00424
00425 char insertion_code_;
00426 };
00427
00428 template <class ResidueContainerType>
00429 const Residue* getNTerminal(const ResidueContainerType& residue_container)
00430 {
00431 ResidueConstIterator res_it(residue_container.beginResidue());
00432 for (; res_it != residue_container.endResidue(); ++res_it)
00433 {
00434 if (res_it->isAminoAcid() == true)
00435 {
00436 return &(*res_it);
00437 }
00438 }
00439
00440 return 0;
00441 }
00442
00443 template <class ResidueContainerType>
00444 const Residue* getCTerminal(const ResidueContainerType& residue_container)
00445 {
00446 ResidueConstReverseIterator res_it(residue_container.rbeginResidue());
00447 for (; res_it != residue_container.rendResidue(); ++res_it)
00448 {
00449
00450 if (res_it->isAminoAcid() == true)
00451 {
00452 return &(*res_it);
00453 }
00454 }
00455
00456 return 0;
00457 }
00458
00459 }
00460
00461 #endif // BALL_KERNEL_RESIDUE_H