BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_KERNEL_RESIDUE_H 00006 #define BALL_KERNEL_RESIDUE_H 00007 00008 #ifndef BALL_KERNEL_FRAGMENT_H 00009 # include <BALL/KERNEL/fragment.h> 00010 #endif 00011 00012 #ifndef BALL_KERNEL_PDBATOMITERATOR_H 00013 # include <BALL/KERNEL/PDBAtomIterator.h> 00014 #endif 00015 00016 #ifndef BALL_KERNEL_RESIDUEITERATOR_H 00017 # include <BALL/KERNEL/residueIterator.h> 00018 #endif 00019 00020 00021 #define BALL_RESIDUE_DEFAULT_ID "" 00022 #define BALL_RESIDUE_DEFAULT_INSERTION_CODE ' ' 00023 00024 namespace BALL 00025 { 00026 class Chain; 00027 class Protein; 00028 class SecondaryStructure; 00029 00036 class BALL_EXPORT Residue 00037 : public Fragment 00038 { 00039 public: 00040 00041 BALL_CREATE_DEEP(Residue) 00042 00043 00046 00048 enum Property 00049 { 00051 PROPERTY__NON_STANDARD = Fragment::NUMBER_OF_PROPERTIES + 1, 00053 PROPERTY__AMINO_ACID, 00055 PROPERTY__WATER, 00057 PROPERTY__HAS_SSBOND, 00059 PROPERTY__C_TERMINAL, 00061 PROPERTY__N_TERMINAL, 00067 PROPERTY__CYCLIC, 00068 00070 NUMBER_OF_PROPERTIES 00071 }; 00072 00076 enum FullNameType 00077 { 00079 NO_VARIANT_EXTENSIONS, 00081 ADD_VARIANT_EXTENSIONS, 00082 // Add the residue ID separated by a colon 00083 ADD_RESIDUE_ID, 00084 // Add the residue ID and the residue extension 00085 ADD_VARIANT_EXTENSIONS_AND_ID 00086 }; 00087 00089 00090 00094 00096 Residue(); 00097 00099 Residue(const Residue& residue, bool deep = true); 00100 00102 Residue 00103 (const String& name, 00104 const String& id = BALL_RESIDUE_DEFAULT_ID, 00105 char insertion_code = BALL_RESIDUE_DEFAULT_INSERTION_CODE); 00106 00108 virtual ~Residue(); 00109 00111 virtual void clear(); 00112 00114 virtual void destroy(); 00115 00117 00120 00124 void persistentWrite(PersistenceManager& pm, const char* name = 0) const; 00125 00129 void persistentRead(PersistenceManager& pm); 00130 00132 00135 00141 void set(const Residue& residue, bool deep = true); 00142 00145 Residue& operator = (const Residue& residue); 00146 00149 void get(Residue& residue, bool deep = true) const; 00150 00153 void swap(Residue& residue); 00154 00156 00161 bool operator == (const Residue& residue) const; 00162 00166 bool operator != (const Residue& residue) const; 00167 00168 00172 00185 String getFullName(FullNameType type = ADD_VARIANT_EXTENSIONS) const; 00186 00190 bool hasTorsionPhi() const; 00191 00195 Angle getTorsionPhi() const; 00196 00200 bool hasTorsionPsi() const; 00201 00205 Angle getTorsionPsi() const; 00206 00211 Protein* getProtein(); 00212 00217 const Protein* getProtein() const; 00218 00223 Chain* getChain(); 00224 00229 const Chain* getChain() const; 00230 00235 SecondaryStructure* getSecondaryStructure(); 00236 00241 const SecondaryStructure* getSecondaryStructure() const; 00242 00248 PDBAtom* getPDBAtom(Position position); 00249 00255 const PDBAtom* getPDBAtom(Position position) const; 00256 00260 void setID(const String& id); 00261 00265 const String& getID() const; 00266 00270 void setInsertionCode(char insertion_code); 00271 00275 char getInsertionCode() const; 00276 00280 Size countPDBAtoms() const; 00281 00285 void prepend(PDBAtom& atom); 00286 00290 void append(PDBAtom& atom); 00291 00295 void insert(PDBAtom& atom); 00296 00301 void insertBefore(PDBAtom& atom, Composite& before); 00302 00307 void insertAfter(PDBAtom& atom, Composite& after); 00308 00312 bool remove(PDBAtom& atom); 00313 00317 void spliceBefore(Residue& residue); 00318 00322 void spliceAfter(Residue& residue); 00323 00327 void splice(Residue& residue); 00328 00330 00333 00338 bool isAminoAcid() const; 00339 00345 bool isTerminal() const; 00346 00352 bool isNTerminal() const; 00353 00359 bool isCTerminal() const; 00360 00362 00365 00370 virtual bool isValid() const; 00371 00378 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const; 00379 00381 00382 // --- EXTERNAL ITERATORS 00383 00384 BALL_KERNEL_DEFINE_ITERATOR_CREATORS(PDBAtom) 00385 00386 00387 private: 00388 00389 AtomContainer* getAtomContainer(Position position); 00390 00391 const AtomContainer* getAtomContainer(Position position) const; 00392 00393 Size countAtomContainers() const; 00394 00395 void prepend(AtomContainer& atom_container); 00396 00397 void append(AtomContainer& atom_container); 00398 00399 void insert(AtomContainer& atom_container); 00400 00401 void insertBefore(AtomContainer& atom_container, Composite& composite); 00402 00403 void insertAfter(AtomContainer& atom_container, Composite& composite); 00404 00405 void spliceBefore(AtomContainer& atom_container); 00406 00407 void spliceAfter(AtomContainer& base_ragment); 00408 00409 void splice(AtomContainer& AtomContainer); 00410 00411 bool remove(AtomContainer& AtomContainer); 00412 00413 bool isSuperAtomContainerOf(const AtomContainer& atom_container) const; 00414 00415 BALL_KERNEL_DEFINE_ITERATOR_CREATORS(AtomContainer) 00416 00417 // --- ATTRIBUTES 00418 00419 String id_; 00420 00421 char insertion_code_; 00422 }; 00423 00424 template <class ResidueContainerType> 00425 const Residue* getNTerminal(const ResidueContainerType& residue_container) 00426 { 00427 ResidueConstIterator res_it(residue_container.beginResidue()); 00428 for (; res_it != residue_container.endResidue(); ++res_it) 00429 { 00430 if (res_it->isAminoAcid() == true) 00431 { 00432 return &(*res_it); 00433 } 00434 } 00435 00436 return 0; 00437 } 00438 00439 template <class ResidueContainerType> 00440 const Residue* getCTerminal(const ResidueContainerType& residue_container) 00441 { 00442 ResidueConstReverseIterator res_it(residue_container.rbeginResidue()); 00443 for (; res_it != residue_container.rendResidue(); ++res_it) 00444 { 00445 // Look for the last residue marked as amino acid 00446 if (res_it->isAminoAcid() == true) 00447 { 00448 return &(*res_it); 00449 } 00450 } 00451 00452 return 0; 00453 } 00454 00455 } // namespace BALL 00456 00457 #endif // BALL_KERNEL_RESIDUE_H