00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __P_CHAIN_H
00021 #define __P_CHAIN_H
00022
00023 #include "PAtom.h"
00024 #include "PAtomNode.h"
00025 #include "PGrid.h"
00026 #include "PLightChain.h"
00027 #include "PResidue.h"
00028 #include "PStructs.h"
00029
00030 #include <list>
00031 using std::list;
00032
00033
00053 class PChain: public PLightChain {
00054 public:
00055 friend class PAtom;
00056
00060 PChain();
00061
00066 PChain(const string &firstResidueName);
00067
00072 PChain(const string &firstResidueName, PResidueSpec &firstResidueSpec);
00073
00078 PChain(PChain *protein, int resStartIndex, int resEndIndex);
00079
00084 ~PChain();
00085
00090 void Obliterate();
00091
00092
00098 PResidue *AddResidue(const string &resName);
00099
00105 PResidue *AddResidue(const string &resName, PResidueSpec &resSpec);
00106
00111 bool IsSubChainOf(const PChain *other) const;
00112
00117 PChain *getParent() const;
00118
00123 PChain *getTopLevelChain();
00124
00131 PBond *getBond(int res_index, const string &id1, const string &id2);
00132
00140 PBond *getBond(int res_index1, const string &id1, int res_index2, const string &id2);
00141
00145 int size() const;
00146
00154 PResidue *getResidue(int localIndex);
00155
00159 int getResidueIndex(const PAtom* atom);
00160
00161
00167 PAtom* getAtomAtRes(const string &atomID, int resNum);
00168
00173 void setAtomColorAtRes(const string &atomID, int resNum, GLColor setColor) {
00174 getAtomAtRes(atomID,resNum)->setColor(setColor);
00175 }
00176
00181 void revertAtomColorAtRes(const string &atomID, int resNum) {
00182 getAtomAtRes(atomID,resNum)->revertColor();
00183 }
00184
00190 PAtom *getAtom(const string &blockType, int index);
00191
00195 Vector3 getAtomPos(const string &blockType,int index);
00196
00200 int NumAtoms(const string &blockType) const;
00201
00206 bool InStaticCollision();
00207
00213 bool InStaticCollision(int resIndex1, int resIndex2);
00214
00219 bool InSelfCollision();
00220
00226 bool InSelfCollision(int resIndex1, int resIndex2);
00227
00232 bool InAnyCollision();
00233
00239 bool InAnyCollision(int resIndex1, int resIndex2);
00240
00246 pair<PAtom *, PAtom *> FindStaticCollision();
00247
00253 pair<PAtom *, PAtom *> FindStaticCollision(int resIndex1, int resIndex2);
00254
00260 pair<PAtom *, PAtom *> FindSelfCollision();
00261
00267 pair<PAtom *, PAtom *> FindSelfCollision(int resIndex1, int resIndex2);
00268
00274 pair<PAtom *, PAtom *> FindAnyCollision();
00275
00281 pair<PAtom *, PAtom *> FindAnyCollision(int resIndex1, int resIndex2);
00282
00287 AtomCollisions* getAllCollidingStatic();
00288
00293 AtomCollisions* getAllCollidingStatic(int resIndex1, int resIndex2);
00294
00299 AtomCollisions* getAllCollidingSelf();
00300
00305 AtomCollisions* getAllCollidingSelf(int resIndex1, int resIndex2);
00306
00311 AtomCollisions* getAllCollidingEither();
00312
00317 AtomCollisions* getAllCollidingEither(int resIndex1, int resIndex2);
00318
00324 vector<PBond *>& GetDOFs(const string &blockType);
00325
00330 int NumDOF(const string &blockType) const;
00331
00336 void RotateChain(const string &blockType,int DOFindex, BondDirection dir, float degrees);
00337
00341 void RotateChain(const ChainMove &move);
00342
00346 void MultiRotate(vector<ChainMove> &moves);
00347
00351 void AntiMultiRotate(vector<ChainMove> &moves);
00352
00356 vector<string> GetBlockTypes() const;
00357
00361 void DetachBlocks(const string &blockType, const string &blockTypeToDetachFrom);
00362
00367 void DetachBlocks(const string &blockType, const string &blockTypeToDetachFrom, int resStartIndex, int resEndIndex);
00368
00372 void ReattachBlocks(const string &blockType);
00373
00378 void ReattachBlocks(const string &blockType, int resStartIndex, int resEndIndex);
00379
00383 void ReattachAllBlocks();
00384
00389 void ReattachAllBlocks(int resStartIndex, int resEndIndex);
00390
00395 void RandomizeDOFs(BondDirection dir);
00396
00402 void finalize();
00403
00408 void AddRotateEventHandler(PRotateEventHandler *handler);
00409
00414 void RemoveRotateEventHandler(PRotateEventHandler *handler);
00415
00416
00421 void traverseFromStart(AtomFunctor *atomFn) { traverseFromStart(atomFn, NULL); }
00422
00427 void traverseFromStart(BondFunctor *bondFn) { traverseFromStart(NULL, bondFn); }
00428
00434 void traverseFromStart(AtomFunctor *atomFn, BondFunctor *bondFn);
00435
00443 pair<int, int> getTopLevelIndices() const;
00444
00448 const PSpaceManager* getSpaceManager() { return m_grid; }
00449
00457 PChain *Clone();
00458
00463 int getResidueLocalIndex(PResidue *res);
00464
00469 int getResidueGlobalIndex(PResidue *res);
00470
00476 vector<const PAtom*> getShortestPath(const PAtom *a1, ConstAtomSet a2Set, int maxLength);
00477
00483 vector<const PAtom*> getShortestPath(const PAtom *a1, const PAtom *a2, int maxLength);
00484
00490 vector<const PAtom*> getShortestPath(const PAtom *a1, ConstAtomSet a2Set, int maxLength, int extendNum);
00491
00496 void inactivateResidue (int Rid1, int Rid2);
00497
00502 void activateResidue (int Rid1, int Rid2);
00503
00504
00508 unsigned int NumChildren() { return m_children.size(); }
00509
00513 PChain *getChild(unsigned int index) {
00514 for(list<PChain *>::iterator it =
00515 m_children.begin();it!=m_children.end();it++) {
00516 if(index==0) return *it;
00517 index--;
00518 }
00519 return NULL;
00520 }
00521
00522 protected:
00523 void CloneResiduesIntoChain(PChain *other);
00524 virtual PResidue *CreateResidue(const string &name) { return new PResidue(this,name); }
00525 virtual PResidue *CreateResidue(const string &name, PResidueSpec &spec) { return new PResidue(this,name,spec); }
00526 virtual PResidue *CreateResidue(const string &name, PResidue *res) { return new PResidue(this,name,res); }
00527 virtual PResidue *CreateResidue(const string &name, PResidueSpec &spec, PResidue *res) { return new
00528 PResidue(this,name,spec,res); }
00529
00530 private:
00531
00532 void UpdateIndexRangeOnAdd(int amtAdded);
00533 void InitChain();
00534 void CheckFinalized() const;
00535 vector<const PAtom*> extractPath(AtomNode* leaveNode);
00536
00537 bool m_isFinalized;
00538 vector<PResidue *> *m_residues;
00539 PGrid *m_grid;
00540
00541 int m_startIndex;
00542 int m_endIndex;
00543
00544 PChain *m_parentChain;
00545 list<PChain *> m_children;
00546 list<PRotateEventHandler *> *m_rotationEvents;
00547
00548
00549
00550 DOF_Cache m_dofs;
00551 Atom_Cache m_atomCache;
00552
00553
00554
00555 bool InCollision(int resIndex1, int resIndex2, CollisionType type);
00556 pair<PAtom *, PAtom *> FindCollision(int resIndex1, int resIndex2, CollisionType type);
00557 AtomCollisions* getAllColliding(int resIndex1, int resIndex2, CollisionType type);
00558
00559 };
00560
00561 #endif // __P_CHAIN_H